Search in sources :

Example 1 with ResteasyDeploymentImpl

use of org.jboss.resteasy.core.ResteasyDeploymentImpl in project resteasy by resteasy.

the class MockedProfilingTest method testCleartext.

@Test
public void testCleartext() throws Exception {
    final int WARMUP = 10;
    final int INTERATIONS = 100;
    // final int WARMUP = 1000;
    // final int INTERATIONS = 1000000;
    ResteasyDeployment deployment = new ResteasyDeploymentImpl();
    deployment.start();
    Registry registry = deployment.getRegistry();
    registry.addPerRequestResource(CleartextResource.class);
    MockHttpResponse response = new MockHttpResponse();
    MockHttpRequest request = MockHttpRequest.post("/test/create").header(HttpHeaders.CONTENT_LANGUAGE, "en").header(HttpHeaders.USER_AGENT, "mozilla").header("Custom-Header1", "mozilla").header("Custom-Header2", "mozilla").header("Custom-Header3", "mozilla").header("Custom-Header4", "mozilla").contentType(MediaType.TEXT_PLAIN);
    ByteArrayInputStream stream = new ByteArrayInputStream("hello".getBytes());
    request.setInputStream(stream);
    for (int i = 0; i < WARMUP; i++) {
        deployment.getDispatcher().invoke(request, response);
        stream.reset();
    }
    // long start = System.currentTimeMillis();
    for (int i = 0; i < INTERATIONS; i++) {
        deployment.getDispatcher().invoke(request, response);
        stream.reset();
    }
// long end = System.currentTimeMillis() - start;
// System.out.println("Time took: " + end);
}
Also used : ResteasyDeployment(org.jboss.resteasy.spi.ResteasyDeployment) MockHttpRequest(org.jboss.resteasy.mock.MockHttpRequest) ByteArrayInputStream(java.io.ByteArrayInputStream) ResteasyDeploymentImpl(org.jboss.resteasy.core.ResteasyDeploymentImpl) Registry(org.jboss.resteasy.spi.Registry) MockHttpResponse(org.jboss.resteasy.mock.MockHttpResponse) Test(org.junit.Test)

Example 2 with ResteasyDeploymentImpl

use of org.jboss.resteasy.core.ResteasyDeploymentImpl in project resteasy by resteasy.

the class UndertowJaxrsServer method deployOldStyle.

// OldStyle requires a mapping prefix to be "/" when the ApplicationPath is some other value
public UndertowJaxrsServer deployOldStyle(Class<? extends Application> application, String ctxtPath) {
    ResteasyDeployment resteasyDeployment = new ResteasyDeploymentImpl();
    resteasyDeployment.setApplicationClass(application.getName());
    String contextPath = serverHelper.checkContextPath(ctxtPath);
    DeploymentInfo di = undertowDeployment(resteasyDeployment, "/");
    populateDeploymentInfo(di, resteasyDeployment.getClass().getClassLoader(), contextPath);
    return deploy(di);
}
Also used : ResteasyDeployment(org.jboss.resteasy.spi.ResteasyDeployment) ResteasyDeploymentImpl(org.jboss.resteasy.core.ResteasyDeploymentImpl) DeploymentInfo(io.undertow.servlet.api.DeploymentInfo)

Example 3 with ResteasyDeploymentImpl

use of org.jboss.resteasy.core.ResteasyDeploymentImpl in project resteasy by resteasy.

the class UndertowJaxrsServer method deploy.

public UndertowJaxrsServer deploy(Class<? extends Application> application, String contextPath) {
    ResteasyDeployment resteasyDeployment = new ResteasyDeploymentImpl();
    resteasyDeployment.setApplicationClass(application.getName());
    return deploy(resteasyDeployment, serverHelper.checkContextPath(contextPath), resteasyDeployment.getClass().getClassLoader());
}
Also used : ResteasyDeployment(org.jboss.resteasy.spi.ResteasyDeployment) ResteasyDeploymentImpl(org.jboss.resteasy.core.ResteasyDeploymentImpl)

Example 4 with ResteasyDeploymentImpl

use of org.jboss.resteasy.core.ResteasyDeploymentImpl 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 5 with ResteasyDeploymentImpl

use of org.jboss.resteasy.core.ResteasyDeploymentImpl in project resteasy by resteasy.

the class CdiNettyTest method init.

@Before
public void init() {
    while (port < 8000) this.port = (int) ((new Random().nextDouble() * 8000) + 1000);
    ResteasyCdiExtension cdiExtension = CDI.current().select(ResteasyCdiExtension.class).get();
    CdiNettyJaxrsServer netty = new CdiNettyJaxrsServer();
    ResteasyDeployment rd = new ResteasyDeploymentImpl();
    rd.setActualResourceClasses(cdiExtension.getResources());
    rd.setInjectorFactoryClass(CdiInjectorFactory.class.getName());
    rd.getActualProviderClasses().addAll(cdiExtension.getProviders());
    netty.setDeployment(rd);
    netty.setPort(port);
    netty.setRootResourcePath("/api");
    netty.start();
    this.server = netty;
}
Also used : ResteasyDeployment(org.jboss.resteasy.spi.ResteasyDeployment) Random(java.util.Random) ResteasyDeploymentImpl(org.jboss.resteasy.core.ResteasyDeploymentImpl) CdiInjectorFactory(org.jboss.resteasy.cdi.CdiInjectorFactory) ResteasyCdiExtension(org.jboss.resteasy.cdi.ResteasyCdiExtension) Before(org.junit.Before)

Aggregations

ResteasyDeploymentImpl (org.jboss.resteasy.core.ResteasyDeploymentImpl)29 ResteasyDeployment (org.jboss.resteasy.spi.ResteasyDeployment)29 Test (org.junit.Test)9 NettyJaxrsServer (org.jboss.resteasy.plugins.server.netty.NettyJaxrsServer)8 ReactorNettyJaxrsServer (org.jboss.resteasy.plugins.server.reactor.netty.ReactorNettyJaxrsServer)4 BeforeClass (org.junit.BeforeClass)4 DeploymentInfo (io.undertow.servlet.api.DeploymentInfo)3 Client (jakarta.ws.rs.client.Client)3 Response (jakarta.ws.rs.core.Response)3 EventLoopGroup (io.netty.channel.EventLoopGroup)2 EpollEventLoopGroup (io.netty.channel.epoll.EpollEventLoopGroup)2 KQueueEventLoopGroup (io.netty.channel.kqueue.KQueueEventLoopGroup)2 SslContext (io.netty.handler.ssl.SslContext)2 File (java.io.File)2 ArrayList (java.util.ArrayList)2 Random (java.util.Random)2 CdiInjectorFactory (org.jboss.resteasy.cdi.CdiInjectorFactory)2 ResteasyCdiExtension (org.jboss.resteasy.cdi.ResteasyCdiExtension)2 Before (org.junit.Before)2 IPCController (com.datastax.mgmtapi.ipc.IPCController)1