本文整理匯總了Java中com.google.api.server.spi.config.Api類的典型用法代碼示例。如果您正苦於以下問題:Java Api類的具體用法?Java Api怎麽用?Java Api使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
Api類屬於com.google.api.server.spi.config包,在下文中一共展示了Api類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: testNonuniqueRestSignatures_multiClass
import com.google.api.server.spi.config.Api; //導入依賴的package包/類
@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) {
}
}
示例2: testInconsistentApiWideConfig
import com.google.api.server.spi.config.Api; //導入依賴的package包/類
@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) {
}
}
示例3: testApiMethodConfigWithApiMethodNameContainingSpecialCharacter
import com.google.api.server.spi.config.Api; //導入依賴的package包/類
@Test
public void testApiMethodConfigWithApiMethodNameContainingSpecialCharacter() throws Exception {
@Api(name = "testApi", version = "v1", resource = "bar")
final class Test {
@ApiMethod(name = "Api.Test#Method")
public void test() {
}
}
ApiConfig config = configLoader.loadConfiguration(ServiceContext.create(), Test.class);
try {
validator.validate(config);
fail("Expected InvalidMethodNameException.");
} catch (InvalidMethodNameException expected) {
}
}
示例4: testApiMethodConfigWithApiMethodNameContainingContinuousDots
import com.google.api.server.spi.config.Api; //導入依賴的package包/類
@Test
public void testApiMethodConfigWithApiMethodNameContainingContinuousDots() throws Exception {
@Api(name = "testApi", version = "v1", resource = "bar")
final class Test {
@ApiMethod(name = "TestApi..testMethod")
public void test() {
}
}
ApiConfig config = configLoader.loadConfiguration(ServiceContext.create(), Test.class);
try {
validator.validate(config);
fail("Expected InvalidMethodNameException.");
} catch (InvalidMethodNameException expected) {
}
}
示例5: testApiMethodConfigWithApiMethodNameContainingStartingDot
import com.google.api.server.spi.config.Api; //導入依賴的package包/類
@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) {
}
}
示例6: testApiMethodConfigWithApiMethodNameContainingEndingDot
import com.google.api.server.spi.config.Api; //導入依賴的package包/類
@Test
public void testApiMethodConfigWithApiMethodNameContainingEndingDot() 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) {
}
}
示例7: testValidateMethods_ignoredMethod
import com.google.api.server.spi.config.Api; //導入依賴的package包/類
@Test
public void testValidateMethods_ignoredMethod() throws Exception {
final class Bean {
}
@Api
final class Endpoint {
@ApiMethod(ignored = AnnotationBoolean.TRUE)
public void thisShouldBeIgnored(Bean resource1, Bean resource2) {
}
}
ApiConfig config = configLoader.loadConfiguration(ServiceContext.create(), Endpoint.class);
// If this passes validation, then no error will be thrown. Otherwise, the validator will
// complain that the method has two resources.
validator.validate(config);
}
示例8: testWildcardParameterTypes
import com.google.api.server.spi.config.Api; //導入依賴的package包/類
@Test
public void testWildcardParameterTypes() throws Exception {
@Api
final class WildcardEndpoint {
@SuppressWarnings("unused")
public void foo(Map<String, ? extends Integer> map) {}
}
try {
ApiConfig config = createConfig(WildcardEndpoint.class);
annotationReader.loadEndpointMethods(serviceContext, WildcardEndpoint.class,
config.getApiClassConfig().getMethods());
fail("Config generation for service class with wildcard parameter type should have failed");
} catch (IllegalArgumentException e) {
// expected
}
}
示例9: testFrontendLimitsRuleWithSameMatchOverridesParentRule
import com.google.api.server.spi.config.Api; //導入依賴的package包/類
@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());
}
示例10: testParameterDescription
import com.google.api.server.spi.config.Api; //導入依賴的package包/類
@Test
public void testParameterDescription() throws Exception {
@Api
final class TestParameterDescription {
public void foo(@Description("desc") String param) {}
}
ApiConfig config = createConfig(TestParameterDescription.class);
annotationReader.loadEndpointMethods(serviceContext, TestParameterDescription.class,
config.getApiClassConfig().getMethods());
ApiMethodConfig methodConfig =
Iterables.getOnlyElement(config.getApiClassConfig().getMethods().values());
ApiParameterConfig parameterConfig =
Iterables.getOnlyElement(methodConfig.getParameterConfigs());
assertEquals("desc", parameterConfig.getDescription());
}
示例11: testSerializedParameter
import com.google.api.server.spi.config.Api; //導入依賴的package包/類
@Test
public void testSerializedParameter() throws Exception {
@Api
final class Test {
@SuppressWarnings("unused")
public void method(@Named("serialized") TestBean tb) {}
}
ApiConfig config = createConfig(Test.class);
annotationReader.loadEndpointClass(serviceContext, Test.class, config);
annotationReader.loadEndpointMethods(serviceContext, Test.class,
config.getApiClassConfig().getMethods());
ApiMethodConfig methodConfig =
config.getApiClassConfig().getMethods().get(methodToEndpointMethod(Test.class.getMethod(
"method", TestBean.class)));
validateMethod(methodConfig, "Test.method", "method/{serialized}", ApiMethod.HttpMethod.POST,
DEFAULT_SCOPES,
DEFAULT_AUDIENCES,
DEFAULT_CLIENTIDS,
null,
null);
validateParameter(methodConfig.getParameterConfigs().get(0), "serialized", false, null,
TestBean.class, TestSerializer.class, String.class);
}
示例12: testLevelOverridingWithDefaultOverrides
import com.google.api.server.spi.config.Api; //導入依賴的package包/類
@Test
public void testLevelOverridingWithDefaultOverrides() throws Exception {
@Api(
scopes = {"s0c", "s1c"},
audiences = {"a0c", "a1c"},
clientIds = {"c0c", "c1c"},
resource = "resource2",
useDatastoreForAdditionalConfig = AnnotationBoolean.TRUE
)
final class Test extends SimpleLevelOverridingInheritedApi {
}
ApiConfig config = createConfig(Test.class);
annotationReader.loadEndpointClass(serviceContext, Test.class, config);
annotationReader.loadEndpointMethods(serviceContext, Test.class,
config.getApiClassConfig().getMethods());
// All values overridden at a lower level, so nothing should change.
verifySimpleLevelOverriding(config);
}
示例13: testGenericParameterTypes
import com.google.api.server.spi.config.Api; //導入依賴的package包/類
@Test
public void testGenericParameterTypes() throws Exception {
@Api
final class Test <T> {
@SuppressWarnings("unused")
public void setT(T t) {}
}
ApiConfig config = createConfig(Test.class);
annotationReader.loadEndpointMethods(serviceContext, Test.class,
config.getApiClassConfig().getMethods());
ApiParameterConfig parameter =
config.getApiClassConfig().getMethods()
.get(methodToEndpointMethod(Test.class.getDeclaredMethod("setT", Object.class)))
.getParameterConfigs()
.get(0);
assertEquals(ApiParameterConfig.Classification.UNKNOWN, parameter.getClassification());
}
示例14: genericParameterTypeTestImpl
import com.google.api.server.spi.config.Api; //導入依賴的package包/類
private <T> void genericParameterTypeTestImpl() throws Exception {
@Api
class Bar <T1> {
@SuppressWarnings("unused")
public void bar(T1 t1) {}
}
class Foo extends Bar<T> {}
ApiConfig config = createConfig(Foo.class);
annotationReader.loadEndpointMethods(serviceContext, Foo.class,
config.getApiClassConfig().getMethods());
ApiParameterConfig parameter =
config.getApiClassConfig().getMethods()
.get(methodToEndpointMethod(
Foo.class.getSuperclass().getDeclaredMethod("bar", Object.class)))
.getParameterConfigs()
.get(0);
assertEquals(ApiParameterConfig.Classification.UNKNOWN, parameter.getClassification());
}
示例15: testKnownParameterizedType
import com.google.api.server.spi.config.Api; //導入依賴的package包/類
@Test
public void testKnownParameterizedType() throws Exception {
@Api
class Bar <T1> {
@SuppressWarnings("unused")
public void bar(T1 t1) {}
}
class Foo extends Bar<Integer> {}
ApiConfig config = createConfig(Foo.class);
annotationReader.loadEndpointMethods(serviceContext, Foo.class,
config.getApiClassConfig().getMethods());
ApiParameterConfig parameter =
config.getApiClassConfig().getMethods()
.get(methodToEndpointMethod(
Foo.class.getSuperclass().getDeclaredMethod("bar", Object.class)))
.getParameterConfigs()
.get(0);
assertEquals(ApiParameterConfig.Classification.API_PARAMETER, parameter.getClassification());
}