Search in sources :

Example 1 with FrontendLimitsRule

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

the class ApiConfigAnnotationReaderTest method testFrontendLimitsRuleWithSameMatchOverridesParentRule.

@Test
public void testFrontendLimitsRuleWithSameMatchOverridesParentRule() throws Exception {
    @Api(frontendLimits = @ApiFrontendLimits(rules = { @ApiFrontendLimitRule(match = "test", qps = 1) }))
    class Test {
    }
    @Api(frontendLimits = @ApiFrontendLimits(rules = { @ApiFrontendLimitRule(match = "test", userQps = 1) }))
    final class Child extends Test {
    }
    ApiConfig config = createConfig(Child.class);
    annotationReader.loadEndpointClass(serviceContext, Child.class, config);
    assertEquals(1, config.getFrontendLimitsConfig().getRules().size());
    FrontendLimitsRule rule = config.getFrontendLimitsConfig().getRules().get(0);
    assertEquals("test", rule.getMatch());
    assertEquals(-1, rule.getQps());
    assertEquals(1, rule.getUserQps());
}
Also used : FrontendLimitsRule(com.google.api.server.spi.config.model.ApiFrontendLimitsConfig.FrontendLimitsRule) Test(org.junit.Test) ApiFrontendLimits(com.google.api.server.spi.config.ApiFrontendLimits) 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

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