Java Code Examples for org.glassfish.jersey.server.ResourceConfig#forApplicationClass()

The following examples show how to use org.glassfish.jersey.server.ResourceConfig#forApplicationClass() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: NettyRestServerTest.java    From tajo with Apache License 2.0 6 votes vote down vote up
@Test
public void testTextPlainApplication() throws Exception {
  ResourceConfig resourceConfig = ResourceConfig.forApplicationClass(TestApplication1.class);
  ServerSocket serverSocket = new ServerSocket(0);
  int availPort = serverSocket.getLocalPort();
  serverSocket.close();
  URI baseUri = new URI("http://localhost:"+availPort+"/rest");

  NettyRestServer restServer = NettyRestServerFactory.createNettyRestServer(baseUri, resourceConfig, 3);

  try {
    WebTarget webTarget = ClientBuilder.newClient().target(baseUri + "/testapp1");

    assertEquals(TestResource1.outputMessage, webTarget.request(MediaType.TEXT_PLAIN).get(String.class));
  } finally {
    restServer.shutdown();
  }
}
 
Example 2
Source File: SpringContextJerseyTest.java    From demo-restWS-spring-jersey-tomcat-mybatis with MIT License 5 votes vote down vote up
/**
 * Construct a new instance with an {@link Application} class.
 *
 * @param jaxrsApplicationClass an application describing how to configure the
 *                              test container.
 * @throws TestContainerException if the default test container factory
 *                                cannot be obtained, or the application descriptor is not
 *                                supported by the test container factory.
 */
public SpringContextJerseyTest(Class<? extends Application> jaxrsApplicationClass) throws TestContainerException {
    ResourceConfig config = ResourceConfig.forApplicationClass(jaxrsApplicationClass);
    config.register(new ServiceFinderBinder<TestContainerFactory>(TestContainerFactory.class, null, RuntimeType.SERVER));
    if (isLogRecordingEnabled()) {
        registerLogHandler();
    }
    this.application = new ApplicationHandler(config);
    this.tc = getContainer(application, getTestContainerFactory());
    if (isLogRecordingEnabled()) {
        loggedStartupRecords.addAll(loggedRuntimeRecords);
        loggedRuntimeRecords.clear();
        unregisterLogHandler();
    }
}
 
Example 3
Source File: ControlMetricsCollectorResourceTest.java    From onos with Apache License 2.0 4 votes vote down vote up
/**
 * Constructs a control metrics collector resource test instance.
 */
public ControlMetricsCollectorResourceTest() {
    super(ResourceConfig.forApplicationClass(CPManWebApplication.class));
}
 
Example 4
Source File: OpenstackManagementWebResourceTest.java    From onos with Apache License 2.0 4 votes vote down vote up
/**
 * Constructs an openstack management REST API test.
 */
public OpenstackManagementWebResourceTest() {
    super(ResourceConfig.forApplicationClass(OpenstackNetworkingWebApplication.class));
}
 
Example 5
Source File: VtnResourceTest.java    From onos with Apache License 2.0 4 votes vote down vote up
/**
 * Creates a new web-resource test.
 */
public VtnResourceTest() {
    super(ResourceConfig.forApplicationClass(VtnWebApplication.class));
}
 
Example 6
Source File: PceResourceTest.java    From onos with Apache License 2.0 4 votes vote down vote up
/**
 * Creates a new web-resource test.
 */
public PceResourceTest() {
    super(ResourceConfig.forApplicationClass(PceWebApplication.class));
    AuthorizationFilter.disableForTests();
    set(TestProperties.CONTAINER_PORT, 0);
}
 
Example 7
Source File: OpenstackVtapNetworkWebResourceTest.java    From onos with Apache License 2.0 4 votes vote down vote up
/**
 * Constructs an openstack vtap network resource test instance.
 */
public OpenstackVtapNetworkWebResourceTest() {
    super(ResourceConfig.forApplicationClass(OpenstackVtapWebApplication.class));
}
 
Example 8
Source File: OpenstackTelemetryConfigWebResourceTest.java    From onos with Apache License 2.0 4 votes vote down vote up
/**
 * Constructs an openstack telemetry config resource test instance.
 */
public OpenstackTelemetryConfigWebResourceTest() {
    super(ResourceConfig.forApplicationClass(OpenstackTelemetryWebApplication.class));
}
 
Example 9
Source File: OpenstackRouterWebResourceTest.java    From onos with Apache License 2.0 4 votes vote down vote up
/**
 * Constructs an openstack router test instance.
 */
public OpenstackRouterWebResourceTest() {
    super(ResourceConfig.forApplicationClass(OpenstackNetworkingWebApplication.class));
}
 
Example 10
Source File: OpenstackSecurityGroupRuleWebResourceTest.java    From onos with Apache License 2.0 4 votes vote down vote up
/**
 * Constructs an openstack security group rule test instance.
 */
public OpenstackSecurityGroupRuleWebResourceTest() {
    super(ResourceConfig.forApplicationClass(OpenstackNetworkingWebApplication.class));
}
 
Example 11
Source File: OpenstackSecurityGroupWebResourceTest.java    From onos with Apache License 2.0 4 votes vote down vote up
/**
 * Constructs an openstack security group test instance.
 */
public OpenstackSecurityGroupWebResourceTest() {
    super(ResourceConfig.forApplicationClass(OpenstackNetworkingWebApplication.class));
}
 
Example 12
Source File: AclWebResourceTest.java    From onos with Apache License 2.0 4 votes vote down vote up
/**
 * Constructs a control metrics collector resource test instance.
 */
public AclWebResourceTest() {
    super(ResourceConfig.forApplicationClass(AclWebApplication.class));
}
 
Example 13
Source File: ResourceConfigProvider.java    From onedev with MIT License 4 votes vote down vote up
@Override
public ResourceConfig get() {
	return ResourceConfig.forApplicationClass(JerseyApplication.class);
}
 
Example 14
Source File: ControlMetricsResourceTest.java    From onos with Apache License 2.0 4 votes vote down vote up
/**
 * Constructs a control metrics resource test instance.
 */
public ControlMetricsResourceTest() {
    super(ResourceConfig.forApplicationClass(CPManWebApplication.class));
}
 
Example 15
Source File: RestconfWebResourceTest.java    From onos with Apache License 2.0 4 votes vote down vote up
public RestconfWebResourceTest() {
    super(ResourceConfig.forApplicationClass(RestconfProtocolProxy.class));
}
 
Example 16
Source File: OFAgentWebResourceTest.java    From onos with Apache License 2.0 4 votes vote down vote up
/**
 * Constructs OFAgent Web application test instance.
 */
public OFAgentWebResourceTest() {
    super(ResourceConfig.forApplicationClass(OFAgentWebApplication.class));
}
 
Example 17
Source File: K8sNodeWebResourceTest.java    From onos with Apache License 2.0 4 votes vote down vote up
/**
 * Constructs a kubernetes node resource test instance.
 */
public K8sNodeWebResourceTest() {
    super(ResourceConfig.forApplicationClass(K8sNodeWebApplication.class));
}
 
Example 18
Source File: OpenstackSubnetWebResourceTest.java    From onos with Apache License 2.0 4 votes vote down vote up
/**
 * Constructs an openstack subnet test instance.
 */
public OpenstackSubnetWebResourceTest() {
    super(ResourceConfig.forApplicationClass(OpenstackNetworkingWebApplication.class));
}
 
Example 19
Source File: Main.java    From Jax-RS-Performance-Comparison with Apache License 2.0 4 votes vote down vote up
public static HttpServer startServer(String host, int port) {
    final ResourceConfig rc = ResourceConfig.forApplicationClass(MyApplication.class);
    URI baseUri = UriBuilder.fromUri(BASE_URI).host(host).port(port).build();
    return GrizzlyHttpServerFactory.createHttpServer(baseUri, rc);
}
 
Example 20
Source File: OpenstackPortWebResourceTest.java    From onos with Apache License 2.0 4 votes vote down vote up
/**
 * Constructs an openstack port test instance.
 */
public OpenstackPortWebResourceTest() {
    super(ResourceConfig.forApplicationClass(OpenstackNetworkingWebApplication.class));
}