com.sun.jersey.test.framework.AppDescriptor Java Examples

The following examples show how to use com.sun.jersey.test.framework.AppDescriptor. 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: TestTransformJSONResource.java    From localization_nifi with Apache License 2.0 5 votes vote down vote up
@Override
protected AppDescriptor configure() {
    return new WebAppDescriptor.Builder()
            .initParam(WebComponent.RESOURCE_CONFIG_CLASS, ClassNamesResourceConfig.class.getName())
            .initParam(ClassNamesResourceConfig.PROPERTY_CLASSNAMES,
                    TransformJSONResource.class.getName() + ";" + MockServletContext.class.getName() + ";" + MockRequestContext.class.getName()+";")
            .initParam("com.sun.jersey.api.json.POJOMappingFeature", "true")
            .build();
}
 
Example #3
Source File: TestProcessorResource.java    From localization_nifi with Apache License 2.0 5 votes vote down vote up
@Override
protected AppDescriptor configure() {
    return new WebAppDescriptor.Builder()
            .initParam(WebComponent.RESOURCE_CONFIG_CLASS, ClassNamesResourceConfig.class.getName())
            .initParam(ClassNamesResourceConfig.PROPERTY_CLASSNAMES,
                    ProcessorResource.class.getName() +
                            ";" + TestProcessorResource.MockServletContext.class.getName() +
                            ";" + TestProcessorResource.MockRequestContext.class.getName()+";")
            .initParam("com.sun.jersey.api.json.POJOMappingFeature", "true")
            .build();
}
 
Example #4
Source File: HmacAuthProviderTest.java    From jersey-hmac-auth with Apache License 2.0 5 votes vote down vote up
@Override
protected AppDescriptor configure() {
    this.requestConfiguration = RequestConfiguration.builder().withApiKeyQueryParamName("passkey")
            .withSignatureHttpHeader("duck-duck-signature-header")
            .withTimestampHttpHeader("duck-duck-timestamp-header")
            .withVersionHttpHeader("duck-duck-version-header")
            .build();
    final Authenticator<String> authenticator = new Authenticator<String>() {
        @Override
        public String getApiKeyName() {
            return DEFAULT_API_KEY_PARAM;
        }

        @Override
        public String authenticate(Credentials credentials) {
            if (GOOD_API_KEY.equals(credentials.getApiKey())) {
                return GOOD_API_KEY;
            }
            if (INTERNAL_ERROR.equals(credentials.getApiKey())) {
                throw new IllegalStateException("An internal error occurred");
            }
            return null;
        }
    };

    ResourceConfig config = new ScanningResourceConfig();
    config.getSingletons().add(new HmacAuthProvider<String>(new DefaultRequestHandler<String>(authenticator, requestConfiguration)));
    config.getSingletons().add(new AuthResource());
    return new LowLevelAppDescriptor.Builder(config).build();
}
 
Example #5
Source File: PublishRestUtilTestIT.java    From pentaho-reporting with GNU Lesser General Public License v2.1 5 votes vote down vote up
@Override
protected AppDescriptor configure() {
  ClientConfig config = new DefaultClientConfig();
  config.getClasses().add( MultiPartWriter.class );
  config.getClasses().add( TestRepositoryPublishResource.class );
  config.getFeatures().put( JSONConfiguration.FEATURE_POJO_MAPPING, Boolean.TRUE );

  return new WebAppDescriptor.Builder( "org.pentaho.reporting.libraries.pensol.resources" )
    .contextPath( "api" )
    .clientConfig( config )
    .build();
}
 
Example #6
Source File: TrimouViewRendererTest.java    From trimou with Apache License 2.0 5 votes vote down vote up
@Override
protected AppDescriptor configure() {
    final DefaultResourceConfig config = new DefaultResourceConfig();
    final ViewRenderer renderer = new TrimouViewRenderer.Builder().build();
    config.getSingletons().add(new ViewMessageBodyWriter(new MetricRegistry(), ImmutableList.of(renderer)));
    config.getSingletons().add(new TestResource());
    return new LowLevelAppDescriptor.Builder(config).build();
}
 
Example #7
Source File: ScriptTestBase.java    From io with Apache License 2.0 2 votes vote down vote up
/**
 * コンストラクタ.
 * @param ad .
 */
public ScriptTestBase(AppDescriptor ad) {
    super(ad);
}