本文整理汇总了Java中org.apache.camel.model.ToDefinition类的典型用法代码示例。如果您正苦于以下问题:Java ToDefinition类的具体用法?Java ToDefinition怎么用?Java ToDefinition使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ToDefinition类属于org.apache.camel.model包,在下文中一共展示了ToDefinition类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: testBefore
import org.apache.camel.model.ToDefinition; //导入依赖的package包/类
public void testBefore() throws Exception {
// START SNIPPET: e3
context.getRouteDefinitions().get(0).adviceWith(context, new AdviceWithRouteBuilder() {
@Override
public void configure() throws Exception {
// weave the type in the route and remove it
// and insert the following route path before the adviced node
weaveByType(ToDefinition.class).before().transform(constant("Bye World"));
}
});
// END SNIPPET: e3
getMockEndpoint("mock:result").expectedBodiesReceived("Bye World");
template.sendBody("direct:start", "World");
assertMockEndpointsSatisfied();
}
开发者ID:HydAu,项目名称:Camel,代码行数:19,代码来源:AdviceWithTypeTest.java
示例2: testAfter
import org.apache.camel.model.ToDefinition; //导入依赖的package包/类
public void testAfter() throws Exception {
// START SNIPPET: e4
context.getRouteDefinitions().get(0).adviceWith(context, new AdviceWithRouteBuilder() {
@Override
public void configure() throws Exception {
// weave the type in the route and remove it
// and insert the following route path after the adviced node
weaveByType(ToDefinition.class).after().transform(constant("Bye World"));
}
});
// END SNIPPET: e4
getMockEndpoint("mock:result").expectedBodiesReceived("Hello World");
Object out = template.requestBody("direct:start", "World");
assertEquals("Bye World", out);
assertMockEndpointsSatisfied();
}
开发者ID:HydAu,项目名称:Camel,代码行数:20,代码来源:AdviceWithTypeTest.java
示例3: testCustomInterceptor
import org.apache.camel.model.ToDefinition; //导入依赖的package包/类
public void testCustomInterceptor() throws Exception {
getMockEndpoint("mock:child").expectedMessageCount(3);
getMockEndpoint("mock:result").expectedMessageCount(1);
template.sendBody("direct:start", "A,B,C");
assertMockEndpointsSatisfied();
assertEquals(4, myInterceptor.getDefs().size());
assertIsInstanceOf(LogDefinition.class, myInterceptor.getDefs().get(0));
assertIsInstanceOf(ToDefinition.class, myInterceptor.getDefs().get(1));
assertEquals("mock:child", myInterceptor.getDefs().get(1).getLabel());
assertIsInstanceOf(SplitDefinition.class, myInterceptor.getDefs().get(2));
assertIsInstanceOf(ToDefinition.class, myInterceptor.getDefs().get(3));
assertEquals("mock:result", myInterceptor.getDefs().get(3).getLabel());
}
开发者ID:HydAu,项目名称:Camel,代码行数:17,代码来源:CustomInterceptorRouteWithChildOutputTest.java
示例4: createProcessor
import org.apache.camel.model.ToDefinition; //导入依赖的package包/类
public Processor createProcessor(RouteContext routeContext, ProcessorDefinition<?> definition) throws Exception {
if (definition instanceof SplitDefinition) {
// add additional output to the splitter
SplitDefinition split = (SplitDefinition) definition;
split.addOutput(new ToDefinition("mock:extra"));
}
if (definition instanceof SetBodyDefinition) {
SetBodyDefinition set = (SetBodyDefinition) definition;
set.setExpression(new ConstantExpression("body was altered"));
}
// return null to let the default implementation create the processor, we just wanted to alter the definition
// before the processor was created
return null;
}
开发者ID:HydAu,项目名称:Camel,代码行数:17,代码来源:CustomProcessorFactoryTest.java
示例5: testFromRestModel
import org.apache.camel.model.ToDefinition; //导入依赖的package包/类
public void testFromRestModel() throws Exception {
assertEquals(getExpectedNumberOfRoutes(), context.getRoutes().size());
assertEquals(1, context.getRestDefinitions().size());
RestDefinition rest = context.getRestDefinitions().get(0);
assertNotNull(rest);
assertEquals("/say/", rest.getPath());
assertEquals(3, rest.getVerbs().size());
assertEquals("/hello", rest.getVerbs().get(0).getUri());
assertEquals("/bye", rest.getVerbs().get(1).getUri());
assertEquals("/hi", rest.getVerbs().get(2).getUri());
ToDefinition to = assertIsInstanceOf(ToDefinition.class, rest.getVerbs().get(0).getTo());
assertEquals("direct:hello", to.getUri());
to = assertIsInstanceOf(ToDefinition.class, rest.getVerbs().get(1).getTo());
assertEquals("direct:bye", to.getUri());
// the rest becomes routes and the input is a seda endpoint created by the DummyRestConsumerFactory
getMockEndpoint("mock:update").expectedMessageCount(1);
template.sendBody("seda:post-say-hi", "I was here");
assertMockEndpointsSatisfied();
String out = template.requestBody("seda:get-say-hello", "Me", String.class);
assertEquals("Hello World", out);
String out2 = template.requestBody("seda:get-say-bye", "Me", String.class);
assertEquals("Bye World", out2);
}
开发者ID:HydAu,项目名称:Camel,代码行数:27,代码来源:FromRestUriPrefixTest.java
示例6: testWeaveByTypeSelectFirst
import org.apache.camel.model.ToDefinition; //导入依赖的package包/类
@Test
public void testWeaveByTypeSelectFirst() throws Exception {
RouteDefinition route = context.getRouteDefinition("quotes");
route.adviceWith(context, new AdviceWithRouteBuilder() {
@Override
public void configure() throws Exception {
// find the send to and select the first which gets replaced
weaveByType(ToDefinition.class).selectFirst().replace().to("mock:line");
}
});
context.start();
getMockEndpoint("mock:line").expectedBodiesReceived("camel rules", "donkey is bad");
getMockEndpoint("mock:combined").expectedMessageCount(1);
getMockEndpoint("mock:combined").message(0).body().isInstanceOf(List.class);
template.sendBody("seda:quotes", "Camel Rules,Donkey is Bad");
assertMockEndpointsSatisfied();
}
开发者ID:camelinaction,项目名称:camelinaction2,代码行数:22,代码来源:WeaveByTypeSelectFirstTest.java
示例7: getUri
import org.apache.camel.model.ToDefinition; //导入依赖的package包/类
public static String getUri(ToDefinition input) {
String key = input.getUri();
if (Strings2.isEmpty(key)) {
String ref = input.getRef();
if (!Strings2.isEmpty(ref)) {
return "ref:" + ref;
}
}
return key;
}
开发者ID:fabric8io,项目名称:fabric8-forge,代码行数:11,代码来源:CamelModelHelper.java
示例8: getExchangePattern
import org.apache.camel.model.ToDefinition; //导入依赖的package包/类
public static String getExchangePattern(ToDefinition input) {
String pattern = input.getPattern() != null ? input.getPattern().name() : null;
if (Strings2.isEmpty(pattern)) {
return null;
}
return pattern;
}
开发者ID:fabric8io,项目名称:fabric8-forge,代码行数:8,代码来源:CamelModelHelper.java
示例9: getTo
import org.apache.camel.model.ToDefinition; //导入依赖的package包/类
public ToDefinition getTo() {
if (to != null) {
return to;
} else if (toOrRoute instanceof ToDefinition) {
return (ToDefinition) toOrRoute;
} else {
return null;
}
}
开发者ID:HydAu,项目名称:Camel,代码行数:10,代码来源:VerbDefinition.java
示例10: testInitIdsOnAllNodes
import org.apache.camel.model.ToDefinition; //导入依赖的package包/类
public void testInitIdsOnAllNodes() throws Exception {
getMockEndpoint("mock:camel").expectedBodiesReceived("Hello Camel");
getMockEndpoint("mock:other").expectedBodiesReceived("Hello World");
getMockEndpoint("mock:end").expectedMessageCount(2);
template.sendBody("direct:start", "Hello Camel");
template.sendBody("direct:start", "Hello World");
assertMockEndpointsSatisfied();
RouteDefinition route = context.getRouteDefinitions().get(0);
assertNotNull(route);
ChoiceDefinition choice = (ChoiceDefinition) route.getOutputs().get(0);
assertEquals("choice1", choice.getId());
WhenDefinition when = (WhenDefinition) choice.getOutputs().get(0);
assertEquals("when1", when.getId());
LogDefinition log1 = (LogDefinition) when.getOutputs().get(0);
assertEquals("log1", log1.getId());
ToDefinition to1 = (ToDefinition) when.getOutputs().get(1);
assertEquals("camel", to1.getId());
OtherwiseDefinition other = (OtherwiseDefinition) choice.getOutputs().get(1);
assertEquals("otherwise1", other.getId());
LogDefinition log2 = (LogDefinition) other.getOutputs().get(0);
assertEquals("log2", log2.getId());
ToDefinition to2 = (ToDefinition) other.getOutputs().get(1);
assertEquals("to1", to2.getId());
ToDefinition to3 = (ToDefinition) other.getOutputs().get(2);
assertEquals("foo", to3.getId());
ToDefinition to4 = (ToDefinition) route.getOutputs().get(1);
assertEquals("end", to4.getId());
}
开发者ID:HydAu,项目名称:Camel,代码行数:41,代码来源:TraceInitIdOnAllNodesTest.java
示例11: setUp
import org.apache.camel.model.ToDefinition; //导入依赖的package包/类
@Override
protected void setUp() throws Exception {
super.setUp();
breakpoint = new BreakpointSupport() {
public void beforeProcess(Exchange exchange, Processor processor, ProcessorDefinition<?> definition) {
String body = exchange.getIn().getBody(String.class);
logs.add("Breakpoint at " + definition + " with body: " + body);
}
public void onEvent(Exchange exchange, EventObject event, ProcessorDefinition<?> definition) {
String body = exchange.getIn().getBody(String.class);
logs.add("Breakpoint event " + event.getClass().getSimpleName() + " with body: " + body);
}
};
camelCondition = new ConditionSupport() {
public boolean matchProcess(Exchange exchange, Processor processor, ProcessorDefinition<?> definition) {
return body().contains("Camel").matches(exchange);
}
};
mockCondition = new ConditionSupport() {
public boolean matchProcess(Exchange exchange, Processor processor, ProcessorDefinition<?> definition) {
// match when sending to mocks
if (definition instanceof ToDefinition) {
ToDefinition to = (ToDefinition) definition;
return to.getUriOrRef().startsWith("mock");
}
return false;
}
};
doneCondition = new ConditionSupport() {
@Override
public boolean matchEvent(Exchange exchange, EventObject event) {
return event instanceof ExchangeCompletedEvent;
}
};
}
开发者ID:HydAu,项目名称:Camel,代码行数:41,代码来源:DebugTest.java
示例12: testFromRestModel
import org.apache.camel.model.ToDefinition; //导入依赖的package包/类
public void testFromRestModel() throws Exception {
assertEquals(1, context.getRestDefinitions().size());
RestDefinition rest = context.getRestDefinitions().get(0);
assertNotNull(rest);
assertEquals("/say/hello", rest.getPath());
assertEquals(1, rest.getVerbs().size());
ToDefinition to = assertIsInstanceOf(ToDefinition.class, rest.getVerbs().get(0).getTo());
assertEquals("log:hello", to.getUri());
// should be 2 routes
assertEquals(2, context.getRoutes().size());
}
开发者ID:HydAu,项目名称:Camel,代码行数:13,代码来源:FromRestApiTest.java
示例13: testFromRestModel
import org.apache.camel.model.ToDefinition; //导入依赖的package包/类
public void testFromRestModel() throws Exception {
assertEquals(getExpectedNumberOfRoutes(), context.getRoutes().size());
assertEquals(2, context.getRestDefinitions().size());
RestDefinition rest = context.getRestDefinitions().get(0);
assertNotNull(rest);
assertEquals("/say/hello", rest.getPath());
assertEquals(1, rest.getVerbs().size());
ToDefinition to = assertIsInstanceOf(ToDefinition.class, rest.getVerbs().get(0).getTo());
assertEquals("direct:hello", to.getUri());
rest = context.getRestDefinitions().get(1);
assertNotNull(rest);
assertEquals("/say/bye", rest.getPath());
assertEquals(2, rest.getVerbs().size());
assertEquals("application/json", rest.getVerbs().get(0).getConsumes());
to = assertIsInstanceOf(ToDefinition.class, rest.getVerbs().get(0).getRoute().getOutputs().get(1));
assertEquals("direct:bye", to.getUri());
// the rest becomes routes and the input is a seda endpoint created by the DummyRestConsumerFactory
getMockEndpoint("mock:update").expectedMessageCount(1);
template.sendBody("seda:post-say-bye", "I was here");
assertMockEndpointsSatisfied();
String out = template.requestBody("seda:get-say-hello", "Me", String.class);
assertEquals("Hello World", out);
String out2 = template.requestBody("seda:get-say-bye", "Me", String.class);
assertEquals("Bye World", out2);
}
开发者ID:HydAu,项目名称:Camel,代码行数:30,代码来源:FromRestGetEndPathTest.java
示例14: testFromRestModel
import org.apache.camel.model.ToDefinition; //导入依赖的package包/类
public void testFromRestModel() throws Exception {
assertEquals(getExpectedNumberOfRoutes(), context.getRoutes().size());
assertEquals(2, context.getRestDefinitions().size());
RestDefinition rest = context.getRestDefinitions().get(0);
assertNotNull(rest);
assertEquals("/say/hello", rest.getPath());
assertEquals(1, rest.getVerbs().size());
ToDefinition to = assertIsInstanceOf(ToDefinition.class, rest.getVerbs().get(0).getRoute().getOutputs().get(1));
assertEquals("mock:hello", to.getUri());
rest = context.getRestDefinitions().get(1);
assertNotNull(rest);
assertEquals("/say/bye", rest.getPath());
assertEquals(2, rest.getVerbs().size());
assertEquals("application/json", rest.getVerbs().get(0).getConsumes());
to = assertIsInstanceOf(ToDefinition.class, rest.getVerbs().get(0).getRoute().getOutputs().get(1));
assertEquals("mock:bye", to.getUri());
// the rest becomes routes and the input is a seda endpoint created by the DummyRestConsumerFactory
getMockEndpoint("mock:update").expectedMessageCount(1);
template.sendBody("seda:post-say-bye", "I was here");
assertMockEndpointsSatisfied();
String out = template.requestBody("seda:get-say-hello", "Me", String.class);
assertEquals("Hello World", out);
String out2 = template.requestBody("seda:get-say-bye", "Me", String.class);
assertEquals("Bye World", out2);
}
开发者ID:HydAu,项目名称:Camel,代码行数:30,代码来源:FromRestGetEmbeddedRouteTest.java
示例15: testFromRestModel
import org.apache.camel.model.ToDefinition; //导入依赖的package包/类
@Test
public void testFromRestModel() throws Exception {
assertEquals(getExpectedNumberOfRoutes(), context.getRoutes().size());
assertEquals(1, context.getRestDefinitions().size());
RestDefinition rest = context.getRestDefinitions().get(0);
assertNotNull(rest);
assertEquals("/say/", rest.getPath());
assertEquals(3, rest.getVerbs().size());
assertEquals("/hello", rest.getVerbs().get(0).getUri());
assertEquals("/bye", rest.getVerbs().get(1).getUri());
assertEquals("/hi", rest.getVerbs().get(2).getUri());
ToDefinition to = assertIsInstanceOf(ToDefinition.class, rest.getVerbs().get(0).getTo());
assertEquals("direct:hello", to.getUri());
to = assertIsInstanceOf(ToDefinition.class, rest.getVerbs().get(1).getTo());
assertEquals("direct:bye", to.getUri());
// the rest becomes routes and the input is a seda endpoint created by the DummyRestConsumerFactory
getMockEndpoint("mock:update").expectedMessageCount(1);
template.sendBody("seda:post-say-hi", "I was here");
assertMockEndpointsSatisfied();
String out = template.requestBody("seda:get-say-hello", "Me", String.class);
assertEquals("Hello World", out);
String out2 = template.requestBody("seda:get-say-bye", "Me", String.class);
assertEquals("Bye World", out2);
}
开发者ID:HydAu,项目名称:Camel,代码行数:28,代码来源:FromRestUriPrefixTest.java
示例16: testRestRefTest
import org.apache.camel.model.ToDefinition; //导入依赖的package包/类
@Test
public void testRestRefTest() throws Exception {
assertEquals(getExpectedNumberOfRoutes(), context.getRoutes().size());
assertEquals(2, context.getRestDefinitions().size());
RestDefinition rest = context.getRestDefinitions().get(0);
assertNotNull(rest);
assertEquals("/say/hello", rest.getPath());
assertEquals(1, rest.getVerbs().size());
ToDefinition to = assertIsInstanceOf(ToDefinition.class, rest.getVerbs().get(0).getTo());
assertEquals("direct:hello", to.getUri());
rest = context.getRestDefinitions().get(1);
assertNotNull(rest);
assertEquals("/say/bye", rest.getPath());
assertEquals(2, rest.getVerbs().size());
assertEquals("application/json", rest.getVerbs().get(0).getConsumes());
to = assertIsInstanceOf(ToDefinition.class, rest.getVerbs().get(0).getTo());
assertEquals("direct:bye", to.getUri());
// the rest becomes routes and the input is a seda endpoint created by the DummyRestConsumerFactory
getMockEndpoint("mock:update").expectedMessageCount(1);
template.sendBody("seda:post-say-bye", "I was here");
assertMockEndpointsSatisfied();
String out = template.requestBody("seda:get-say-hello", "Me", String.class);
assertEquals("Hello World", out);
String out2 = template.requestBody("seda:get-say-bye", "Me", String.class);
assertEquals("Bye World", out2);
}
开发者ID:HydAu,项目名称:Camel,代码行数:31,代码来源:RestRefTest.java
示例17: testFromRestModel
import org.apache.camel.model.ToDefinition; //导入依赖的package包/类
@Test
public void testFromRestModel() throws Exception {
assertEquals(getExpectedNumberOfRoutes(), context.getRoutes().size());
assertEquals(2, context.getRestDefinitions().size());
RestDefinition rest = context.getRestDefinitions().get(0);
assertNotNull(rest);
assertEquals("/say/hello", rest.getPath());
assertEquals(1, rest.getVerbs().size());
ToDefinition to = assertIsInstanceOf(ToDefinition.class, rest.getVerbs().get(0).getRoute().getOutputs().get(1));
assertEquals("mock:hello", to.getUri());
rest = context.getRestDefinitions().get(1);
assertNotNull(rest);
assertEquals("/say/bye", rest.getPath());
assertEquals(2, rest.getVerbs().size());
assertEquals("application/json", rest.getVerbs().get(0).getConsumes());
to = assertIsInstanceOf(ToDefinition.class, rest.getVerbs().get(0).getRoute().getOutputs().get(1));
assertEquals("mock:bye", to.getUri());
// the rest becomes routes and the input is a seda endpoint created by the DummyRestConsumerFactory
getMockEndpoint("mock:update").expectedMessageCount(1);
template.sendBody("seda:post-say-bye", "I was here");
assertMockEndpointsSatisfied();
String out = template.requestBody("seda:get-say-hello", "Me", String.class);
assertEquals("Hello World", out);
String out2 = template.requestBody("seda:get-say-bye", "Me", String.class);
assertEquals("Bye World", out2);
}
开发者ID:HydAu,项目名称:Camel,代码行数:31,代码来源:FromRestGetEmbeddedRouteTest.java
示例18: testRestRefTest
import org.apache.camel.model.ToDefinition; //导入依赖的package包/类
public void testRestRefTest() throws Exception {
assertEquals(2 + 3, context.getRoutes().size());
assertEquals(2, context.getRestDefinitions().size());
RestDefinition rest = context.getRestDefinitions().get(0);
assertNotNull(rest);
assertEquals("/say/hello", rest.getPath());
assertEquals(1, rest.getVerbs().size());
ToDefinition to = assertIsInstanceOf(ToDefinition.class, rest.getVerbs().get(0).getTo());
assertEquals("direct:hello", to.getUri());
rest = context.getRestDefinitions().get(1);
assertNotNull(rest);
assertEquals("/say/bye", rest.getPath());
assertEquals(2, rest.getVerbs().size());
assertEquals("application/json", rest.getVerbs().get(0).getConsumes());
to = assertIsInstanceOf(ToDefinition.class, rest.getVerbs().get(0).getTo());
assertEquals("direct:bye", to.getUri());
// the rest becomes routes and the input is a seda endpoint created by the DummyRestConsumerFactory
getMockEndpoint("mock:update").expectedMessageCount(1);
template.sendBody("seda:post-say-bye", "I was here");
assertMockEndpointsSatisfied();
String out = template.requestBody("seda:get-say-hello", "Me", String.class);
assertEquals("Hello World", out);
String out2 = template.requestBody("seda:get-say-bye", "Me", String.class);
assertEquals("Bye World", out2);
}
开发者ID:HydAu,项目名称:Camel,代码行数:30,代码来源:RestRefTest.java
示例19: getUriFromProcessor
import org.apache.camel.model.ToDefinition; //导入依赖的package包/类
/**
* Get the uri from the processor (NOTE: Current impl uses reflection, so could fail easily)
*
* @param current
* @return
*/
private String getUriFromProcessor(Processor current) {
String uri = "";
//NOTE: What if camel uses different 'Channels', this wont work.
// How can i get the URI from the processor in a nice way?
if (current instanceof DefaultChannel) {
DefaultChannel currentChannel = (DefaultChannel)current;
Object outputValue = null;
try {
//NOTE: Shouldnt really be using reflection...but dont know what class i can use
Field outputField = FieldUtils.getField(DefaultChannel.class, "childDefinition", true);
outputValue = FieldUtils.readField(outputField, currentChannel, true);
} catch (IllegalAccessException ex) {
LOG.error("Cannot access 'childDefinition' on {} because: {}", current, ExceptionUtils.getStackTrace(ex));
}
//NOTE: What if the definition isnt a To, its another type...
if (outputValue != null && outputValue instanceof ToDefinition) {
ToDefinition to = (ToDefinition)outputValue;
uri = normalizeUri(to.getUri());
}
}
if (uri.isEmpty()) {
throw new IllegalStateException("Could not get URI from processor '" + current + "'");
}
return uri;
}
开发者ID:garethahealy,项目名称:camel-dynamic-loadbalancer,代码行数:39,代码来源:MBeanRouteStatisticsCollector.java
示例20: replaceToAsynch
import org.apache.camel.model.ToDefinition; //导入依赖的package包/类
/**
* Replaces calling TO {@link AsynchConstants#URI_ASYNCH_IN_MSG} with processor that creates OK response.
* <p/>
* Useful when you want to test input (IN) route of asynchronous process.
*
* @param builder the advice builder
*/
public static final void replaceToAsynch(AdviceWithRouteBuilder builder) {
// remove AsynchInMessageRoute.URI_ASYNCH_IN_MSG
builder.weaveByType(ToDefinition.class).replace().process(new Processor() {
@Override
public void process(Exchange exchange) throws Exception {
// creates OK response
CallbackResponse callbackResponse = new CallbackResponse();
callbackResponse.setStatus(ConfirmationTypes.OK);
exchange.getIn().setBody(callbackResponse);
}
});
}
开发者ID:integram,项目名称:cleverbus,代码行数:21,代码来源:TestUtils.java
注:本文中的org.apache.camel.model.ToDefinition类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论