use of org.apache.camel.impl.ExplicitCamelContextNameStrategy in project camel by apache.
the class ContextListCommandTest method testEndpointStats.
@Test
public void testEndpointStats() throws Exception {
CamelContext context = new DefaultCamelContext();
context.setNameStrategy(new ExplicitCamelContextNameStrategy("foobar"));
context.addRoutes(new RouteBuilder() {
@Override
public void configure() throws Exception {
from("direct:start").to("mock:result");
}
});
context.start();
context.createProducerTemplate().sendBody("direct:start", "Hello World");
CamelController controller = new DummyCamelController(context);
OutputStream os = new ByteArrayOutputStream();
PrintStream ps = new PrintStream(os);
EndpointStatisticCommand command = new EndpointStatisticCommand("foobar", false, null);
command.execute(controller, ps, null);
String out = os.toString();
assertNotNull(out);
LOG.info("\n\n{}\n", out);
assertTrue(out.contains("direct://start"));
assertTrue(out.contains("mock://result"));
context.stop();
}
use of org.apache.camel.impl.ExplicitCamelContextNameStrategy in project camel by apache.
the class ContextListCommandTest method testContextList.
@Test
public void testContextList() throws Exception {
CamelContext context = new DefaultCamelContext();
context.setNameStrategy(new ExplicitCamelContextNameStrategy("foobar"));
context.start();
CamelController controller = new DummyCamelController(context);
OutputStream os = new ByteArrayOutputStream();
PrintStream ps = new PrintStream(os);
ContextListCommand command = new ContextListCommand();
command.execute(controller, ps, null);
String out = os.toString();
assertNotNull(out);
LOG.info("\n\n{}\n", out);
// should contain a table with the context
assertTrue(out.contains("foobar"));
assertTrue(out.contains("Started"));
context.stop();
}
use of org.apache.camel.impl.ExplicitCamelContextNameStrategy in project camel by apache.
the class ValidatorListCommandTest method doTest.
private String doTest(boolean verbose) throws Exception {
CamelContext context = new DefaultCamelContext();
EndpointValidatorDefinition evd = new EndpointValidatorDefinition();
evd.setType("xml:foo");
evd.setUri("direct:validator");
context.getValidators().add(evd);
PredicateValidatorDefinition pvd = new PredicateValidatorDefinition();
pvd.setType(this.getClass());
pvd.setExpression(new ExpressionDefinition(ExpressionBuilder.bodyExpression()));
context.getValidators().add(pvd);
CustomValidatorDefinition cvd = new CustomValidatorDefinition();
cvd.setType("custom");
cvd.setClassName(MyValidator.class.getName());
context.getValidators().add(cvd);
context.setNameStrategy(new ExplicitCamelContextNameStrategy("foobar"));
context.start();
CamelController controller = new DummyCamelController(context);
OutputStream os = new ByteArrayOutputStream();
PrintStream ps = new PrintStream(os);
ValidatorListCommand command = new ValidatorListCommand(null, false, verbose, false);
command.execute(controller, ps, null);
String out = os.toString();
assertNotNull(out);
LOG.info("\n\n{}\n", out);
context.stop();
return out;
}
use of org.apache.camel.impl.ExplicitCamelContextNameStrategy in project camel by apache.
the class TransformerListCommandTest method doTest.
private String doTest(boolean verbose) throws Exception {
CamelContext context = new DefaultCamelContext();
EndpointTransformerDefinition etd = new EndpointTransformerDefinition();
etd.setFromType("xml:foo");
etd.setToType("json:bar");
etd.setUri("direct:transformer");
context.getTransformers().add(etd);
DataFormatTransformerDefinition dftd = new DataFormatTransformerDefinition();
dftd.setFromType(this.getClass());
dftd.setToType("xml:test");
dftd.setDataFormatType(new StringDataFormat());
context.getTransformers().add(dftd);
CustomTransformerDefinition ctd = new CustomTransformerDefinition();
ctd.setScheme("custom");
ctd.setClassName(MyTransformer.class.getName());
context.getTransformers().add(ctd);
context.setNameStrategy(new ExplicitCamelContextNameStrategy("foobar"));
context.start();
CamelController controller = new DummyCamelController(context);
OutputStream os = new ByteArrayOutputStream();
PrintStream ps = new PrintStream(os);
TransformerListCommand command = new TransformerListCommand(null, false, verbose, false);
command.execute(controller, ps, null);
String out = os.toString();
assertNotNull(out);
LOG.info("\n\n{}\n", out);
context.stop();
return out;
}
Aggregations