org.glassfish.jersey.test.TestProperties Java Examples

The following examples show how to use org.glassfish.jersey.test.TestProperties. 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: HttpClientSourceIT.java    From datacollector with Apache License 2.0 6 votes vote down vote up
@Override
protected Application configure() {
  forceSet(TestProperties.CONTAINER_PORT, "0");
  return 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
      )
  );
}
 
Example #2
Source File: HttpProcessorIT.java    From datacollector with Apache License 2.0 6 votes vote down vote up
@Override
protected Application configure() {
  forceSet(TestProperties.CONTAINER_PORT, "0");
  return new ResourceConfig(
      Sets.newHashSet(
          TestGet.class,
          TestNull.class,
          TestGetZip.class,
          TestPut.class,
          HttpStageTestUtil.TestPostCustomType.class,
          TestXmlGet.class,
          TestHead.class,
          StreamTokenResetResource.class,
          Auth2Resource.class,
          Auth2ResourceOwnerWithIdResource.class,
          Auth2BasicResource.class,
          Auth2JWTResource.class,
          TestTimeEL.class
      )
  );
}
 
Example #3
Source File: Util.java    From tessera with Apache License 2.0 6 votes vote down vote up
public static JerseyTest create(Enclave enclave) {

        SLF4JBridgeHandler.removeHandlersForRootLogger();
        SLF4JBridgeHandler.install();

        return new JerseyTest() {
            @Override
            protected Application configure() {
                
                enable(TestProperties.LOG_TRAFFIC);
                enable(TestProperties.DUMP_ENTITY);
                set(TestProperties.CONTAINER_PORT, SocketUtils.findAvailableTcpPort());
                EnclaveApplication application = new EnclaveApplication(new EnclaveResource(enclave));

                ResourceConfig config = ResourceConfig.forApplication(application);
                config.packages("com.quorum.tessera.enclave.rest");
                return config;
            }

        };
    }
 
Example #4
Source File: Q2TRestAppTest.java    From tessera with Apache License 2.0 6 votes vote down vote up
@Before
public void setUp() throws Exception {

    final Set services = new HashSet();
    services.add(mock(TransactionManager.class));

    serviceLocator = (MockServiceLocator) ServiceLocator.create();
    serviceLocator.setServices(services);

    q2TRestApp = new Q2TRestApp();

    jersey =
            new JerseyTest() {
                @Override
                protected Application configure() {
                    enable(TestProperties.LOG_TRAFFIC);
                    enable(TestProperties.DUMP_ENTITY);
                    ResourceConfig jerseyconfig = ResourceConfig.forApplication(q2TRestApp);
                    return jerseyconfig;
                }
            };

    jersey.setUp();
}
 
Example #5
Source File: ThirdPartyRestAppTest.java    From tessera with Apache License 2.0 6 votes vote down vote up
@Before
public void setUp() throws Exception {
    serviceLocator = (MockServiceLocator) ServiceLocator.create();

    Set services = new HashSet();
    services.add(mock(IPWhitelistFilter.class));
    services.add(mock(TransactionManager.class));
    services.add(mock(PartyInfoService.class));

    serviceLocator.setServices(services);

    thirdParty = new ThirdPartyRestApp();

    jersey =
            new JerseyTest() {
                @Override
                protected Application configure() {
                    enable(TestProperties.LOG_TRAFFIC);
                    enable(TestProperties.DUMP_ENTITY);
                    ResourceConfig jerseyconfig = ResourceConfig.forApplication(thirdParty);
                    return jerseyconfig;
                }
            };
    jersey.setUp();
}
 
Example #6
Source File: LocaleContextFilterTest.java    From sinavi-jfw with Apache License 2.0 6 votes vote down vote up
@Override
protected Application configure() {
    enable(TestProperties.LOG_TRAFFIC);
    ResourceConfig config = new ResourceConfig();
    config.register(LocaleContextFilter.class, 1);
    config.register(new ContainerRequestFilter() {

        @Override
        public void filter(ContainerRequestContext requestContext) throws IOException {
            called.incrementAndGet();
            locale = LocaleContextKeeper.getLocale();
        }

    }, 2);
    config.register(TestResource.class);
    return config;
}
 
Example #7
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 #8
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 #9
Source File: WorkMgrServiceV2TestBase.java    From batfish with Apache License 2.0 5 votes vote down vote up
@Override
public Application configure() {
  forceSet(TestProperties.CONTAINER_PORT, "0");
  return new ResourceConfig(WorkMgrServiceV2.class)
      .register(ServiceObjectMapper.class)
      .register(ExceptionMapper.class)
      .register(JacksonFeature.class)
      .register(ApiKeyAuthenticationFilter.class)
      .register(VersionCompatibilityFilter.class)
      .register(CrossDomainFilter.class);
}
 
Example #10
Source File: PoolMgrServiceTest.java    From batfish with Apache License 2.0 5 votes vote down vote up
@Override
public Application configure() {
  forceSet(TestProperties.CONTAINER_PORT, "0");
  return new ResourceConfig(PoolMgrService.class)
      .register(new JettisonFeature())
      .register(MultiPartFeature.class)
      .register(CrossDomainFilter.class);
}
 
Example #11
Source File: LoadBenchmark.java    From oryx with Apache License 2.0 5 votes vote down vote up
@Override
protected void configureProperties() {
  super.configureProperties();
  if (isEnabled(TestProperties.LOG_TRAFFIC)) {
    disable(TestProperties.LOG_TRAFFIC);
  }
  if (isEnabled(TestProperties.DUMP_ENTITY)) {
    disable(TestProperties.DUMP_ENTITY);
  }
}
 
Example #12
Source File: OptionalQueryParamResourceTest.java    From dropwizard-java8 with Apache License 2.0 5 votes vote down vote up
@Override
protected Application configure() {
    forceSet(TestProperties.CONTAINER_PORT, "0");
    return DropwizardResourceConfig.forTesting(new MetricRegistry())
            .register(OptionalParamFeature.class)
            .register(OptionalQueryParamResource.class)
            .register(MyMessageParamConverterProvider.class);
}
 
Example #13
Source File: OptionalMessageBodyWriterTest.java    From dropwizard-java8 with Apache License 2.0 5 votes vote down vote up
@Override
protected Application configure() {
    forceSet(TestProperties.CONTAINER_PORT, "0");
    return DropwizardResourceConfig.forTesting(new MetricRegistry())
            .register(OptionalMessageBodyWriter.class)
            .register(OptionalReturnResource.class);
}
 
Example #14
Source File: OptionalCookieParamResourceTest.java    From dropwizard-java8 with Apache License 2.0 5 votes vote down vote up
@Override
protected Application configure() {
    forceSet(TestProperties.CONTAINER_PORT, "0");
    return DropwizardResourceConfig.forTesting(new MetricRegistry())
            .register(OptionalParamFeature.class)
            .register(OptionalCookieParamResource.class)
            .register(MyMessageParamConverterProvider.class);
}
 
Example #15
Source File: OptionalFormParamResourceTest.java    From dropwizard-java8 with Apache License 2.0 5 votes vote down vote up
@Override
protected Application configure() {
    forceSet(TestProperties.CONTAINER_PORT, "0");
    return DropwizardResourceConfig.forTesting(new MetricRegistry())
            .register(OptionalParamFeature.class)
            .register(OptionalFormParamResource.class)
            .register(MyMessageParamConverterProvider.class);
}
 
Example #16
Source File: OptionalHeaderParamResourceTest.java    From dropwizard-java8 with Apache License 2.0 5 votes vote down vote up
@Override
protected Application configure() {
    forceSet(TestProperties.CONTAINER_PORT, "0");
    return DropwizardResourceConfig.forTesting(new MetricRegistry())
            .register(OptionalParamFeature.class)
            .register(OptionalHeaderParamResource.class)
            .register(MyMessageParamConverterProvider.class);
}
 
Example #17
Source File: FruitResourceIntegrationTest.java    From tutorials with MIT License 5 votes vote down vote up
@Override
protected Application configure() {
    enable(TestProperties.LOG_TRAFFIC);
    enable(TestProperties.DUMP_ENTITY);
    forceSet(TestProperties.CONTAINER_PORT, "0");

    ViewApplicationConfig config = new ViewApplicationConfig();
    config.register(FruitExceptionMapper.class);
    return config;
}
 
Example #18
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 #19
Source File: FastJsonProviderTest.java    From fastjson-jaxrs-json-provider with Apache License 2.0 5 votes vote down vote up
@Override
protected Application configure() {
	enable(TestProperties.LOG_TRAFFIC);
	enable(TestProperties.DUMP_ENTITY);

	ResourceConfig config = new ResourceConfig();
	//config.register(new FastJsonFeature()).register(FastJsonProvider.class);
	config.register(new FastJsonFeature()).register(new FastJsonProvider().setPretty(true));
	config.packages("com.colobu.fastjson");
	return config;
}
 
Example #20
Source File: ClassDefinitionFastJsonProviderTest.java    From fastjson-jaxrs-json-provider with Apache License 2.0 5 votes vote down vote up
@Override
protected Application configure() {
	enable(TestProperties.LOG_TRAFFIC);
	enable(TestProperties.DUMP_ENTITY);

	ResourceConfig config = new ResourceConfig();
	Class<?>[] jsonTypes = {User.class};
	config.register(new FastJsonFeature()).register(new FastJsonProvider(jsonTypes));
	config.packages("com.colobu.fastjson", "com.colobu.test");
	return config;
}
 
Example #21
Source File: ServerTest.java    From divide with Apache License 2.0 5 votes vote down vote up
@Override
protected Application configure() {
    container = TestUtils.setUp();
    enable(TestProperties.LOG_TRAFFIC);
    enable(TestProperties.DUMP_ENTITY);
    return container.app;
}
 
Example #22
Source File: QuestionnairResourceTest.java    From gazpachoquest with GNU General Public License v3.0 5 votes vote down vote up
@Override
protected ResourceConfig configure() {
    enable(TestProperties.LOG_TRAFFIC);
    enable(TestProperties.DUMP_ENTITY);
    ResourceConfig config = new ApplicationConfig();
    Map<String, Object> properties = new HashMap<String, Object>();
    properties.put("contextConfigLocation", "root-test-context.xml");
    config.setProperties(properties);
    return config;
}
 
Example #23
Source File: EngineAPIResourcesTest.java    From clouditor with Apache License 2.0 5 votes vote down vote up
@Override
protected Application configure() {
  // Find first available port.
  forceSet(TestProperties.CONTAINER_PORT, "0");

  return new EngineAPI(engine);
}
 
Example #24
Source File: JerseySpringTest.java    From gravitee-management-rest-api with Apache License 2.0 5 votes vote down vote up
@Autowired
public void setApplicationContext(final ApplicationContext context)
{
    _jerseyTest = new JerseyTest()
    {
        @Override
        protected Application configure()
        {
            // Find first available port.
            forceSet(TestProperties.CONTAINER_PORT, "0");

            ResourceConfig application = new GraviteePortalApplication(authenticationProviderManager);

            application.property("contextConfig", context);
            decorate(application);

            return application;
        }

        @Override
        protected void configureClient(ClientConfig config) {
            super.configureClient(config);

            config.register(ObjectMapperResolver.class);
            config.register(MultiPartFeature.class);
        }
    };
}
 
Example #25
Source File: FcmClientJerseyIntegrationTest.java    From FcmJava with MIT License 5 votes vote down vote up
@Override
protected Application configure() {
    restResource = new RestResource();
    forceSet(TestProperties.CONTAINER_PORT, "0");

    return new ResourceConfig()
            .register(restResource);
}
 
Example #26
Source File: SecretInjectionIT.java    From fernet-java8 with Apache License 2.0 5 votes vote down vote up
protected Application configure() {
    SLF4JBridgeHandler.removeHandlersForRootLogger();
    SLF4JBridgeHandler.install();
    enable(TestProperties.LOG_TRAFFIC);

    return new ExampleSecretInjectionApplication<User>();
}
 
Example #27
Source File: P2PRestAppTest.java    From tessera with Apache License 2.0 5 votes vote down vote up
@Before
public void setUp() throws Exception {

    Set services = new HashSet<>();
    services.add(mock(PartyInfoService.class));
    services.add(mock(TransactionManager.class));
    services.add(mock(Enclave.class));

    Client client = mock(Client.class);
    when(runtimeContext.getP2pClient()).thenReturn(client);
    when(runtimeContext.isRemoteKeyValidation()).thenReturn(true);


    MockServiceLocator serviceLocator = (MockServiceLocator) ServiceLocator.create();
    serviceLocator.setServices(services);

    p2PRestApp = new P2PRestApp();

    jersey =
        new JerseyTest() {
            @Override
            protected Application configure() {
                enable(TestProperties.LOG_TRAFFIC);
                enable(TestProperties.DUMP_ENTITY);
                ResourceConfig jerseyconfig = ResourceConfig.forApplication(p2PRestApp);
                return jerseyconfig;
            }
        };

    jersey.setUp();
}
 
Example #28
Source File: JerseySpringTest.java    From gravitee-management-rest-api with Apache License 2.0 5 votes vote down vote up
@Autowired
public void setApplicationContext(final ApplicationContext context)
{
    _jerseyTest = new JerseyTest()
    {
        
        @Override
        protected Application configure()
        {
            // Find first available port.
            forceSet(TestProperties.CONTAINER_PORT, "0");

            ResourceConfig application = new GraviteeManagementApplication(authenticationProviderManager);

            application.property("contextConfig", context);
            decorate(application);

            return application;
        }

        @Override
        protected void configureClient(ClientConfig config) {
            super.configureClient(config);

            config.register(ObjectMapperResolver.class);
            config.register(MultiPartFeature.class);
            config.property(HttpUrlConnectorProvider.SET_METHOD_WORKAROUND, true);

        }
    };
}
 
Example #29
Source File: EndpointTestBase.java    From emissary with Apache License 2.0 5 votes vote down vote up
@Override
protected Application configure() {
    new UnitTest().setupSystemProperties();
    // Tells Jersey to use first available port, fixes address already in use exception
    forceSet(TestProperties.CONTAINER_PORT, "0");
    final ResourceConfig application = new ResourceConfig();
    application.register(MultiPartFeature.class);
    application.property(MustacheMvcFeature.TEMPLATE_BASE_PATH, "/templates");
    application.register(MustacheMvcFeature.class).packages("emissary.server.mvc");
    application.register(MustacheMvcFeature.class).packages("emissary.server.api");

    return application;
}
 
Example #30
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();
}