为什么我在运行apache camel测试用例时遇到初始化错误?

时间:2017-01-05 11:44:34

标签: eclipse junit apache-camel

我正在使用以下代码来处理基于Apache camel的应用程序。我使用的是JUNIT4和骆驼版2.18。我在Eclipse IDE中运行测试用例。 我正在使用MockEndPoint概念来测试我的API

 package com.service;

import org.apache.camel.*;
import org.apache.camel.builder.RouteBuilder;
import org.apache.camel.component.mock.MockEndpoint;
import org.apache.camel.test.junit4.CamelTestSupport;
import org.junit.Test;

public class FilterTest extends CamelTestSupport {

    @EndpointInject(uri = "mock:result")
    protected MockEndpoint resultEndpoint;

    @Produce(uri = "direct:start")
    protected ProducerTemplate template;

    @Override
    public boolean isDumpRouteCoverage() {
        return true;
    }

    @Test
    public void testSendMatchingMessage() throws Exception {
        String expectedBody = "<matched/>";

        resultEndpoint.expectedBodiesReceived(expectedBody);

        template.sendBodyAndHeader(expectedBody, "foo", "bar");

        resultEndpoint.assertIsSatisfied();
    }

    @Test
    public void testSendNotMatchingMessage() throws Exception {
        resultEndpoint.expectedMessageCount(0);

        template.sendBodyAndHeader("<notMatched/>", "foo", "notMatchedHeaderValue");

        resultEndpoint.assertIsSatisfied();
    }

    @Override
    protected RouteBuilder createRouteBuilder() {
        return new RouteBuilder() {
            public void configure() {
                from("direct:start").filter(header("foo").isEqualTo("bar")).to("mock:result");
            }
        };
    }}

我的错误代码

FilterTest.testSendMatchingMessage
initializationError(org.junit.runner.manipulation.Filter)
java.lang.Exception: No tests found matching [{ExactMatcher:fDisplayName=testSendMatchingMessage], {ExactMatcher:fDisplayName=testSendMatchingMessage(com.service.FilterTest)], {LeadingIdentifierMatcher:fClassName=com.service.FilterTest,fLeadingIdentifier=testSendMatchingMessage]] from org.junit.internal.requests.ClassRequest@255316f2

    at org.junit.internal.requests.FilterRequest.getRunner(FilterRequest.java:40)

0 个答案:

没有答案