use of com.google.api.server.spi.TypeLoader in project endpoints-java by cloudendpoints.
the class JsonConfigWriterTest method writeConfigOrderIsPreservedMulticlass.
@Test
public void writeConfigOrderIsPreservedMulticlass() throws Exception {
@Api(name = "onetoday", description = "OneToday API")
final class OneToday {
}
@Api(name = "onetoday", description = "OneToday API")
final class OneToday2 {
}
@Api(name = "onetodayadmin", description = "One Today Admin API")
final class OneTodayAdmin {
}
@Api(name = "onetodayadmin", description = "One Today Admin API")
final class OneTodayAdmin2 {
}
ApiConfigValidator validator = Mockito.mock(ApiConfigValidator.class);
TypeLoader typeLoader = new TypeLoader();
JsonConfigWriter writer = new JsonConfigWriter(new TypeLoader(JsonConfigWriter.class.getClassLoader()), validator);
ApiConfig oneToday = new ApiConfig.Factory().create(serviceContext, typeLoader, OneToday.class);
ApiConfig oneToday2 = new ApiConfig.Factory().create(serviceContext, typeLoader, OneToday2.class);
ApiConfig oneTodayAdmin = new ApiConfig.Factory().create(serviceContext, typeLoader, OneTodayAdmin.class);
ApiConfig oneTodayAdmin2 = new ApiConfig.Factory().create(serviceContext, typeLoader, OneTodayAdmin2.class);
oneToday.setName("onetoday");
oneToday.setVersion("v1");
oneToday2.setName("onetoday");
oneToday2.setVersion("v1");
oneTodayAdmin.setName("onetodayadmin");
oneTodayAdmin.setVersion("v1");
oneTodayAdmin2.setName("onetodayadmin");
oneTodayAdmin2.setVersion("v1");
Map<ApiKey, String> configs = writer.writeConfig(Lists.newArrayList(oneToday, oneTodayAdmin, oneTodayAdmin2, oneToday2));
Iterator<ApiKey> iterator = configs.keySet().iterator();
assertEquals(new ApiKey("onetoday", "v1", "https://myapp.appspot.com/_ah/api"), iterator.next());
assertEquals(new ApiKey("onetodayadmin", "v1", "https://myapp.appspot.com/_ah/api"), iterator.next());
}
use of com.google.api.server.spi.TypeLoader in project endpoints-java by cloudendpoints.
the class JsonConfigWriterTest method writeConfigOrderIsPreserved.
@Test
public void writeConfigOrderIsPreserved() throws Exception {
@Api(name = "onetoday", description = "OneToday API")
final class OneToday {
}
@Api(name = "onetodayadmin", description = "One Today Admin API")
final class OneTodayAdmin {
}
ApiConfigValidator validator = Mockito.mock(ApiConfigValidator.class);
TypeLoader typeLoader = new TypeLoader();
JsonConfigWriter writer = new JsonConfigWriter(new TypeLoader(JsonConfigWriter.class.getClassLoader()), validator);
ApiConfig oneToday = new ApiConfig.Factory().create(serviceContext, typeLoader, OneToday.class);
ApiConfig oneTodayAdmin = new ApiConfig.Factory().create(serviceContext, typeLoader, OneTodayAdmin.class);
oneToday.setName("onetoday");
oneToday.setVersion("v1");
oneTodayAdmin.setName("onetodayadmin");
oneTodayAdmin.setVersion("v1");
Map<ApiKey, String> configs = writer.writeConfig(Lists.newArrayList(oneToday, oneTodayAdmin));
Iterator<ApiKey> iterator = configs.keySet().iterator();
assertEquals(new ApiKey("onetoday", "v1", "https://myapp.appspot.com/_ah/api"), iterator.next());
assertEquals(new ApiKey("onetodayadmin", "v1", "https://myapp.appspot.com/_ah/api"), iterator.next());
}
use of com.google.api.server.spi.TypeLoader in project endpoints-java by cloudendpoints.
the class RestServletRequestParamReaderTest method setUp.
@Before
public void setUp() throws Exception {
endpointMethod = EndpointMethod.create(TestApi.class, TestApi.class.getMethod("test", Long.TYPE, List.class, SimpleDate.class, TestResource.class));
request = new MockHttpServletRequest();
ServiceContext serviceContext = ServiceContext.create();
serializationConfig = new ApiSerializationConfig();
TypeLoader typeLoader = new TypeLoader();
apiConfig = new ApiConfig.Factory().create(serviceContext, typeLoader, TestApi.class);
ApiConfigAnnotationReader annotationReader = new ApiConfigAnnotationReader();
annotationReader.loadEndpointClass(serviceContext, TestApi.class, apiConfig);
annotationReader.loadEndpointMethods(serviceContext, TestApi.class, apiConfig.getApiClassConfig().getMethods());
methodConfig = apiConfig.getApiClassConfig().getMethods().get(endpointMethod);
}
Aggregations