我正在尝试在 Mule 3.3 中运行一个简单的功能测试
。下面是我的示例代码:
import java.util.Map;
import org.junit.Test;
import org.mule.api.MuleMessage;
import org.mule.api.client.MuleClient;
import org.mule.tck.junit4.FunctionalTestCase;
import static org.junit.Assert.*;
public class SoapServiceTest extends FunctionalTestCase {
@Override
protected String getConfigResources() {
return "mule-config.xml,core-config.xml";
}
@Test
public void testSend() throws Exception
{
MuleClient client = muleContext.getClient();
String payload = "foo";
Map<String, Object> properties = null;
MuleMessage result = client.send("http://localhost:61005/service", payload, properties);
assertNotNull(result.getPayloadAsString());
}
}
但它会提示 java.lang.NoClassDefFoundError: org/junit/rules/TestRule
。我的类路径中有 junit4.8.1.jar
,但没有 TestRule
类,我猜是 junit4.9
以后的版本。
Mule 需要这个类吗?我没有使用 TestRule
最佳答案
来自 Mule's parent POM :
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.9</version>
</dependency>
是的,无论您是否直接依赖 JUnit 4.9,Mule 都依赖于它。
添加时:
<dependency>
<groupId>org.mule.tests</groupId>
<artifactId>mule-tests-functional</artifactId>
<version>3.3.1</version>
<scope>test</scope>
</dependency>
对于您项目的 POM,应该为您引入 JUnit 4.9。
关于java - Mule FunctionalTestCase 是否需要 org.junit.rules.TestRule 类来运行,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14635581/