Skip to content

Commit

Permalink
Updated tests to work well with new context implementation and remove…
Browse files Browse the repository at this point in the history
…d debug System.out calls (#239 contd)
  • Loading branch information
sapessi committed Sep 11, 2019
1 parent 8128f78 commit ab0217e
Show file tree
Hide file tree
Showing 8 changed files with 3 additions and 23 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,6 @@ public SingleValueModel returnFilterAttribute(@Context HttpServletRequest req) {
@Path("/list-query-string") @GET
@Produces(MediaType.APPLICATION_JSON)
public SingleValueModel echoQueryStringLength(@QueryParam("list") List<String> param) {
System.out.println("param: " + param + " = " + param.size());
SingleValueModel model = new SingleValueModel();
model.setValue(param.size() + "");
return model;
Expand Down Expand Up @@ -157,7 +156,6 @@ public MapResponseModel echoQueryString(@Context UriInfo context) {
@Produces(MediaType.APPLICATION_JSON)
public SingleValueModel echoRequestScheme(@Context UriInfo context) {
SingleValueModel model = new SingleValueModel();
System.out.println("RequestUri: " + context.getRequestUri().toString());
model.setValue(context.getRequestUri().getScheme());
return model;
}
Expand Down Expand Up @@ -261,11 +259,6 @@ public Response fileSize(@FormDataParam("file") final File uploadedFile,
@Context ContainerRequestContext req) {
SingleValueModel sv = new SingleValueModel();

System.out.println(
"Is base64 encoded: " +
((AwsProxyHttpServletRequest)req.getProperty(JERSEY_SERVLET_REQUEST_PROPERTY)).getAwsProxyRequest().isBase64Encoded()
);

try {
InputStream fileIs = new FileInputStream(uploadedFile);
System.out.println("File: " + fileDetail.getName() + " " + fileDetail.getFileName() + " " + fileDetail.getSize());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,6 @@ public void alb_basicRequest_expectSuccess() {
assertEquals(200, output.getStatusCode());
assertEquals("application/json", output.getMultiValueHeaders().getFirst("Content-Type"));
assertNotNull(output.getStatusDescription());
System.out.println(output.getStatusDescription());

validateMapResponseModel(output);
}
Expand Down Expand Up @@ -170,9 +169,6 @@ public void context_servletResponse_setCustomHeader() {
public void context_serverInfo_correctContext() {
AwsProxyRequest request = getRequestBuilder("/echo/servlet-context", "GET").build();
AwsProxyResponse output = handler.proxy(request, lambdaContext);
for (String header : output.getMultiValueHeaders().keySet()) {
System.out.println(header + ": " + output.getMultiValueHeaders().getFirst(header));
}
assertEquals(200, output.getStatusCode());
assertEquals("application/json", output.getMultiValueHeaders().getFirst("Content-Type"));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,6 @@ public void queryParam_encoding_expectFullyEncodedUrl() {
assertNotNull(resp);
assertEquals(resp.getStatusCode(), 200);
validateSingleValueModel(resp, "%2F%2B%3D");
System.out.println("body:" + resp.getBody());
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
public class CustomExceptionMapper implements ExceptionMapper<UnsupportedOperationException> {

public CustomExceptionMapper() {
System.out.println("Starting custom exception mapper");

}

@Inject
Expand All @@ -23,7 +23,6 @@ public Response toResponse(UnsupportedOperationException throwable) {
if (request == null) {
return Response.status(Response.Status.NOT_FOUND).build();
} else {
System.out.println("Request uri: " + request.get().getRequestURI());
return Response.ok(throwable.getMessage()).status(Response.Status.NOT_IMPLEMENTED).build();
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,6 @@ public static void stopSpark() {

private static void configureRoutes() {
initExceptionHandler((e) -> {
System.out.println("Exception Handler called: " + e.getLocalizedMessage());
assertEquals(TEST_EXCEPTION_MESSAGE, e.getLocalizedMessage());
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ public void filters_onStartupMethod_executeFilters() {

handler.onStartup(c -> {
if (c == null) {
System.out.println("Null servlet context");
fail();
}
FilterRegistration.Dynamic registration = c.addFilter("CustomHeaderFilter", CustomHeaderFilter.class);
Expand Down Expand Up @@ -75,7 +74,6 @@ public void filters_unauthenticatedFilter_stopRequestProcessing() {

handler.onStartup(c -> {
if (c == null) {
System.out.println("Null servlet context");
fail();
}
FilterRegistration.Dynamic registration = c.addFilter("UnauthenticatedFilter", UnauthenticatedFilter.class);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,11 @@ public class CustomHeaderFilter implements Filter {

@Override
public void init(FilterConfig filterConfig) throws ServletException {
System.out.println("Called init on filter");

}

@Override
public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain) throws IOException, ServletException {
System.out.println("Called doFilter");
HttpServletResponse resp = (HttpServletResponse)servletResponse;
resp.addHeader(HEADER_NAME, HEADER_VALUE);

Expand All @@ -33,6 +32,6 @@ public void doFilter(ServletRequest servletRequest, ServletResponse servletRespo

@Override
public void destroy() {
System.out.println("Called destroy");

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,10 @@ public void init(FilterConfig filterConfig)
@Override
public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain)
throws IOException, ServletException {
System.out.println("Running unauth filter");
if (((HttpServletRequest)servletRequest).getHeader(HEADER_NAME) != null) {
((HttpServletResponse) servletResponse).setStatus(401);
System.out.println("Returning 401");
return;
}
System.out.println("Continue chain");
filterChain.doFilter(servletRequest, servletResponse);
}

Expand Down

0 comments on commit ab0217e

Please sign in to comment.