当前位置: 首页>>代码示例>>Java>>正文


Java MockEndpoint.reset方法代码示例

本文整理汇总了Java中org.apache.camel.component.mock.MockEndpoint.reset方法的典型用法代码示例。如果您正苦于以下问题:Java MockEndpoint.reset方法的具体用法?Java MockEndpoint.reset怎么用?Java MockEndpoint.reset使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.camel.component.mock.MockEndpoint的用法示例。


在下文中一共展示了MockEndpoint.reset方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: testNotCached

import org.apache.camel.component.mock.MockEndpoint; //导入方法依赖的package包/类
@Test
public void testNotCached() throws Exception {
    MockEndpoint mock = getMockEndpoint("mock:result");
    mock.expectedBodiesReceived("Hello London");

    template.sendBodyAndHeader("direct:a", "Body", "name", "London");
    mock.assertIsSatisfied();

    // now change content in the file in the classpath and try again
    template.sendBodyAndHeader("file://target/test-classes/org/apache/camel/component/stringtemplate", "Bye <headers.name>", Exchange.FILE_NAME, "hello.tm");

    mock.reset();
    mock.expectedBodiesReceived("Bye Paris");

    template.sendBodyAndHeader("direct:a", "Body", "name", "Paris");
    mock.assertIsSatisfied();
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:18,代码来源:StringTemplateContentCacheTest.java

示例2: testA

import org.apache.camel.component.mock.MockEndpoint; //导入方法依赖的package包/类
public void testA() throws Exception {
    MockEndpoint mock = getMockEndpoint("mock:a");

    mock.expectedBodiesReceived("Hello World");
    template.sendBody("direct:a", "Hello World");
    assertMockEndpointsSatisfied();

    mock.reset();
    mock.expectedBodiesReceived("");
    template.sendBody("direct:a", "");
    assertMockEndpointsSatisfied();

    mock.reset();
    mock.expectedMessageCount(1);
    mock.message(0).body().isNull();
    template.sendBody("direct:a", null);
    assertMockEndpointsSatisfied();
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:19,代码来源:BeanInvokeTest.java

示例3: testTwoCamelContextRestart

import org.apache.camel.component.mock.MockEndpoint; //导入方法依赖的package包/类
@Test
public void testTwoCamelContextRestart() throws Exception {
    MockEndpoint mock1 = camel1.getEndpoint("mock:one", MockEndpoint.class);
    mock1.expectedMinimumMessageCount(2);

    MockEndpoint mock2 = camel2.getEndpoint("mock:two", MockEndpoint.class);
    mock2.expectedMinimumMessageCount(6);
    mock1.assertIsSatisfied();

    camel1.suspend();

    mock2.assertIsSatisfied();

    // should resume triggers when we start camel 1 again
    mock1.reset();
    mock1.expectedMinimumMessageCount(2);
    camel1.resume();

    mock1.assertIsSatisfied();
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:21,代码来源:QuartzTwoCamelContextSuspendResumeTest.java

示例4: setUp

import org.apache.camel.component.mock.MockEndpoint; //导入方法依赖的package包/类
public void setUp() throws Exception {
    service1 = (MockEndpoint) camelContext.getEndpoint("mock:service1");
    service1.reset();
    service2 = (MockEndpoint) camelContext.getEndpoint("mock:service2");
    service2.reset();
    camelContext.addRoutes(new RouteBuilder() {

        @Override
        public void configure() throws Exception {
            from("direct:start").to("flowable:camelProcess");
            from("flowable:camelProcess:serviceTask1").setBody().exchangeProperty("var1").to("mock:service1").setProperty("var2").constant("var2").setBody().properties();
            from("direct:receive").to("flowable:camelProcess:receive");
            from("flowable:camelProcess:serviceTask2?copyVariablesToBodyAsMap=true").to("mock:service2");
        }
    });
}
 
开发者ID:flowable,项目名称:flowable-engine,代码行数:17,代码来源:SimpleProcessTest.java

示例5: testMaxMessagesPerPoll

import org.apache.camel.component.mock.MockEndpoint; //导入方法依赖的package包/类
@Test
public void testMaxMessagesPerPoll() throws Exception {
    // start route
    context.startRoute("foo");

    MockEndpoint mock = getMockEndpoint("mock:result");
    mock.expectedBodiesReceived("AAA", "BBB");
    mock.setResultWaitTime(4000);
    mock.expectedPropertyReceived(Exchange.BATCH_SIZE, 2);

    assertMockEndpointsSatisfied();

    mock.reset();
    mock.expectedBodiesReceived("CCC");
    mock.expectedPropertyReceived(Exchange.BATCH_SIZE, 1);

    assertMockEndpointsSatisfied();
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:19,代码来源:FtpConsumerNotEagerMaxMessagesPerPollTest.java

示例6: setUp

import org.apache.camel.component.mock.MockEndpoint; //导入方法依赖的package包/类
public void setUp() throws Exception {
    camelContext.addRoutes(new RouteBuilder() {

        @Override
        public void configure() throws Exception {
            from("direct:startWithInitiatorHeader").setHeader("CamelProcessInitiatorHeader", constant("kermit")).to(
                    "flowable:InitiatorCamelCallProcess?processInitiatorHeaderName=CamelProcessInitiatorHeader");

            from("direct:start").to("flowable:camelProcess");
            from("direct:receive").to("flowable:camelProcess:receive");
            from("flowable:camelProcess:serviceTask2?copyVariablesToBodyAsMap=true").to("mock:service2");
            from("flowable:camelProcess:serviceTask1").setBody().simple("property[var1]").to("mock:service1").setProperty("var2").constant("var2").setBody().mvel("properties");
        }
    });

    service1 = (MockEndpoint) camelContext.getEndpoint("mock:service1");
    service1.reset();
    service2 = (MockEndpoint) camelContext.getEndpoint("mock:service2");
    service2.reset();
}
 
开发者ID:flowable,项目名称:flowable-engine,代码行数:21,代码来源:SimpleSpringProcessTest.java

示例7: setUp

import org.apache.camel.component.mock.MockEndpoint; //导入方法依赖的package包/类
@Override
public void setUp() throws Exception {
    super.setUp();
    camelContext.addRoutes(new RouteBuilder() {

        @Override
        public void configure() throws Exception {
            from("direct:start").to("flowable:camelProcess");

            from("flowable:camelProcess:serviceTask1").setBody().exchangeProperty("var1").to("mock:service1").setProperty("var2").constant("var2").setBody()
                            .properties();

            from("flowable:camelProcess:serviceTask2?copyVariablesToBodyAsMap=true").to("mock:service2");

            from("direct:receive").to("flowable:camelProcess:receive");
        }
    });

    service1 = (MockEndpoint) camelContext.getEndpoint("mock:service1");
    service1.reset();
    service2 = (MockEndpoint) camelContext.getEndpoint("mock:service2");
    service2.reset();
}
 
开发者ID:flowable,项目名称:flowable-engine,代码行数:24,代码来源:CdiCustomNonDefaultNamedContextTest.java

示例8: setUp

import org.apache.camel.component.mock.MockEndpoint; //导入方法依赖的package包/类
@Override
public void setUp() throws Exception {
    super.setUp();
    camelContext.addRoutes(new RouteBuilder() {

        @Override
        public void configure() throws Exception {
            from("direct:start").to("flowable:camelProcess");
            from("flowable:camelProcess:serviceTask1").setBody().exchangeProperty("var1").to("mock:service1").setProperty("var2").constant("var2").setBody()
                            .properties();
            from("flowable:camelProcess:serviceTask2?copyVariablesToBodyAsMap=true").to("mock:service2");
            from("direct:receive").to("flowable:camelProcess:receive");
        }
    });

    service1 = (MockEndpoint) camelContext.getEndpoint("mock:service1");
    service1.reset();
    service2 = (MockEndpoint) camelContext.getEndpoint("mock:service2");
    service2.reset();
}
 
开发者ID:flowable,项目名称:flowable-engine,代码行数:21,代码来源:CdiCustomContextTest.java

示例9: testIdempotentDiffSize

import org.apache.camel.component.mock.MockEndpoint; //导入方法依赖的package包/类
public void testIdempotentDiffSize() throws Exception {
    // consume the file the first time
    MockEndpoint mock = getMockEndpoint("mock:result");
    mock.expectedBodiesReceived("Hello World");

    assertMockEndpointsSatisfied();

    oneExchangeDone.matchesMockWaitTime();

    // reset mock and set new expectations
    mock.reset();
    mock.expectedBodiesReceived("Bye World");

    // create new file which has different length
    template.sendBodyAndHeader("file://target/idempotent", "Bye World", Exchange.FILE_NAME, "report.txt");

    assertMockEndpointsSatisfied();
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:19,代码来源:FileConsumerIdempotentKeyNameAndSizeTest.java

示例10: testTimerSuspendResume

import org.apache.camel.component.mock.MockEndpoint; //导入方法依赖的package包/类
public void testTimerSuspendResume() throws Exception {
    MockEndpoint mock = getMockEndpoint("mock:result");
    mock.expectedMinimumMessageCount(1);

    assertMockEndpointsSatisfied();

    mock.reset();
    mock.expectedMessageCount(0);

    context.suspend();
    Thread.sleep(2000);

    assertMockEndpointsSatisfied();

    mock.reset();
    mock.expectedMinimumMessageCount(1);

    context.resume();
    assertMockEndpointsSatisfied();
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:21,代码来源:TimerSuspendCamelContextTest.java

示例11: testClearCacheViaJmx

import org.apache.camel.component.mock.MockEndpoint; //导入方法依赖的package包/类
@Test
public void testClearCacheViaJmx() throws Exception {
    MockEndpoint mock = getMockEndpoint("mock:result");
    mock.expectedBodiesReceived("Hello London");

    template.sendBodyAndHeader("direct:b", "Body", "name", "London");
    mock.assertIsSatisfied();

    // now change content in the file in the classpath and try again
    template.sendBodyAndHeader("file://target/test-classes/org/apache/camel/component/freemarker?fileExist=Override", "Bye ${headers.name}", Exchange.FILE_NAME, "hello.ftl");

    mock.reset();
    // we must expected the original filecontent as the cache is enabled, so its Hello and not Bye
    mock.expectedBodiesReceived("Hello Paris");

    template.sendBodyAndHeader("direct:b", "Body", "name", "Paris");
    mock.assertIsSatisfied();

    // clear the cache via the mbean server
    MBeanServer mbeanServer = context.getManagementStrategy().getManagementAgent().getMBeanServer();
    Set<ObjectName> objNameSet = mbeanServer.queryNames(new ObjectName("org.apache.camel:type=endpoints,name=\"freemarker:*contentCache=true*\",*"), null);
    ObjectName managedObjName = new ArrayList<ObjectName>(objNameSet).get(0);
    mbeanServer.invoke(managedObjName, "clearContentCache", null, null);

    // change content in the file in the classpath and try again
    template.sendBodyAndHeader("file://target/test-classes/org/apache/camel/component/freemarker?fileExist=Override", "Bye ${headers.name}", Exchange.FILE_NAME, "hello.ftl");
    mock.reset();
    // we expect the updated file content because the cache was cleared
    mock.expectedBodiesReceived("Bye Paris");
    template.sendBodyAndHeader("direct:b", "Body", "name", "Paris");
    mock.assertIsSatisfied();

    // change content in the file in the classpath and try again to verify that the caching is still in effect after clearing the cache
    template.sendBodyAndHeader("file://target/test-classes/org/apache/camel/component/freemarker?fileExist=Override", "Hello ${headers.name}", Exchange.FILE_NAME, "hello.ftl");
    mock.reset();
    // we expect the cached content from the prior update
    mock.expectedBodiesReceived("Bye Paris");
    template.sendBodyAndHeader("direct:b", "Body", "name", "Paris");
    mock.assertIsSatisfied();
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:41,代码来源:FreemarkerContentCacheTest.java

示例12: testConsuming

import org.apache.camel.component.mock.MockEndpoint; //导入方法依赖的package包/类
@Test
public void testConsuming() throws Exception {
    // clear mailbox
    Mailbox.clearAll();

    MockEndpoint mock = getMockEndpoint("mock:result");
    mock.expectedBodiesReceived("Hello London");

    template.sendBody("smtp://[email protected]", "Hello London");

    // first poll should happen immediately
    mock.setResultWaitTime(2000L);
    mock.assertIsSatisfied();

    mock.reset();
    mock.expectedBodiesReceived("Hello Paris");
    mock.setResultWaitTime(5000L + 2000L);

    StopWatch watch = new StopWatch();

    template.sendBody("smtp://[email protected]", "Hello Paris");

    // poll next mail and that is should be done within the default delay (overrule to 5 sec) + 2 sec slack
    mock.assertIsSatisfied();

    long delta = watch.stop();
    assertTrue("Camel should not default poll the mailbox to often", delta > 5000 - 1000L);
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:29,代码来源:MailDefaultDelayForMailConsumeTest.java

示例13: testIdempotent

import org.apache.camel.component.mock.MockEndpoint; //导入方法依赖的package包/类
public void testIdempotent() throws Exception {
    // consume the file the first time
    MockEndpoint mock = getMockEndpoint("mock:result");
    mock.expectedBodiesReceived("Hello World");

    assertMockEndpointsSatisfied();

    oneExchangeDone.matchesMockWaitTime();

    // reset mock and set new expectations
    mock.reset();
    mock.expectedMessageCount(0);

    // move file back
    File file = new File("target/idempotent/done/report.txt");
    File renamed = new File("target/idempotent/report.txt");
    file.renameTo(renamed);

    // should NOT consume the file again, let a bit time pass to let the consumer try to consume it but it should not
    Thread.sleep(100);
    assertMockEndpointsSatisfied();

    FileEndpoint fe = context.getEndpoint(uri, FileEndpoint.class);
    assertNotNull(fe);

    MemoryIdempotentRepository repo = (MemoryIdempotentRepository) fe.getInProgressRepository();
    assertEquals("Should be no in-progress files", 0, repo.getCacheSize());
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:29,代码来源:FileConsumerIdempotentTest.java

示例14: testMarshalXMLSources

import org.apache.camel.component.mock.MockEndpoint; //导入方法依赖的package包/类
@Test
public void testMarshalXMLSources() throws Exception {
    InputStream inStream = getClass().getResourceAsStream("testMessage1.xml");
    DOMSource inDOM = context.getTypeConverter().convertTo(DOMSource.class, inStream);
    inStream = getClass().getResourceAsStream("testMessage1.xml");
    SAXSource inSAX = context.getTypeConverter().convertTo(SAXSource.class, inStream);
    inStream = getClass().getResourceAsStream("testMessage1.xml");
    Document inDocument = context.getTypeConverter().convertTo(Document.class, inStream);

    // save the expected body of the message to set it later
    Object expectedBody = template.requestBody("direct:marshal", inDOM);

    MockEndpoint mockJSON = getMockEndpoint("mock:json");
    // reset the mock endpoint to get rid of the previous message
    mockJSON.reset();
    // all three messages should arrive, should be of type byte[] and
    // identical to one another
    mockJSON.expectedMessageCount(3);
    mockJSON.allMessages().body().isInstanceOf(byte[].class);
    mockJSON.expectedBodiesReceived(Arrays.asList(expectedBody, expectedBody, expectedBody));

    // start bombarding the route
    Object json = template.requestBody("direct:marshal", inDOM);
    String jsonString = context.getTypeConverter().convertTo(String.class, json);
    JSONObject obj = (JSONObject) JSONSerializer.toJSON(jsonString);
    assertEquals("JSONObject doesn't contain 7 keys", 7, obj.entrySet().size());
    template.requestBody("direct:marshal", inSAX);
    template.requestBody("direct:marshal", inDocument);

    mockJSON.assertIsSatisfied();
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:32,代码来源:XmlJsonDataFormatTest.java

示例15: setUp

import org.apache.camel.component.mock.MockEndpoint; //导入方法依赖的package包/类
@Override
public void setUp() throws Exception {
	super.setUp();
    camelContext.addRoutes(new RouteBuilder() {

        @Override
        public void configure() throws Exception {
            from("flowable:HelloCamel:serviceTask1").log(LoggingLevel.INFO, "Received message on service task").to("mock:serviceBehavior");
        }
    });
    service1 = (MockEndpoint) camelContext.getEndpoint("mock:serviceBehavior");
    service1.reset();
}
 
开发者ID:flowable,项目名称:flowable-engine,代码行数:14,代码来源:CdiCamelVariableBodyTest.java


注:本文中的org.apache.camel.component.mock.MockEndpoint.reset方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。