use of org.glassfish.jersey.server.ResourceConfig in project jersey by jersey.
the class FilterSetMethodTest method testPreMatchingFilter.
@Test
public void testPreMatchingFilter() throws ExecutionException, InterruptedException {
ApplicationHandler handler = new ApplicationHandler(new ResourceConfig(Resource.class, PreMatchFilter.class));
ContainerResponse res = handler.apply(RequestContextBuilder.from("", "/resource/setMethod", "GET").build()).get();
assertEquals(200, res.getStatus());
}
use of org.glassfish.jersey.server.ResourceConfig in project jersey by jersey.
the class App method main.
public static void main(final String[] args) throws Exception {
try {
LOGGER.info("Resource Config Reload Jersey Example App");
for (String s : args) {
if (s.startsWith("-cp=")) {
Compiler.classpath = s.substring(4);
}
}
final ResourceConfig resourceConfig = createResourceConfig(new File(CONFIG_FILENAME));
registerReloader(resourceConfig);
final HttpServer server = GrizzlyHttpServerFactory.createHttpServer(BASE_URI, resourceConfig, true);
Runtime.getRuntime().addShutdownHook(new Thread(new Runnable() {
@Override
public void run() {
server.shutdownNow();
}
}));
server.start();
System.out.println(String.format("Application started.\nTry out %s%s\nStop the application using CTRL+C", BASE_URI, ROOT_PATH));
Thread.currentThread().join();
} catch (IOException | InterruptedException ex) {
Logger.getLogger(App.class.getName()).log(Level.SEVERE, null, ex);
}
}
use of org.glassfish.jersey.server.ResourceConfig in project jersey by jersey.
the class ReloadTest method testReload.
@Test
public void testReload() {
// hit arrivals
Response response = target().path("arrivals").request(MediaType.TEXT_PLAIN).get();
assertEquals(200, response.getStatus());
// make sure stats resource is not found
response = target().path("stats").request(MediaType.TEXT_PLAIN).get();
assertEquals(404, response.getStatus());
// add stats resource
container.reload(new ResourceConfig(ArrivalsResource.class, StatsResource.class));
// check stats
response = target().path("stats").request(MediaType.TEXT_PLAIN).get();
assertEquals(200, response.getStatus());
assertTrue("1 expected as number of arrivals hits in stats", response.readEntity(String.class).contains("1"));
// another arrivals hit
response = target().path("arrivals").request(MediaType.TEXT_PLAIN).get();
assertEquals(200, response.getStatus());
// check updated stats
response = target().path("stats").request(MediaType.TEXT_PLAIN).get();
assertEquals(200, response.getStatus());
assertTrue("2 expected as number of arrivals hits in stats", response.readEntity(String.class).contains("2"));
// remove stats
container.reload(new ResourceConfig(ArrivalsResource.class));
// make sure stats resource is not found
response = target().path("stats").request(MediaType.TEXT_PLAIN).get();
assertEquals(404, response.getStatus());
}
use of org.glassfish.jersey.server.ResourceConfig in project jersey by jersey.
the class App method main.
public static void main(String[] args) {
try {
System.out.println("\"Server-Sent Events\" Jersey Example App");
final ResourceConfig resourceConfig = new ResourceConfig(ServerSentEventsResource.class, SseFeature.class);
final HttpServer server = GrizzlyHttpServerFactory.createHttpServer(BASE_URI, resourceConfig, false);
Runtime.getRuntime().addShutdownHook(new Thread(new Runnable() {
@Override
public void run() {
server.shutdownNow();
}
}));
server.start();
System.out.println(String.format("Application started.\nTry out %s%s\nStop the application using CTRL+C", BASE_URI, ROOT_PATH));
Thread.currentThread().join();
} catch (IOException | InterruptedException ex) {
Logger.getLogger(App.class.getName()).log(Level.SEVERE, null, ex);
}
}
use of org.glassfish.jersey.server.ResourceConfig in project jersey by jersey.
the class BroadcasterTest method configure.
@Override
protected Application configure() {
final ResourceConfig rc = new ResourceConfig(SseResource.class);
rc.property(ServerProperties.WADL_FEATURE_DISABLE, true);
return rc;
}
Aggregations