2015-05-04 63 views
0

我在蝕食中寫仙人掌測試。我已經添加了所需的jar文件。仙人掌屬性缺失[cactus.contextURL]

但是當我使用的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"); 
} 


} 

回答

0

終於在beginFirst添加以下行解決了它()

System.setProperty("cactus.contextURL","http://localhost:8080/test");