Java源码示例:io.dropwizard.jersey.DropwizardResourceConfig
示例1
@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();
}
示例2
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);
}
示例3
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);
}
示例4
@Override
protected Application configure() {
forceSet(TestProperties.CONTAINER_PORT, "0");
return DropwizardResourceConfig.forTesting(new MetricRegistry())
.register(OptionalParamFeature.class)
.register(OptionalQueryParamResource.class)
.register(MyMessageParamConverterProvider.class);
}
示例5
@Override
protected Application configure() {
forceSet(TestProperties.CONTAINER_PORT, "0");
return DropwizardResourceConfig.forTesting(new MetricRegistry())
.register(OptionalMessageBodyWriter.class)
.register(OptionalReturnResource.class);
}
示例6
@Override
protected Application configure() {
forceSet(TestProperties.CONTAINER_PORT, "0");
return DropwizardResourceConfig.forTesting(new MetricRegistry())
.register(OptionalParamFeature.class)
.register(OptionalCookieParamResource.class)
.register(MyMessageParamConverterProvider.class);
}
示例7
@Override
protected Application configure() {
forceSet(TestProperties.CONTAINER_PORT, "0");
return DropwizardResourceConfig.forTesting(new MetricRegistry())
.register(OptionalParamFeature.class)
.register(OptionalFormParamResource.class)
.register(MyMessageParamConverterProvider.class);
}
示例8
@Override
protected Application configure() {
forceSet(TestProperties.CONTAINER_PORT, "0");
return DropwizardResourceConfig.forTesting(new MetricRegistry())
.register(OptionalParamFeature.class)
.register(OptionalHeaderParamResource.class)
.register(MyMessageParamConverterProvider.class);
}
示例9
@Override
protected DropwizardResourceConfig getDropwizardResourceConfig() {
return new JwtAuthTestResourceConfig();
}
示例10
@Override
protected DropwizardResourceConfig getDropwizardResourceConfig() {
return new ChainedAuthTestResourceConfig();
}
示例11
@Override
protected DropwizardResourceConfig getDropwizardResourceConfig() {
return new BasicAuthTestResourceConfig();
}
示例12
@Override
protected DropwizardResourceConfig getDropwizardResourceConfig() {
return new OAuthProviderTest.BasicAuthTestResourceConfig();
}
示例13
@Override
protected DropwizardResourceConfig getDropwizardResourceConfig() {
return new BasicAuthTestResourceConfig();
}
示例14
@Override
protected DropwizardResourceConfig getDropwizardResourceConfig() {
return new BasicAuthTestResourceConfig();
}
示例15
protected abstract DropwizardResourceConfig getDropwizardResourceConfig();
示例16
protected abstract DropwizardResourceConfig getDropwizardResourceConfig();