org.glassfish.jersey.test.DeploymentContext Java Examples

The following examples show how to use org.glassfish.jersey.test.DeploymentContext. 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: CalculatorResourceTest.java    From dependency-track with Apache License 2.0 5 votes vote down vote up
@Override
protected DeploymentContext configureDeployment() {
    return ServletDeploymentContext.forServlet(new ServletContainer(
            new ResourceConfig(CalculatorResource.class)
                    .register(AuthenticationFilter.class)))
            .build();
}
 
Example #3
Source File: RepositoryResourceTest.java    From dependency-track with Apache License 2.0 5 votes vote down vote up
@Override
protected DeploymentContext configureDeployment() {
    return ServletDeploymentContext.forServlet(new ServletContainer(
            new ResourceConfig(RepositoryResource.class)
                    .register(AuthenticationFilter.class)))
            .build();
}
 
Example #4
Source File: DependencyResourceTest.java    From dependency-track with Apache License 2.0 5 votes vote down vote up
@Override
protected DeploymentContext configureDeployment() {
    return ServletDeploymentContext.forServlet(new ServletContainer(
            new ResourceConfig(DependencyResource.class)
                    .register(AuthenticationFilter.class)))
            .build();
}
 
Example #5
Source File: LicenseResourceTest.java    From dependency-track with Apache License 2.0 5 votes vote down vote up
@Override
protected DeploymentContext configureDeployment() {
    return ServletDeploymentContext.forServlet(new ServletContainer(
            new ResourceConfig(LicenseResource.class)
                    .register(AuthenticationFilter.class)))
            .build();
}
 
Example #6
Source File: BomResourceTest.java    From dependency-track with Apache License 2.0 5 votes vote down vote up
@Override
protected DeploymentContext configureDeployment() {
    return ServletDeploymentContext.forServlet(new ServletContainer(
            new ResourceConfig(BomResource.class)
                    .register(AuthenticationFilter.class)
                    .register(MultiPartFeature.class)))
            .build();
}
 
Example #7
Source File: ProjectResourceTest.java    From dependency-track with Apache License 2.0 5 votes vote down vote up
@Override
protected DeploymentContext configureDeployment() {
    return ServletDeploymentContext.forServlet(new ServletContainer(
            new ResourceConfig(ProjectResource.class)
                    .register(AuthenticationFilter.class)))
            .build();
}
 
Example #8
Source File: LdapResourceTest.java    From dependency-track with Apache License 2.0 5 votes vote down vote up
@Override
protected DeploymentContext configureDeployment() {
    return ServletDeploymentContext.forServlet(new ServletContainer(
            new ResourceConfig(LdapResource.class)
                    .register(AuthenticationFilter.class)))
            .build();
}
 
Example #9
Source File: ComponentResourceTest.java    From dependency-track with Apache License 2.0 5 votes vote down vote up
@Override
protected DeploymentContext configureDeployment() {
    return ServletDeploymentContext.forServlet(new ServletContainer(
            new ResourceConfig(ComponentResource.class)
                    .register(AuthenticationFilter.class)))
            .build();
}
 
Example #10
Source File: PermissionResourceTest.java    From dependency-track with Apache License 2.0 5 votes vote down vote up
@Override
protected DeploymentContext configureDeployment() {
    return ServletDeploymentContext.forServlet(new ServletContainer(
            new ResourceConfig(PermissionResource.class)
                    .register(AuthenticationFilter.class)))
            .build();
}
 
Example #11
Source File: UserResourceAuthenticatedTest.java    From dependency-track with Apache License 2.0 5 votes vote down vote up
@Override
protected DeploymentContext configureDeployment() {
    return ServletDeploymentContext.forServlet(new ServletContainer(
            new ResourceConfig(UserResource.class)
                    .register(AuthenticationFilter.class)))
            .build();
}
 
Example #12
Source File: AbstractRestTest.java    From usergrid with Apache License 2.0 5 votes vote down vote up
@Override
protected DeploymentContext configureDeployment() {
    if ( context == null ) {
        context = ServletDeploymentContext.builder( configure() ) .addListener( StartupListener.class ).build();
    }
    return context;
}
 
Example #13
Source File: VulnerabilityResourceTest.java    From dependency-track with Apache License 2.0 5 votes vote down vote up
@Override
protected DeploymentContext configureDeployment() {
    return ServletDeploymentContext.forServlet(new ServletContainer(
            new ResourceConfig(VulnerabilityResource.class)
                    .register(AuthenticationFilter.class)))
            .build();
}
 
Example #14
Source File: NotificationRuleResourceTest.java    From dependency-track with Apache License 2.0 5 votes vote down vote up
@Override
protected DeploymentContext configureDeployment() {
    return ServletDeploymentContext.forServlet(new ServletContainer(
            new ResourceConfig(NotificationRuleResource.class)
                    .register(AuthenticationFilter.class)))
            .build();
}
 
Example #15
Source File: CweResourceTest.java    From dependency-track with Apache License 2.0 5 votes vote down vote up
@Override
protected DeploymentContext configureDeployment() {
    return ServletDeploymentContext.forServlet(new ServletContainer(
            new ResourceConfig(CweResource.class)
                    .register(AuthenticationFilter.class)))
            .build();
}
 
Example #16
Source File: NotificationPublisherResourceTest.java    From dependency-track with Apache License 2.0 5 votes vote down vote up
@Override
protected DeploymentContext configureDeployment() {
    return ServletDeploymentContext.forServlet(new ServletContainer(
            new ResourceConfig(NotificationPublisherResource.class)
                    .register(AuthenticationFilter.class)))
            .build();
}
 
Example #17
Source File: AnalysisResourceTest.java    From dependency-track with Apache License 2.0 5 votes vote down vote up
@Override
protected DeploymentContext configureDeployment() {
    return ServletDeploymentContext.forServlet(new ServletContainer(
            new ResourceConfig(AnalysisResource.class)
                    .register(AuthenticationFilter.class)))
            .build();
}
 
Example #18
Source File: TeamResourceTest.java    From dependency-track with Apache License 2.0 5 votes vote down vote up
@Override
protected DeploymentContext configureDeployment() {
    return ServletDeploymentContext.forServlet(new ServletContainer(
            new ResourceConfig(TeamResource.class)
                    .register(AuthenticationFilter.class)))
            .build();
}
 
Example #19
Source File: ProjectPropertyResourceTest.java    From dependency-track with Apache License 2.0 5 votes vote down vote up
@Override
protected DeploymentContext configureDeployment() {
    return ServletDeploymentContext.forServlet(new ServletContainer(
            new ResourceConfig(ProjectPropertyResource.class)
                    .register(AuthenticationFilter.class)))
            .build();
}
 
Example #20
Source File: ConfigPropertyResourceTest.java    From dependency-track with Apache License 2.0 5 votes vote down vote up
@Override
protected DeploymentContext configureDeployment() {
    return ServletDeploymentContext.forServlet(new ServletContainer(
            new ResourceConfig(ConfigPropertyResource.class)
                    .register(AuthenticationFilter.class)))
            .build();
}
 
Example #21
Source File: FindingResourceTest.java    From dependency-track with Apache License 2.0 5 votes vote down vote up
@Override
protected DeploymentContext configureDeployment() {
    return ServletDeploymentContext.forServlet(new ServletContainer(
            new ResourceConfig(FindingResource.class)
                    .register(AuthenticationFilter.class)))
            .build();
}
 
Example #22
Source File: SearchResourceTest.java    From dependency-track with Apache License 2.0 5 votes vote down vote up
@Override
protected DeploymentContext configureDeployment() {
    return ServletDeploymentContext.forServlet(new ServletContainer(
            new ResourceConfig(SearchResource.class)
                    .register(AuthenticationFilter.class)))
            .build();
}
 
Example #23
Source File: AuthBaseTest.java    From dropwizard-java8 with Apache License 2.0 5 votes vote down vote up
@Override
protected DeploymentContext configureDeployment() {
    forceSet(TestProperties.CONTAINER_PORT, "0");
    return ServletDeploymentContext.builder(getDropwizardResourceConfig())
        .initParam(ServletProperties.JAXRS_APPLICATION_CLASS, getDropwizardResourceConfigClass().getName())
        .build();
}
 
Example #24
Source File: BaseHttpTargetTest.java    From datacollector with Apache License 2.0 5 votes vote down vote up
@Override
protected DeploymentContext configureDeployment() {
  forceSet(TestProperties.CONTAINER_PORT, String.valueOf(NetworkUtils.getRandomPort()));
  ResourceConfig resourceConfig = new ResourceConfig(MockServer.class);
  return ServletDeploymentContext.forServlet(
    new ServletContainer(resourceConfig)
  ).build();
}
 
Example #25
Source File: TestHttpTarget.java    From datacollector with Apache License 2.0 5 votes vote down vote up
@Override
protected DeploymentContext configureDeployment() {
  forceSet(TestProperties.CONTAINER_PORT, String.valueOf(NetworkUtils.getRandomPort()));
  ResourceConfig resourceConfig = new ResourceConfig(MockServer.class);
  resourceConfig.register(SnappyReaderInterceptor.class);
  return ServletDeploymentContext.forServlet(
    new ServletContainer(resourceConfig)
  ).build();
}
 
Example #26
Source File: HttpClientSourceIT.java    From datacollector with Apache License 2.0 5 votes vote down vote up
@Override
protected DeploymentContext configureDeployment() {
  return ServletDeploymentContext.forServlet(
      new ServletContainer(
          new ResourceConfig(
              Sets.newHashSet(
                  StreamResource.class,
                  NewlineStreamResource.class,
                  TextStreamResource.class,
                  SlowTextStreamResource.class,
                  XmlStreamResource.class,
                  PreemptiveAuthResource.class,
                  AuthResource.class,
                  HeaderRequired.class,
                  AlwaysUnauthorized.class,
                  HttpStageTestUtil.TestPostCustomType.class,
                  StreamTokenResetResource.class,
                  Auth2Resource.class,
                  Auth2ResourceOwnerWithIdResource.class,
                  Auth2BasicResource.class,
                  Auth2JWTResource.class,
                  JsonArrayResource.class
              )
          )
      )
  ).build();
}
 
Example #27
Source File: AuthBaseTest.java    From dropwizard-auth-jwt with Apache License 2.0 5 votes vote down vote up
@Override
protected DeploymentContext configureDeployment() {
    forceSet(TestProperties.CONTAINER_PORT, "0");

    return ServletDeploymentContext.builder(getDropwizardResourceConfig())
        .initParam(JAXRS_APPLICATION_CLASS, getDropwizardResourceConfigClass().getName())
        .build();
}
 
Example #28
Source File: AbstractServingTest.java    From oryx with Apache License 2.0 5 votes vote down vote up
@Override
protected final DeploymentContext configureDeployment() {
  configureProperties();
  String joinedPackages = String.join(",", getResourcePackages()) +
      ",com.cloudera.oryx.lambda.serving";
  return ServletDeploymentContext.builder(OryxApplication.class)
      .initParam("javax.ws.rs.Application", OryxApplication.class.getName())
      .contextParam(OryxApplication.class.getName() + ".packages", joinedPackages)
      .addListener(getInitListenerClass())
      .build();
}
 
Example #29
Source File: NoAuthPrincipalEntityTest.java    From dropwizard-java8 with Apache License 2.0 5 votes vote down vote up
@Override
protected DeploymentContext configureDeployment() {
    forceSet(TestProperties.CONTAINER_PORT, "0");
    return ServletDeploymentContext
            .builder(new NoAuthPrincipalInjectedResourceConfig())
            .initParam(ServletProperties.JAXRS_APPLICATION_CLASS, NoAuthPrincipalInjectedResourceConfig.class.getName())
            .build();
}
 
Example #30
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
                }
            };
        }
    };

}