Search in sources :

Example 16 with ApplicationHandler

use of org.glassfish.jersey.server.ApplicationHandler in project jersey by jersey.

the class MonitoringFeatureTest method testStatisticsEnabled.

@Test
public void testStatisticsEnabled() {
    final ResourceConfig resourceConfig = new ResourceConfig();
    resourceConfig.register(MonitoringFeature.class);
    final ApplicationHandler applicationHandler = new ApplicationHandler(resourceConfig);
    final ResourceConfig config = applicationHandler.getConfiguration();
    Assert.assertTrue(config.isRegistered(ApplicationInfoListener.class));
    Assert.assertTrue(config.isRegistered(MonitoringEventListener.class));
    Assert.assertFalse(config.isRegistered(MBeanExposer.class));
}
Also used : ApplicationInfoListener(org.glassfish.jersey.server.internal.monitoring.ApplicationInfoListener) ApplicationHandler(org.glassfish.jersey.server.ApplicationHandler) ResourceConfig(org.glassfish.jersey.server.ResourceConfig) MonitoringEventListener(org.glassfish.jersey.server.internal.monitoring.MonitoringEventListener) MBeanExposer(org.glassfish.jersey.server.internal.monitoring.jmx.MBeanExposer) Test(org.junit.Test)

Example 17 with ApplicationHandler

use of org.glassfish.jersey.server.ApplicationHandler in project jersey by jersey.

the class MonitoringFeatureTest method testOnlyMBeansEnabled3.

@Test
public void testOnlyMBeansEnabled3() {
    final ResourceConfig resourceConfig = new ResourceConfig();
    resourceConfig.property(ServerProperties.MONITORING_STATISTICS_MBEANS_ENABLED, true);
    resourceConfig.property(ServerProperties.MONITORING_STATISTICS_ENABLED, false);
    resourceConfig.register(new MonitoringFeature());
    final ApplicationHandler applicationHandler = new ApplicationHandler(resourceConfig);
    final ResourceConfig config = applicationHandler.getConfiguration();
    Assert.assertTrue(config.isRegistered(ApplicationInfoListener.class));
    Assert.assertTrue(config.isRegistered(MonitoringEventListener.class));
    Assert.assertTrue(config.isRegistered(MBeanExposer.class));
}
Also used : MonitoringFeature(org.glassfish.jersey.server.internal.monitoring.MonitoringFeature) ApplicationInfoListener(org.glassfish.jersey.server.internal.monitoring.ApplicationInfoListener) ApplicationHandler(org.glassfish.jersey.server.ApplicationHandler) ResourceConfig(org.glassfish.jersey.server.ResourceConfig) MonitoringEventListener(org.glassfish.jersey.server.internal.monitoring.MonitoringEventListener) MBeanExposer(org.glassfish.jersey.server.internal.monitoring.jmx.MBeanExposer) Test(org.junit.Test)

Example 18 with ApplicationHandler

use of org.glassfish.jersey.server.ApplicationHandler in project jersey by jersey.

the class MonitoringFeatureTest method testMonitoringEnabledByAutodiscovery.

@Test
public void testMonitoringEnabledByAutodiscovery() {
    final ResourceConfig resourceConfig = new ResourceConfig();
    resourceConfig.property(ServerProperties.MONITORING_ENABLED, true);
    final ApplicationHandler applicationHandler = new ApplicationHandler(resourceConfig);
    final ResourceConfig config = applicationHandler.getConfiguration();
    Assert.assertTrue(config.isRegistered(ApplicationInfoListener.class));
    Assert.assertTrue(config.isRegistered(MonitoringEventListener.class));
    Assert.assertFalse(config.isRegistered(MBeanExposer.class));
}
Also used : ApplicationInfoListener(org.glassfish.jersey.server.internal.monitoring.ApplicationInfoListener) ApplicationHandler(org.glassfish.jersey.server.ApplicationHandler) ResourceConfig(org.glassfish.jersey.server.ResourceConfig) MonitoringEventListener(org.glassfish.jersey.server.internal.monitoring.MonitoringEventListener) MBeanExposer(org.glassfish.jersey.server.internal.monitoring.jmx.MBeanExposer) Test(org.junit.Test)

Example 19 with ApplicationHandler

use of org.glassfish.jersey.server.ApplicationHandler in project jersey by jersey.

the class MonitoringFeatureTest method testAllEnabled2.

@Test
public void testAllEnabled2() {
    final ResourceConfig resourceConfig = new ResourceConfig();
    resourceConfig.property(ServerProperties.MONITORING_STATISTICS_MBEANS_ENABLED, true);
    resourceConfig.property(ServerProperties.MONITORING_STATISTICS_ENABLED, true);
    final MonitoringFeature monitoringFeature = new MonitoringFeature();
    monitoringFeature.setmBeansEnabled(false);
    resourceConfig.register(monitoringFeature);
    final ApplicationHandler applicationHandler = new ApplicationHandler(resourceConfig);
    final ResourceConfig config = applicationHandler.getConfiguration();
    Assert.assertTrue(config.isRegistered(ApplicationInfoListener.class));
    Assert.assertTrue(config.isRegistered(MonitoringEventListener.class));
    Assert.assertTrue(config.isRegistered(MBeanExposer.class));
}
Also used : MonitoringFeature(org.glassfish.jersey.server.internal.monitoring.MonitoringFeature) ApplicationInfoListener(org.glassfish.jersey.server.internal.monitoring.ApplicationInfoListener) ApplicationHandler(org.glassfish.jersey.server.ApplicationHandler) ResourceConfig(org.glassfish.jersey.server.ResourceConfig) MonitoringEventListener(org.glassfish.jersey.server.internal.monitoring.MonitoringEventListener) MBeanExposer(org.glassfish.jersey.server.internal.monitoring.jmx.MBeanExposer) Test(org.junit.Test)

Example 20 with ApplicationHandler

use of org.glassfish.jersey.server.ApplicationHandler in project jersey by jersey.

the class MonitoringFeatureTest method testAllEnabled.

@Test
public void testAllEnabled() {
    final ResourceConfig resourceConfig = new ResourceConfig();
    resourceConfig.property(ServerProperties.MONITORING_STATISTICS_MBEANS_ENABLED, true);
    resourceConfig.property(ServerProperties.MONITORING_STATISTICS_ENABLED, true);
    final ApplicationHandler applicationHandler = new ApplicationHandler(resourceConfig);
    final ResourceConfig config = applicationHandler.getConfiguration();
    Assert.assertTrue(config.isRegistered(ApplicationInfoListener.class));
    Assert.assertTrue(config.isRegistered(MonitoringEventListener.class));
    Assert.assertTrue(config.isRegistered(MBeanExposer.class));
}
Also used : ApplicationInfoListener(org.glassfish.jersey.server.internal.monitoring.ApplicationInfoListener) ApplicationHandler(org.glassfish.jersey.server.ApplicationHandler) ResourceConfig(org.glassfish.jersey.server.ResourceConfig) MonitoringEventListener(org.glassfish.jersey.server.internal.monitoring.MonitoringEventListener) MBeanExposer(org.glassfish.jersey.server.internal.monitoring.jmx.MBeanExposer) Test(org.junit.Test)

Aggregations

ApplicationHandler (org.glassfish.jersey.server.ApplicationHandler)162 Test (org.junit.Test)142 ResourceConfig (org.glassfish.jersey.server.ResourceConfig)104 ContainerResponse (org.glassfish.jersey.server.ContainerResponse)99 ApplicationInfoListener (org.glassfish.jersey.server.internal.monitoring.ApplicationInfoListener)17 MonitoringEventListener (org.glassfish.jersey.server.internal.monitoring.MonitoringEventListener)17 MBeanExposer (org.glassfish.jersey.server.internal.monitoring.jmx.MBeanExposer)17 ContainerRequestContext (javax.ws.rs.container.ContainerRequestContext)12 Response (javax.ws.rs.core.Response)10 MediaType (javax.ws.rs.core.MediaType)8 ContainerRequest (org.glassfish.jersey.server.ContainerRequest)7 MonitoringFeature (org.glassfish.jersey.server.internal.monitoring.MonitoringFeature)6 Resource (org.glassfish.jersey.server.model.Resource)6 ContainerResponseFilter (javax.ws.rs.container.ContainerResponseFilter)5 ArrayList (java.util.ArrayList)4 Ignore (org.junit.Ignore)4 IOException (java.io.IOException)3 ContainerRequestFilter (javax.ws.rs.container.ContainerRequestFilter)3 Inflector (org.glassfish.jersey.process.Inflector)3 Before (org.junit.Before)3