use of org.apache.camel.CamelContext in project camel by apache.
the class CamelGroovyTest method testCamelGroovy.
@Test
public void testCamelGroovy() throws Exception {
// install the camel blueprint xml file we use in this test
URL url = ObjectHelper.loadResourceAsURL("org/apache/camel/itest/CamelGroovyTest.xml", CamelGroovyTest.class.getClassLoader());
installBlueprintAsBundle("CamelGroovyTest", url, true);
// lookup Camel from OSGi
CamelContext camel = getOsgiService(bundleContext, CamelContext.class);
// test camel
MockEndpoint mock = camel.getEndpoint("mock:result", MockEndpoint.class);
mock.expectedBodiesReceived(6);
camel.createProducerTemplate().sendBody("direct:start", 3);
mock.assertIsSatisfied();
}
use of org.apache.camel.CamelContext in project camel by apache.
the class CamelTypeConverterTest method testTypeConverterInSameBundleAsCamelRoute.
@Test
public void testTypeConverterInSameBundleAsCamelRoute() throws Exception {
// install the camel blueprint xml file and the Camel converter we use in this test
URL blueprintUrl = ObjectHelper.loadResourceAsURL("org/apache/camel/itest/CamelTypeConverterTest.xml", CamelTypeConverterTest.class.getClassLoader());
installBlueprintAsBundle("CamelTypeConverterTest", blueprintUrl, true, bundle -> {
((TinyBundle) bundle).add("META-INF/services/org/apache/camel/TypeConverter", new ByteArrayInputStream("org.apache.camel.itest.typeconverter.MyConverter".getBytes())).add(MyConverter.class, InnerClassStrategy.NONE).set(Constants.DYNAMICIMPORT_PACKAGE, "*");
});
// lookup Camel from OSGi
CamelContext camel = getOsgiService(bundleContext, CamelContext.class);
final Pojo pojo = new Pojo();
String pojoName = "Constantine";
pojo.setName(pojoName);
final DefaultExchange exchange = new DefaultExchange(camel);
final String string = camel.getTypeConverter().mandatoryConvertTo(String.class, exchange, pojo);
LOG.info("POJO -> String: {}", string);
final Pojo copy = camel.getTypeConverter().mandatoryConvertTo(Pojo.class, exchange, string);
LOG.info("String -> POJO: {}", copy);
Assert.assertEquals(pojoName, copy.getName());
}
use of org.apache.camel.CamelContext in project camel by apache.
the class DataFormatComponentConfigurationAndDocumentationTest method testUniVocityTsvEscapeChar.
@Test
public void testUniVocityTsvEscapeChar() throws Exception {
CamelContext context = new DefaultCamelContext();
String json = context.getEipParameterJsonSchema("univocity-tsv");
assertNotNull(json);
assertTrue(json.contains("\"name\": \"univocity-tsv"));
// the default value is a bit tricky as its \, which is written escaped as \\
assertTrue(json.contains("\"escapeChar\": { \"kind\": \"attribute\", \"displayName\": \"Escape Char\", \"required\": false, \"type\": \"string\", \"javaType\": \"java.lang.String\"," + " \"deprecated\": false, \"secret\": false, \"defaultValue\": \"\\\\\", \"description\": \"The escape character.\""));
List<Map<String, String>> rows = JsonSchemaHelper.parseJsonSchema("properties", json, true);
assertEquals(16, rows.size());
Map<String, String> found = null;
for (Map<String, String> row : rows) {
if ("escapeChar".equals(row.get("name"))) {
found = row;
break;
}
}
assertNotNull(found);
assertEquals("escapeChar", found.get("name"));
assertEquals("attribute", found.get("kind"));
assertEquals("false", found.get("required"));
assertEquals("string", found.get("type"));
assertEquals("java.lang.String", found.get("javaType"));
assertEquals("false", found.get("deprecated"));
assertEquals("false", found.get("secret"));
assertEquals("\\", found.get("defaultValue"));
assertEquals("The escape character.", found.get("description"));
}
use of org.apache.camel.CamelContext in project camel by apache.
the class DataFormatComponentConfigurationAndDocumentationTest method testFlatpackDefaultValue.
@Test
public void testFlatpackDefaultValue() throws Exception {
CamelContext context = new DefaultCamelContext();
String json = context.getEipParameterJsonSchema("flatpack");
assertNotNull(json);
assertTrue(json.contains("\"name\": \"flatpack"));
// the default value is a bit tricky as its ", which is written escaped as \"
assertTrue(json.contains("\"textQualifier\": { \"kind\": \"attribute\", \"displayName\": \"Text Qualifier\", \"required\": false, \"type\": \"string\"" + ", \"javaType\": \"java.lang.String\", \"deprecated\": false, \"secret\": false, \"defaultValue\": \"\\\"\""));
List<Map<String, String>> rows = JsonSchemaHelper.parseJsonSchema("properties", json, true);
assertEquals(10, rows.size());
Map<String, String> found = null;
for (Map<String, String> row : rows) {
if ("textQualifier".equals(row.get("name"))) {
found = row;
break;
}
}
assertNotNull(found);
assertEquals("textQualifier", found.get("name"));
assertEquals("attribute", found.get("kind"));
assertEquals("false", found.get("required"));
assertEquals("string", found.get("type"));
assertEquals("java.lang.String", found.get("javaType"));
assertEquals("false", found.get("deprecated"));
assertEquals("false", found.get("secret"));
assertEquals("\"", found.get("defaultValue"));
assertEquals("If the text is qualified with a char such as \"", found.get("description"));
}
use of org.apache.camel.CamelContext in project camel by apache.
the class EipDocumentationTest method testFailOverDocumentation.
@Test
public void testFailOverDocumentation() throws Exception {
CamelContext context = new DefaultCamelContext();
String json = context.getEipParameterJsonSchema("failover");
log.info(json);
assertNotNull("Should have found json for failover", json);
assertTrue(json.contains("\"name\": \"failover\""));
assertTrue(json.contains("\"exception\": { \"kind\": \"element\", \"displayName\": \"Exception\", \"required\": false, \"type\": \"array\"" + ", \"javaType\": \"java.util.List<java.lang.String>\", \"deprecated\": false"));
}
Aggregations