Search in sources :

Example 1 with ApiReference

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

the class ApiConfigAnnotationReaderTest method testSimpleInheritanceCycleDetection.

@Test
public void testSimpleInheritanceCycleDetection() throws Exception {
    // Nest the classes, so Java doesn't get upset about declaration/reference order.
    @ApiReference(Test1.Test2.class)
    final class Test1 {

        @ApiReference(Test1.class)
        final class Test2 {
        }
    }
    try {
        ApiConfig config = createConfig(Test1.class);
        annotationReader.loadEndpointClass(serviceContext, Test1.class, config);
        fail();
    } catch (CyclicApiInheritanceException e) {
    // Expected.
    }
}
Also used : ApiReference(com.google.api.server.spi.config.ApiReference) ApiConfig(com.google.api.server.spi.config.model.ApiConfig) Test(org.junit.Test)

Example 2 with ApiReference

use of com.google.api.server.spi.config.ApiReference 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.
    }
}
Also used : ApiReference(com.google.api.server.spi.config.ApiReference) 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) Test(org.junit.Test)

Aggregations

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