use of org.apache.camel.impl.DefaultClassResolver in project camel by apache.
the class RestSwaggerReaderModelTest method testReaderRead.
@Test
public void testReaderRead() throws Exception {
BeanConfig config = new BeanConfig();
config.setHost("localhost:8080");
config.setSchemes(new String[] { "http" });
config.setBasePath("/api");
config.setTitle("Camel User store");
config.setLicense("Apache 2.0");
config.setLicenseUrl("http://www.apache.org/licenses/LICENSE-2.0.html");
RestSwaggerReader reader = new RestSwaggerReader();
Swagger swagger = reader.read(context.getRestDefinitions(), null, config, context.getName(), new DefaultClassResolver());
assertNotNull(swagger);
ObjectMapper mapper = new ObjectMapper();
mapper.enable(SerializationFeature.INDENT_OUTPUT);
mapper.setSerializationInclusion(JsonInclude.Include.NON_NULL);
String json = mapper.writeValueAsString(swagger);
log.info(json);
assertTrue(json.contains("\"host\" : \"localhost:8080\""));
assertTrue(json.contains("\"description\" : \"The user returned\""));
assertTrue(json.contains("\"$ref\" : \"#/definitions/User\""));
assertTrue(json.contains("\"x-className\""));
assertTrue(json.contains("\"format\" : \"org.apache.camel.swagger.User\""));
assertFalse(json.contains("\"enum\""));
context.stop();
}
use of org.apache.camel.impl.DefaultClassResolver in project camel by apache.
the class RestSwaggerReaderTest method testReaderRead.
@Test
public void testReaderRead() throws Exception {
BeanConfig config = new BeanConfig();
config.setHost("localhost:8080");
config.setSchemes(new String[] { "http" });
config.setBasePath("/api");
RestSwaggerReader reader = new RestSwaggerReader();
Swagger swagger = reader.read(context.getRestDefinitions(), null, config, context.getName(), new DefaultClassResolver());
assertNotNull(swagger);
ObjectMapper mapper = new ObjectMapper();
mapper.enable(SerializationFeature.INDENT_OUTPUT);
mapper.setSerializationInclusion(JsonInclude.Include.NON_NULL);
String json = mapper.writeValueAsString(swagger);
log.info(json);
assertTrue(json.contains("\"host\" : \"localhost:8080\""));
assertTrue(json.contains("\"basePath\" : \"/api\""));
assertTrue(json.contains("\"/hello/bye\""));
assertTrue(json.contains("\"summary\" : \"To update the greeting message\""));
assertTrue(json.contains("\"/hello/bye/{name}\""));
assertTrue(json.contains("\"/hello/hi/{name}\""));
context.stop();
}
use of org.apache.camel.impl.DefaultClassResolver in project camel by apache.
the class OsgiFactoryFinderTest method testFindClass.
@Test
public void testFindClass() throws Exception {
OsgiFactoryFinder finder = new OsgiFactoryFinder(getBundleContext(), new DefaultClassResolver(), "META-INF/services/org/apache/camel/component/");
Class<?> clazz = finder.findClass("file_test", "strategy.factory.");
assertNotNull("We should get the file strategy factory here", clazz);
try {
clazz = finder.findClass("nofile", "strategy.factory.");
fail("We should get exception here");
} catch (Exception ex) {
assertTrue("Should get NoFactoryAvailableException", ex instanceof NoFactoryAvailableException);
}
try {
clazz = finder.findClass("file_test", "nostrategy.factory.");
fail("We should get exception here");
} catch (Exception ex) {
assertTrue("Should get IOException", ex instanceof IOException);
}
}
use of org.apache.camel.impl.DefaultClassResolver in project camel by apache.
the class RestSwaggerReaderApiDocsTest method testReaderRead.
@Test
public void testReaderRead() throws Exception {
BeanConfig config = new BeanConfig();
config.setHost("localhost:8080");
config.setSchemes(new String[] { "http" });
config.setBasePath("/api");
RestSwaggerReader reader = new RestSwaggerReader();
Swagger swagger = reader.read(context.getRestDefinitions(), null, config, context.getName(), new DefaultClassResolver());
assertNotNull(swagger);
ObjectMapper mapper = new ObjectMapper();
mapper.enable(SerializationFeature.INDENT_OUTPUT);
mapper.setSerializationInclusion(JsonInclude.Include.NON_NULL);
String json = mapper.writeValueAsString(swagger);
log.info(json);
assertTrue(json.contains("\"host\" : \"localhost:8080\""));
assertTrue(json.contains("\"basePath\" : \"/api\""));
assertFalse(json.contains("\"/hello/bye\""));
assertFalse(json.contains("\"summary\" : \"To update the greeting message\""));
assertFalse(json.contains("\"/hello/bye/{name}\""));
assertTrue(json.contains("\"/hello/hi/{name}\""));
context.stop();
}
use of org.apache.camel.impl.DefaultClassResolver in project camel by apache.
the class RestSwaggerReaderDayOfWeekTest method testReaderRead.
@Test
public void testReaderRead() throws Exception {
BeanConfig config = new BeanConfig();
config.setHost("localhost:8080");
config.setSchemes(new String[] { "http" });
config.setBasePath("/api");
config.setTitle("Day");
config.setLicense("Apache 2.0");
config.setLicenseUrl("http://www.apache.org/licenses/LICENSE-2.0.html");
RestSwaggerReader reader = new RestSwaggerReader();
Swagger swagger = reader.read(context.getRestDefinitions(), null, config, context.getName(), new DefaultClassResolver());
assertNotNull(swagger);
ObjectMapper mapper = new ObjectMapper();
mapper.enable(SerializationFeature.INDENT_OUTPUT);
mapper.setSerializationInclusion(JsonInclude.Include.NON_NULL);
String json = mapper.writeValueAsString(swagger);
log.info(json);
assertTrue(json.contains("\"host\" : \"localhost:8080\""));
assertTrue(json.contains("\"default\" : \"friday\""));
assertTrue(json.contains("\"enum\" : [ \"monday\", \"tuesday\", \"wednesday\", \"thursday\", \"friday\" ]"));
assertTrue(json.contains("\"$ref\" : \"#/definitions/DayResponse\""));
assertTrue(json.contains("\"format\" : \"org.apache.camel.swagger.DayResponse\""));
assertTrue(json.contains("\"X-Rate-Limit-Limit\" : {"));
assertTrue(json.contains("\"description\" : \"The number of allowed requests in the current period\""));
context.stop();
}
Aggregations