camel-SimpleRegistry
来源:互联网 发布:大数据平台建设方案 编辑:程序博客网 时间:2024/05/16 15:24
SimpleRegistry实际上是基于Map的注册,它主要被用于测试,或者单独的运行camel。
下面举一个例子,使用SimpleRegistry去单元测试Camel路由。
public class HelloBean {
public String hello(String name) {
return "Hello " + name;
}
}
public class SimpleRegistryTest extends TestCase {
private CamelContext context;
private ProducerTemplate template;
protected void setUp() throws Exception {
SimpleRegistry registry = new SimpleRegistry();
registry.put("helloBean", new HelloBean());
context = new DefaultCamelContext(registry);
template = context.createProducerTemplate();
context.addRoutes(new RouteBuilder() {
public void configure() throws Exception {
from("direct:hello").beanRef("helloBean");
}
});
context.start();
}
protected void tearDown() throws Exception {
template.stop();
context.stop();
}
public void testHello() throws Exception {
Object reply = template.requestBody("direct:hello", "World");
assertEquals("Hello World", reply);
}
}
为了测试你需要创建一个ProducerTemplate,使用它简单的发送一些消息给camel。当测试的方法做完后,需要使用template.stop()和context.stop()来释放资源。
- camel-SimpleRegistry
- Camel
- Camel
- Camel
- camel 基本概念
- camel-file
- camel components
- camel Intercept
- AdviceWith camel
- Camel summary
- Camel-MongoDb
- Camel-blueprint
- Apache Camel
- camel笔记
- camel-exchange
- camel-Transform
- camel-JAXB
- camel-bean
- 随机+文件流[乱搞]
- 身份认证与数字签名基础(一)
- EOJ1855 Expedition 贪心
- 在ubuntu上通过jenkins+Gradle搭建android自动化构建环境
- EditText添加drawableXXX的点击事件
- camel-SimpleRegistry
- Linus:利用二级指针删除单向链表
- Hadoop基于文件的数据结构及实例
- kubeadm init源码分析
- Android属性动画完全解析(中),ValueAnimator和ObjectAnimator的高级用法
- Toolbar menu 遇到的问题
- 宏与内联函数
- N32905 DEMO板启动过程
- jQuery Easing 动画效果扩展