org.glassfish.jersey.test.spi.TestContainer Java Examples

The following examples show how to use org.glassfish.jersey.test.spi.TestContainer. 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: SecurityModuleIntTest.java    From crnk-framework with Apache License 2.0 6 votes vote down vote up
protected TestContainerFactory getTestContainerFactory() throws TestContainerException {
    final TestContainerFactory testContainerFactory = super.getTestContainerFactory();

    return new TestContainerFactory() {

        @Override
        public TestContainer create(URI baseUri, DeploymentContext deploymentContext) {
            TestContainer container = testContainerFactory.create(baseUri, deploymentContext);
            try {
                Field field = container.getClass().getDeclaredField("server");
                field.setAccessible(true);
                Server server = (Server) field.get(container);

                Handler handler = server.getHandler();
                SecurityHandler securityHandler = identityManager.getSecurityHandler();
                if (securityHandler.getHandler() == null) {
                    securityHandler.setHandler(handler);
                }
                server.setHandler(securityHandler);
            } catch (Exception e) {
                throw new IllegalStateException(e);
            }
            return container;
        }
    };
}
 
Example #2
Source File: AbstractRestIT.java    From usergrid with Apache License 2.0 6 votes vote down vote up
@Override
protected TestContainerFactory getTestContainerFactory() {
    final URI baseURI = getBaseURI();
    return (uri, deploymentContext) -> new TestContainer() {
        @Override
        public ClientConfig getClientConfig() {
            return clientConfig;
        }

        @Override
        public URI getBaseUri() {
            return baseURI;
        }

        @Override
        public void start() {
            // noop
        }

        @Override
        public void stop() {
            // noop
        }
    };
}
 
Example #3
Source File: AbstractTestClass.java    From helix with Apache License 2.0 5 votes vote down vote up
@Override
protected TestContainerFactory getTestContainerFactory()
    throws TestContainerException {
  return new TestContainerFactory() {
    @Override
    public TestContainer create(final URI baseUri, DeploymentContext deploymentContext) {
      return new TestContainer() {

        @Override
        public ClientConfig getClientConfig() {
          return null;
        }

        @Override
        public URI getBaseUri() {
          return baseUri;
        }

        @Override
        public void start() {
          if (_helixRestServer == null) {
            _helixRestServer = startRestServer();
          }
        }

        @Override
        public void stop() {
        }
      };
    }
  };
}
 
Example #4
Source File: SpringContextJerseyTest.java    From demo-restWS-spring-jersey-jpa2-hibernate with MIT License 5 votes vote down vote up
private TestContainer getContainer(ApplicationHandler application, TestContainerFactory tcf) {
    if (application == null) {
        throw new IllegalArgumentException("The application cannot be null");
    }

    return tcf.create(getBaseUri(), application);
}
 
Example #5
Source File: WebContainerFactory.java    From divide with Apache License 2.0 5 votes vote down vote up
@Override
public TestContainer create(URI baseUri, ApplicationHandler application) throws IllegalArgumentException {
    URI uri = UriBuilder.fromUri(baseUri).port(baseUri.getPort() + getCount()).build();
    System.out.println("Uri: " + uri);
    System.out.println("App: " + application.getConfiguration().getApplication().getClass().getName());

    return new MyTestContainer(uri, application);
}
 
Example #6
Source File: SpringContextJerseyTest.java    From demo-restWS-spring-jersey-tomcat-mybatis with MIT License 5 votes vote down vote up
private TestContainer getContainer(ApplicationHandler application, TestContainerFactory tcf) {
    if (application == null) {
        throw new IllegalArgumentException("The application cannot be null");
    }

    return tcf.create(getBaseUri(), application);
}
 
Example #7
Source File: OrganizationTest.java    From usergrid with Apache License 2.0 5 votes vote down vote up
@Override
protected TestContainerFactory getTestContainerFactory() {
    final URI baseURI = getBaseUri();
    
    return new TestContainerFactory() {
        @Override
        public TestContainer create(URI uri, DeploymentContext deploymentContext) {
            return new TestContainer() {

                @Override
                public ClientConfig getClientConfig() {
                    return clientConfig;
                }

                @Override
                public URI getBaseUri() {
                    return baseURI;
                }

                @Override
                public void start() {
                    // noop
                }

                @Override
                public void stop() {
                    // noop
                }
            };
        }
    };

}
 
Example #8
Source File: SpringContextJerseyTest.java    From demo-restWS-spring-jersey-tomcat-mybatis with MIT License 5 votes vote down vote up
private TestContainer getContainer(ApplicationHandler application, TestContainerFactory tcf) {
    if (application == null) {
        throw new IllegalArgumentException("The application cannot be null");
    }

    return tcf.create(getBaseUri(), application);
}
 
Example #9
Source File: MCRJerseyTest.java    From mycore with GNU General Public License v3.0 4 votes vote down vote up
@Override
public TestContainer create(URI baseUri, DeploymentContext deploymentContext) {
    return new GrizzlyTestContainer(baseUri, deploymentContext.getResourceConfig());
}