2 Replies Latest reply on Feb 16, 2008 8:51 PM by maykellff

    problem when runing a test case

    maykellff

      Hi all, i follow all the steps in the JSFUnit documentation site, but when i try to run my first test i get the following error:
      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)
      at org.apache.cactus.internal.client.connector.http.HttpProtocolHandler.runTest_aroundBody1$advice(HttpProtocolHandler.java:288)
      at org.apache.cactus.internal.client.connector.http.HttpProtocolHandler.runTest(HttpProtocolHandler.java)
      at org.apache.cactus.internal.client.ClientTestCaseCaller.runTest(ClientTestCaseCaller.java:144)
      at org.apache.cactus.internal.AbstractCactusTestCase.runBareClient(AbstractCactusTestCase.java:215)
      at org.apache.cactus.internal.AbstractCactusTestCase.runBare(AbstractCactusTestCase.java:133)
      at junit.framework.TestResult$1.protect(TestResult.java:110)
      at junit.framework.TestResult.runProtected(TestResult.java:128)
      at junit.framework.TestResult.run(TestResult.java:113)
      at junit.framework.TestCase.run(TestCase.java:120)
      at junit.framework.TestSuite.runTest(TestSuite.java:228)
      at junit.framework.TestSuite.run(TestSuite.java:223)
      at org.junit.internal.runners.OldTestClassRunner.run(OldTestClassRunner.java:35)
      at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:38)
      at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
      at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:460)
      at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:673)
      at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:386)
      at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:196)

      This is my test class:

      package pruebas;

      import java.io.IOException;

      import javax.faces.component.UIComponent;

      import junit.framework.Test;
      import junit.framework.TestSuite;

      import org.apache.cactus.ServletTestCase;
      import org.jboss.jsfunit.facade.JSFClientSession;
      import org.jboss.jsfunit.facade.JSFServerSession;
      import org.xml.sax.SAXException;

      public class JSFUnitPersonaTest extends ServletTestCase{

      public static Test suite()
      {
      return new TestSuite( JSFUnitPersonaTest.class );
      }

      public void testInitialPage() throws IOException, SAXException
      {
      // Send an HTTP request for the initial page
      JSFClientSession client = new JSFClientSession("comun/escritorioDeTrabajo.jsf");

      // A JSFServerSession gives you access to JSF state
      JSFServerSession server = new JSFServerSession(client);

      // Test navigation to initial viewID
      assertEquals("comun/escritorioDeTrabajo.jsf", server.getCurrentViewID());

      // Assert that the prompt component is in the component tree and rendered
      UIComponent prompt = server.findComponent("escritorioManejado_1");
      assertTrue(prompt.isRendered());

      // Test a managed bean
      //assertEquals("Stan", server.getManagedBeanValue("#{foo.text}"));
      }

      }


      Can any body help me with this issue?

      Thank you in advance,
      Maykell.

        • 1. Re: problem when runing a test case

           

          "maykellff" wrote:

          org.apache.cactus.util.ChainedRuntimeException: Missing Cactus property [cactus.contextURL]


          In your root-directory of the class-path of the test-classes (== the root of the source-directory) create a simple file called cactus.properties. Using standard java-properties format add this property cactus.contextURL. As value use the url of your web-application root.
          Mine looks like this:
          cactus.contextURL=http://localhost:8080/test1/


          • 2. Re: problem when runing a test case
            maykellff

            Thank you very much, everything works just fine now.