use of com.google.api.server.spi.EndpointsContext in project endpoints-java by cloudendpoints.
the class ExplorerHandlerTest method testHandle.
private void testHandle(String scheme, int port, String expectedLocation) throws Exception {
MockHttpServletRequest request = new MockHttpServletRequest();
request.setScheme(scheme);
request.setServerName("localhost");
request.setServerPort(port);
request.setRequestURI("/_ah/api/explorer/");
MockHttpServletResponse response = new MockHttpServletResponse();
ExplorerHandler handler = new ExplorerHandler();
EndpointsContext context = new EndpointsContext("GET", "explorer", request, response, true);
handler.handle(context);
assertThat(response.getStatus()).isEqualTo(HttpServletResponse.SC_FOUND);
assertThat(response.getHeader("Location")).isEqualTo(expectedLocation);
}
use of com.google.api.server.spi.EndpointsContext in project endpoints-java by cloudendpoints.
the class EndpointsMethodHandlerTest method setUp.
@Before
public void setUp() throws Exception {
classLoader = EndpointsMethodHandlerTest.class.getClassLoader();
request = new MockHttpServletRequest();
response = new MockHttpServletResponse();
context = new EndpointsContext("", "", request, response, true);
systemService = SystemService.builder().withDefaults(classLoader).addService(TestEndpoint.class, new TestEndpoint()).build();
typeLoader = new TypeLoader(classLoader);
apiConfig = new ApiConfig.Factory().create(ServiceContext.create(), typeLoader, TestEndpoint.class);
}
use of com.google.api.server.spi.EndpointsContext in project endpoints-java by cloudendpoints.
the class RestServletRequestParamReaderTest method createReader.
private RestServletRequestParamReader createReader(Map<String, String> rawPathParameters) {
EndpointsContext endpointsContext = new EndpointsContext("GET", "/", request, new MockHttpServletResponse(), true);
endpointsContext.setRawPathParameters(rawPathParameters);
return new RestServletRequestParamReader(endpointMethod, endpointsContext, null, serializationConfig, methodConfig);
}
use of com.google.api.server.spi.EndpointsContext in project endpoints-java by cloudendpoints.
the class ApiProxyHandlerTest method testWithServletPath.
private void testWithServletPath(String servletPath) throws Exception {
MockHttpServletRequest request = new MockHttpServletRequest();
request.setServerName("localhost");
request.setServerPort(8080);
request.setServletPath(servletPath);
MockHttpServletResponse response = new MockHttpServletResponse();
ApiProxyHandler handler = new ApiProxyHandler();
EndpointsContext context = new EndpointsContext("GET", "static/proxy.html", request, response, true);
handler.handle(context);
assertThat(response.getContentAsString()).contains("googleapis.server.init()");
}
Aggregations