缺少仙人掌属性[cactus.contextURL]

时间:2015-05-04 09:29:29

标签: java junit cactus

我在日食中写仙人掌测试。我添加了必需的jar文件。

但是当我使用RunAs运行我的代码时 - > JUnit测试,我收到了错误

我在cactus.properties文件中添加了“cactus.contextURL = http://localhost:8080/test”。

请帮我解决这里的错误

我收到错误

org.apache.cactus.util.ChainedRuntimeException: Missing Cactus property
[cactus.contextURL]
    at
org.apache.cactus.internal.configuration.BaseConfiguration.getContextURL(BaseConfiguration.java:59)
    at
org.apache.cactus.internal.configuration.AbstractWebConfiguration.getRedirectorURL_aroundBody0(AbstractWebConfiguration.java:46)
    at
org.apache.cactus.internal.configuration.AbstractWebConfiguration.getRedirectorURL_aroundBody1$advice(AbstractWebConfiguration.java:288)
    at
org.apache.cactus.internal.configuration.AbstractWebConfiguration.getRedirectorURL(AbstractWebConfiguration.java)
    at
org.apache.cactus.internal.client.connector.http.DefaultHttpClient.callRunTest(DefaultHttpClient.java:159)
    at
org.apache.cactus.internal.client.connector.http.DefaultHttpClient.doTest_aroundBody0(DefaultHttpClient.java:80)
    at
org.apache.cactus.internal.client.connector.http.DefaultHttpClient.doTest_aroundBody1$advice(DefaultHttpClient.java:288)
    at
org.apache.cactus.internal.client.connector.http.DefaultHttpClient.doTest(DefaultHttpClient.java)
    at
org.apache.cactus.internal.client.connector.http.HttpProtocolHandler.runWebTest(HttpProtocolHandler.java:159)
    at
org.apache.cactus.internal.client.connector.http.HttpProtocolHandler.runTest_aroundBody0(HttpProtocolHandler.java:80)

我的代码是

package com.xtremum.taskapplication;

import org.apache.cactus.ServletTestCase;
import org.apache.cactus.WebRequest;
import org.apache.cactus.WebResponse;
import org.junit.Test;


public class CactusServletTest extends ServletTestCase{


public void beginFirst(WebRequest theRequest){

    theRequest.setURL( "localhost:8080", "/CactusTest", "/CactusTestServlet", null, null );
    System.out.println("in setup");
}

public void testFirst() throws Exception {

    assertEquals("Hello Earth!", "ni");
}

public void endFirst(WebResponse theResponse){
    System.out.println("in tear down");
}


}

1 个答案:

答案 0 :(得分:0)

最后通过在beginFirst()

中添加以下行来解决它
System.setProperty("cactus.contextURL","http://localhost:8080/test");