Search in sources :

Example 1 with ApiNamespace

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

the class ApiConfigAnnotationReaderTest method testReadParametersInApiNamespace.

@Test
public void testReadParametersInApiNamespace() throws Exception {
    @Api
    class ValidNamespaceDefault {
    }
    ApiConfig config = createConfig(ValidNamespaceDefault.class);
    annotationReader.loadEndpointClass(serviceContext, ValidNamespaceDefault.class, config);
    @Api(namespace = @ApiNamespace(ownerDomain = "domain", ownerName = ""))
    class BadNamespaceEmptyName {
    }
    config = createConfig(BadNamespaceEmptyName.class);
    annotationReader.loadEndpointClass(serviceContext, BadNamespaceEmptyName.class, config);
    assertEquals("domain", config.getNamespaceConfig().getOwnerDomain());
    @Api(namespace = @ApiNamespace(ownerDomain = "", ownerName = "name"))
    class BadNamespaceEmptyDomain {
    }
    config = createConfig(BadNamespaceEmptyDomain.class);
    annotationReader.loadEndpointClass(serviceContext, BadNamespaceEmptyDomain.class, config);
    assertEquals("name", config.getNamespaceConfig().getOwnerName());
    @Api(namespace = @ApiNamespace(ownerDomain = "domain", ownerName = "name"))
    class ValidNamespaceEmptyPackage {
    }
    config = createConfig(ValidNamespaceEmptyPackage.class);
    annotationReader.loadEndpointClass(serviceContext, ValidNamespaceEmptyPackage.class, config);
    assertEquals("domain", config.getNamespaceConfig().getOwnerDomain());
    assertEquals("name", config.getNamespaceConfig().getOwnerName());
    @Api(namespace = @ApiNamespace(ownerDomain = "domain", ownerName = "name", packagePath = "package"))
    class ValidNamespaceFullySpecified {
    }
    config = createConfig(ValidNamespaceFullySpecified.class);
    annotationReader.loadEndpointClass(serviceContext, ValidNamespaceFullySpecified.class, config);
    assertEquals("domain", config.getNamespaceConfig().getOwnerDomain());
    assertEquals("name", config.getNamespaceConfig().getOwnerName());
    assertEquals("package", config.getNamespaceConfig().getPackagePath());
}
Also used : ApiConfig(com.google.api.server.spi.config.model.ApiConfig) SimpleLevelOverridingApi(com.google.api.server.spi.testing.SimpleLevelOverridingApi) SimpleLevelOverridingInheritedApi(com.google.api.server.spi.testing.SimpleLevelOverridingInheritedApi) Api(com.google.api.server.spi.config.Api) ApiNamespace(com.google.api.server.spi.config.ApiNamespace) Test(org.junit.Test)

Aggregations

Api (com.google.api.server.spi.config.Api)1 ApiNamespace (com.google.api.server.spi.config.ApiNamespace)1 ApiConfig (com.google.api.server.spi.config.model.ApiConfig)1 SimpleLevelOverridingApi (com.google.api.server.spi.testing.SimpleLevelOverridingApi)1 SimpleLevelOverridingInheritedApi (com.google.api.server.spi.testing.SimpleLevelOverridingInheritedApi)1 Test (org.junit.Test)1