Search in sources :

Example 1 with ServerUtils.httpsServerForTest

use of scaffolding.ServerUtils.httpsServerForTest in project mu-server by 3redronin.

the class JaxMatchingTest method matrixParametersMatchDefaultPathParamRegex.

@Test
public void matrixParametersMatchDefaultPathParamRegex() throws IOException {
    @Path("/blah/{thing}")
    class Thing {

        @GET
        @Path("/something")
        public String get(@PathParam("thing") String thing) {
            return thing;
        }
    }
    server = ServerUtils.httpsServerForTest().addHandler(RestHandlerBuilder.restHandler(new Thing()).build()).start();
    URI matrixUri = server.uri().resolve("/blah;ignored=true/tiger;color=red;type=cat/something;ignored=true");
    try (Response resp = call(request().url(matrixUri.toString()))) {
        assertThat(resp.body().string(), is("tiger"));
    }
}
Also used : Path(javax.ws.rs.Path) Response(okhttp3.Response) Matchers.containsString(org.hamcrest.Matchers.containsString) PathParam(javax.ws.rs.PathParam) URI(java.net.URI) ServerUtils.httpsServerForTest(scaffolding.ServerUtils.httpsServerForTest) Test(org.junit.Test)

Example 2 with ServerUtils.httpsServerForTest

use of scaffolding.ServerUtils.httpsServerForTest in project mu-server by 3redronin.

the class JaxMatchingTest method interfacesWithDefaultImplementationSupported.

@Test
public void interfacesWithDefaultImplementationSupported() throws IOException {
    server = ServerUtils.httpsServerForTest().addHandler(restHandler(new DefaultImplementationResource())).start();
    try (Response resp = call(request(server.uri().resolve("/default-impl/jax1")))) {
        assertThat(resp.code(), Matchers.is(200));
        assertThat(resp.body().string(), equalTo("Hello from default impl"));
    }
    try (Response resp = call(request(server.uri().resolve("/default-impl/jax2")))) {
        assertThat(resp.code(), Matchers.is(200));
        assertThat(resp.body().string(), equalTo("Overwritten by implementation"));
    }
}
Also used : Response(okhttp3.Response) ServerUtils.httpsServerForTest(scaffolding.ServerUtils.httpsServerForTest) Test(org.junit.Test)

Aggregations

Response (okhttp3.Response)2 Test (org.junit.Test)2 ServerUtils.httpsServerForTest (scaffolding.ServerUtils.httpsServerForTest)2 URI (java.net.URI)1 Path (javax.ws.rs.Path)1 PathParam (javax.ws.rs.PathParam)1 Matchers.containsString (org.hamcrest.Matchers.containsString)1