io.dropwizard.jersey.DropwizardResourceConfig Java Examples

The following examples show how to use io.dropwizard.jersey.DropwizardResourceConfig. 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: AbstractResourceTest.java    From monasca-common with Apache License 2.0 6 votes vote down vote up
@BeforeMethod
protected void beforeTestCase() throws Exception {
  singletons.clear();
  providers.clear();
  features.clear();
  properties.clear();
  setupResources();

  test = new JerseyTest() {
    @Override
    protected AppDescriptor configure() {
      final DropwizardResourceConfig config = DropwizardResourceConfig.forTesting(metricRegistry);
      for (Class<?> provider : providers)
        config.getClasses().add(provider);
      for (Map.Entry<String, Boolean> feature : features.entrySet())
        config.getFeatures().put(feature.getKey(), feature.getValue());
      for (Map.Entry<String, Object> property : properties.entrySet())
        config.getProperties().put(property.getKey(), property.getValue());
      config.getSingletons().add(new JacksonMessageBodyProvider(objectMapper, validator));
      config.getSingletons().addAll(singletons);
      return new LowLevelAppDescriptor.Builder(config).build();
    }
  };

  test.setUp();
}
 
Example #2
Source File: TestHelpers.java    From jobson with Apache License 2.0 5 votes vote down vote up
public static AuthenticationBootstrap createTypicalAuthBootstrap() {
    final UserDAO userDAO = mock(UserDAO.class);
    final Server s = new Server(0);
    final Servlet se = new ServletContainer();
    final JerseyEnvironment env = new JerseyEnvironment(new JerseyContainerHolder(se), new DropwizardResourceConfig());

    return new AuthenticationBootstrap(env, userDAO);
}
 
Example #3
Source File: SoaBundle.java    From soabase with Apache License 2.0 5 votes vote down vote up
private void initJerseyAdmin(SoaConfiguration configuration, SoaFeaturesImpl features, Ports ports, final Environment environment, AbstractBinder binder)
{
    if ( (configuration.getAdminJerseyPath() == null) || !ports.adminPort.hasPort() )
    {
        return;
    }

    String jerseyRootPath = configuration.getAdminJerseyPath();
    if ( !jerseyRootPath.endsWith("/*") )
    {
        if ( jerseyRootPath.endsWith("/") )
        {
            jerseyRootPath += "*";
        }
        else
        {
            jerseyRootPath += "/*";
        }
    }

    DropwizardResourceConfig jerseyConfig = new DropwizardResourceConfig(environment.metrics());
    jerseyConfig.setUrlPattern(jerseyRootPath);

    JerseyContainerHolder jerseyServletContainer = new JerseyContainerHolder(new ServletContainer(jerseyConfig));
    environment.admin().addServlet("soa-admin-jersey", jerseyServletContainer.getContainer()).addMapping(jerseyRootPath);

    JerseyEnvironment jerseyEnvironment = new JerseyEnvironment(jerseyServletContainer, jerseyConfig);
    features.putNamed(jerseyEnvironment, JerseyEnvironment.class, SoaFeatures.ADMIN_NAME);
    jerseyEnvironment.register(SoaApis.class);
    jerseyEnvironment.register(DiscoveryApis.class);
    jerseyEnvironment.register(DynamicAttributeApis.class);
    jerseyEnvironment.register(LoggingApis.class);
    jerseyEnvironment.register(binder);
    jerseyEnvironment.setUrlPattern(jerseyConfig.getUrlPattern());
    jerseyEnvironment.register(new JacksonMessageBodyProvider(environment.getObjectMapper()));

    checkCorsFilter(configuration, environment.admin());
    checkAdminGuiceFeature(environment, jerseyEnvironment);
}
 
Example #4
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 #5
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 #6
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 #7
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 #8
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 #9
Source File: JwtAuthProviderTest.java    From dropwizard-auth-jwt with Apache License 2.0 4 votes vote down vote up
@Override
protected DropwizardResourceConfig getDropwizardResourceConfig() {
    return new JwtAuthTestResourceConfig();
}
 
Example #10
Source File: ChainedAuthProviderTest.java    From dropwizard-java8 with Apache License 2.0 4 votes vote down vote up
@Override
protected DropwizardResourceConfig getDropwizardResourceConfig() {
    return new ChainedAuthTestResourceConfig();
}
 
Example #11
Source File: OAuthProviderTest.java    From dropwizard-java8 with Apache License 2.0 4 votes vote down vote up
@Override
protected DropwizardResourceConfig getDropwizardResourceConfig() {
    return new BasicAuthTestResourceConfig();
}
 
Example #12
Source File: OAuthCustomProviderTest.java    From dropwizard-java8 with Apache License 2.0 4 votes vote down vote up
@Override
protected DropwizardResourceConfig getDropwizardResourceConfig() {
    return new OAuthProviderTest.BasicAuthTestResourceConfig();
}
 
Example #13
Source File: BasicAuthProviderTest.java    From dropwizard-java8 with Apache License 2.0 4 votes vote down vote up
@Override
protected DropwizardResourceConfig getDropwizardResourceConfig() {
    return new BasicAuthTestResourceConfig();
}
 
Example #14
Source File: BasicCustomAuthProviderTest.java    From dropwizard-java8 with Apache License 2.0 4 votes vote down vote up
@Override
protected DropwizardResourceConfig getDropwizardResourceConfig() {
    return new BasicAuthTestResourceConfig();
}
 
Example #15
Source File: AuthBaseTest.java    From dropwizard-auth-jwt with Apache License 2.0 votes vote down vote up
protected abstract DropwizardResourceConfig getDropwizardResourceConfig(); 
Example #16
Source File: AuthBaseTest.java    From dropwizard-java8 with Apache License 2.0 votes vote down vote up
protected abstract DropwizardResourceConfig getDropwizardResourceConfig();