use of com.google.api.server.spi.config.Api in project endpoints-java by cloudendpoints.
the class ApiConfigAnnotationReaderTest method testDeepInheritanceCycleDetection.
@Test
public void testDeepInheritanceCycleDetection() throws Exception {
// Nest the classes, so Java doesn't get upset about declaration/reference order.
@ApiReference(Test1.Test2.class)
@Api(name = "Test1")
final class Test1 {
@ApiReference(Test2.Test3.class)
final class Test2 {
@ApiReference(Test3.Test4.class)
@Api(name = "Test3")
final class Test3 {
@ApiReference(Test4.Test5.class)
final class Test4 {
@ApiReference(Test5.Test6.class)
@Api(name = "Test5")
final class Test5 {
@ApiReference(Test6.Test7.class)
final class Test6 {
@ApiReference(Test7.Test8.class)
@Api(name = "Test7")
final class Test7 {
@ApiReference(Test1.class)
final class Test8 {
}
}
}
}
}
}
}
}
try {
ApiConfig config = createConfig(Test1.class);
annotationReader.loadEndpointClass(serviceContext, Test1.class, config);
fail();
} catch (CyclicApiInheritanceException e) {
// Expected.
}
}
use of com.google.api.server.spi.config.Api in project endpoints-java by cloudendpoints.
the class ApiConfigValidatorTest method testApiMethodConfigWithApiMethodNameContainingStartingDot.
@Test
public void testApiMethodConfigWithApiMethodNameContainingStartingDot() throws Exception {
@Api(name = "testApi", version = "v1", resource = "bar")
final class Test {
@ApiMethod(name = ".Api.TestMethod")
public void test() {
}
}
ApiConfig config = configLoader.loadConfiguration(ServiceContext.create(), Test.class);
try {
validator.validate(config);
fail("Expected InvalidMethodNameException.");
} catch (InvalidMethodNameException expected) {
}
}
use of com.google.api.server.spi.config.Api in project endpoints-java by cloudendpoints.
the class ApiConfigValidatorTest method testInconsistentApiWideConfig.
@Test
public void testInconsistentApiWideConfig() throws Exception {
@Api(name = "testApi", version = "v1", resource = "foo")
final class Test1 {
}
ApiConfig config1 = configLoader.loadConfiguration(ServiceContext.create(), Test1.class);
@Api(name = "testApi", version = "v1", resource = "bar")
final class Test2 {
}
ApiConfig config2 = configLoader.loadConfiguration(ServiceContext.create(), Test2.class);
try {
validator.validate(Lists.newArrayList(config1, config2));
fail("Expected InconsistentApiConfigurationException.");
} catch (InconsistentApiConfigurationException expected) {
}
}
use of com.google.api.server.spi.config.Api in project endpoints-java by cloudendpoints.
the class ApiConfigValidatorTest method testDifferentApisWithSameApiWideConfig.
@Test
public void testDifferentApisWithSameApiWideConfig() throws Exception {
@Api(name = "testApi", version = "v1", resource = "foo")
final class Test1 {
}
ApiConfig config1 = configLoader.loadConfiguration(ServiceContext.create(), Test1.class);
@Api(name = "testApi", version = "v1", resource = "foo")
@ApiClass(resource = "bar")
final class Test2 {
}
ApiConfig config2 = configLoader.loadConfiguration(ServiceContext.create(), Test2.class);
validator.validate(Lists.newArrayList(config1, config2));
}
use of com.google.api.server.spi.config.Api in project endpoints-java by cloudendpoints.
the class ApiConfigValidatorTest method testNonuniqueRestSignatures_multiClass.
@Test
public void testNonuniqueRestSignatures_multiClass() throws Exception {
@Api
class Foo {
@ApiMethod(path = "path")
public void foo() {
}
}
ApiConfig config1 = configLoader.loadConfiguration(ServiceContext.create(), Foo.class);
@Api
class Bar {
@ApiMethod(path = "path")
public void bar() {
}
}
ApiConfig config2 = configLoader.loadConfiguration(ServiceContext.create(), Bar.class);
try {
validator.validate(Lists.newArrayList(config1, config2));
fail();
} catch (DuplicateRestPathException expected) {
}
}
Aggregations