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);
}
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);
}
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());
}
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();
}
}
}
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;
}
Aggregations