Java Code Examples for org.glassfish.jersey.test.DeploymentContext

The following examples show how to use org.glassfish.jersey.test.DeploymentContext. These examples are extracted from open source projects. 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 Project: crnk-framework   Source File: SecurityModuleIntTest.java    License: 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 Project: datacollector   Source File: BaseHttpTargetTest.java    License: 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 3
Source Project: datacollector   Source File: TestHttpTarget.java    License: 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 4
Source Project: datacollector   Source File: HttpClientSourceIT.java    License: 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 5
Source Project: dropwizard-auth-jwt   Source File: AuthBaseTest.java    License: 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 6
Source Project: helix   Source File: AbstractTestClass.java    License: 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 7
Source Project: oryx   Source File: AbstractServingTest.java    License: 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 8
@Override
protected DeploymentContext configureDeployment() {
    forceSet(TestProperties.CONTAINER_PORT, "0");
    return ServletDeploymentContext
            .builder(new NoAuthPrincipalInjectedResourceConfig())
            .initParam(ServletProperties.JAXRS_APPLICATION_CLASS, NoAuthPrincipalInjectedResourceConfig.class.getName())
            .build();
}
 
Example 9
Source Project: dropwizard-java8   Source File: AuthBaseTest.java    License: 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 10
Source Project: usergrid   Source File: OrganizationTest.java    License: 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 11
Source Project: usergrid   Source File: AbstractRestTest.java    License: 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 12
Source Project: dependency-track   Source File: RepositoryResourceTest.java    License: 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 13
Source Project: dependency-track   Source File: DependencyResourceTest.java    License: 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 14
Source Project: dependency-track   Source File: LicenseResourceTest.java    License: 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 15
Source Project: dependency-track   Source File: BomResourceTest.java    License: 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 16
Source Project: dependency-track   Source File: ProjectResourceTest.java    License: 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 17
Source Project: dependency-track   Source File: LdapResourceTest.java    License: 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 18
Source Project: dependency-track   Source File: ComponentResourceTest.java    License: 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 19
Source Project: dependency-track   Source File: PermissionResourceTest.java    License: 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 20
@Override
protected DeploymentContext configureDeployment() {
    return ServletDeploymentContext.forServlet(new ServletContainer(
            new ResourceConfig(UserResource.class)
                    .register(AuthenticationFilter.class)))
            .build();
}
 
Example 21
Source Project: dependency-track   Source File: CalculatorResourceTest.java    License: 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 22
@Override
protected DeploymentContext configureDeployment() {
    return ServletDeploymentContext.forServlet(new ServletContainer(
            new ResourceConfig(VulnerabilityResource.class)
                    .register(AuthenticationFilter.class)))
            .build();
}
 
Example 23
@Override
protected DeploymentContext configureDeployment() {
    return ServletDeploymentContext.forServlet(new ServletContainer(
            new ResourceConfig(NotificationRuleResource.class)
                    .register(AuthenticationFilter.class)))
            .build();
}
 
Example 24
Source Project: dependency-track   Source File: CweResourceTest.java    License: 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 25
@Override
protected DeploymentContext configureDeployment() {
    return ServletDeploymentContext.forServlet(new ServletContainer(
            new ResourceConfig(NotificationPublisherResource.class)
                    .register(AuthenticationFilter.class)))
            .build();
}
 
Example 26
Source Project: dependency-track   Source File: AnalysisResourceTest.java    License: 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 27
Source Project: dependency-track   Source File: TeamResourceTest.java    License: 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 28
@Override
protected DeploymentContext configureDeployment() {
    return ServletDeploymentContext.forServlet(new ServletContainer(
            new ResourceConfig(ProjectPropertyResource.class)
                    .register(AuthenticationFilter.class)))
            .build();
}
 
Example 29
@Override
protected DeploymentContext configureDeployment() {
    return ServletDeploymentContext.forServlet(new ServletContainer(
            new ResourceConfig(ConfigPropertyResource.class)
                    .register(AuthenticationFilter.class)))
            .build();
}
 
Example 30
Source Project: dependency-track   Source File: FindingResourceTest.java    License: 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();
}