Search in sources :

Example 6 with TypeLoader

use of com.google.api.server.spi.TypeLoader in project endpoints-java by cloudendpoints.

the class ApiConfigTest method setUp.

@Before
public void setUp() throws Exception {
    serviceContext = ServiceContext.create();
    typeLoader = new TypeLoader();
    apiConfig = new ApiConfig.Factory().create(serviceContext, typeLoader, TestEndpoint.class);
    apiConfig.getSerializationConfig().addSerializationConfig(IntegerToStringSerializer.class);
    apiConfig.getSerializationConfig().addSerializationConfig(LongToStringSerializer.class);
    apiConfig.getSerializationConfig().addSerializationConfig(FloatToStringSerializer.class);
    apiConfig2 = new ApiConfig.Factory().create(serviceContext, typeLoader, TestEndpoint.class);
    apiConfig2.getSerializationConfig().addSerializationConfig(IntegerToStringSerializer.class);
    apiConfig2.getSerializationConfig().addSerializationConfig(LongToStringSerializer.class);
    apiConfig2.getSerializationConfig().addSerializationConfig(FloatToStringSerializer.class);
}
Also used : TestEndpoint(com.google.api.server.spi.testing.TestEndpoint) TypeLoader(com.google.api.server.spi.TypeLoader) Before(org.junit.Before)

Example 7 with TypeLoader

use of com.google.api.server.spi.TypeLoader in project endpoints-java by cloudendpoints.

the class SwaggerGeneratorTest method setUp.

@Before
public void setUp() throws Exception {
    TypeLoader typeLoader = new TypeLoader(getClass().getClassLoader());
    ApiConfigAnnotationReader annotationReader = new ApiConfigAnnotationReader(typeLoader.getAnnotationTypes());
    this.configLoader = new ApiConfigLoader(new ApiConfig.Factory(), typeLoader, annotationReader);
}
Also used : ApiConfigAnnotationReader(com.google.api.server.spi.config.annotationreader.ApiConfigAnnotationReader) ApiConfigLoader(com.google.api.server.spi.config.ApiConfigLoader) TypeLoader(com.google.api.server.spi.TypeLoader) Before(org.junit.Before)

Example 8 with TypeLoader

use of com.google.api.server.spi.TypeLoader in project endpoints-java by cloudendpoints.

the class SwaggerGenerator method writeSwagger.

public Swagger writeSwagger(Iterable<ApiConfig> configs, boolean writeInternal, SwaggerContext context) throws ApiConfigException {
    try {
        TypeLoader typeLoader = new TypeLoader(SwaggerGenerator.class.getClassLoader());
        SchemaRepository repo = new SchemaRepository(typeLoader);
        GenerationContext genCtx = new GenerationContext();
        genCtx.validator = new ApiConfigValidator(typeLoader, repo);
        genCtx.writeInternal = writeInternal;
        genCtx.schemata = new SchemaRepository(typeLoader);
        return writeSwagger(configs, context, genCtx);
    } catch (ClassNotFoundException e) {
        throw new IllegalStateException(e);
    }
}
Also used : ApiConfigValidator(com.google.api.server.spi.config.validation.ApiConfigValidator) TypeLoader(com.google.api.server.spi.TypeLoader) SchemaRepository(com.google.api.server.spi.config.model.SchemaRepository)

Example 9 with TypeLoader

use of com.google.api.server.spi.TypeLoader in project endpoints-java by cloudendpoints.

the class ApiConfigValidatorTest method setUp.

@Before
public void setUp() throws Exception {
    TypeLoader typeLoader = new TypeLoader(ApiConfigValidator.class.getClassLoader());
    SchemaRepository schemaRepository = new SchemaRepository(typeLoader);
    validator = new ApiConfigValidator(typeLoader, schemaRepository);
    configFactory = new ApiConfig.Factory();
    configLoader = new ApiConfigLoader();
    config = configLoader.loadConfiguration(ServiceContext.create(), TestEndpoint.class);
}
Also used : TestEndpoint(com.google.api.server.spi.testing.TestEndpoint) ApiConfigLoader(com.google.api.server.spi.config.ApiConfigLoader) TypeLoader(com.google.api.server.spi.TypeLoader) ApiConfig(com.google.api.server.spi.config.model.ApiConfig) SchemaRepository(com.google.api.server.spi.config.model.SchemaRepository) Before(org.junit.Before)

Example 10 with TypeLoader

use of com.google.api.server.spi.TypeLoader in project endpoints-java by cloudendpoints.

the class DiscoveryGeneratorTest method setUp.

@Before
public void setUp() throws Exception {
    TypeLoader typeLoader = new TypeLoader(getClass().getClassLoader());
    ApiConfigAnnotationReader annotationReader = new ApiConfigAnnotationReader(typeLoader.getAnnotationTypes());
    this.configLoader = new ApiConfigLoader(new ApiConfig.Factory(), typeLoader, annotationReader);
    this.generator = new DiscoveryGenerator(typeLoader);
    this.schemaRepository = new SchemaRepository(typeLoader);
}
Also used : ApiConfigAnnotationReader(com.google.api.server.spi.config.annotationreader.ApiConfigAnnotationReader) ApiConfigLoader(com.google.api.server.spi.config.ApiConfigLoader) TypeLoader(com.google.api.server.spi.TypeLoader) JacksonFactory(com.google.api.client.json.jackson2.JacksonFactory) SchemaRepository(com.google.api.server.spi.config.model.SchemaRepository) Before(org.junit.Before)

Aggregations

TypeLoader (com.google.api.server.spi.TypeLoader)18 Before (org.junit.Before)11 ApiConfig (com.google.api.server.spi.config.model.ApiConfig)7 ApiConfigLoader (com.google.api.server.spi.config.ApiConfigLoader)6 ApiConfigAnnotationReader (com.google.api.server.spi.config.annotationreader.ApiConfigAnnotationReader)6 SchemaRepository (com.google.api.server.spi.config.model.SchemaRepository)5 ApiConfigValidator (com.google.api.server.spi.config.validation.ApiConfigValidator)5 ServiceContext (com.google.api.server.spi.ServiceContext)4 TestEndpoint (com.google.api.server.spi.testing.TestEndpoint)4 ApiKey (com.google.api.server.spi.config.model.ApiKey)3 File (java.io.File)3 URLClassLoader (java.net.URLClassLoader)3 Test (org.junit.Test)3 Api (com.google.api.server.spi.config.Api)2 ApiSerializationConfig (com.google.api.server.spi.config.model.ApiSerializationConfig)2 EndpointsPrettyPrinter (com.google.api.server.spi.response.EndpointsPrettyPrinter)2 Map (java.util.Map)2 MockHttpServletRequest (org.springframework.mock.web.MockHttpServletRequest)2 ObjectWriter (com.fasterxml.jackson.databind.ObjectWriter)1 JacksonFactory (com.google.api.client.json.jackson2.JacksonFactory)1