├── .gitignore ├── .travis.yml ├── CONTRIBUTING.md ├── LICENSE ├── README.md ├── build.gradle ├── discovery-client ├── LICENSE.txt ├── build.gradle ├── proguard-google-api-client.txt ├── readme.html └── src │ └── main │ └── java │ └── com │ └── google │ └── api │ └── services │ └── discovery │ ├── Discovery.java │ ├── DiscoveryRequest.java │ ├── DiscoveryRequestInitializer.java │ └── model │ ├── ApiConfig.java │ ├── ApiConfigs.java │ ├── DirectoryList.java │ ├── JsonSchema.java │ ├── RestDescription.java │ ├── RestMethod.java │ ├── RestResource.java │ ├── RpcDescription.java │ └── RpcMethod.java ├── endpoints-framework-all └── build.gradle ├── endpoints-framework-guice ├── build.gradle └── src │ ├── main │ └── java │ │ └── com │ │ └── google │ │ └── api │ │ └── server │ │ └── spi │ │ └── guice │ │ ├── EndpointsModule.java │ │ ├── GuiceEndpointsServlet.java │ │ ├── Preconditions.java │ │ └── ServiceMap.java │ └── test │ └── java │ └── com │ └── google │ └── api │ └── server │ └── spi │ └── guice │ ├── DummyModule.java │ ├── EndpointsModuleTest.java │ ├── InterceptorModule.java │ ├── SystemServiceTest.java │ └── TestInterceptor.java ├── endpoints-framework-tools ├── build.gradle └── src │ ├── main │ ├── java │ │ └── com │ │ │ └── google │ │ │ └── api │ │ │ └── server │ │ │ └── spi │ │ │ └── tools │ │ │ ├── AnnotationApiConfigGenerator.java │ │ │ ├── ApiConfigGenerator.java │ │ │ ├── AppEngineUtil.java │ │ │ ├── ClientLibGenerator.java │ │ │ ├── CloudClientLibGenerator.java │ │ │ ├── EndpointsTool.java │ │ │ ├── EndpointsToolAction.java │ │ │ ├── GenApiConfigAction.java │ │ │ ├── GenClientLibAction.java │ │ │ ├── GetClientLibAction.java │ │ │ ├── GetDiscoveryDocAction.java │ │ │ ├── GetOpenApiDocAction.java │ │ │ ├── HelpAction.java │ │ │ ├── JacksonUtil.java │ │ │ ├── WebXml.java │ │ │ └── testing │ │ │ ├── FakeApiConfigGenerator.java │ │ │ └── FakeClientLibGenerator.java │ └── resources │ │ └── com │ │ └── google │ │ └── api │ │ └── server │ │ └── spi │ │ └── tools │ │ └── testing │ │ ├── fake-api-client-lib.jar │ │ ├── fake-api-config.json │ │ └── fake-discovery-doc-rest.json │ └── test │ ├── java │ └── com │ │ └── google │ │ └── api │ │ └── server │ │ └── spi │ │ └── tools │ │ ├── AnnotationApiConfigGeneratorTest.java │ │ ├── CloudClientLibGeneratorTest.java │ │ ├── EndpointsToolActionTest.java │ │ ├── EndpointsToolTest.java │ │ ├── GenApiConfigActionTest.java │ │ ├── GenClientLibActionTest.java │ │ ├── GetClientLibActionTest.java │ │ ├── GetDiscoveryDocActionTest.java │ │ ├── GetOpenApiDocActionTest.java │ │ ├── GpeMockTest.java │ │ ├── HelpActionTest.java │ │ ├── JacksonUtilTest.java │ │ ├── WebXmlTest.java │ │ └── testing │ │ ├── FakeApiConfigGeneratorTest.java │ │ └── FakeClientLibGeneratorTest.java │ └── resources │ └── com │ └── google │ └── api │ └── server │ └── spi │ └── tools │ ├── devserver │ ├── guestbook-v1.api │ └── sample-v1.api │ └── web.xml ├── endpoints-framework ├── build.gradle └── src │ ├── main │ ├── java │ │ └── com │ │ │ └── google │ │ │ └── api │ │ │ └── server │ │ │ └── spi │ │ │ ├── BackendProperties.java │ │ │ ├── Client.java │ │ │ ├── ConfiguredObjectMapper.java │ │ │ ├── Constant.java │ │ │ ├── EndpointMethod.java │ │ │ ├── EndpointsContext.java │ │ │ ├── EndpointsServlet.java │ │ │ ├── EnvUtil.java │ │ │ ├── Headers.java │ │ │ ├── IoUtil.java │ │ │ ├── MethodHierarchyReader.java │ │ │ ├── ObjectMapperUtil.java │ │ │ ├── PeerAuth.java │ │ │ ├── ServiceContext.java │ │ │ ├── ServiceException.java │ │ │ ├── ServletInitializationParameters.java │ │ │ ├── Strings.java │ │ │ ├── SystemService.java │ │ │ ├── TypeLoader.java │ │ │ ├── auth │ │ │ ├── EndpointsAuthenticator.java │ │ │ ├── EndpointsPeerAuthenticator.java │ │ │ ├── GoogleAppEngineAuthenticator.java │ │ │ ├── GoogleAuth.java │ │ │ ├── GoogleJwtAuthenticator.java │ │ │ ├── GoogleOAuth2Authenticator.java │ │ │ └── common │ │ │ │ └── User.java │ │ │ ├── config │ │ │ ├── AnnotationBoolean.java │ │ │ ├── Api.java │ │ │ ├── ApiAuth.java │ │ │ ├── ApiCacheControl.java │ │ │ ├── ApiClass.java │ │ │ ├── ApiConfigException.java │ │ │ ├── ApiConfigInconsistency.java │ │ │ ├── ApiConfigLoader.java │ │ │ ├── ApiConfigSource.java │ │ │ ├── ApiConfigWriter.java │ │ │ ├── ApiFrontendLimitRule.java │ │ │ ├── ApiFrontendLimits.java │ │ │ ├── ApiIssuer.java │ │ │ ├── ApiIssuerAudience.java │ │ │ ├── ApiLimitMetric.java │ │ │ ├── ApiMethod.java │ │ │ ├── ApiMethodCacheControl.java │ │ │ ├── ApiMetricCost.java │ │ │ ├── ApiNamespace.java │ │ │ ├── ApiReference.java │ │ │ ├── ApiResourceProperty.java │ │ │ ├── ApiTransformer.java │ │ │ ├── AuthLevel.java │ │ │ ├── Authenticator.java │ │ │ ├── DefaultAnnotation.java │ │ │ ├── DefaultValue.java │ │ │ ├── Description.java │ │ │ ├── Named.java │ │ │ ├── Nullable.java │ │ │ ├── PeerAuthenticator.java │ │ │ ├── ResourcePropertySchema.java │ │ │ ├── ResourceSchema.java │ │ │ ├── ResourceTransformer.java │ │ │ ├── Singleton.java │ │ │ ├── Transformer.java │ │ │ ├── annotationreader │ │ │ │ ├── AnnotationUtil.java │ │ │ │ ├── ApiAnnotationConfig.java │ │ │ │ ├── ApiAnnotationIntrospector.java │ │ │ │ ├── ApiAuthAnnotationConfig.java │ │ │ │ ├── ApiCacheControlAnnotationConfig.java │ │ │ │ ├── ApiClassAnnotationConfig.java │ │ │ │ ├── ApiConfigAnnotationReader.java │ │ │ │ ├── ApiFrontendLimitsAnnotationConfig.java │ │ │ │ ├── ApiMethodAnnotationConfig.java │ │ │ │ ├── ApiNamespaceAnnotationConfig.java │ │ │ │ ├── CyclicApiInheritanceException.java │ │ │ │ └── IssuerUtil.java │ │ │ ├── jsonwriter │ │ │ │ ├── AbstractResourceSchemaProvider.java │ │ │ │ ├── JacksonResourceSchemaProvider.java │ │ │ │ ├── JsonConfigWriter.java │ │ │ │ └── ResourceSchemaProvider.java │ │ │ ├── model │ │ │ │ ├── ApiAuthConfig.java │ │ │ │ ├── ApiCacheControlConfig.java │ │ │ │ ├── ApiClassConfig.java │ │ │ │ ├── ApiConfig.java │ │ │ │ ├── ApiFrontendLimitsConfig.java │ │ │ │ ├── ApiIssuerAudienceConfig.java │ │ │ │ ├── ApiIssuerConfigs.java │ │ │ │ ├── ApiKey.java │ │ │ │ ├── ApiLimitMetricConfig.java │ │ │ │ ├── ApiMethodConfig.java │ │ │ │ ├── ApiMetricCostConfig.java │ │ │ │ ├── ApiNamespaceConfig.java │ │ │ │ ├── ApiParameterConfig.java │ │ │ │ ├── ApiSerializationConfig.java │ │ │ │ ├── AuthScopeRepository.java │ │ │ │ ├── EndpointsFlag.java │ │ │ │ ├── FieldType.java │ │ │ │ ├── Schema.java │ │ │ │ ├── SchemaRepository.java │ │ │ │ ├── Serializers.java │ │ │ │ ├── StandardParameters.java │ │ │ │ └── Types.java │ │ │ ├── scope │ │ │ │ ├── AbstractAuthScopeExpression.java │ │ │ │ ├── AuthScopeExpression.java │ │ │ │ ├── AuthScopeExpressions.java │ │ │ │ ├── ConjunctAuthScopeExpression.java │ │ │ │ ├── DisjunctAuthScopeExpression.java │ │ │ │ └── SingleAuthScopeExpression.java │ │ │ └── validation │ │ │ │ ├── ApiClassConfigInvalidException.java │ │ │ │ ├── ApiConfigInvalidException.java │ │ │ │ ├── ApiConfigValidator.java │ │ │ │ ├── ApiMethodConfigInvalidException.java │ │ │ │ ├── ApiParameterConfigInvalidException.java │ │ │ │ ├── CollectionResourceException.java │ │ │ │ ├── DuplicateParameterNameException.java │ │ │ │ ├── DuplicateRestPathException.java │ │ │ │ ├── GenericTypeException.java │ │ │ │ ├── InconsistentApiConfigurationException.java │ │ │ │ ├── InvalidApiNameException.java │ │ │ │ ├── InvalidConstructorException.java │ │ │ │ ├── InvalidIssuerValueException.java │ │ │ │ ├── InvalidMethodNameException.java │ │ │ │ ├── InvalidNamespaceException.java │ │ │ │ ├── InvalidParameterAnnotationsException.java │ │ │ │ ├── InvalidReturnTypeException.java │ │ │ │ ├── MissingParameterNameException.java │ │ │ │ ├── MultipleTransformersException.java │ │ │ │ ├── NamedResourceException.java │ │ │ │ ├── NestedCollectionException.java │ │ │ │ ├── NoTransformerInterfaceException.java │ │ │ │ ├── OverloadedMethodException.java │ │ │ │ ├── PropertyParameterNameConflictException.java │ │ │ │ └── WrongTransformerTypeException.java │ │ │ ├── discovery │ │ │ ├── AbstractDiscoveryProvider.java │ │ │ ├── CachingDiscoveryProvider.java │ │ │ ├── CommonPathPrefixBuilder.java │ │ │ ├── DiscoveryGenerator.java │ │ │ ├── DiscoveryProvider.java │ │ │ ├── LocalDiscoveryProvider.java │ │ │ ├── ProxyingDiscoveryProvider.java │ │ │ └── ProxyingDiscoveryService.java │ │ │ ├── dispatcher │ │ │ ├── DispatcherContext.java │ │ │ ├── DispatcherHandler.java │ │ │ ├── HttpMethod.java │ │ │ ├── PathDispatcher.java │ │ │ └── PathTrie.java │ │ │ ├── handlers │ │ │ ├── ApiProxyHandler.java │ │ │ ├── CorsHandler.java │ │ │ ├── EndpointsMethodHandler.java │ │ │ └── ExplorerHandler.java │ │ │ ├── request │ │ │ ├── AbstractParamReader.java │ │ │ ├── Attribute.java │ │ │ ├── Auth.java │ │ │ ├── ParamReader.java │ │ │ ├── RestServletRequestParamReader.java │ │ │ └── ServletRequestParamReader.java │ │ │ ├── response │ │ │ ├── BadRequestException.java │ │ │ ├── CollectionResponse.java │ │ │ ├── ConflictException.java │ │ │ ├── EndpointsPrettyPrinter.java │ │ │ ├── ErrorMap.java │ │ │ ├── ForbiddenException.java │ │ │ ├── InternalServerErrorException.java │ │ │ ├── NotFoundException.java │ │ │ ├── ResponseUtil.java │ │ │ ├── RestResponseResultWriter.java │ │ │ ├── ResultWriter.java │ │ │ ├── ServiceUnavailableException.java │ │ │ ├── ServletResponseResultWriter.java │ │ │ └── UnauthorizedException.java │ │ │ ├── swagger │ │ │ └── SwaggerGenerator.java │ │ │ └── types │ │ │ ├── DateAndTime.java │ │ │ └── SimpleDate.java │ └── resources │ │ └── com │ │ └── google │ │ └── api │ │ └── server │ │ └── spi │ │ ├── discovery │ │ └── googleScopeDescriptions.properties │ │ └── handlers │ │ └── proxy.html │ └── test │ ├── java │ └── com │ │ └── google │ │ └── api │ │ └── server │ │ └── spi │ │ ├── BackendPropertiesTest.java │ │ ├── ConfiguredObjectMapperTest.java │ │ ├── EndpointMethodTest.java │ │ ├── EndpointsServletTest.java │ │ ├── EnvUtilTest.java │ │ ├── IoUtilTest.java │ │ ├── MethodHierarchyReaderTest.java │ │ ├── ObjectMapperUtilTest.java │ │ ├── PeerAuthTest.java │ │ ├── ServiceContextTest.java │ │ ├── ServiceExceptionTest.java │ │ ├── ServletInitializationParametersTest.java │ │ ├── StringsTest.java │ │ ├── SystemServiceTest.java │ │ ├── TypeLoaderTest.java │ │ ├── auth │ │ ├── EndpointsAuthenticatorTest.java │ │ ├── EndpointsPeerAuthenticatorTest.java │ │ ├── GoogleAppEngineAuthenticatorTest.java │ │ ├── GoogleAuthTest.java │ │ ├── GoogleJwtAuthenticatorTest.java │ │ └── GoogleOAuth2AuthenticatorTest.java │ │ ├── config │ │ ├── ApiConfigInconsistencyTest.java │ │ ├── ApiConfigLoaderTest.java │ │ ├── annotationreader │ │ │ ├── ApiAnnotationConfigTest.java │ │ │ ├── ApiAnnotationIntrospectorTest.java │ │ │ ├── ApiAuthAnnotationConfigTest.java │ │ │ ├── ApiCacheControlAnnotationConfigTest.java │ │ │ ├── ApiClassAnnotationConfigTest.java │ │ │ ├── ApiConfigAnnotationReaderTest.java │ │ │ ├── ApiFrontendLimitsAnnotationConfigTest.java │ │ │ └── ApiMethodAnnotationConfigTest.java │ │ ├── jsonwriter │ │ │ ├── JacksonResourceSchemaProviderTest.java │ │ │ ├── JsonConfigWriterTest.java │ │ │ └── ResourceSchemaProviderTest.java │ │ ├── model │ │ │ ├── ApiClassConfigTest.java │ │ │ ├── ApiConfigTest.java │ │ │ ├── ApiIssuerAudienceConfigTest.java │ │ │ ├── ApiIssuerConfigsTest.java │ │ │ ├── ApiMethodConfigTest.java │ │ │ ├── ApiParameterConfigTest.java │ │ │ ├── ResourceSchemaTest.java │ │ │ ├── SchemaRepositoryTest.java │ │ │ ├── SerializersTest.java │ │ │ ├── StandardParametersTest.java │ │ │ └── TypesTest.java │ │ ├── scope │ │ │ ├── AuthScopeExpressionsTest.java │ │ │ ├── ConjunctAuthScopeExpressionTest.java │ │ │ ├── DisjunctAuthScopeExpressionTest.java │ │ │ └── SingleAuthScopeExpressionTest.java │ │ └── validation │ │ │ └── ApiConfigValidatorTest.java │ │ ├── discovery │ │ ├── AuthScopeDescriptions.java │ │ ├── CachingDiscoveryProviderTest.java │ │ ├── CommonPathPrefixBuilderTest.java │ │ ├── DiscoveryGeneratorTest.java │ │ ├── LocalDiscoveryProviderTest.java │ │ ├── ProxyingDiscoveryProviderTest.java │ │ └── ProxyingDiscoveryServiceTest.java │ │ ├── dispatcher │ │ ├── PathDispatcherTest.java │ │ └── PathTrieTest.java │ │ ├── handlers │ │ ├── ApiProxyHandlerTest.java │ │ ├── CorsHandlerTest.java │ │ ├── EndpointsMethodHandlerTest.java │ │ └── ExplorerHandlerTest.java │ │ ├── request │ │ ├── AttributeTest.java │ │ ├── AuthTest.java │ │ ├── RestServletRequestParamReaderTest.java │ │ └── ServletRequestParamReaderTest.java │ │ ├── response │ │ ├── CollectionResponseTest.java │ │ ├── EndpointsPrettyPrinterTest.java │ │ ├── RestResponseResultWriterTest.java │ │ └── ServletResponseResultWriterTest.java │ │ ├── swagger │ │ └── SwaggerGeneratorTest.java │ │ └── types │ │ ├── DateAndTimeTest.java │ │ └── SimpleDateTest.java │ └── resources │ └── com │ └── google │ └── api │ └── server │ └── spi │ ├── discovery │ ├── absolute_common_path_endpoint.json │ ├── absolute_path_endpoint.json │ ├── array_endpoint.json │ ├── custom_scopes.json │ ├── directory.json │ ├── enum_endpoint.json │ ├── foo_endpoint.json │ ├── foo_endpoint_default_context.json │ ├── foo_endpoint_localhost.json │ ├── foo_with_description_endpoint.json │ ├── map_endpoint.json │ ├── map_endpoint_legacy.json │ ├── map_endpoint_with_array.json │ ├── multiple_parameter_endpoint.json │ ├── namespace_endpoint.json │ ├── primitive_endpoint.json │ └── tictactoe.json │ └── swagger │ ├── absolute_common_path_endpoint.swagger │ ├── absolute_path_endpoint.swagger │ ├── api_keys.swagger │ ├── array_endpoint.swagger │ ├── enum_endpoint.swagger │ ├── foo_endpoint.swagger │ ├── foo_endpoint_default_context.swagger │ ├── foo_endpoint_internal.swagger │ ├── foo_endpoint_localhost.swagger │ ├── foo_with_description_endpoint.swagger │ ├── google_auth.swagger │ ├── limit_metrics_endpoint.swagger │ ├── map_endpoint.swagger │ ├── map_endpoint_legacy.swagger │ ├── map_endpoint_with_array.swagger │ ├── multi_resource_endpoint.swagger │ ├── multi_version_endpoint.swagger │ └── third_party_auth.swagger ├── gradle.properties ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── gradlew ├── gradlew.bat ├── settings.gradle ├── test-compat ├── build.gradle ├── legacy-app-guice │ ├── build.gradle │ └── src │ │ └── main │ │ ├── java │ │ └── com │ │ │ └── google │ │ │ └── testapp │ │ │ ├── TestGuiceServletContextListener.java │ │ │ └── TestSystemServiceModule.java │ │ └── webapp │ │ └── WEB-INF │ │ ├── appengine-web.xml │ │ ├── logging.properties │ │ └── web.xml ├── legacy-app │ ├── build.gradle │ └── src │ │ └── main │ │ └── webapp │ │ └── WEB-INF │ │ ├── appengine-web.xml │ │ ├── logging.properties │ │ └── web.xml ├── new-app-guice │ ├── build.gradle │ └── src │ │ └── main │ │ ├── java │ │ └── com │ │ │ └── google │ │ │ └── testapp │ │ │ ├── TestEndpointsModule.java │ │ │ └── TestGuiceServletContextListener.java │ │ └── webapp │ │ └── WEB-INF │ │ ├── appengine-web.xml │ │ ├── logging.properties │ │ └── web.xml ├── new-app │ ├── build.gradle │ └── src │ │ └── main │ │ └── webapp │ │ └── WEB-INF │ │ ├── appengine-web.xml │ │ ├── logging.properties │ │ └── web.xml └── src │ └── main │ ├── java │ └── com │ │ └── google │ │ ├── testapi │ │ └── TestEndpoint.java │ │ └── waxapi │ │ ├── InMemoryWaxDataStore.java │ │ ├── InvalidSessionException.java │ │ ├── InvalidWaxDataItemException.java │ │ ├── ObjectifyInitializer.java │ │ ├── ObjectifyWaxDataStore.java │ │ ├── WaxDataItem.java │ │ ├── WaxDataStore.java │ │ ├── WaxDataStoreException.java │ │ ├── WaxEndpoint.java │ │ ├── WaxNewSessionRequest.java │ │ ├── WaxNewSessionResponse.java │ │ ├── WaxRemoveSessionResponse.java │ │ └── WaxSession.java │ └── webapp │ └── WEB-INF │ ├── appengine-web.xml │ └── web.xml └── test-utils ├── build.gradle └── src └── main └── java └── com └── google └── api └── server └── spi ├── BaseSystemServiceTest.java ├── request └── FakeParamReader.java ├── response ├── ErrorResultWriter.java └── SuccessResultWriter.java └── testing ├── AbsoluteCommonPathEndpoint.java ├── AbsolutePathEndpoint.java ├── AppEngineAuthenticator.java ├── ArrayEndpoint.java ├── Bar.java ├── Baz.java ├── BoundedGenericEndpoint.java ├── BridgeInheritanceEndpoint.java ├── ChildBean.java ├── CollectionContravarianceEndpoint.java ├── CollectionCovarianceEndpoint.java ├── CustomScopesEndpoint.java ├── DeepGenericHierarchyFailEndpoint.java ├── DeepGenericHierarchySuccessEndpoint.java ├── DefaultValueSerializer.java ├── DumbSerializer1.java ├── DumbSerializer2.java ├── DuplicateMethodEndpoint.java ├── Endpoint0.java ├── Endpoint1.java ├── Endpoint2.java ├── Endpoint3.java ├── Endpoint4.java ├── Endpoint5.java ├── EnumEndpoint.java ├── EnumEndpointV2.java ├── EnumValue.java ├── FailAuthenticator.java ├── FailPeerAuthenticator.java ├── FloatToStringSerializer.java ├── Foo.java ├── FooDescription.java ├── FooDescriptionEndpoint.java ├── FooEndpoint.java ├── IntegerToStringSerializer.java ├── InterfaceConfiguration.java ├── InterfaceReferenceEndpoint.java ├── LimitMetricsEndpoint.java ├── LongToStringSerializer.java ├── MapEndpoint.java ├── MapEndpointInvalid.java ├── MultiResourceEndpoint.java ├── MultiVersionEndpoint.java ├── MultipleParameterEndpoint.java ├── NamespaceEndpoint.java ├── NonDiscoverableEndpoint.java ├── ParameterizedParameterEndpoint.java ├── ParentBean.java ├── ParentChildEndpoint.java ├── PassAuthenticator.java ├── PassPeerAuthenticator.java ├── PrimitiveBean.java ├── PrimitiveEndpoint.java ├── RecursiveBean.java ├── RecursiveEndpoint.java ├── ReferenceOverridingEndpoint.java ├── RestfulResourceEndpointBase.java ├── SimpleBean.java ├── SimpleContravarianceEndpoint.java ├── SimpleCovarianceEndpoint.java ├── SimpleLevelOverridingApi.java ├── SimpleLevelOverridingInheritedApi.java ├── SimpleOverloadEndpoint.java ├── SimpleOverrideEndpoint.java ├── SimpleReferenceEndpoint.java ├── StringValue.java ├── StringValueTransformer.java ├── SubclassedEndpoint.java ├── SubclassedOverridingEndpoint.java ├── TestEndpoint.java ├── TestEndpointSuperclass.java ├── TestEnum.java └── TestEnumDescription.java /.gitignore: -------------------------------------------------------------------------------- 1 | # built application files 2 | *.apk 3 | *.ap_ 4 | 5 | # files for the dex VM 6 | *.dex 7 | 8 | # Java class files 9 | *.class 10 | 11 | # generated files 12 | bin/ 13 | gen/ 14 | 15 | # Local configuration file (sdk path, etc) 16 | local.properties 17 | 18 | # Windows thumbnail db 19 | Thumbs.db 20 | 21 | # OSX files 22 | .DS_Store 23 | 24 | # Eclipse project files 25 | .classpath 26 | .project 27 | 28 | # Android Studio 29 | *.iml 30 | .idea 31 | #.idea/workspace.xml - remove # and delete .idea if it better suit your needs. 32 | .gradle 33 | build/ 34 | 35 | #NDK 36 | obj/ 37 | 38 | *~ 39 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: java 2 | jdk: 3 | - openjdk7 4 | install: 5 | - JAVA_HOME=$(jdk_switcher home openjdk8) ./gradlew classes testClasses 6 | after_success: 7 | - ./gradlew jacocoTestReport 8 | - bash <(curl -s https://codecov.io/bash) 9 | -------------------------------------------------------------------------------- /CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | Want to contribute? Great! First, read this page (including the small print at the end). 2 | 3 | ### Before you contribute 4 | Before we can use your code, you must sign the 5 | [Google Individual Contributor License Agreement] 6 | (https://cla.developers.google.com/about/google-individual) 7 | (CLA), which you can do online. The CLA is necessary mainly because you own the 8 | copyright to your changes, even after your contribution becomes part of our 9 | codebase, so we need your permission to use and distribute your code. We also 10 | need to be sure of various other things—for instance that you'll tell us if you 11 | know that your code infringes on other people's patents. You don't have to sign 12 | the CLA until after you've submitted your code for review and a member has 13 | approved it, but you must do it before we can put your code into our codebase. 14 | Before you start working on a larger contribution, you should get in touch with 15 | us first through the issue tracker with your idea so that we can help out and 16 | possibly guide you. Coordinating up front makes it much easier to avoid 17 | frustration later on. 18 | 19 | ### Code reviews 20 | All submissions, including submissions by project members, require review. We 21 | use Github pull requests for this purpose. 22 | 23 | ### The small print 24 | Contributions made by corporations are covered by a different agreement than 25 | the one above, the 26 | [Software Grant and Corporate Contributor License Agreement] 27 | (https://cla.developers.google.com/about/google-corporate). 28 | -------------------------------------------------------------------------------- /discovery-client/build.gradle: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 Google Inc. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | apply plugin: 'java' 17 | apply plugin: 'maven' 18 | 19 | 20 | group = 'com.google.apis' 21 | archivesBaseName = 'google-api-services-discovery' 22 | version = 'v1-rev20151119-1.20.0' 23 | 24 | sourceCompatibility = 1.6 25 | targetCompatibility = 1.6 26 | jar.manifest.attributes("Built-By": "Google") 27 | jar.manifest.attributes("Build-Jdk": "1.6.x") 28 | 29 | task sourceJar(type: Jar) { 30 | classifier = 'sources' 31 | from sourceSets.main.allJava 32 | } 33 | 34 | artifacts { 35 | archives sourceJar 36 | } 37 | 38 | repositories { 39 | mavenCentral() 40 | } 41 | 42 | dependencies { 43 | compile module(group: 'com.google.api-client', name: 'google-api-client', version: '1.21.0') { 44 | module(group: 'com.google.http-client', name: 'google-http-client-jackson2', version: '1.21.0') { 45 | dependency('com.fasterxml.jackson.core:jackson-core:2.6.4') 46 | dependency('com.google.http-client:google-http-client:1.21.0') 47 | } 48 | dependency('com.google.oauth-client:google-oauth-client:1.21.0') 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /discovery-client/proguard-google-api-client.txt: -------------------------------------------------------------------------------- 1 | # ProGuard Configuration file 2 | # 3 | # See http://proguard.sourceforge.net/index.html#manual/usage.html 4 | 5 | # Needed to keep generic types and @Key annotations accessed via reflection 6 | 7 | -keepattributes Signature,RuntimeVisibleAnnotations,AnnotationDefault 8 | 9 | -keepclassmembers class * { 10 | @com.google.api.client.util.Key ; 11 | } 12 | 13 | # Needed by google-http-client-android when linking against an older platform version 14 | 15 | -dontwarn com.google.api.client.extensions.android.** 16 | 17 | # Needed by google-api-client-android when linking against an older platform version 18 | 19 | -dontwarn com.google.api.client.googleapis.extensions.android.** 20 | 21 | # Needed by google-play-services when linking against an older platform version 22 | 23 | -dontwarn com.google.android.gms.** 24 | -------------------------------------------------------------------------------- /endpoints-framework-all/build.gradle: -------------------------------------------------------------------------------- 1 | plugins { 2 | id 'com.github.johnrengelman.shadow' version '1.2.3' 3 | } 4 | 5 | configurations { 6 | include 7 | compile.extendsFrom include 8 | } 9 | 10 | jar { 11 | from { 12 | configurations.include.collect { it.isDirectory() ? it : zipTree(it) } 13 | } 14 | } 15 | 16 | def repackagedDir = 'endpoints.repackaged' 17 | 18 | shadowJar { 19 | classifier = null 20 | relocate 'org.apache', "${repackagedDir}.org.apache" 21 | relocate 'org.yaml', "${repackagedDir}.org.yaml" 22 | relocate 'org.joda', "${repackagedDir}.org.joda" 23 | relocate 'com.fasterxml', "${repackagedDir}.com.fasterxml" 24 | relocate 'io.swagger', "${repackagedDir}.io.swagger" 25 | relocate 'com.google.common', "${repackagedDir}.com.google.common" 26 | relocate 'com.google.api.client', "${repackagedDir}.com.google.api.client" 27 | relocate 'org.slf4j', "${repackagedDir}.org.slf4j" 28 | 29 | dependencies { 30 | exclude(dependency('com.google.appengine:appengine-api-1.0-sdk:.*')) 31 | exclude(dependency('javax.servlet:servlet-api:.*')) 32 | } 33 | } 34 | 35 | artifacts { 36 | archives shadowJar 37 | } 38 | 39 | dependencies { 40 | include project(':endpoints-framework') 41 | compile group: 'com.google.appengine', name: 'appengine-api-1.0-sdk', version: appengineVersion 42 | compile group: 'javax.servlet', name: 'servlet-api', version: servletVersion 43 | } 44 | 45 | configureMaven(project, 'Endpoints Framework', 'A framework for building RESTful web APIs.') 46 | -------------------------------------------------------------------------------- /endpoints-framework-guice/build.gradle: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 Google Inc. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | configureMaven( 18 | project, 19 | 'Endpoints Framework Guice Extension', 20 | 'Extension to configure the Endpoints Framework via Guice.') 21 | 22 | dependencies { 23 | compileOnly project(':endpoints-framework') 24 | compile group: 'com.google.inject', name: 'guice', version: guiceVersion 25 | compile group: 'com.google.inject.extensions', name: 'guice-servlet', version: guiceVersion 26 | 27 | testCompile project(':test-utils') 28 | testCompile group: 'junit', name: 'junit', version: junitVersion 29 | testCompile group: 'org.mockito', name: 'mockito-core', version: mockitoVersion 30 | } 31 | -------------------------------------------------------------------------------- /endpoints-framework-guice/src/main/java/com/google/api/server/spi/guice/GuiceEndpointsServlet.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 Google Inc. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.google.api.server.spi.guice; 17 | 18 | import com.google.api.server.spi.EndpointsServlet; 19 | import com.google.inject.Inject; 20 | import com.google.inject.Singleton; 21 | 22 | /** 23 | * A subclass of {@link EndpointsServlet} which facilitates Guice injection. 24 | */ 25 | @Singleton 26 | public class GuiceEndpointsServlet extends EndpointsServlet { 27 | private final ServiceMap services; 28 | 29 | @Inject 30 | public GuiceEndpointsServlet(ServiceMap services) { 31 | this.services = Preconditions.checkNotNull(services, "services"); 32 | } 33 | 34 | @Override 35 | protected T createService(Class serviceClass) { 36 | return services.get(serviceClass); 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /endpoints-framework-guice/src/main/java/com/google/api/server/spi/guice/Preconditions.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2017 Google Inc. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.google.api.server.spi.guice; 17 | 18 | /** 19 | * Rather than shading all of Guava into an endpoints-framework-guice-all artifact, we include the 20 | * necessary functionality in this small helper class to remove the dependency. 21 | */ 22 | final class Preconditions { 23 | static T checkNotNull(T ref, String errorMessage) { 24 | if (ref == null) { 25 | throw new NullPointerException(errorMessage); 26 | } 27 | return ref; 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /endpoints-framework-guice/src/test/java/com/google/api/server/spi/guice/DummyModule.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 Google Inc. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.google.api.server.spi.guice; 17 | 18 | import com.google.api.server.spi.testing.Endpoint0; 19 | import com.google.api.server.spi.testing.TestEndpoint; 20 | import com.google.inject.AbstractModule; 21 | 22 | /** 23 | * Module that binds the service to a simple constructor. 24 | */ 25 | public class DummyModule extends AbstractModule { 26 | 27 | @Override 28 | protected void configure() { 29 | bind(TestEndpoint.class); 30 | bind(Endpoint0.class); 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /endpoints-framework-guice/src/test/java/com/google/api/server/spi/guice/InterceptorModule.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 Google Inc. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.google.api.server.spi.guice; 17 | 18 | import com.google.api.server.spi.testing.Endpoint0; 19 | import com.google.api.server.spi.testing.TestEndpoint; 20 | import com.google.inject.AbstractModule; 21 | import com.google.inject.matcher.Matchers; 22 | 23 | /** 24 | * Module that installs enhancements by Guice typically found in Guice servlets. 25 | */ 26 | public class InterceptorModule extends AbstractModule { 27 | 28 | @Override 29 | protected void configure() { 30 | bindInterceptor(Matchers.subclassesOf(TestEndpoint.class), Matchers.any(), 31 | new TestInterceptor()); 32 | bindInterceptor(Matchers.subclassesOf(Endpoint0.class), Matchers.any(), 33 | new TestInterceptor()); 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /endpoints-framework-guice/src/test/java/com/google/api/server/spi/guice/SystemServiceTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 Google Inc. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.google.api.server.spi.guice; 17 | 18 | import com.google.api.server.spi.BaseSystemServiceTest; 19 | import com.google.api.server.spi.testing.Endpoint0; 20 | import com.google.api.server.spi.testing.TestEndpoint; 21 | import com.google.inject.Guice; 22 | 23 | import org.junit.runner.RunWith; 24 | import org.junit.runners.JUnit4; 25 | 26 | /** 27 | * Tests for {@link com.google.api.server.spi.SystemService} with a Guice-enchanced service class. 28 | * A Guice EnhancedBean will be created if the class contains an interceptor. 29 | */ 30 | @RunWith(JUnit4.class) 31 | public class SystemServiceTest extends BaseSystemServiceTest { 32 | @Override 33 | protected TestEndpoint getTestService() { 34 | return Guice.createInjector(new InterceptorModule()).getInstance(TestEndpoint.class); 35 | } 36 | 37 | @Override 38 | protected Endpoint0 getTestService2() { 39 | return Guice.createInjector(new InterceptorModule()).getInstance(Endpoint0.class); 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /endpoints-framework-guice/src/test/java/com/google/api/server/spi/guice/TestInterceptor.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 Google Inc. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.google.api.server.spi.guice; 17 | 18 | import org.aopalliance.intercept.MethodInterceptor; 19 | import org.aopalliance.intercept.MethodInvocation; 20 | 21 | /** 22 | * Interceptor for testing purposes. 23 | */ 24 | public class TestInterceptor implements MethodInterceptor { 25 | 26 | @Override 27 | public Object invoke(MethodInvocation invocation) throws Throwable { 28 | return invocation.proceed(); 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /endpoints-framework-tools/build.gradle: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 Google Inc. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | configureMaven( 18 | project, 19 | 'Endpoints Framework Tools', 20 | 'Command line tools for supporting the Endpoints Framework.') 21 | 22 | // Needed to copy resources into build directories 23 | task copyTestResources(type: Copy) { 24 | from "${projectDir}/src/test/resources" 25 | into "${buildDir}/classes/test" 26 | } 27 | processTestResources.dependsOn copyTestResources 28 | 29 | apply plugin: 'application' 30 | mainClassName = 'com.google.api.server.spi.tools.EndpointsTool' 31 | 32 | dependencies { 33 | compile project(':endpoints-framework') 34 | compile group: 'com.google.appengine', name: 'appengine-tools-sdk', version: appengineVersion 35 | 36 | testCompile project(':test-utils') 37 | testCompile group: 'junit', name: 'junit', version: junitVersion 38 | testCompile group: 'org.mockito', name: 'mockito-core', version: mockitoVersion 39 | testCompile group: 'com.google.truth', name: 'truth', version: truthVersion 40 | testCompile group: 'org.springframework', name: 'spring-test', version: springtestVersion 41 | } 42 | -------------------------------------------------------------------------------- /endpoints-framework-tools/src/main/java/com/google/api/server/spi/tools/ClientLibGenerator.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 Google Inc. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.google.api.server.spi.tools; 17 | 18 | import java.io.File; 19 | import java.io.IOException; 20 | 21 | /** 22 | * Client library generator. 23 | */ 24 | public interface ClientLibGenerator { 25 | 26 | /** 27 | * Generates the client library for an API and saves it in a file. 28 | * 29 | * @param discoveryDoc Discovery document of the API 30 | * @param language Language of the client library, valid options can be found at 31 | * https://developers.google.com/resources/api-libraries/endpoints/genlib 32 | * @param languageVersion Version of language. {@code null} for default. 33 | * @param layout of the client bundle. {@code null} for default. 34 | * @param file Zip/jar file to save the generated source into 35 | */ 36 | public void generateClientLib(String discoveryDoc, String language, String languageVersion, 37 | String layout, File file) throws IOException; 38 | } 39 | -------------------------------------------------------------------------------- /endpoints-framework-tools/src/main/java/com/google/api/server/spi/tools/testing/FakeClientLibGenerator.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 Google Inc. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.google.api.server.spi.tools.testing; 17 | 18 | import com.google.api.server.spi.IoUtil; 19 | import com.google.api.server.spi.tools.ClientLibGenerator; 20 | 21 | import java.io.File; 22 | import java.io.IOException; 23 | 24 | /** 25 | * Generates a client library for any discovery document by loading a static jar file. 26 | */ 27 | public class FakeClientLibGenerator implements ClientLibGenerator { 28 | 29 | @Override 30 | public void generateClientLib(String discoveryDoc, String language, String languageVersion, 31 | String layout, File file) throws IOException { 32 | IoUtil.copy(getClass().getResourceAsStream("fake-api-client-lib.jar"), file); 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /endpoints-framework-tools/src/main/resources/com/google/api/server/spi/tools/testing/fake-api-client-lib.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cloudendpoints/endpoints-java/44933a4d5d38b7bf6a11ee0c139a120563ef9d6b/endpoints-framework-tools/src/main/resources/com/google/api/server/spi/tools/testing/fake-api-client-lib.jar -------------------------------------------------------------------------------- /endpoints-framework-tools/src/test/java/com/google/api/server/spi/tools/testing/FakeApiConfigGeneratorTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 Google Inc. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.google.api.server.spi.tools.testing; 17 | 18 | import static org.junit.Assert.assertNotNull; 19 | 20 | import org.junit.Test; 21 | import org.junit.runner.RunWith; 22 | import org.junit.runners.JUnit4; 23 | 24 | /** 25 | * Tests for {@link FakeApiConfigGenerator}. 26 | */ 27 | @RunWith(JUnit4.class) 28 | public class FakeApiConfigGeneratorTest { 29 | 30 | @Test 31 | public void testGenerateApiConfig() { 32 | assertNotNull(new FakeApiConfigGenerator().generateConfig(getClass())); 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /endpoints-framework-tools/src/test/java/com/google/api/server/spi/tools/testing/FakeClientLibGeneratorTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 Google Inc. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.google.api.server.spi.tools.testing; 17 | 18 | import static org.junit.Assert.assertTrue; 19 | 20 | import org.junit.Rule; 21 | import org.junit.Test; 22 | import org.junit.rules.TemporaryFolder; 23 | import org.junit.runner.RunWith; 24 | import org.junit.runners.JUnit4; 25 | 26 | import java.io.File; 27 | import java.io.IOException; 28 | 29 | /** 30 | * Tests for {@link FakeClientLibGenerator}. 31 | */ 32 | @RunWith(JUnit4.class) 33 | public class FakeClientLibGeneratorTest { 34 | @Rule public TemporaryFolder tmpFolder = new TemporaryFolder(); 35 | 36 | @Test 37 | public void testGenerateClientLib() throws IOException { 38 | File destFile = 39 | File.createTempFile("my-client-lib", ".jar", tmpFolder.getRoot().getAbsoluteFile()); 40 | new FakeClientLibGenerator().generateClientLib("", "java", null, null, destFile); 41 | assertTrue(destFile.exists()); 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /endpoints-framework/src/main/java/com/google/api/server/spi/config/AnnotationBoolean.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 Google Inc. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.google.api.server.spi.config; 17 | 18 | /** 19 | * Enum allowing a boolean flag or unspecified. For use in api annotations. 20 | * 21 | * @author Eric Orth 22 | */ 23 | public enum AnnotationBoolean { 24 | TRUE, 25 | FALSE, 26 | UNSPECIFIED 27 | } 28 | -------------------------------------------------------------------------------- /endpoints-framework/src/main/java/com/google/api/server/spi/config/ApiConfigException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 Google Inc. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.google.api.server.spi.config; 17 | 18 | /** 19 | * Exception for any errors thrown reading api configuration. 20 | * 21 | * @author Eric Orth 22 | */ 23 | public class ApiConfigException extends Exception { 24 | public ApiConfigException(Throwable cause) { 25 | super(cause); 26 | } 27 | 28 | public ApiConfigException(String message) { 29 | super(message); 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /endpoints-framework/src/main/java/com/google/api/server/spi/config/ApiConfigWriter.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 Google Inc. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.google.api.server.spi.config; 17 | 18 | import com.google.api.server.spi.config.model.ApiConfig; 19 | import com.google.api.server.spi.config.model.ApiKey; 20 | 21 | import java.util.Map; 22 | 23 | /** 24 | * Generator of wire-formatted configuration strings to send to the API frontend. 25 | * 26 | * @author Eric Orth 27 | */ 28 | public interface ApiConfigWriter { 29 | /** 30 | * Generate wire-formatted configuration strings for the given configs. 31 | * 32 | * @return A map from {@link ApiKey}s to wire-formatted configuration strings. 33 | */ 34 | Map writeConfig(Iterable configs) throws ApiConfigException; 35 | 36 | /** 37 | * The file extension associated with this writer. 38 | */ 39 | String getFileExtension(); 40 | } 41 | -------------------------------------------------------------------------------- /endpoints-framework/src/main/java/com/google/api/server/spi/config/ApiIssuer.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 Google Inc. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.google.api.server.spi.config; 17 | 18 | /** 19 | * Annotation to specify a JWT issuer configuration. 20 | */ 21 | public @interface ApiIssuer { 22 | /** 23 | * A JWT provider id. This field is referenced by {@link ApiIssuerAudience}. 24 | */ 25 | String name() default ""; 26 | 27 | /** 28 | * The expected issuer (iss) value for JWT tokens generated by this issuer. 29 | */ 30 | String issuer() default ""; 31 | 32 | /** 33 | * The location of the JSON web key set used to verify tokens generated by this issuer. 34 | */ 35 | String jwksUri() default ""; 36 | } 37 | -------------------------------------------------------------------------------- /endpoints-framework/src/main/java/com/google/api/server/spi/config/ApiIssuerAudience.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 Google Inc. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.google.api.server.spi.config; 17 | 18 | /** 19 | * An annotation that specifies a list of allowed audiences for an issuer. 20 | */ 21 | public @interface ApiIssuerAudience { 22 | /** 23 | * The JWT provider id, named in {@link ApiIssuer}. 24 | */ 25 | String name() default ""; 26 | 27 | /** 28 | * The list of audiences allowed by the issuer. 29 | */ 30 | String[] audiences() default {}; 31 | } 32 | -------------------------------------------------------------------------------- /endpoints-framework/src/main/java/com/google/api/server/spi/config/ApiLimitMetric.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2017 Google Inc. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.google.api.server.spi.config; 17 | 18 | /** 19 | * A rate limiting metric. 20 | */ 21 | public @interface ApiLimitMetric { 22 | /** 23 | * A limit identifier, consisting of alphanumeric characters and hyphens. 24 | */ 25 | String name(); 26 | 27 | /** 28 | * A human readable description of the metric, e.g. Bookstore Read API Requests per Minute. 29 | */ 30 | String displayName() default ""; 31 | 32 | /** 33 | * The default cost limit. 34 | */ 35 | int limit(); 36 | } 37 | -------------------------------------------------------------------------------- /endpoints-framework/src/main/java/com/google/api/server/spi/config/ApiMetricCost.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2017 Google Inc. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.google.api.server.spi.config; 17 | 18 | /** 19 | * Metric cost definition for a method. 20 | */ 21 | public @interface ApiMetricCost { 22 | /** 23 | * The metric name, which must be defined using {@link ApiLimitMetric}. 24 | */ 25 | String name(); 26 | 27 | /** 28 | * The cost charged to the metric. 29 | */ 30 | int cost(); 31 | } 32 | -------------------------------------------------------------------------------- /endpoints-framework/src/main/java/com/google/api/server/spi/config/ApiTransformer.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 Google Inc. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.google.api.server.spi.config; 17 | 18 | import java.lang.annotation.Retention; 19 | import java.lang.annotation.RetentionPolicy; 20 | 21 | /** 22 | * An annotation for customizing API output by simple type conversion. 23 | *

24 | * This can be used in two ways. The first is to annotate a class. This specifies that the 25 | * transformer should be used to convert any objects of this type to the target type. This applies 26 | * to all APIs in the current App Engine application. 27 | *

28 | * The second is to use {@link Api#transformers()}. This can be used to customize serialization of 29 | * third-party classes, but is not applied globally and is instead done per-API. 30 | */ 31 | @Retention(RetentionPolicy.RUNTIME) 32 | public @interface ApiTransformer { 33 | /** 34 | * The serializer class to do the type conversion. It must be possible to create this class using 35 | * {@link Class#newInstance()}. 36 | */ 37 | Class> value(); 38 | } 39 | -------------------------------------------------------------------------------- /endpoints-framework/src/main/java/com/google/api/server/spi/config/DefaultAnnotation.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 Google Inc. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.google.api.server.spi.config; 17 | 18 | import java.lang.annotation.Annotation; 19 | import java.lang.reflect.InvocationHandler; 20 | import java.lang.reflect.Method; 21 | import java.lang.reflect.Proxy; 22 | 23 | /** 24 | * Class used for creation of a default instance of an annotation. 25 | */ 26 | public class DefaultAnnotation { 27 | 28 | private static class Handler implements InvocationHandler { 29 | 30 | @Override 31 | public Object invoke(Object proxy, Method method, Object[] args) throws Throwable { 32 | return method.getDefaultValue(); 33 | } 34 | } 35 | 36 | /** 37 | * Creates an instance of an annotation with all properties set to their default values. 38 | * @param annotation Class of annotation to create default instance for 39 | */ 40 | @SuppressWarnings("unchecked") 41 | public static A of(Class annotation) { 42 | return (A) Proxy.newProxyInstance( 43 | annotation.getClassLoader(), new Class[] {annotation}, new Handler()); 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /endpoints-framework/src/main/java/com/google/api/server/spi/config/DefaultValue.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 Google Inc. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.google.api.server.spi.config; 17 | 18 | import java.lang.annotation.ElementType; 19 | import java.lang.annotation.Retention; 20 | import java.lang.annotation.RetentionPolicy; 21 | import java.lang.annotation.Target; 22 | 23 | /** 24 | * Default value for parameters. 25 | */ 26 | @Target(ElementType.PARAMETER) 27 | @Retention(RetentionPolicy.RUNTIME) 28 | public @interface DefaultValue { 29 | 30 | /** 31 | * Sets the default value of a named parameter. 32 | */ 33 | String value() default ""; 34 | } -------------------------------------------------------------------------------- /endpoints-framework/src/main/java/com/google/api/server/spi/config/Description.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 Google Inc. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.google.api.server.spi.config; 17 | 18 | import java.lang.annotation.ElementType; 19 | import java.lang.annotation.Retention; 20 | import java.lang.annotation.RetentionPolicy; 21 | import java.lang.annotation.Target; 22 | 23 | /** 24 | * Annotation to specify the description of an API parameter or enum constants. 25 | * The description will be ignored if the annotation is used on resource fields. 26 | */ 27 | @Target({ElementType.PARAMETER, ElementType.FIELD}) 28 | @Retention(RetentionPolicy.RUNTIME) 29 | public @interface Description { 30 | /** 31 | * The parameter description. 32 | */ 33 | String value() default ""; 34 | } 35 | -------------------------------------------------------------------------------- /endpoints-framework/src/main/java/com/google/api/server/spi/config/Named.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 Google Inc. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.google.api.server.spi.config; 17 | 18 | import java.lang.annotation.ElementType; 19 | import java.lang.annotation.Retention; 20 | import java.lang.annotation.RetentionPolicy; 21 | import java.lang.annotation.Target; 22 | 23 | /** 24 | * Annotation to specify the name of an API parameter. 25 | */ 26 | @Target(ElementType.PARAMETER) 27 | @Retention(RetentionPolicy.RUNTIME) 28 | public @interface Named { 29 | /** 30 | * The parameter name. 31 | */ 32 | String value() default ""; 33 | } 34 | -------------------------------------------------------------------------------- /endpoints-framework/src/main/java/com/google/api/server/spi/config/Nullable.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 Google Inc. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.google.api.server.spi.config; 17 | 18 | import java.lang.annotation.ElementType; 19 | import java.lang.annotation.Retention; 20 | import java.lang.annotation.RetentionPolicy; 21 | import java.lang.annotation.Target; 22 | 23 | /** 24 | * Annotation to specify that an API parameter is optional. 25 | */ 26 | @Target(ElementType.PARAMETER) 27 | @Retention(RetentionPolicy.RUNTIME) 28 | public @interface Nullable {} 29 | -------------------------------------------------------------------------------- /endpoints-framework/src/main/java/com/google/api/server/spi/config/PeerAuthenticator.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 Google Inc. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.google.api.server.spi.config; 17 | 18 | import javax.servlet.http.HttpServletRequest; 19 | 20 | /** 21 | * Peer authenticators aim to verify the peer and run before {@code Authenticator}. It returns false 22 | * if authentication failed and stops handling the rest of the request; true if authentication 23 | * succeeds and continue to execute rest of peer authenticators. 24 | * 25 | *

26 | * If no peer authenticator is set, {@code EndpointsPeerAuthenticator} will be the default to verify 27 | * the request is from Google. If you supply your own peer authenticator, make sure you also put 28 | * {@code EndpointsPeerAuthenticator} to the head of peerAuthenticators list to verify the request 29 | * is from Google. 30 | */ 31 | public interface PeerAuthenticator { 32 | boolean authenticate(HttpServletRequest request); 33 | } 34 | -------------------------------------------------------------------------------- /endpoints-framework/src/main/java/com/google/api/server/spi/config/ResourceTransformer.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 Google Inc. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.google.api.server.spi.config; 17 | 18 | import java.util.Map; 19 | 20 | /** 21 | * A specialized transformer for handling Resource types. Resources get serialized to a map of 22 | * property name to property value. In addition, resource transformer must expose schema. This 23 | * allows proper discovery documentation to be generated. 24 | * 25 | * @param The resource being transformed 26 | */ 27 | public interface ResourceTransformer extends Transformer> { 28 | 29 | /** 30 | * Gets the schema for this resource, which documents how this resource should be exposed in 31 | * discovery. 32 | */ 33 | ResourceSchema getResourceSchema(); 34 | } 35 | -------------------------------------------------------------------------------- /endpoints-framework/src/main/java/com/google/api/server/spi/config/Transformer.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 Google Inc. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.google.api.server.spi.config; 17 | 18 | /** 19 | * An interface used to transform between a bean type and another type during JSON serialization. 20 | *

21 | * A serializer is constructed using one of the following constructor signatures (sorted by 22 | * precedence): 23 | *

    24 | *
  1. A constructor taking in a single {@code java.lang.reflect.Type}. This is the type being 25 | * serialized.
  2. 26 | *
  3. A constructor taking in a single {@code java.lang.Class}. This is the class being serialized. 27 | *
  4. 28 | *
  5. A no-arg constructor
  6. 29 | *
30 | * 31 | * @param The type being transformed 32 | * @param The type being transformed to 33 | */ 34 | public interface Transformer { 35 | /** 36 | * Converts the source object into the destination type. 37 | */ 38 | TTo transformTo(TFrom in); 39 | 40 | /** 41 | * Converts an object from the destination type into the source type. 42 | */ 43 | TFrom transformFrom(TTo in); 44 | } 45 | -------------------------------------------------------------------------------- /endpoints-framework/src/main/java/com/google/api/server/spi/config/annotationreader/CyclicApiInheritanceException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 Google Inc. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.google.api.server.spi.config.annotationreader; 17 | 18 | import com.google.api.server.spi.config.ApiConfigException; 19 | 20 | /** 21 | * Exception for detected cycles in the endpoint class inheritance. 22 | * 23 | * @author Eric Orth 24 | */ 25 | public class CyclicApiInheritanceException extends ApiConfigException { 26 | public CyclicApiInheritanceException(Class endpointClass) { 27 | super(String.format("%s: Cycle detected in API inheritance.", endpointClass.getName())); 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /endpoints-framework/src/main/java/com/google/api/server/spi/config/jsonwriter/ResourceSchemaProvider.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 Google Inc. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.google.api.server.spi.config.jsonwriter; 17 | 18 | import com.google.api.server.spi.config.ResourceSchema; 19 | import com.google.api.server.spi.config.model.ApiConfig; 20 | import com.google.common.reflect.TypeToken; 21 | 22 | /** 23 | * An interface that provides a way to get properties of a Resource 24 | */ 25 | public interface ResourceSchemaProvider { 26 | /** 27 | * Gets a schema for a resource. 28 | */ 29 | ResourceSchema getResourceSchema(TypeToken type, ApiConfig serializationConfig); 30 | } 31 | -------------------------------------------------------------------------------- /endpoints-framework/src/main/java/com/google/api/server/spi/config/model/ApiLimitMetricConfig.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2017 Google Inc. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.google.api.server.spi.config.model; 17 | 18 | import com.google.auto.value.AutoValue; 19 | 20 | @AutoValue 21 | public abstract class ApiLimitMetricConfig { 22 | public abstract String name(); 23 | public abstract String displayName(); 24 | public abstract int limit(); 25 | 26 | public static Builder builder() { 27 | return new AutoValue_ApiLimitMetricConfig.Builder(); 28 | } 29 | 30 | @AutoValue.Builder 31 | public static abstract class Builder { 32 | public abstract Builder setName(String name); 33 | public abstract Builder setDisplayName(String displayName); 34 | public abstract Builder setLimit(int limit); 35 | public abstract ApiLimitMetricConfig build(); 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /endpoints-framework/src/main/java/com/google/api/server/spi/config/model/ApiMetricCostConfig.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2017 Google Inc. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.google.api.server.spi.config.model; 17 | 18 | import com.google.auto.value.AutoValue; 19 | 20 | @AutoValue 21 | public abstract class ApiMetricCostConfig { 22 | public abstract String name(); 23 | public abstract int cost(); 24 | 25 | public static Builder builder() { 26 | return new AutoValue_ApiMetricCostConfig.Builder(); 27 | } 28 | 29 | @AutoValue.Builder 30 | public static abstract class Builder { 31 | public abstract Builder setName(String name); 32 | public abstract Builder setCost(int cost); 33 | public abstract ApiMetricCostConfig build(); 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /endpoints-framework/src/main/java/com/google/api/server/spi/config/scope/AbstractAuthScopeExpression.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 Google Inc. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.google.api.server.spi.config.scope; 17 | 18 | import java.util.List; 19 | 20 | /** 21 | * A base class for all AuthScopeExpression implementations, allowing for package visible 22 | * capabilities. 23 | */ 24 | abstract class AbstractAuthScopeExpression implements AuthScopeExpression { 25 | /** 26 | * Encodes the expression to match what the {@link AuthScopeExpressions#interpret(List)} would 27 | * accept. 28 | */ 29 | abstract List encode(); 30 | 31 | /** 32 | * Encodes the expression to match what {@link AuthScopeExpressions#interpret(List)} 33 | * accepts. The returned list is mutable. 34 | */ 35 | abstract List encodeMutable(); 36 | 37 | @Override 38 | public String toString() { 39 | return toLoggingForm(); 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /endpoints-framework/src/main/java/com/google/api/server/spi/config/scope/AuthScopeExpression.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 Google Inc. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.google.api.server.spi.config.scope; 17 | 18 | import java.util.Set; 19 | 20 | /** 21 | * Representation of the set of OAuth scopes that are required to invoke a method. 22 | */ 23 | public interface AuthScopeExpression { 24 | /** 25 | * Gets all OAuth scopes that are involved with this expression. 26 | */ 27 | String[] getAllScopes(); 28 | 29 | /** 30 | * Determines whether a set of scopes that a user has is sufficient for the expression. 31 | */ 32 | boolean isAuthorized(Set userScopes); 33 | 34 | /** 35 | * Gets a stringified form of the expression that can be used for logging. 36 | */ 37 | String toLoggingForm(); 38 | } 39 | -------------------------------------------------------------------------------- /endpoints-framework/src/main/java/com/google/api/server/spi/config/validation/ApiClassConfigInvalidException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 Google Inc. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.google.api.server.spi.config.validation; 17 | 18 | import com.google.api.server.spi.config.ApiConfigException; 19 | import com.google.api.server.spi.config.model.ApiClassConfig; 20 | 21 | /** 22 | * Exception for any errors thrown validating an API class configuration. 23 | * 24 | * @author Eric Orth 25 | */ 26 | public class ApiClassConfigInvalidException extends ApiConfigException { 27 | public ApiClassConfigInvalidException(ApiClassConfig config, String message) { 28 | super(getErrorMessage(config, message)); 29 | } 30 | 31 | private static String getErrorMessage(ApiClassConfig config, String message) { 32 | return String.format("%s.%s: %s", config.getApiConfig().getName(), config.getApiClassJavaName(), 33 | message); 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /endpoints-framework/src/main/java/com/google/api/server/spi/config/validation/ApiConfigInvalidException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 Google Inc. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.google.api.server.spi.config.validation; 17 | 18 | import com.google.api.server.spi.config.ApiConfigException; 19 | import com.google.api.server.spi.config.model.ApiConfig; 20 | 21 | /** 22 | * Exception for any errors thrown validating API-wide configuration. 23 | * 24 | * @author Eric Orth 25 | */ 26 | public class ApiConfigInvalidException extends ApiConfigException { 27 | public ApiConfigInvalidException(ApiConfig config, String message) { 28 | super(getErrorMessage(config, message)); 29 | } 30 | 31 | private static String getErrorMessage(ApiConfig config, String message) { 32 | return String.format("%s: %s", config.getName(), message); 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /endpoints-framework/src/main/java/com/google/api/server/spi/config/validation/ApiMethodConfigInvalidException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 Google Inc. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.google.api.server.spi.config.validation; 17 | 18 | import com.google.api.server.spi.config.ApiConfigException; 19 | import com.google.api.server.spi.config.model.ApiMethodConfig; 20 | 21 | /** 22 | * Exception for any invalid configuration specific to an API method. 23 | * 24 | * @author Eric Orth 25 | */ 26 | public class ApiMethodConfigInvalidException extends ApiConfigException { 27 | public ApiMethodConfigInvalidException(ApiMethodConfig config, String message) { 28 | super(getErrorMessage(config, message)); 29 | } 30 | 31 | private static String getErrorMessage(ApiMethodConfig config, String message) { 32 | return String.format("%s.%s.%s: %s", config.getApiClassConfig().getApiConfig().getName(), 33 | config.getApiClassConfig().getApiClassJavaName(), config.getName(), message); 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /endpoints-framework/src/main/java/com/google/api/server/spi/config/validation/CollectionResourceException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 Google Inc. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.google.api.server.spi.config.validation; 17 | 18 | import com.google.api.server.spi.config.model.ApiParameterConfig; 19 | import com.google.common.reflect.TypeToken; 20 | 21 | /** 22 | * Exception for arrays or collections of entity (resource) type parameters. 23 | * 24 | * @author Eric Orth 25 | */ 26 | public class CollectionResourceException extends ApiParameterConfigInvalidException { 27 | public CollectionResourceException( 28 | ApiParameterConfig config, TypeToken repeatedItemType, TypeToken type) { 29 | super(config, getErrorMessage(repeatedItemType, type)); 30 | } 31 | 32 | private static String getErrorMessage(TypeToken repeatedItemType, TypeToken type) { 33 | return String.format( 34 | "Illegal parameter type ('%s' in collection type '%s'). Arrays or collections of entity " 35 | + "types are not allowed.", 36 | repeatedItemType, type); 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /endpoints-framework/src/main/java/com/google/api/server/spi/config/validation/DuplicateParameterNameException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 Google Inc. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.google.api.server.spi.config.validation; 17 | 18 | import com.google.api.server.spi.config.model.ApiParameterConfig; 19 | 20 | /** 21 | * Exception for non-unique parameter names. 22 | * 23 | * @author Eric Orth 24 | */ 25 | public class DuplicateParameterNameException extends ApiParameterConfigInvalidException { 26 | private static final String ERROR_MESSAGE = 27 | "Duplicate parameter name. Parameter names must be unique."; 28 | 29 | public DuplicateParameterNameException(ApiParameterConfig config) { 30 | super(config, ERROR_MESSAGE); 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /endpoints-framework/src/main/java/com/google/api/server/spi/config/validation/DuplicateRestPathException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 Google Inc. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.google.api.server.spi.config.validation; 17 | 18 | import com.google.api.server.spi.config.model.ApiClassConfig; 19 | 20 | /** 21 | * Exception for API configurations that would result in ambiguous REST paths. 22 | * 23 | * @author Eric Orth 24 | */ 25 | public class DuplicateRestPathException extends ApiClassConfigInvalidException { 26 | public DuplicateRestPathException(ApiClassConfig config, String restSignature, String method1, 27 | String method2) { 28 | super(config, getErrorMessage(restSignature, method1, method2)); 29 | } 30 | 31 | private static String getErrorMessage(String restSignature, String method1, String method2) { 32 | return String.format("Multiple methods with same rest path \"%s\": \"%s\" and \"%s\"", 33 | restSignature, method1, method2); 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /endpoints-framework/src/main/java/com/google/api/server/spi/config/validation/GenericTypeException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 Google Inc. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.google.api.server.spi.config.validation; 17 | 18 | import com.google.api.server.spi.config.model.ApiParameterConfig; 19 | 20 | /** 21 | * Exception for parameters with an generic type. 22 | * 23 | * @author Eric Orth 24 | */ 25 | public class GenericTypeException extends ApiParameterConfigInvalidException { 26 | private static final String ERROR_MESSAGE = 27 | "Parameter type is generic. The actual type must be known."; 28 | 29 | public GenericTypeException(ApiParameterConfig config) { 30 | super(config, ERROR_MESSAGE); 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /endpoints-framework/src/main/java/com/google/api/server/spi/config/validation/InvalidApiNameException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 Google Inc. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.google.api.server.spi.config.validation; 17 | 18 | import com.google.api.server.spi.config.model.ApiConfig; 19 | 20 | /** 21 | * Exception for API with an invalid name (such as "TestApi", "1api", "api$"). 22 | */ 23 | public class InvalidApiNameException extends ApiConfigInvalidException { 24 | 25 | public InvalidApiNameException(ApiConfig config, String name) { 26 | super(config, getErrorMessage(name)); 27 | } 28 | 29 | private static String getErrorMessage(String name) { 30 | return String.format( 31 | "Invalid api name '%s'. The api name must match '[a-z]+[A-Za-z0-9]*'", name); 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /endpoints-framework/src/main/java/com/google/api/server/spi/config/validation/InvalidConstructorException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 Google Inc. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.google.api.server.spi.config.validation; 17 | 18 | import com.google.api.server.spi.config.model.ApiMethodConfig; 19 | 20 | /** 21 | * Exception for custom authenticators/peer authenticators without a nullary constructor. 22 | * 23 | * @author Eric Orth 24 | */ 25 | public class InvalidConstructorException extends ApiMethodConfigInvalidException { 26 | public InvalidConstructorException(Class clazz, ApiMethodConfig config, String description) { 27 | super(config, getErrorMessage(clazz, description)); 28 | } 29 | 30 | private static String getErrorMessage(Class clazz, String description) { 31 | return String.format("Invalid %s %s. It must have a public nullary constructor.", description, 32 | clazz.getName()); 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /endpoints-framework/src/main/java/com/google/api/server/spi/config/validation/InvalidIssuerValueException.java: -------------------------------------------------------------------------------- 1 | package com.google.api.server.spi.config.validation; 2 | 3 | import com.google.api.server.spi.config.model.ApiClassConfig; 4 | import com.google.api.server.spi.config.model.ApiConfig; 5 | import com.google.api.server.spi.config.model.ApiMethodConfig; 6 | 7 | /** 8 | * Exception types revolving around invalid issuer values. 9 | */ 10 | public final class InvalidIssuerValueException { 11 | private InvalidIssuerValueException() { } 12 | 13 | public static class ForApi extends ApiConfigInvalidException { 14 | public ForApi(ApiConfig config, String message) { 15 | super(config, message); 16 | } 17 | } 18 | 19 | public static class ForApiClass extends ApiClassConfigInvalidException { 20 | public ForApiClass(ApiClassConfig config, String message) { 21 | super(config, message); 22 | } 23 | } 24 | 25 | public static class ForApiMethod extends ApiMethodConfigInvalidException { 26 | public ForApiMethod(ApiMethodConfig config, String message) { 27 | super(config, message); 28 | } 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /endpoints-framework/src/main/java/com/google/api/server/spi/config/validation/InvalidMethodNameException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 Google Inc. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.google.api.server.spi.config.validation; 17 | 18 | import com.google.api.server.spi.config.model.ApiMethodConfig; 19 | 20 | /** 21 | * Exception for API methods with an invalid name (such as "", "..", "ab$"). 22 | * 23 | * @author Eric Orth 24 | */ 25 | public class InvalidMethodNameException extends ApiMethodConfigInvalidException { 26 | public InvalidMethodNameException(ApiMethodConfig config, String name) { 27 | super(config, getErrorMessage(name)); 28 | } 29 | 30 | private static String getErrorMessage(String name) { 31 | return String.format( 32 | "Invalid method name '%s'. The method name must match '\\w+(\\.\\w+)*'", name); 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /endpoints-framework/src/main/java/com/google/api/server/spi/config/validation/InvalidNamespaceException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 Google Inc. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.google.api.server.spi.config.validation; 17 | 18 | import com.google.api.server.spi.config.model.ApiClassConfig; 19 | 20 | /** 21 | * Exception for invalid namespace configurations. 22 | * 23 | * @author Eric Orth 24 | */ 25 | public class InvalidNamespaceException extends ApiClassConfigInvalidException { 26 | private static final String ERROR_MESSAGE = 27 | "Invalid namespace configuration. If a namespace is set," 28 | + " make sure to set an Owner Domain and Name. Package Path is optional."; 29 | 30 | public InvalidNamespaceException(ApiClassConfig config) { 31 | super(config, ERROR_MESSAGE); 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /endpoints-framework/src/main/java/com/google/api/server/spi/config/validation/InvalidParameterAnnotationsException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 Google Inc. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.google.api.server.spi.config.validation; 17 | 18 | import com.google.api.server.spi.config.model.ApiParameterConfig; 19 | 20 | /** 21 | * Exception for parameters with annotations they are not allowed to have. 22 | * 23 | * @author Eric Orth 24 | */ 25 | public class InvalidParameterAnnotationsException extends ApiParameterConfigInvalidException { 26 | private static final String ERROR_MESSAGE = 27 | "Invalid parameter configuration. A parameter in the method path should not have a " 28 | + "default value or be marked @nullable."; 29 | 30 | public InvalidParameterAnnotationsException(ApiParameterConfig config) { 31 | super(config, ERROR_MESSAGE); 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /endpoints-framework/src/main/java/com/google/api/server/spi/config/validation/InvalidReturnTypeException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 Google Inc. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.google.api.server.spi.config.validation; 17 | 18 | import com.google.api.server.spi.config.model.ApiMethodConfig; 19 | import com.google.common.reflect.TypeToken; 20 | 21 | /** 22 | * Exception for endpoint methods returning unsupported types such as primitives or enum types. 23 | * 24 | * @author Eric Orth 25 | */ 26 | public class InvalidReturnTypeException extends ApiMethodConfigInvalidException { 27 | public InvalidReturnTypeException(ApiMethodConfig config, TypeToken type) { 28 | super(config, getErrorMessage(type)); 29 | } 30 | 31 | private static String getErrorMessage(TypeToken type) { 32 | return String.format("Invalid return type: %s. Primitives and enums are not allowed.", type); 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /endpoints-framework/src/main/java/com/google/api/server/spi/config/validation/MissingParameterNameException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 Google Inc. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.google.api.server.spi.config.validation; 17 | 18 | import com.google.api.server.spi.config.model.ApiParameterConfig; 19 | import com.google.common.reflect.TypeToken; 20 | 21 | /** 22 | * Exception for unnamed API parameters. 23 | * 24 | * @author Eric Orth 25 | */ 26 | public class MissingParameterNameException extends ApiParameterConfigInvalidException { 27 | public MissingParameterNameException(ApiParameterConfig config, TypeToken type) { 28 | super(config, getErrorMessage(type)); 29 | } 30 | 31 | private static String getErrorMessage(TypeToken type) { 32 | return String.format( 33 | "Missing parameter name. Parameter type (%s) is not an entity type and thus should be " 34 | + "annotated with @Named.", type); 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /endpoints-framework/src/main/java/com/google/api/server/spi/config/validation/MultipleTransformersException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 Google Inc. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.google.api.server.spi.config.validation; 17 | 18 | import com.google.api.server.spi.config.Transformer; 19 | import com.google.api.server.spi.config.model.ApiParameterConfig; 20 | 21 | import java.util.Collection; 22 | 23 | /** 24 | * Exception for parameter types with multiple serializers available from its superclass or 25 | * interfaces. 26 | * 27 | * @author Eric Orth 28 | */ 29 | public class MultipleTransformersException extends ApiParameterConfigInvalidException { 30 | public MultipleTransformersException(ApiParameterConfig config, 31 | Collection>> serializers) { 32 | super(config, getErrorMessage(serializers)); 33 | } 34 | 35 | private static String getErrorMessage( 36 | Collection>> serializers) { 37 | return String.format("Found multiple transformers for parameter type. Only one superclass or " 38 | + "implemented interface may be annotated. Transformed found: %s.", serializers); 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /endpoints-framework/src/main/java/com/google/api/server/spi/config/validation/NamedResourceException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 Google Inc. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.google.api.server.spi.config.validation; 17 | 18 | import com.google.api.server.spi.config.model.ApiParameterConfig; 19 | import com.google.common.reflect.TypeToken; 20 | 21 | /** 22 | * Exception for entity (resource) type parameters that have an @named annotation. 23 | * 24 | * @author Eric Orth 25 | */ 26 | public class NamedResourceException extends ApiParameterConfigInvalidException { 27 | public NamedResourceException(ApiParameterConfig config, TypeToken type) { 28 | super(config, getErrorMessage(type)); 29 | } 30 | 31 | private static String getErrorMessage(TypeToken type) { 32 | return String.format( 33 | "Bad parameter name. Parameter is entity type (%s) and should not be named.", type); 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /endpoints-framework/src/main/java/com/google/api/server/spi/config/validation/NestedCollectionException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 Google Inc. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.google.api.server.spi.config.validation; 17 | 18 | import com.google.api.server.spi.config.model.ApiParameterConfig; 19 | import com.google.common.reflect.TypeToken; 20 | 21 | /** 22 | * Exception for parameter types containing multiple levels of collections or arrays. 23 | * 24 | * @author Eric Orth 25 | */ 26 | public class NestedCollectionException extends ApiParameterConfigInvalidException { 27 | public NestedCollectionException(ApiParameterConfig config, TypeToken type) { 28 | super(config, getErrorMessage(type)); 29 | } 30 | 31 | private static String getErrorMessage(TypeToken type) { 32 | return String.format("Illegal nested collection type '%s'.", type); 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /endpoints-framework/src/main/java/com/google/api/server/spi/config/validation/NoTransformerInterfaceException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 Google Inc. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.google.api.server.spi.config.validation; 17 | 18 | import com.google.api.server.spi.config.Transformer; 19 | import com.google.api.server.spi.config.model.ApiParameterConfig; 20 | 21 | /** 22 | * Exception for transformers that do not actually implement the {@link Transformer} interface. 23 | * 24 | * @author Eric Orth 25 | */ 26 | public class NoTransformerInterfaceException extends ApiParameterConfigInvalidException { 27 | public NoTransformerInterfaceException(ApiParameterConfig config, 28 | Class> transformer) { 29 | super(config, getErrorMessage(transformer)); 30 | } 31 | 32 | private static String getErrorMessage(Class> transformer) { 33 | return String.format("Bad transformer (%s). No transformer interface implemented.", 34 | transformer); 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /endpoints-framework/src/main/java/com/google/api/server/spi/config/validation/OverloadedMethodException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 Google Inc. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.google.api.server.spi.config.validation; 17 | 18 | import com.google.api.server.spi.config.model.ApiClassConfig; 19 | 20 | /** 21 | * Exception for overloaded methods in an API class. 22 | * 23 | * @author Eric Orth 24 | */ 25 | public class OverloadedMethodException extends ApiClassConfigInvalidException { 26 | public OverloadedMethodException(ApiClassConfig config, String className, String method1, 27 | String method2) { 28 | super(config, getErrorMessage(className, method1, method2)); 29 | } 30 | 31 | private static String getErrorMessage(String className, String method1, String method2) { 32 | return String.format( 33 | "Overloaded methods are not supported. %s has at least one overload: %s and %s", 34 | className, method1, method2); 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /endpoints-framework/src/main/java/com/google/api/server/spi/config/validation/PropertyParameterNameConflictException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 Google Inc. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.google.api.server.spi.config.validation; 17 | 18 | import com.google.api.server.spi.config.model.ApiParameterConfig; 19 | 20 | /** 21 | * Exception for parameters with the same name as a property in the resource. 22 | * 23 | * @author Eric Orth 24 | */ 25 | public class PropertyParameterNameConflictException extends ApiParameterConfigInvalidException { 26 | private static final String ERROR_MESSAGE = 27 | "Parameter name conflicts with a property in the resource."; 28 | 29 | public PropertyParameterNameConflictException(ApiParameterConfig config) { 30 | super(config, ERROR_MESSAGE); 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /endpoints-framework/src/main/java/com/google/api/server/spi/dispatcher/DispatcherHandler.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 Google Inc. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.google.api.server.spi.dispatcher; 17 | 18 | import java.io.IOException; 19 | 20 | /** 21 | * An interface for {@link PathDispatcher} to call into. 22 | */ 23 | public interface DispatcherHandler { 24 | void handle(ContextT context) throws IOException; 25 | } 26 | -------------------------------------------------------------------------------- /endpoints-framework/src/main/java/com/google/api/server/spi/dispatcher/HttpMethod.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 Google Inc. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.google.api.server.spi.dispatcher; 17 | 18 | import com.google.common.base.Preconditions; 19 | import com.google.common.collect.ImmutableMap; 20 | 21 | /** 22 | * Possible HTTP methods for use in the dispatcher. 23 | */ 24 | enum HttpMethod { 25 | GET, 26 | POST, 27 | PUT, 28 | DELETE, 29 | PATCH; 30 | 31 | private static final ImmutableMap STRING_TO_ENUM = 32 | ImmutableMap.builder() 33 | .put("GET", GET) 34 | .put("POST", POST) 35 | .put("PUT", PUT) 36 | .put("DELETE", DELETE) 37 | .put("PATCH", PATCH) 38 | .build(); 39 | 40 | /** 41 | * Returns an {@link HttpMethod} corresponding to a string value, or null if it doesn't exist. 42 | */ 43 | public static HttpMethod fromString(String method) { 44 | Preconditions.checkNotNull(method, "method"); 45 | return STRING_TO_ENUM.get(method.toUpperCase()); 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /endpoints-framework/src/main/java/com/google/api/server/spi/request/AbstractParamReader.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 Google Inc. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.google.api.server.spi.request; 17 | 18 | import com.google.api.server.spi.EndpointMethod; 19 | 20 | /** 21 | * Implementation of functionality common to all implementations of {@link ParamReader}. 22 | */ 23 | public abstract class AbstractParamReader implements ParamReader { 24 | private final EndpointMethod method; 25 | 26 | protected AbstractParamReader(EndpointMethod method) { 27 | this.method = method; 28 | } 29 | 30 | protected EndpointMethod getMethod() { 31 | return method; 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /endpoints-framework/src/main/java/com/google/api/server/spi/request/ParamReader.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 Google Inc. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.google.api.server.spi.request; 17 | 18 | import com.google.api.server.spi.ServiceException; 19 | 20 | /** 21 | * Reads a request and returns an array of parameter values. 22 | */ 23 | public interface ParamReader { 24 | 25 | /** 26 | * Reads parameters in JSON into an Object array to be used to invoke an Endpoint method. 27 | * @throws ServiceException when reading of input stream failed, input JSON is invalid, 28 | * or cannot be mapped into parameter objects, or user authentication fails. 29 | */ 30 | Object[] read() throws ServiceException; 31 | } 32 | -------------------------------------------------------------------------------- /endpoints-framework/src/main/java/com/google/api/server/spi/response/ResponseUtil.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 Google Inc. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.google.api.server.spi.response; 17 | 18 | import com.google.api.server.spi.Constant; 19 | 20 | import java.util.Collection; 21 | import java.util.HashMap; 22 | import java.util.Map; 23 | 24 | /** 25 | * Utility methods for writing responses. 26 | */ 27 | public final class ResponseUtil { 28 | 29 | private ResponseUtil() {} 30 | 31 | /** 32 | * Wraps a collection in an "items" property. 33 | */ 34 | static Object wrapCollection(Object value) { 35 | if (isCollection(value)) { 36 | Map wrapped = new HashMap(); 37 | wrapped.put(Constant.ITEMS, value); 38 | return wrapped; 39 | } else { 40 | return value; 41 | } 42 | } 43 | 44 | /** 45 | * Returns {@code true} if {@code value} is either a collection or an array; {@code false} 46 | * otherwise. 47 | */ 48 | private static boolean isCollection(Object value) { 49 | return value == null ? false : value instanceof Collection || value.getClass().isArray(); 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /endpoints-framework/src/main/java/com/google/api/server/spi/response/ResultWriter.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 Google Inc. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.google.api.server.spi.response; 17 | 18 | import com.google.api.server.spi.ServiceException; 19 | 20 | import java.io.IOException; 21 | 22 | /** 23 | * Writes a result or error. 24 | */ 25 | public interface ResultWriter { 26 | 27 | /** 28 | * Writes a result JSON object. 29 | * @throws IOException 30 | */ 31 | void write(Object result) throws IOException; 32 | 33 | /** 34 | * Writes an error response with the HTTP status code and JSON body of {"message": 35 | * "<exception's message>"}. 36 | */ 37 | void writeError(ServiceException e) throws IOException; 38 | } 39 | -------------------------------------------------------------------------------- /endpoints-framework/src/main/resources/com/google/api/server/spi/handlers/proxy.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 21 | 26 | 28 | 29 | 30 | 31 | 32 | -------------------------------------------------------------------------------- /endpoints-framework/src/test/java/com/google/api/server/spi/ServiceExceptionTest.java: -------------------------------------------------------------------------------- 1 | package com.google.api.server.spi; 2 | 3 | import static com.google.common.truth.Truth.assertThat; 4 | 5 | import com.google.api.server.spi.response.UnauthorizedException; 6 | import java.util.logging.Level; 7 | import org.junit.Test; 8 | import org.junit.runner.RunWith; 9 | import org.junit.runners.JUnit4; 10 | 11 | @RunWith(JUnit4.class) 12 | public class ServiceExceptionTest { 13 | @Test 14 | public void testWithLogLevel() { 15 | UnauthorizedException ex = new UnauthorizedException(""); 16 | assertThat(ex.getLogLevel()).isEqualTo(Level.INFO); 17 | assertThat(ServiceException.withLogLevel(ex, Level.WARNING).getLogLevel()) 18 | .isEqualTo(Level.WARNING); 19 | } 20 | } -------------------------------------------------------------------------------- /endpoints-framework/src/test/java/com/google/api/server/spi/SystemServiceTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 Google Inc. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.google.api.server.spi; 17 | 18 | import com.google.api.server.spi.testing.Endpoint0; 19 | import com.google.api.server.spi.testing.TestEndpoint; 20 | 21 | import org.junit.runner.RunWith; 22 | import org.junit.runners.JUnit4; 23 | 24 | /** 25 | * Tests for {@link SystemService}. 26 | */ 27 | @RunWith(JUnit4.class) 28 | public class SystemServiceTest extends BaseSystemServiceTest { 29 | @Override 30 | protected TestEndpoint getTestService() { 31 | return new TestEndpoint(); 32 | } 33 | 34 | @Override 35 | protected Endpoint0 getTestService2() { 36 | return new Endpoint0(); 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /endpoints-framework/src/test/java/com/google/api/server/spi/config/jsonwriter/JacksonResourceSchemaProviderTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 Google Inc. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.google.api.server.spi.config.jsonwriter; 17 | 18 | import org.junit.runner.RunWith; 19 | import org.junit.runners.JUnit4; 20 | 21 | /** 22 | * Tests for {@link JacksonResourceSchemaProvider}. 23 | */ 24 | @RunWith(JUnit4.class) 25 | public class JacksonResourceSchemaProviderTest extends ResourceSchemaProviderTest { 26 | @Override 27 | public ResourceSchemaProvider getResourceSchemaProvider() { 28 | return new JacksonResourceSchemaProvider(); 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /endpoints-framework/src/test/java/com/google/api/server/spi/config/model/ApiIssuerConfigsTest.java: -------------------------------------------------------------------------------- 1 | package com.google.api.server.spi.config.model; 2 | 3 | import static com.google.common.truth.Truth.assertThat; 4 | 5 | import com.google.api.server.spi.config.model.ApiIssuerConfigs.IssuerConfig; 6 | 7 | import org.junit.Test; 8 | import org.junit.runner.RunWith; 9 | import org.junit.runners.JUnit4; 10 | 11 | /** 12 | * Tests for {@link ApiIssuerConfigs}. 13 | */ 14 | @RunWith(JUnit4.class) 15 | public class ApiIssuerConfigsTest { 16 | @Test 17 | public void isSpecified() { 18 | assertThat(ApiIssuerConfigs.builder().build().isSpecified()).isTrue(); 19 | assertThat(ApiIssuerConfigs.UNSPECIFIED.isSpecified()).isFalse(); 20 | } 21 | 22 | @Test 23 | public void asMap() { 24 | assertThat(ApiIssuerConfigs.builder().build().asMap()).isEmpty(); 25 | ApiIssuerConfigs configs = ApiIssuerConfigs.builder() 26 | .addIssuer(new IssuerConfig("issuerName", "issuer", "jwks")) 27 | .build(); 28 | assertThat(configs.asMap()).containsExactly( 29 | "issuerName", new IssuerConfig("issuerName", "issuer", "jwks")); 30 | } 31 | 32 | @Test 33 | public void equals() { 34 | ApiIssuerConfigs configs1 = ApiIssuerConfigs.builder() 35 | .addIssuer(new IssuerConfig("issuerName", "issuer", "jwks")) 36 | .build(); 37 | ApiIssuerConfigs configs2 = ApiIssuerConfigs.builder() 38 | .addIssuer(new IssuerConfig("issuerName", "issuer", "jwks")) 39 | .build(); 40 | assertThat(configs1).isEqualTo(configs2); 41 | assertThat(configs1).isNotEqualTo(ApiIssuerConfigs.UNSPECIFIED); 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /endpoints-framework/src/test/resources/com/google/api/server/spi/discovery/directory.json: -------------------------------------------------------------------------------- 1 | { 2 | "discoveryVersion": "v1", 3 | "items": [ 4 | { 5 | "description": "This is an API", 6 | "discoveryLink": "./apis/myapi/v1/rest", 7 | "discoveryRestUrl": "https://myapi.appspot.com/_ah/api/discovery/v1/apis/myapi/v1/rest", 8 | "icons": { 9 | "x16": "https://www.gstatic.com/images/branding/product/1x/googleg_16dp.png", 10 | "x32": "https://www.gstatic.com/images/branding/product/1x/googleg_32dp.png" 11 | }, 12 | "id": "myapi:v1", 13 | "kind": "discovery#directoryItem", 14 | "name": "myapi", 15 | "preferred": true, 16 | "version": "v1" 17 | }, 18 | { 19 | "description": "This is an API", 20 | "discoveryLink": "./apis/enum/v1/rest", 21 | "discoveryRestUrl": "https://myapi.appspot.com/_ah/api/discovery/v1/apis/enum/v1/rest", 22 | "icons": { 23 | "x16": "https://www.gstatic.com/images/branding/product/1x/googleg_16dp.png", 24 | "x32": "https://www.gstatic.com/images/branding/product/1x/googleg_32dp.png" 25 | }, 26 | "id": "enum:v1", 27 | "kind": "discovery#directoryItem", 28 | "name": "enum", 29 | "preferred": true, 30 | "version": "v1" 31 | } 32 | ], 33 | "kind": "discovery#directoryList" 34 | } 35 | -------------------------------------------------------------------------------- /endpoints-framework/src/test/resources/com/google/api/server/spi/swagger/absolute_common_path_endpoint.swagger: -------------------------------------------------------------------------------- 1 | { 2 | "swagger": "2.0", 3 | "info": { 4 | "version": "1.0.0", 5 | "title": "myapi.appspot.com" 6 | }, 7 | "host": "myapi.appspot.com", 8 | "basePath": "/_ah/api", 9 | "schemes": [ 10 | "https" 11 | ], 12 | "consumes": [ 13 | "application/json" 14 | ], 15 | "produces": [ 16 | "application/json" 17 | ], 18 | "paths": { 19 | "/absolutepath/v1/absolutepathmethod": { 20 | "post": { 21 | "operationId": "AbsolutepathV1AbsolutePath", 22 | "parameters": [], 23 | "responses": { 24 | "200": { 25 | "description": "A successful response" 26 | } 27 | } 28 | } 29 | }, 30 | "/absolutepath/v1/create": { 31 | "post": { 32 | "operationId": "AbsolutepathV1CreateFoo", 33 | "parameters": [], 34 | "responses": { 35 | "200": { 36 | "description": "A successful response", 37 | "schema": { 38 | "$ref": "#/definitions/Foo" 39 | } 40 | } 41 | } 42 | } 43 | } 44 | }, 45 | "definitions": { 46 | "Foo": { 47 | "type": "object", 48 | "properties": { 49 | "name": { 50 | "type": "string" 51 | }, 52 | "value": { 53 | "type": "integer", 54 | "format": "int32" 55 | } 56 | } 57 | } 58 | } 59 | } 60 | -------------------------------------------------------------------------------- /endpoints-framework/src/test/resources/com/google/api/server/spi/swagger/absolute_path_endpoint.swagger: -------------------------------------------------------------------------------- 1 | { 2 | "swagger": "2.0", 3 | "info": { 4 | "version": "1.0.0", 5 | "title": "myapi.appspot.com" 6 | }, 7 | "host": "myapi.appspot.com", 8 | "basePath": "/_ah/api", 9 | "schemes": [ 10 | "https" 11 | ], 12 | "consumes": [ 13 | "application/json" 14 | ], 15 | "produces": [ 16 | "application/json" 17 | ], 18 | "paths": { 19 | "/absolutepath/v1/create": { 20 | "post": { 21 | "operationId": "AbsolutepathV1CreateFoo", 22 | "parameters": [], 23 | "responses": { 24 | "200": { 25 | "description": "A successful response", 26 | "schema": { 27 | "$ref": "#/definitions/Foo" 28 | } 29 | } 30 | } 31 | } 32 | }, 33 | "/absolutepathmethod/v1": { 34 | "post": { 35 | "operationId": "AbsolutepathV1AbsolutePath", 36 | "parameters": [], 37 | "responses": { 38 | "200": { 39 | "description": "A successful response" 40 | } 41 | } 42 | } 43 | }, 44 | "/absolutepathmethod2/v1": { 45 | "post": { 46 | "operationId": "AbsolutepathV1AbsolutePath2", 47 | "parameters": [], 48 | "responses": { 49 | "200": { 50 | "description": "A successful response" 51 | } 52 | } 53 | } 54 | } 55 | }, 56 | "definitions": { 57 | "Foo": { 58 | "type": "object", 59 | "properties": { 60 | "name": { 61 | "type": "string" 62 | }, 63 | "value": { 64 | "type": "integer", 65 | "format": "int32" 66 | } 67 | } 68 | } 69 | } 70 | } 71 | -------------------------------------------------------------------------------- /endpoints-framework/src/test/resources/com/google/api/server/spi/swagger/enum_endpoint.swagger: -------------------------------------------------------------------------------- 1 | { 2 | "swagger": "2.0", 3 | "info": { 4 | "version": "1.0.0", 5 | "title": "myapi.appspot.com" 6 | }, 7 | "host": "myapi.appspot.com", 8 | "basePath": "/_ah/api", 9 | "schemes": [ 10 | "https" 11 | ], 12 | "consumes": [ 13 | "application/json" 14 | ], 15 | "produces": [ 16 | "application/json" 17 | ], 18 | "paths": { 19 | "/enum/v1/{value}": { 20 | "post": { 21 | "operationId": "EnumV1Create", 22 | "parameters": [ 23 | { 24 | "name": "value", 25 | "in": "path", 26 | "required": true, 27 | "type": "string", 28 | "enum": [ 29 | "VALUE1", 30 | "VALUE2" 31 | ] 32 | } 33 | ], 34 | "responses": { 35 | "200": { 36 | "description": "A successful response", 37 | "schema": { 38 | "$ref": "#/definitions/EnumValue" 39 | } 40 | } 41 | } 42 | } 43 | } 44 | }, 45 | "definitions": { 46 | "EnumValue": { 47 | "type": "object", 48 | "properties": { 49 | "value": { 50 | "type": "string", 51 | "enum": [ 52 | "VALUE1", 53 | "VALUE2" 54 | ] 55 | } 56 | } 57 | } 58 | } 59 | } 60 | -------------------------------------------------------------------------------- /endpoints-framework/src/test/resources/com/google/api/server/spi/swagger/multi_version_endpoint.swagger: -------------------------------------------------------------------------------- 1 | { 2 | "swagger": "2.0", 3 | "info": { 4 | "version": "1.0.0", 5 | "title": "swagger-test.appspot.com" 6 | }, 7 | "host": "swagger-test.appspot.com", 8 | "basePath": "/api", 9 | "schemes": [ 10 | "https" 11 | ], 12 | "consumes": [ 13 | "application/json" 14 | ], 15 | "produces": [ 16 | "application/json" 17 | ], 18 | "paths": { 19 | "/myapi/v1/foo": { 20 | "get": { 21 | "operationId": "MyapiV1Get", 22 | "parameters": [], 23 | "responses": { 24 | "200": { 25 | "description": "A successful response", 26 | "schema": { 27 | "$ref": "#/definitions/Foo" 28 | } 29 | } 30 | } 31 | } 32 | }, 33 | "/myapi/v2/foo": { 34 | "get": { 35 | "operationId": "MyapiV2Get", 36 | "parameters": [], 37 | "responses": { 38 | "200": { 39 | "description": "A successful response", 40 | "schema": { 41 | "$ref": "#/definitions/Foo" 42 | } 43 | } 44 | } 45 | } 46 | } 47 | }, 48 | "definitions": { 49 | "Foo": { 50 | "type": "object", 51 | "properties": { 52 | "name": { 53 | "type": "string" 54 | }, 55 | "value": { 56 | "type": "integer", 57 | "format": "int32" 58 | } 59 | } 60 | } 61 | } 62 | } 63 | -------------------------------------------------------------------------------- /gradle.properties: -------------------------------------------------------------------------------- 1 | version=2.2.2 2 | 3 | sourceCompatibility=1.7 4 | targetCompatibility=1.7 5 | group=com.google.endpoints 6 | 7 | servletVersion=2.5 8 | javaxinjectVersion=1 9 | guavaVersion=20.0 10 | jacksonVersion=2.9.6 11 | gradleAppenginePluginVersion=1.9.59 12 | appengineVersion=1.9.60 13 | apiclientVersion=1.25.0 14 | fileUploadVersion=1.3.3 15 | findbugsVersion=3.0.1 16 | swaggerVersion=1.5.9 17 | slf4jVersion=1.7.21 18 | guiceVersion=4.0 19 | objectifyVersion=5.1.21 20 | floggerVersion=0.3.1 21 | 22 | junitVersion=4.12 23 | mockitoVersion=1.10.19 24 | truthVersion=0.28 25 | springtestVersion=3.2.16.RELEASE 26 | -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cloudendpoints/endpoints-java/44933a4d5d38b7bf6a11ee0c139a120563ef9d6b/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | #Wed Aug 03 14:48:55 PDT 2016 2 | distributionBase=GRADLE_USER_HOME 3 | distributionPath=wrapper/dists 4 | zipStoreBase=GRADLE_USER_HOME 5 | zipStorePath=wrapper/dists 6 | distributionUrl=https\://services.gradle.org/distributions/gradle-2.14.1-bin.zip 7 | -------------------------------------------------------------------------------- /settings.gradle: -------------------------------------------------------------------------------- 1 | include ':endpoints-framework', 'endpoints-framework-all', ':endpoints-framework-tools', ':endpoints-framework-guice', ':test-utils', ':discovery-client', ':test-compat', ':test-compat:legacy-app', ':test-compat:new-app', ':test-compat:new-app-guice' 2 | -------------------------------------------------------------------------------- /test-compat/legacy-app-guice/build.gradle: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 Google Inc. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | dependencies { 18 | compile project(':endpoints-framework-guice') 19 | compile project(':endpoints-framework') 20 | compile project(':test-compat') 21 | appengineSdk "com.google.appengine:appengine-java-sdk:${appengineVersion}" 22 | } 23 | -------------------------------------------------------------------------------- /test-compat/legacy-app-guice/src/main/java/com/google/testapp/TestGuiceServletContextListener.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 Google Inc. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.google.testapp; 17 | 18 | import com.google.inject.Guice; 19 | import com.google.inject.Injector; 20 | import com.google.inject.servlet.GuiceServletContextListener; 21 | 22 | /** 23 | * A {@link GuiceServletContextListener} that configures a test injector. 24 | */ 25 | public class TestGuiceServletContextListener extends GuiceServletContextListener { 26 | @Override 27 | protected Injector getInjector() { 28 | return Guice.createInjector(new TestSystemServiceModule()); 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /test-compat/legacy-app-guice/src/main/java/com/google/testapp/TestSystemServiceModule.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 Google Inc. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.google.testapp; 17 | 18 | import com.google.api.server.spi.guice.GuiceSystemServiceServletModule; 19 | import com.google.common.collect.ImmutableList; 20 | import com.google.inject.Scopes; 21 | import com.google.testapi.TestEndpoint; 22 | import com.google.waxapi.InMemoryWaxDataStore; 23 | import com.google.waxapi.WaxEndpoint; 24 | 25 | /** 26 | * A Guice-configured test servlet module. 27 | */ 28 | public class TestSystemServiceModule extends GuiceSystemServiceServletModule { 29 | @Override 30 | public void configureServlets() { 31 | bind(WaxEndpoint.class).toInstance(new WaxEndpoint(new InMemoryWaxDataStore())); 32 | bind(TestEndpoint.class).in(Scopes.SINGLETON); 33 | serveGuiceSystemServiceServlet("/_ah/spi/*", 34 | ImmutableList.of(WaxEndpoint.class, TestEndpoint.class)); 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /test-compat/legacy-app-guice/src/main/webapp/WEB-INF/appengine-web.xml: -------------------------------------------------------------------------------- 1 | 16 | 17 | ${projectId} 18 | legacy-guice 19 | true 20 | true 21 | true 22 | false 23 | false 24 | 25 | 26 | 27 | 28 | -------------------------------------------------------------------------------- /test-compat/legacy-app-guice/src/main/webapp/WEB-INF/logging.properties: -------------------------------------------------------------------------------- 1 | .level = INFO 2 | -------------------------------------------------------------------------------- /test-compat/legacy-app-guice/src/main/webapp/WEB-INF/web.xml: -------------------------------------------------------------------------------- 1 | 16 | 17 | 18 | com.google.testapp.TestGuiceServletContextListener 19 | 20 | 21 | GuiceFilter 22 | com.google.inject.servlet.GuiceFilter 23 | 24 | 25 | GuiceFilter 26 | /_ah/api/* 27 | 28 | 29 | -------------------------------------------------------------------------------- /test-compat/legacy-app/build.gradle: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 Google Inc. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | dependencies { 18 | compile project(':test-compat') 19 | appengineSdk "com.google.appengine:appengine-java-sdk:${appengineVersion}" 20 | compile group: 'com.google.appengine', name: 'appengine-endpoints', version: appengineVersion 21 | } 22 | -------------------------------------------------------------------------------- /test-compat/legacy-app/src/main/webapp/WEB-INF/appengine-web.xml: -------------------------------------------------------------------------------- 1 | 16 | 17 | ${projectId} 18 | legacy 19 | true 20 | true 21 | false 22 | false 23 | false 24 | 25 | 26 | 27 | 28 | -------------------------------------------------------------------------------- /test-compat/legacy-app/src/main/webapp/WEB-INF/logging.properties: -------------------------------------------------------------------------------- 1 | .level = INFO 2 | -------------------------------------------------------------------------------- /test-compat/new-app-guice/build.gradle: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 Google Inc. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | dependencies { 18 | compile project(':endpoints-framework-guice') 19 | compile project(':endpoints-framework') 20 | compile project(':test-compat') 21 | appengineSdk "com.google.appengine:appengine-java-sdk:${appengineVersion}" 22 | } 23 | -------------------------------------------------------------------------------- /test-compat/new-app-guice/src/main/java/com/google/testapp/TestEndpointsModule.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 Google Inc. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.google.testapp; 17 | 18 | import com.google.api.server.spi.guice.EndpointsModule; 19 | import com.google.common.collect.ImmutableList; 20 | import com.google.inject.Scopes; 21 | import com.google.testapi.TestEndpoint; 22 | import com.google.waxapi.InMemoryWaxDataStore; 23 | import com.google.waxapi.WaxEndpoint; 24 | 25 | /** 26 | * A Guice-configured test servlet module. 27 | */ 28 | public class TestEndpointsModule extends EndpointsModule { 29 | @Override 30 | public void configureServlets() { 31 | bind(WaxEndpoint.class).toInstance(new WaxEndpoint(new InMemoryWaxDataStore())); 32 | bind(TestEndpoint.class).in(Scopes.SINGLETON); 33 | configureEndpoints("/_ah/api/*", ImmutableList.of(WaxEndpoint.class, TestEndpoint.class)); 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /test-compat/new-app-guice/src/main/java/com/google/testapp/TestGuiceServletContextListener.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 Google Inc. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.google.testapp; 17 | 18 | import com.google.inject.Guice; 19 | import com.google.inject.Injector; 20 | import com.google.inject.servlet.GuiceServletContextListener; 21 | 22 | /** 23 | * A {@link GuiceServletContextListener} that configures a test injector. 24 | */ 25 | public class TestGuiceServletContextListener extends GuiceServletContextListener { 26 | @Override 27 | protected Injector getInjector() { 28 | return Guice.createInjector(new TestEndpointsModule()); 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /test-compat/new-app-guice/src/main/webapp/WEB-INF/appengine-web.xml: -------------------------------------------------------------------------------- 1 | 16 | 17 | ${projectId} 18 | dev-guice 19 | true 20 | true 21 | false 22 | false 23 | false 24 | 25 | 26 | 27 | 28 | -------------------------------------------------------------------------------- /test-compat/new-app-guice/src/main/webapp/WEB-INF/logging.properties: -------------------------------------------------------------------------------- 1 | .level = INFO 2 | -------------------------------------------------------------------------------- /test-compat/new-app-guice/src/main/webapp/WEB-INF/web.xml: -------------------------------------------------------------------------------- 1 | 16 | 17 | 18 | com.google.testapp.TestGuiceServletContextListener 19 | 20 | 21 | GuiceFilter 22 | com.google.inject.servlet.GuiceFilter 23 | 24 | 25 | GuiceFilter 26 | /_ah/api/* 27 | 28 | 29 | -------------------------------------------------------------------------------- /test-compat/new-app/build.gradle: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 Google Inc. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | dependencies { 18 | compile project(':endpoints-framework') 19 | compile project(':test-compat') 20 | appengineSdk "com.google.appengine:appengine-java-sdk:${appengineVersion}" 21 | } 22 | -------------------------------------------------------------------------------- /test-compat/new-app/src/main/webapp/WEB-INF/appengine-web.xml: -------------------------------------------------------------------------------- 1 | 16 | 17 | ${projectId} 18 | dev 19 | true 20 | true 21 | false 22 | false 23 | false 24 | 25 | 26 | 27 | 28 | -------------------------------------------------------------------------------- /test-compat/new-app/src/main/webapp/WEB-INF/logging.properties: -------------------------------------------------------------------------------- 1 | .level = INFO 2 | -------------------------------------------------------------------------------- /test-compat/src/main/java/com/google/waxapi/InvalidSessionException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 Google Inc. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.google.waxapi; 17 | 18 | /** 19 | * An exception used to indicate that a given session id doesn't exist in a data store. 20 | */ 21 | public class InvalidSessionException extends WaxDataStoreException { 22 | public InvalidSessionException(String sessionId) { 23 | super("Invalid sessionId: " + sessionId); 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /test-compat/src/main/java/com/google/waxapi/InvalidWaxDataItemException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 Google Inc. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.google.waxapi; 17 | 18 | /** 19 | * An exception used to indicate that a provided {@link WaxDataItem} is invalid. 20 | */ 21 | public class InvalidWaxDataItemException extends WaxDataStoreException { 22 | public InvalidWaxDataItemException(String itemId) { 23 | super("Invalid item with id: " + itemId); 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /test-compat/src/main/java/com/google/waxapi/ObjectifyInitializer.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 Google Inc. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.google.waxapi; 17 | 18 | import com.googlecode.objectify.ObjectifyService; 19 | 20 | import javax.servlet.ServletContextEvent; 21 | import javax.servlet.ServletContextListener; 22 | 23 | /** 24 | * An initializer for registering entity classes with Objectify upon application initialization. 25 | */ 26 | public class ObjectifyInitializer implements ServletContextListener { 27 | 28 | @Override 29 | public void contextInitialized(ServletContextEvent sce) { 30 | ObjectifyService.register(WaxSession.class); 31 | } 32 | 33 | @Override 34 | public void contextDestroyed(ServletContextEvent sce) { 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /test-compat/src/main/java/com/google/waxapi/WaxDataStoreException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 Google Inc. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.google.waxapi; 17 | 18 | /** 19 | * A parent exception class for Wax data store exceptions. 20 | */ 21 | public class WaxDataStoreException extends Exception { 22 | public WaxDataStoreException(String msg) { 23 | super(msg); 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /test-compat/src/main/java/com/google/waxapi/WaxNewSessionRequest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 Google Inc. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.google.waxapi; 17 | 18 | /** 19 | * An object representing the request of an API call to create a session. 20 | */ 21 | public class WaxNewSessionRequest { 22 | private String sessionName; 23 | private Long durationInMillis; 24 | 25 | public WaxNewSessionRequest() { 26 | } 27 | 28 | public WaxNewSessionRequest(String sessionName, Long durationInMillis) { 29 | this.sessionName = sessionName; 30 | this.durationInMillis = durationInMillis; 31 | } 32 | 33 | public String getSessionName() { 34 | return sessionName; 35 | } 36 | 37 | public void setSessionName(String sessionName) { 38 | this.sessionName = sessionName; 39 | } 40 | 41 | public Long getDurationInMillis() { 42 | return durationInMillis; 43 | } 44 | 45 | public void setDurationInMillis(long durationInMillis) { 46 | this.durationInMillis = durationInMillis; 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /test-compat/src/main/java/com/google/waxapi/WaxNewSessionResponse.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 Google Inc. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.google.waxapi; 17 | 18 | /** 19 | * An object representing the response of an API call to create a session. 20 | */ 21 | public class WaxNewSessionResponse { 22 | private String newSessionId; 23 | 24 | public WaxNewSessionResponse() { 25 | } 26 | 27 | public WaxNewSessionResponse(String newSessionId) { 28 | this.newSessionId = newSessionId; 29 | } 30 | 31 | public String getNewSessionId() { 32 | return newSessionId; 33 | } 34 | 35 | public void setNewSessionId(String newSessionId) { 36 | this.newSessionId = newSessionId; 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /test-compat/src/main/java/com/google/waxapi/WaxRemoveSessionResponse.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 Google Inc. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.google.waxapi; 17 | 18 | /** 19 | * An object representing the response of an API call to delete a session. 20 | */ 21 | public class WaxRemoveSessionResponse { 22 | private String removedSessionId; 23 | 24 | public WaxRemoveSessionResponse() { 25 | } 26 | 27 | public WaxRemoveSessionResponse(String removedSessionId) { 28 | this.removedSessionId = removedSessionId; 29 | } 30 | 31 | public String getRemovedSessionId() { 32 | return removedSessionId; 33 | } 34 | 35 | public void setRemovedSessionId(String removedSessionId) { 36 | this.removedSessionId = removedSessionId; 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /test-compat/src/main/webapp/WEB-INF/appengine-web.xml: -------------------------------------------------------------------------------- 1 | 16 | 17 | compat-tests 18 | legacy 19 | true 20 | true 21 | false 22 | false 23 | false 24 | 25 | 26 | 27 | 28 | -------------------------------------------------------------------------------- /test-utils/build.gradle: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 Google Inc. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | dependencies { 17 | compile project(':endpoints-framework') 18 | compile group: 'javax.inject', name: 'javax.inject', version: javaxinjectVersion 19 | compile group: 'junit', name: 'junit', version: junitVersion 20 | compile group: 'org.mockito', name: 'mockito-core', version: mockitoVersion 21 | compile group: 'com.google.truth', name: 'truth', version: truthVersion 22 | } 23 | -------------------------------------------------------------------------------- /test-utils/src/main/java/com/google/api/server/spi/request/FakeParamReader.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 Google Inc. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.google.api.server.spi.request; 17 | 18 | import com.google.api.server.spi.response.BadRequestException; 19 | 20 | import java.util.Arrays; 21 | 22 | /** 23 | * A simple fake {@link ParamReader}. 24 | */ 25 | public class FakeParamReader implements ParamReader { 26 | private final Object[] params; 27 | 28 | public FakeParamReader(Object... params) { 29 | this.params = params; 30 | } 31 | 32 | @Override 33 | public Object[] read() throws BadRequestException { 34 | return Arrays.copyOf(params, params.length); 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /test-utils/src/main/java/com/google/api/server/spi/response/SuccessResultWriter.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 Google Inc. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.google.api.server.spi.response; 17 | 18 | import static com.google.common.truth.Truth.assertThat; 19 | import static org.junit.Assert.fail; 20 | 21 | import com.google.api.server.spi.ServiceException; 22 | 23 | import java.io.IOException; 24 | 25 | /** 26 | * A fake {@link ResultWriter} that expects success. 27 | */ 28 | public class SuccessResultWriter implements ResultWriter { 29 | private final Object expectedResult; 30 | 31 | public SuccessResultWriter(Object expectedResult) { 32 | this.expectedResult = expectedResult; 33 | } 34 | 35 | @Override 36 | public void write(Object result) throws IOException { 37 | assertThat(result).isEqualTo(expectedResult); 38 | } 39 | 40 | @Override 41 | public void writeError(ServiceException e) throws IOException { 42 | fail("expected success to be returned"); 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /test-utils/src/main/java/com/google/api/server/spi/testing/AbsoluteCommonPathEndpoint.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2017 Google Inc. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.google.api.server.spi.testing; 17 | 18 | import com.google.api.server.spi.config.Api; 19 | import com.google.api.server.spi.config.ApiMethod; 20 | 21 | /** 22 | * Testing for API methods that have absolute paths. 23 | */ 24 | @Api(name = "absolutepath", version = "v1") 25 | public class AbsoluteCommonPathEndpoint { 26 | @ApiMethod(name = "create", path = "create") 27 | public Foo createFoo() { 28 | return null; 29 | } 30 | 31 | @ApiMethod(name = "absolutepath", path = "/absolutepath/v1/absolutepathmethod") 32 | public void absolutePath() { } 33 | } 34 | -------------------------------------------------------------------------------- /test-utils/src/main/java/com/google/api/server/spi/testing/AbsolutePathEndpoint.java: -------------------------------------------------------------------------------- 1 | package com.google.api.server.spi.testing; 2 | 3 | import com.google.api.server.spi.config.Api; 4 | import com.google.api.server.spi.config.ApiMethod; 5 | 6 | /** 7 | * Testing for API methods that have absolute paths. 8 | */ 9 | @Api(name = "absolutepath", version = "v1") 10 | public class AbsolutePathEndpoint { 11 | @ApiMethod(name = "create", path = "create") 12 | public Foo createFoo() { 13 | return null; 14 | } 15 | 16 | @ApiMethod(name = "absolutepath", path = "/absolutepathmethod/v1") 17 | public void absolutePath() { } 18 | 19 | @ApiMethod(name = "absolutepath2", path = "/absolutepathmethod2/v1") 20 | public void absolutePath2() { } 21 | } 22 | -------------------------------------------------------------------------------- /test-utils/src/main/java/com/google/api/server/spi/testing/AppEngineAuthenticator.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 Google Inc. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.google.api.server.spi.testing; 17 | 18 | import com.google.api.server.spi.auth.common.User; 19 | import com.google.api.server.spi.config.Authenticator; 20 | import com.google.api.server.spi.request.Attribute; 21 | 22 | import javax.servlet.http.HttpServletRequest; 23 | 24 | /** 25 | * Simple dumb custom authenticator for tests that returns a predefined User and also set App Engine 26 | * User. 27 | */ 28 | public class AppEngineAuthenticator implements Authenticator { 29 | public static final User USER = new User("test@test.com"); 30 | public static final com.google.appengine.api.users.User APP_ENGINE_USER = 31 | new com.google.appengine.api.users.User("test@test.com", ""); 32 | 33 | @Override 34 | public User authenticate(HttpServletRequest request) { 35 | request.setAttribute(Attribute.AUTHENTICATED_APPENGINE_USER, APP_ENGINE_USER); 36 | return USER; 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /test-utils/src/main/java/com/google/api/server/spi/testing/Bar.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 Google Inc. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.google.api.server.spi.testing; 17 | 18 | 19 | /** 20 | * Test resource type with inheritance. 21 | */ 22 | public class Bar extends Foo { 23 | } 24 | -------------------------------------------------------------------------------- /test-utils/src/main/java/com/google/api/server/spi/testing/Baz.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 Google Inc. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.google.api.server.spi.testing; 17 | 18 | 19 | import java.util.List; 20 | 21 | /** 22 | * Test resource type with nested bean properties. 23 | */ 24 | public class Baz { 25 | 26 | public Foo getFoo() { 27 | return null; 28 | } 29 | 30 | public List getFoos() { 31 | return null; 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /test-utils/src/main/java/com/google/api/server/spi/testing/BridgeInheritanceEndpoint.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 Google Inc. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.google.api.server.spi.testing; 17 | 18 | import com.google.api.server.spi.config.Api; 19 | import com.google.api.server.spi.config.ApiMethod; 20 | import com.google.api.server.spi.config.ApiMethod.HttpMethod; 21 | 22 | /** 23 | * Test base service in order to make sure inherited methods filter through. 24 | */ 25 | class Base { 26 | public Object fn1() { 27 | return null; 28 | } 29 | 30 | @ApiMethod( 31 | name = "api6.foos.fn2", 32 | path = "fn2", 33 | httpMethod = HttpMethod.GET 34 | ) 35 | public Object fn2() { 36 | return null; 37 | } 38 | } 39 | 40 | /** 41 | * Test service which overrides a method with covariant return type, 42 | * resulting in bridge methods 43 | */ 44 | @Api 45 | public class BridgeInheritanceEndpoint extends Base { 46 | @Override 47 | @ApiMethod( 48 | name = "api6.foos.fn1", 49 | path = "fn1", 50 | httpMethod = HttpMethod.GET 51 | ) 52 | public Object fn1() { 53 | return null; 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /test-utils/src/main/java/com/google/api/server/spi/testing/ChildBean.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 Google Inc. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.google.api.server.spi.testing; 17 | 18 | 19 | import java.util.Arrays; 20 | import java.util.Collection; 21 | 22 | /** 23 | * A child bean, contains a reference to its parent. 24 | * 25 | * @author sven@google.com (Sven Mawson) 26 | */ 27 | public class ChildBean { 28 | 29 | public int getId() { 30 | return 11; 31 | } 32 | 33 | public ParentBean getParent() { 34 | return new ParentBean(); 35 | } 36 | 37 | public Collection getNames() { 38 | return Arrays.asList(new String[] {"sue", "phil"}); 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /test-utils/src/main/java/com/google/api/server/spi/testing/CustomScopesEndpoint.java: -------------------------------------------------------------------------------- 1 | package com.google.api.server.spi.testing; 2 | 3 | import com.google.api.server.spi.config.Api; 4 | import com.google.api.server.spi.config.ApiMethod; 5 | 6 | @Api( 7 | name = "customScopes", 8 | version = "v1", 9 | scopes = { 10 | "openid", //short scope with description 11 | "https://www.googleapis.com/auth/drive", //long scope with description 12 | "doesnotexist" //should not find a description 13 | }) 14 | public class CustomScopesEndpoint { 15 | @ApiMethod(scopes = "https://mail.google.com/") 16 | public Foo foo() { 17 | return null; 18 | } 19 | @ApiMethod(scopes = "email") 20 | public Bar bar() { 21 | return null; 22 | } 23 | @ApiMethod(scopes = {"email profile", "https://mail.google.com/"}) 24 | public void complexScopeExpression() {} 25 | } 26 | -------------------------------------------------------------------------------- /test-utils/src/main/java/com/google/api/server/spi/testing/DeepGenericHierarchyFailEndpoint.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 Google Inc. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.google.api.server.spi.testing; 17 | 18 | import com.google.api.server.spi.config.Api; 19 | import com.google.api.server.spi.config.ApiMethod; 20 | 21 | import java.util.Collection; 22 | import java.util.List; 23 | 24 | import javax.inject.Named; 25 | 26 | class DeepGenericHierarchyFailEndpoint3 { 27 | @ApiMethod(name = "Endpoint3.foo", path = "bar") 28 | public void foo(@Named("1") T t, @Named("2") U u, @Named("3") V v) { 29 | 30 | } 31 | } 32 | 33 | class DeepGenericHierarchyFailEndpoint2 34 | extends DeepGenericHierarchyFailEndpoint3> { 35 | } 36 | 37 | class DeepGenericHierarchyFailEndpoint1 extends DeepGenericHierarchyFailEndpoint2 { 38 | } 39 | 40 | /** 41 | * Deep hierarchy 42 | */ 43 | @Api 44 | public class DeepGenericHierarchyFailEndpoint extends DeepGenericHierarchyFailEndpoint1 { 45 | @ApiMethod 46 | public void foo(@Named("id_1") String s, @Named("id_2") Integer i, 47 | @Named("id_3") Collection c) { 48 | 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /test-utils/src/main/java/com/google/api/server/spi/testing/DeepGenericHierarchySuccessEndpoint.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 Google Inc. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.google.api.server.spi.testing; 17 | 18 | import com.google.api.server.spi.config.Api; 19 | import com.google.api.server.spi.config.ApiMethod; 20 | 21 | import javax.inject.Named; 22 | 23 | class DeepGenericHierarchySuccessEndpoint3 { 24 | public void foo(V v, U u, T t) { 25 | 26 | } 27 | } 28 | 29 | class DeepGenericHierarchySuccessEndpoint2 30 | extends DeepGenericHierarchySuccessEndpoint3 { 31 | } 32 | 33 | class DeepGenericHierarchySuccessEndpoint1 34 | extends DeepGenericHierarchySuccessEndpoint2 { 35 | } 36 | 37 | /** 38 | * Deep hierarchy 39 | */ 40 | @Api 41 | public class DeepGenericHierarchySuccessEndpoint 42 | extends DeepGenericHierarchySuccessEndpoint1 { 43 | @Override 44 | @ApiMethod 45 | public void foo(@Named("id_1") String s, @Named("id_2") Integer i, @Named("id_3") Boolean c) { 46 | 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /test-utils/src/main/java/com/google/api/server/spi/testing/DumbSerializer1.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 Google Inc. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.google.api.server.spi.testing; 17 | 18 | import com.google.api.server.spi.config.Transformer; 19 | 20 | /** 21 | * Dumb serializer for use in tests. 22 | */ 23 | public class DumbSerializer1 implements Transformer { 24 | @Override 25 | public String transformTo(SimpleBean in) { 26 | return "foo"; 27 | } 28 | 29 | @Override 30 | public SimpleBean transformFrom(String in) { 31 | return new SimpleBean(); 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /test-utils/src/main/java/com/google/api/server/spi/testing/DumbSerializer2.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 Google Inc. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.google.api.server.spi.testing; 17 | 18 | import com.google.api.server.spi.config.Transformer; 19 | 20 | /** 21 | * Dumb serializer for use in tests. 22 | */ 23 | public class DumbSerializer2 implements Transformer { 24 | @Override 25 | public Integer transformTo(SimpleBean in) { 26 | return 27; 27 | } 28 | 29 | @Override 30 | public SimpleBean transformFrom(Integer in) { 31 | return new SimpleBean(); 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /test-utils/src/main/java/com/google/api/server/spi/testing/DuplicateMethodEndpoint.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 Google Inc. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.google.api.server.spi.testing; 17 | 18 | import com.google.api.server.spi.config.Api; 19 | import com.google.api.server.spi.config.ApiMethod; 20 | import com.google.api.server.spi.config.ApiMethod.HttpMethod; 21 | 22 | import javax.inject.Named; 23 | 24 | /** 25 | * Test occurrence of overloaded methods, which are not supported. 26 | * DuplicateMethodEndpoint, itself, tests the case of many overloads within a class. 27 | */ 28 | @Api 29 | public class DuplicateMethodEndpoint { 30 | @ApiMethod(name = "api.foos.fn1", path = "fn1", httpMethod = HttpMethod.GET) 31 | public Foo foo(@Named("id") String id) { 32 | return null; 33 | } 34 | 35 | @ApiMethod(name = "api.foos.fn2", path = "fn2", httpMethod = HttpMethod.GET) 36 | public Foo foo(@Named("id") Integer id) { 37 | return null; 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /test-utils/src/main/java/com/google/api/server/spi/testing/Endpoint0.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 Google Inc. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.google.api.server.spi.testing; 17 | 18 | import com.google.api.server.spi.config.Api; 19 | 20 | import javax.inject.Named; 21 | 22 | /** 23 | * Test endpoint with default configuration. 24 | */ 25 | @Api 26 | public class Endpoint0 { 27 | 28 | public Foo getFoo(@Named("id") String id) { 29 | return null; 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /test-utils/src/main/java/com/google/api/server/spi/testing/Endpoint2.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 Google Inc. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.google.api.server.spi.testing; 17 | 18 | import com.google.api.server.spi.config.Api; 19 | import com.google.api.server.spi.config.ApiMethod; 20 | import com.google.api.server.spi.config.ApiMethod.HttpMethod; 21 | 22 | /** 23 | * Test endpoint with no public methods. 24 | */ 25 | @Api 26 | public class Endpoint2 { 27 | 28 | @ApiMethod( 29 | name = "api2.foos.invisible0", 30 | path = "invisible0", 31 | httpMethod = HttpMethod.POST 32 | ) 33 | protected String invisible0() { 34 | return null; 35 | } 36 | 37 | @SuppressWarnings("unused") 38 | @ApiMethod( 39 | name = "api2.foos.invisible1", 40 | path = "invisible1", 41 | httpMethod = HttpMethod.POST 42 | ) 43 | private String invisible1() { 44 | return null; 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /test-utils/src/main/java/com/google/api/server/spi/testing/Endpoint3.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 Google Inc. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.google.api.server.spi.testing; 17 | 18 | 19 | import java.util.List; 20 | 21 | import javax.inject.Named; 22 | 23 | /** 24 | * Test endpoint with inheritance and 2 resource collections, second of which uses 25 | * default configuration. 26 | */ 27 | public class Endpoint3 extends Endpoint1 { 28 | 29 | public List listBars() { 30 | return null; 31 | } 32 | 33 | public Bar getBar(@Named("id") String id) { 34 | return null; 35 | } 36 | 37 | public Bar insertBar(Bar bar) { 38 | return null; 39 | } 40 | 41 | public Bar updateBar(@Named("id") String id, Bar bar) { 42 | return null; 43 | } 44 | 45 | public void removeBar(@Named("id") String id) { 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /test-utils/src/main/java/com/google/api/server/spi/testing/Endpoint4.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 Google Inc. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.google.api.server.spi.testing; 17 | 18 | import com.google.api.server.spi.config.Api; 19 | 20 | /** 21 | * Test endpoint whose API name is provided in annotation. 22 | */ 23 | @Api(name = "api4") 24 | public class Endpoint4 { 25 | 26 | public Foo getFoo() { 27 | return null; 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /test-utils/src/main/java/com/google/api/server/spi/testing/Endpoint5.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 Google Inc. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.google.api.server.spi.testing; 17 | 18 | import com.google.api.server.spi.config.Api; 19 | 20 | import javax.inject.Named; 21 | 22 | /** 23 | * Test endpoint with default configuration. 24 | */ 25 | @Api 26 | public class Endpoint5 { 27 | 28 | public Baz getBaz(@Named("id") String id) { 29 | return null; 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /test-utils/src/main/java/com/google/api/server/spi/testing/EnumEndpoint.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 Google Inc. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.google.api.server.spi.testing; 17 | 18 | import com.google.api.server.spi.config.Api; 19 | import com.google.api.server.spi.config.ApiMethod; 20 | import com.google.api.server.spi.config.Named; 21 | 22 | @Api(name = "enum", version = "v1") 23 | public class EnumEndpoint { 24 | @ApiMethod(name = "create", path = "{value}") 25 | public EnumValue create(@Named("value") TestEnum value) { 26 | return null; 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /test-utils/src/main/java/com/google/api/server/spi/testing/EnumEndpointV2.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2017 Google Inc. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.google.api.server.spi.testing; 17 | 18 | import com.google.api.server.spi.config.Api; 19 | import com.google.api.server.spi.config.ApiMethod; 20 | import com.google.api.server.spi.config.Named; 21 | 22 | @Api(name = "enum", version = "v2") 23 | public class EnumEndpointV2 { 24 | @ApiMethod(name = "create", path = "{value}") 25 | public EnumValue create(@Named("value") TestEnum value) { 26 | return null; 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /test-utils/src/main/java/com/google/api/server/spi/testing/EnumValue.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2017 Google Inc. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.google.api.server.spi.testing; 17 | 18 | /** 19 | * A resource which wraps a test enum. 20 | */ 21 | public class EnumValue { 22 | public TestEnum value; 23 | } 24 | -------------------------------------------------------------------------------- /test-utils/src/main/java/com/google/api/server/spi/testing/FailAuthenticator.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 Google Inc. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.google.api.server.spi.testing; 17 | 18 | import com.google.api.server.spi.auth.common.User; 19 | import com.google.api.server.spi.config.Authenticator; 20 | 21 | import javax.servlet.http.HttpServletRequest; 22 | 23 | /** 24 | * Simple dumb custom authenticator for tests that always fails authentication. 25 | */ 26 | public class FailAuthenticator implements Authenticator { 27 | @Override 28 | public User authenticate(HttpServletRequest request) { 29 | return null; 30 | } 31 | } 32 | 33 | -------------------------------------------------------------------------------- /test-utils/src/main/java/com/google/api/server/spi/testing/FailPeerAuthenticator.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 Google Inc. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.google.api.server.spi.testing; 17 | 18 | import com.google.api.server.spi.config.PeerAuthenticator; 19 | 20 | import javax.servlet.http.HttpServletRequest; 21 | 22 | /** 23 | * Simple dumb peer authenticator for tests that always fail. 24 | */ 25 | public class FailPeerAuthenticator implements PeerAuthenticator { 26 | @Override 27 | public boolean authenticate(HttpServletRequest request) { 28 | return false; 29 | } 30 | 31 | public static Class[] testArray = makeTestArray(); 32 | 33 | // Unchecked cast needed to get a generic array type. 34 | @SuppressWarnings("unchecked") 35 | private static Class[] makeTestArray() { 36 | Class[] peerAuthenticators = {FailPeerAuthenticator.class}; 37 | return (Class[]) peerAuthenticators; 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /test-utils/src/main/java/com/google/api/server/spi/testing/FloatToStringSerializer.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 Google Inc. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.google.api.server.spi.testing; 17 | 18 | import com.google.api.server.spi.config.ResourceSchema; 19 | import com.google.api.server.spi.config.ResourceTransformer; 20 | 21 | import java.util.Map; 22 | 23 | public class FloatToStringSerializer extends DefaultValueSerializer> 24 | implements ResourceTransformer { 25 | 26 | @Override 27 | public ResourceSchema getResourceSchema() { 28 | return ResourceSchema.builderForType(Float.class).build(); 29 | } 30 | } -------------------------------------------------------------------------------- /test-utils/src/main/java/com/google/api/server/spi/testing/Foo.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 Google Inc. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.google.api.server.spi.testing; 17 | 18 | /** 19 | * Test resource type. 20 | */ 21 | public class Foo { 22 | 23 | public String getName() { 24 | return null; 25 | } 26 | 27 | public int getValue() { 28 | return 0; 29 | } 30 | 31 | private String getHidden() { 32 | return null; 33 | } 34 | 35 | private void setHidden(String hidden) { 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /test-utils/src/main/java/com/google/api/server/spi/testing/FooDescription.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 Google Inc. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.google.api.server.spi.testing; 17 | 18 | import com.google.api.server.spi.config.ApiResourceProperty; 19 | 20 | /** 21 | * Test resource type with descriptions. 22 | */ 23 | public class FooDescription { 24 | 25 | @ApiResourceProperty(description = "description of name") 26 | private String name; 27 | private int value; 28 | private String hidden; 29 | @ApiResourceProperty(description = "description of choice") 30 | private TestEnumDescription choice; 31 | 32 | public String getName() { 33 | return name; 34 | } 35 | 36 | @ApiResourceProperty(description = "description of value") 37 | public int getValue() { 38 | return value; 39 | } 40 | 41 | private String getHidden() { 42 | return hidden; 43 | } 44 | 45 | private void setHidden(String hidden) { 46 | this.hidden = hidden; 47 | } 48 | 49 | public TestEnumDescription getChoice() { 50 | return choice; 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /test-utils/src/main/java/com/google/api/server/spi/testing/IntegerToStringSerializer.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 Google Inc. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.google.api.server.spi.testing; 17 | 18 | public class IntegerToStringSerializer extends DefaultValueSerializer { 19 | } -------------------------------------------------------------------------------- /test-utils/src/main/java/com/google/api/server/spi/testing/InterfaceConfiguration.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 Google Inc. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.google.api.server.spi.testing; 17 | 18 | import com.google.api.server.spi.config.Api; 19 | 20 | /** 21 | * An interface containing API configuration. 22 | */ 23 | @Api(name = "interfaceBasedApi", version = "v1") 24 | public interface InterfaceConfiguration { 25 | // No methods. 26 | } 27 | -------------------------------------------------------------------------------- /test-utils/src/main/java/com/google/api/server/spi/testing/InterfaceReferenceEndpoint.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 Google Inc. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.google.api.server.spi.testing; 17 | 18 | import com.google.api.server.spi.config.Api; 19 | import com.google.api.server.spi.config.ApiReference; 20 | 21 | /** 22 | * Test endpoint that references {@link InterfaceConfiguration} and overrides an annotation 23 | * value. Used to test that {@link @ApiReference} works with interfaces. 24 | */ 25 | @ApiReference(InterfaceConfiguration.class) 26 | @Api(version = "v2") 27 | public class InterfaceReferenceEndpoint { 28 | 29 | } 30 | -------------------------------------------------------------------------------- /test-utils/src/main/java/com/google/api/server/spi/testing/LongToStringSerializer.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 Google Inc. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.google.api.server.spi.testing; 17 | 18 | import com.google.api.server.spi.config.ResourceSchema; 19 | import com.google.api.server.spi.config.ResourceTransformer; 20 | 21 | import java.util.Map; 22 | 23 | public class LongToStringSerializer extends DefaultValueSerializer> 24 | implements ResourceTransformer { 25 | 26 | @Override 27 | public ResourceSchema getResourceSchema() { 28 | return ResourceSchema.builderForType(Long.class).setName("Number").build(); 29 | } 30 | } -------------------------------------------------------------------------------- /test-utils/src/main/java/com/google/api/server/spi/testing/MapEndpointInvalid.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 Google Inc. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.google.api.server.spi.testing; 17 | 18 | import com.google.api.server.spi.config.Api; 19 | import java.util.Map; 20 | 21 | /** 22 | * Test service used for testing Map schemas with invalid key. 23 | */ 24 | @Api 25 | public class MapEndpointInvalid { 26 | 27 | public Map getInvalidKeyMap() { 28 | return null; 29 | } 30 | 31 | } 32 | -------------------------------------------------------------------------------- /test-utils/src/main/java/com/google/api/server/spi/testing/MultiResourceEndpoint.java: -------------------------------------------------------------------------------- 1 | package com.google.api.server.spi.testing; 2 | 3 | import com.google.api.server.spi.config.Api; 4 | import com.google.api.server.spi.config.ApiClass; 5 | import com.google.api.server.spi.config.ApiMethod; 6 | 7 | public class MultiResourceEndpoint { 8 | 9 | @Api( 10 | name = "multiresource", 11 | version = "v1") 12 | public static class NoResourceEndpoint { 13 | 14 | @ApiMethod(path = "noresource") 15 | public Foo get() { 16 | return null; 17 | } 18 | 19 | } 20 | 21 | @Api( 22 | name = "multiresource", 23 | version = "v1") 24 | @ApiClass(resource = "resource1") 25 | public static class Resource1Endpoint { 26 | 27 | @ApiMethod(path = "resource1") 28 | public Foo get() { 29 | return null; 30 | } 31 | 32 | } 33 | 34 | @Api( 35 | name = "multiresource", 36 | version = "v1") 37 | @ApiClass(resource = "resource2") 38 | public static class Resource2Endpoint { 39 | 40 | @ApiMethod(path = "resource2") 41 | public Foo get() { 42 | return null; 43 | } 44 | 45 | } 46 | 47 | } 48 | -------------------------------------------------------------------------------- /test-utils/src/main/java/com/google/api/server/spi/testing/MultiVersionEndpoint.java: -------------------------------------------------------------------------------- 1 | package com.google.api.server.spi.testing; 2 | 3 | import com.google.api.server.spi.config.Api; 4 | import com.google.api.server.spi.config.ApiClass; 5 | import com.google.api.server.spi.config.ApiMethod; 6 | 7 | public class MultiVersionEndpoint { 8 | 9 | @Api( 10 | name = "myapi", 11 | version = "v1") 12 | public static class Version1Endpoint { 13 | 14 | public Foo get() { 15 | return null; 16 | } 17 | 18 | } 19 | 20 | @Api( 21 | name = "myapi", 22 | version = "v2") 23 | public static class Version2Endpoint { 24 | 25 | public Foo get() { 26 | return null; 27 | } 28 | 29 | } 30 | 31 | } 32 | -------------------------------------------------------------------------------- /test-utils/src/main/java/com/google/api/server/spi/testing/MultipleParameterEndpoint.java: -------------------------------------------------------------------------------- 1 | package com.google.api.server.spi.testing; 2 | 3 | import com.google.api.server.spi.config.Api; 4 | import com.google.api.server.spi.config.ApiMethod; 5 | import com.google.api.server.spi.config.Named; 6 | import com.google.api.server.spi.config.Nullable; 7 | 8 | /** 9 | * This endpoint is used for testing that named parameters are output in order. 10 | */ 11 | @Api(name = "multipleparam", version = "v1") 12 | public class MultipleParameterEndpoint { 13 | @ApiMethod(name = "param", path = "param/{parent}/{child}") 14 | public void param( 15 | @Named("parent") String parent, 16 | @Named("query") @Nullable String query, 17 | @Named("child") String child, 18 | @Named("queryb") String queryB, 19 | @Named("querya") String queryA) { } 20 | } 21 | -------------------------------------------------------------------------------- /test-utils/src/main/java/com/google/api/server/spi/testing/NamespaceEndpoint.java: -------------------------------------------------------------------------------- 1 | package com.google.api.server.spi.testing; 2 | 3 | import com.google.api.server.spi.config.Api; 4 | import com.google.api.server.spi.config.ApiMethod; 5 | import com.google.api.server.spi.config.ApiNamespace; 6 | 7 | /** 8 | * API endpoint for testing namespace configuration. 9 | */ 10 | @Api( 11 | name = "namespace", 12 | version = "v1", 13 | namespace = @ApiNamespace(ownerDomain = "domain", ownerName = "name", packagePath = "path")) 14 | public class NamespaceEndpoint { 15 | @ApiMethod 16 | public void empty() { } 17 | } 18 | -------------------------------------------------------------------------------- /test-utils/src/main/java/com/google/api/server/spi/testing/ParameterizedParameterEndpoint.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 Google Inc. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.google.api.server.spi.testing; 17 | 18 | import com.google.api.server.spi.config.Api; 19 | import com.google.api.server.spi.config.ApiMethod; 20 | 21 | import java.io.Serializable; 22 | import java.util.Date; 23 | import java.util.Map; 24 | 25 | class ParameterizedParameterEndpoint2 { 26 | public void foo(Map map) { 27 | 28 | } 29 | } 30 | 31 | class ParameterizedParameterEndpoint1> 32 | extends ParameterizedParameterEndpoint2 { 33 | } 34 | 35 | @Api 36 | public class ParameterizedParameterEndpoint extends ParameterizedParameterEndpoint1 { 37 | @Override 38 | @ApiMethod 39 | public void foo(Map map) { 40 | 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /test-utils/src/main/java/com/google/api/server/spi/testing/ParentBean.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 Google Inc. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.google.api.server.spi.testing; 17 | 18 | 19 | import java.util.ArrayList; 20 | import java.util.List; 21 | 22 | /** 23 | * A parent bean, contains a reference to its children. 24 | * 25 | * @author sven@google.com (Sven Mawson) 26 | */ 27 | public class ParentBean { 28 | 29 | private final List children = new ArrayList(); 30 | 31 | public String getName() { 32 | return "parent"; 33 | } 34 | 35 | public List getChildren() { 36 | return children; 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /test-utils/src/main/java/com/google/api/server/spi/testing/ParentChildEndpoint.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 Google Inc. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.google.api.server.spi.testing; 17 | 18 | import com.google.api.server.spi.config.Api; 19 | 20 | import java.util.ArrayList; 21 | import java.util.List; 22 | 23 | import javax.inject.Named; 24 | 25 | /** 26 | * Endpoint to test parent child relationships. 27 | * 28 | * @author sven@google.com (Sven Mawson) 29 | */ 30 | @Api 31 | public class ParentChildEndpoint { 32 | 33 | public ParentBean getParent() { 34 | return new ParentBean(); 35 | } 36 | 37 | public List listChildren(@Named("parentId") String parentId) { 38 | return new ArrayList(); 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /test-utils/src/main/java/com/google/api/server/spi/testing/PassAuthenticator.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 Google Inc. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.google.api.server.spi.testing; 17 | 18 | import com.google.api.server.spi.auth.common.User; 19 | import com.google.api.server.spi.config.Authenticator; 20 | import com.google.api.server.spi.config.Singleton; 21 | 22 | import javax.servlet.http.HttpServletRequest; 23 | 24 | /** 25 | * Simple dumb custom authenticator for tests that just returns a predefined User. 26 | */ 27 | @Singleton 28 | public class PassAuthenticator implements Authenticator { 29 | public static final User USER = new User("test@test.com"); 30 | 31 | @Override 32 | public User authenticate(HttpServletRequest request) { 33 | return USER; 34 | } 35 | 36 | public static Class[] testArray = makeTestArray(); 37 | 38 | // Unchecked cast needed to get a generic array type. 39 | @SuppressWarnings("unchecked") 40 | private static Class[] makeTestArray() { 41 | Class[] authenticators = {PassAuthenticator.class}; 42 | return (Class[]) authenticators; 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /test-utils/src/main/java/com/google/api/server/spi/testing/PassPeerAuthenticator.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 Google Inc. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.google.api.server.spi.testing; 17 | 18 | import com.google.api.server.spi.config.PeerAuthenticator; 19 | import com.google.api.server.spi.config.Singleton; 20 | 21 | import javax.servlet.http.HttpServletRequest; 22 | 23 | /** 24 | * Simple dumb peer authenticator for tests that always pass. 25 | */ 26 | @Singleton 27 | public class PassPeerAuthenticator implements PeerAuthenticator { 28 | @Override 29 | public boolean authenticate(HttpServletRequest request) { 30 | return true; 31 | } 32 | 33 | public static Class[] testArray = makeTestArray(); 34 | 35 | // Unchecked cast needed to get a generic array type. 36 | @SuppressWarnings("unchecked") 37 | private static Class[] makeTestArray() { 38 | Class[] peerAuthenticators = {PassPeerAuthenticator.class}; 39 | return (Class[]) peerAuthenticators; 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /test-utils/src/main/java/com/google/api/server/spi/testing/PrimitiveBean.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 Google Inc. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.google.api.server.spi.testing; 17 | 18 | /** 19 | * A bean containing all of the primitive types. 20 | * 21 | * @author sven@google.com (Sven Mawson) 22 | */ 23 | public class PrimitiveBean { 24 | 25 | public boolean getBool() { 26 | return true; 27 | } 28 | 29 | public byte getByte() { 30 | return 4; 31 | } 32 | 33 | public char getChar() { 34 | return 'c'; 35 | } 36 | 37 | public double getDouble() { 38 | return 45.5d; 39 | } 40 | 41 | public float getFloat() { 42 | return 22.2f; 43 | } 44 | 45 | public int getInt() { 46 | return 42; 47 | } 48 | 49 | public long getLong() { 50 | return 123456789012L; 51 | } 52 | 53 | public short getShort() { 54 | return 22; 55 | } 56 | 57 | public String getStr() { 58 | return "hello"; 59 | } 60 | } 61 | -------------------------------------------------------------------------------- /test-utils/src/main/java/com/google/api/server/spi/testing/PrimitiveEndpoint.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 Google Inc. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.google.api.server.spi.testing; 17 | 18 | import com.google.api.server.spi.config.Api; 19 | 20 | import java.util.ArrayList; 21 | import java.util.List; 22 | 23 | /** 24 | * Endpoint testing primitive schemas. 25 | * 26 | * @author sven@google.com (Sven Mawson) 27 | */ 28 | @Api 29 | public class PrimitiveEndpoint { 30 | 31 | public PrimitiveBean getPrimitive() { 32 | return new PrimitiveBean(); 33 | } 34 | 35 | public List getPrimitives() { 36 | return new ArrayList(); 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /test-utils/src/main/java/com/google/api/server/spi/testing/RecursiveBean.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 Google Inc. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.google.api.server.spi.testing; 17 | 18 | /** 19 | * A simple bean that refers to itself. 20 | * 21 | * @author sven@google.com (Sven Mawson) 22 | */ 23 | public class RecursiveBean { 24 | 25 | public String getName() { 26 | return "recursion"; 27 | } 28 | 29 | public RecursiveBean getChild() { 30 | return new RecursiveBean(); 31 | } 32 | 33 | public PrimitiveBean getPrimitive() { 34 | return new PrimitiveBean(); 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /test-utils/src/main/java/com/google/api/server/spi/testing/RecursiveEndpoint.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 Google Inc. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.google.api.server.spi.testing; 17 | 18 | import com.google.api.server.spi.config.Api; 19 | 20 | /** 21 | * Endpoint testing recursive schemas. 22 | * 23 | * @author sven@google.com (Sven Mawson) 24 | */ 25 | @Api 26 | public class RecursiveEndpoint { 27 | 28 | public RecursiveBean getRecursive() { 29 | return new RecursiveBean(); 30 | } 31 | 32 | public RecursiveBean updateRecursive(RecursiveBean recursive) { 33 | return recursive; 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /test-utils/src/main/java/com/google/api/server/spi/testing/SimpleBean.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 Google Inc. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.google.api.server.spi.testing; 17 | 18 | /** 19 | * Simple bean for use in tests. 20 | */ 21 | public class SimpleBean { 22 | private int i = 0; 23 | 24 | public int getI() { 25 | return i; 26 | } 27 | 28 | public void setI(int i) { 29 | this.i = i; 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /test-utils/src/main/java/com/google/api/server/spi/testing/SimpleContravarianceEndpoint.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 Google Inc. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.google.api.server.spi.testing; 17 | 18 | import com.google.api.server.spi.config.Api; 19 | import com.google.api.server.spi.config.ApiMethod; 20 | import com.google.api.server.spi.config.ApiMethod.HttpMethod; 21 | 22 | class BaseSimpleContravarianceEndpoint { 23 | @ApiMethod(name = "api.foos.base", path = "base", httpMethod = HttpMethod.GET) 24 | public Foo foo(Number id) { 25 | return null; 26 | } 27 | } 28 | 29 | /** 30 | * Tests contravariance of parameter type. Not supported in Java, should fail. 31 | */ 32 | @Api 33 | public class SimpleContravarianceEndpoint extends BaseSimpleContravarianceEndpoint { 34 | @ApiMethod(name = "api.foos.fn", path = "fn", httpMethod = HttpMethod.GET) 35 | public Foo foo(Object id) { 36 | return null; 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /test-utils/src/main/java/com/google/api/server/spi/testing/SimpleCovarianceEndpoint.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 Google Inc. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.google.api.server.spi.testing; 17 | 18 | import com.google.api.server.spi.config.Api; 19 | import com.google.api.server.spi.config.ApiMethod; 20 | import com.google.api.server.spi.config.ApiMethod.HttpMethod; 21 | 22 | import javax.inject.Named; 23 | 24 | class BaseSimpleCovarianceEndpoint { 25 | @ApiMethod(name = "api.foos.base", path = "base", httpMethod = HttpMethod.GET) 26 | public Foo foo(Object id) { 27 | return null; 28 | } 29 | } 30 | 31 | /** 32 | * Tests covariance of parameter type. Not supported in Java, should fail. 33 | */ 34 | @Api 35 | public class SimpleCovarianceEndpoint extends BaseSimpleCovarianceEndpoint { 36 | @ApiMethod(name = "api.foos.fn", path = "fn", httpMethod = HttpMethod.GET) 37 | public Foo foo(@Named("id") String id) { 38 | return null; 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /test-utils/src/main/java/com/google/api/server/spi/testing/SimpleLevelOverridingInheritedApi.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 Google Inc. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.google.api.server.spi.testing; 17 | 18 | /** 19 | * Test API inheriting from {@link SimpleLevelOverridingApi} but not changing anything. 20 | */ 21 | public class SimpleLevelOverridingInheritedApi extends SimpleLevelOverridingApi { 22 | 23 | } 24 | -------------------------------------------------------------------------------- /test-utils/src/main/java/com/google/api/server/spi/testing/SimpleOverloadEndpoint.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 Google Inc. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.google.api.server.spi.testing; 17 | 18 | import com.google.api.server.spi.config.Api; 19 | import com.google.api.server.spi.config.ApiMethod; 20 | import com.google.api.server.spi.config.ApiMethod.HttpMethod; 21 | 22 | import javax.inject.Named; 23 | 24 | class BaseSimpleOverloadEndpoint { 25 | @ApiMethod(name = "api.foos.base", path = "base", httpMethod = HttpMethod.GET) 26 | public Foo foo(@Named("id") String id) { 27 | return null; 28 | } 29 | } 30 | 31 | /** 32 | * Canonical inheritance overload example, should fail. 33 | */ 34 | @Api 35 | public class SimpleOverloadEndpoint extends BaseSimpleOverloadEndpoint { 36 | @ApiMethod(name = "api.foos.fn", path = "fn", httpMethod = HttpMethod.GET) 37 | public Foo foo(@Named("id") Integer id) { 38 | return null; 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /test-utils/src/main/java/com/google/api/server/spi/testing/SimpleOverrideEndpoint.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 Google Inc. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.google.api.server.spi.testing; 17 | 18 | import com.google.api.server.spi.config.Api; 19 | import com.google.api.server.spi.config.ApiMethod; 20 | import com.google.api.server.spi.config.ApiMethod.HttpMethod; 21 | 22 | import javax.inject.Named; 23 | 24 | class BaseSimpleOverrideEndpoint { 25 | @ApiMethod(name = "api.foos.base", path = "base", httpMethod = HttpMethod.GET) 26 | public Object foo(@Named("id") String id) { 27 | return null; 28 | } 29 | } 30 | 31 | /** 32 | * Tests override -- should pass. 33 | */ 34 | @Api 35 | public class SimpleOverrideEndpoint extends BaseSimpleOverrideEndpoint { 36 | @ApiMethod(name = "api.foos.fn", path = "fn", httpMethod = HttpMethod.GET) 37 | @Override 38 | public Object foo(@Named("id") String id) { 39 | return null; 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /test-utils/src/main/java/com/google/api/server/spi/testing/SimpleReferenceEndpoint.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 Google Inc. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.google.api.server.spi.testing; 17 | 18 | import com.google.api.server.spi.config.ApiReference; 19 | 20 | /** 21 | * Test endpoint that references {@link Endpoint1} without overriding any configuration values. 22 | * Extends {@link Endpoint4} to test that API and class configuration is 23 | * not loaded through inheritance. Method configuration still comes through inheritance. 24 | * 25 | * @author Eric Orth 26 | */ 27 | @ApiReference(Endpoint1.class) 28 | public class SimpleReferenceEndpoint extends Endpoint4 { 29 | // No methods. 30 | } 31 | -------------------------------------------------------------------------------- /test-utils/src/main/java/com/google/api/server/spi/testing/StringValue.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2017 Google Inc. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.google.api.server.spi.testing; 17 | 18 | public class StringValue { 19 | public String value; 20 | } 21 | -------------------------------------------------------------------------------- /test-utils/src/main/java/com/google/api/server/spi/testing/StringValueTransformer.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2017 Google Inc. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.google.api.server.spi.testing; 17 | 18 | import com.google.api.server.spi.config.Transformer; 19 | 20 | public class StringValueTransformer implements Transformer { 21 | @Override 22 | public String transformTo(StringValue in) { 23 | return null; 24 | } 25 | 26 | @Override 27 | public StringValue transformFrom(String in) { 28 | return null; 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /test-utils/src/main/java/com/google/api/server/spi/testing/SubclassedEndpoint.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 Google Inc. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.google.api.server.spi.testing; 17 | 18 | import com.google.api.server.spi.config.Api; 19 | 20 | /** 21 | * Test endpoint that subclasses {@link Endpoint1} but doesn't override anything. 22 | * 23 | * @author Eric Orth 24 | */ 25 | @Api 26 | public class SubclassedEndpoint extends Endpoint1 { 27 | } 28 | -------------------------------------------------------------------------------- /test-utils/src/main/java/com/google/api/server/spi/testing/TestEndpointSuperclass.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 Google Inc. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.google.api.server.spi.testing; 17 | 18 | /** 19 | * Superclass of the endpoint class for testing. 20 | * 21 | * @param the generic type used to test covariant return types in the subclass. 22 | */ 23 | public class TestEndpointSuperclass { 24 | 25 | public void superclassMethod() {} 26 | 27 | public T overrideMethod(T param) { 28 | return null; 29 | } 30 | 31 | public void overrideMethod1() {} 32 | 33 | public Foo overrideMethod2(boolean bleh) { 34 | return null; 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /test-utils/src/main/java/com/google/api/server/spi/testing/TestEnum.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 Google Inc. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.google.api.server.spi.testing; 17 | 18 | public enum TestEnum { 19 | VALUE1, VALUE2 20 | } 21 | -------------------------------------------------------------------------------- /test-utils/src/main/java/com/google/api/server/spi/testing/TestEnumDescription.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018 Google Inc. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.google.api.server.spi.testing; 17 | 18 | import com.google.api.server.spi.config.Description; 19 | 20 | public enum TestEnumDescription { 21 | @Description("description of value1") 22 | VALUE1, 23 | @Description("description of value2") 24 | VALUE2; 25 | 26 | public String notAConstant; 27 | } 28 | --------------------------------------------------------------------------------