Search in sources :

Example 1 with ReactorNettyJaxrsServer

use of org.jboss.resteasy.plugins.server.reactor.netty.ReactorNettyJaxrsServer in project resteasy by resteasy.

the class Netty4ApplicationPathTest method testWithApplication.

@Test
public void testWithApplication() throws Exception {
    ReactorNettyJaxrsServer server = null;
    Client client = null;
    try {
        ResteasyDeployment deployment = new ResteasyDeploymentImpl();
        Application app = new TestApplication();
        deployment.setApplication(app);
        server = new ReactorNettyJaxrsServer();
        server.setDeployment(deployment);
        server.setHostname("localhost");
        server.setPort(8080);
        server.start();
        // call resource
        final String path = "/rest-test/echo";
        client = ClientBuilder.newClient();
        String url = String.format("http://%s:%d%s", server.getHostname(), server.getPort(), path);
        Response response = client.target(url).queryParam("text", ECHO).request().get();
        assertEquals(HttpResponseCodes.SC_OK, response.getStatus());
        String msg = response.readEntity(String.class);
        assertEquals(ECHO, msg);
    } finally {
        if (client != null) {
            client.close();
        }
        if (server != null) {
            server.stop();
        }
    }
}
Also used : Response(jakarta.ws.rs.core.Response) ResteasyDeployment(org.jboss.resteasy.spi.ResteasyDeployment) ReactorNettyJaxrsServer(org.jboss.resteasy.plugins.server.reactor.netty.ReactorNettyJaxrsServer) ResteasyDeploymentImpl(org.jboss.resteasy.core.ResteasyDeploymentImpl) Client(jakarta.ws.rs.client.Client) Application(jakarta.ws.rs.core.Application) Test(org.junit.Test)

Example 2 with ReactorNettyJaxrsServer

use of org.jboss.resteasy.plugins.server.reactor.netty.ReactorNettyJaxrsServer in project resteasy by resteasy.

the class PortAssigningTest method testZeroPort.

@Test
public void testZeroPort() throws Exception {
    // given
    ReactorNettyJaxrsServer server = new ReactorNettyJaxrsServer();
    server.setPort(0);
    server.getDeployment();
    // when
    server.start();
    int ip = server.getPort();
    server.stop();
    // then
    Assert.assertTrue(ip != 0);
}
Also used : ReactorNettyJaxrsServer(org.jboss.resteasy.plugins.server.reactor.netty.ReactorNettyJaxrsServer) Test(org.junit.Test)

Example 3 with ReactorNettyJaxrsServer

use of org.jboss.resteasy.plugins.server.reactor.netty.ReactorNettyJaxrsServer in project resteasy by resteasy.

the class HeaderTooLongTest method setup.

@BeforeClass
public static void setup() throws Exception {
    final ReactorNettyJaxrsServer reactorNettyJaxrsServer = new ReactorNettyJaxrsServer();
    reactorNettyJaxrsServer.setDecoderSpecFn(spec -> spec.maxHeaderSize(MAX_HEADER_SIZE));
    ReactorNettyContainer.start(reactorNettyJaxrsServer).getRegistry().addPerRequestResource(Resource.class);
    client = ClientBuilder.newClient();
}
Also used : ReactorNettyJaxrsServer(org.jboss.resteasy.plugins.server.reactor.netty.ReactorNettyJaxrsServer) BeforeClass(org.junit.BeforeClass)

Example 4 with ReactorNettyJaxrsServer

use of org.jboss.resteasy.plugins.server.reactor.netty.ReactorNettyJaxrsServer in project resteasy by resteasy.

the class RESTEASY1325Test method testIdleCloseConnection.

@Test(timeout = IDLE_TIMEOUT_SEC * 1000 + 1000)
public void testIdleCloseConnection() throws Exception {
    ReactorNettyJaxrsServer netty = new ReactorNettyJaxrsServer();
    ResteasyDeployment deployment = new ResteasyDeploymentImpl();
    netty.setDeployment(deployment);
    netty.setPort(TestPortProvider.getPort());
    netty.setRootResourcePath("");
    netty.setSecurityDomain(null);
    netty.setIdleTimeout(IDLE_TIMEOUT);
    netty.start();
    deployment.getRegistry().addSingletonResource(new Resource());
    try {
        callAndIdle();
    } finally {
        netty.stop();
    }
}
Also used : ResteasyDeployment(org.jboss.resteasy.spi.ResteasyDeployment) ReactorNettyJaxrsServer(org.jboss.resteasy.plugins.server.reactor.netty.ReactorNettyJaxrsServer) ResteasyDeploymentImpl(org.jboss.resteasy.core.ResteasyDeploymentImpl) Test(org.junit.Test)

Example 5 with ReactorNettyJaxrsServer

use of org.jboss.resteasy.plugins.server.reactor.netty.ReactorNettyJaxrsServer in project resteasy by resteasy.

the class ResteasyTrailingSlashTest method init.

@BeforeClass
public static void init() throws Exception {
    server = new ReactorNettyJaxrsServer();
    server.setPort(TestPortProvider.getPort());
    server.setRootResourcePath("");
    server.setSecurityDomain(null);
    // rls   server.getDeployment().getRegistry().addPerRequestResource(Resource.class);
    // rls   ResteasyDeployment deployment = server.getDeployment();
    server.getDeployment().getScannedResourceClasses().add(Resource.class.getName());
    server.start();
}
Also used : ReactorNettyJaxrsServer(org.jboss.resteasy.plugins.server.reactor.netty.ReactorNettyJaxrsServer) BeforeClass(org.junit.BeforeClass)

Aggregations

ReactorNettyJaxrsServer (org.jboss.resteasy.plugins.server.reactor.netty.ReactorNettyJaxrsServer)7 Test (org.junit.Test)5 ResteasyDeploymentImpl (org.jboss.resteasy.core.ResteasyDeploymentImpl)4 ResteasyDeployment (org.jboss.resteasy.spi.ResteasyDeployment)4 Client (jakarta.ws.rs.client.Client)3 Response (jakarta.ws.rs.core.Response)3 BeforeClass (org.junit.BeforeClass)2 Application (jakarta.ws.rs.core.Application)1