You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cactus-user@jakarta.apache.org by Harald Ring <hr...@scoop-gmbh.de> on 2003/02/07 20:28:14 UTC

Missing Cactus property [cactus.contextURL]

Hi all,
I've expirienced some problems by running CactusStrutsTestcases wit Ant:
I have 2 TestCases which extend CactusStrutsTestcase.
TestTermine contains 1 Test and TestLogin contains 2 Tests.
If I run first TestLogin then TestTermine fails with 1 Error,
if I run first TestTermine then TestLogin fails with 2 Errors.
I've setup cactus.properties on the client side.

Here my Target:

    <target depends="cleanTestReports" name="runTests">
        <junit printsummary="yes" haltonfailure="no" fork="no">
            <formatter type="xml"/>
            <classpath>
                <path id="comp.classpath"/>
                <path id="tests.classpath"/>
                <pathelement location="${cactus.lvn.classes.dir}"/>
                <pathelement location="${lvn.classes.dir}"/>
            </classpath>

            <test name="test.testcases.TestTermine"
todir="${cactus.lvn.dir}/testreports"/>
            <test name="test.testcases.TestLogin"
todir="${cactus.lvn.dir}/testreports"/>

            <batchtest fork="no" todir="${cactus.lvn.dir}/testreports">
                <fileset dir="${cactus.lvn.classes.dir}">
                    <!--include name="**/testcases/**/*Test*"/-->
                    <!--include name="**/testcases/**/*TestTermine*"/-->
                    <!--include name="**/testcases/**/*TestLogin*"/-->
                </fileset>
            </batchtest>

        </junit>
        <junitreport todir="${cactus.lvn.dir}/testreports">
            <fileset dir="${cactus.lvn.dir}/testreports">
                <include name="TEST-*.xml"/>
            </fileset>
            <report format="frames" todir="${cactus.lvn.dir}/testreports"/>
        </junitreport>
    </target>

TestLogin
------------------------------------------------------

public class TestLogin extends LvnStrutsTestCase
{

    public TestLogin(String s)
    {
        super(s);
    }

    public void setUp() throws Exception
    {
        super.setUp();
        getLogger().info("test.testcases.TestWebLogin: Ok jetzt geht's
gleich los");
    }


    public void testSuccessfulLogin()
    {
        setRequestPathInfo("/jsp/lvn/login.do");
        addRequestParameter("lbId", "1");
        addRequestParameter("loginname", "tdak");
        addRequestParameter("button", "anmelden");
        addRequestParameter("passwort", "-1234567");
        actionPerform();
        Benutzer b = (Benutzer) getSession().getAttribute("benutzer");
        assertNotNull("Der Benutzer ist nicht in der Session", b);
        if (b.isDez() || b.isSb())
                verifyForward("startingPageSbDez");
        else
                verifyForward("doStartingPage");
        assertEquals("Im Benutzerobjekt ist ein falscher Loginname
enthalten","tdak", ((Benutzer)
getSession().getAttribute("benutzer")).getLoginname());
        verifyNoActionErrors();
    }

     public void endSuccessfulLogin(WebResponse theResponse)
     {
        String responseString = theResponse.getText();
        //getLogger().info("Der ResponseString ist: " + responseString);
     }

    public void testFailedLogin()
    {
        setRequestPathInfo("/jsp/lvn/login.do");
        addRequestParameter("lbId", "1");
        addRequestParameter("loginname", "tdak");
        addRequestParameter("button", "anmelden");
        addRequestParameter("passwort", "+12345699");
        actionPerform();
        verifyForward("login");
        verifyActionErrors(new String[]{"error.password.mismatch"});
        assertNull(getSession().getAttribute("benutzer"));
    }

    public static Test suite()
    {
        TestSuite ts = new TestSuite();
        ts.addTest(new TestLogin("testSuccessfulLogin"));
        ts.addTest(new TestLogin("testFailedLogin"));
        return ts;
    }

    public static void main(String[] args)
    {
        junit.textui.TestRunner.main(new
String[]{TestLogin.class.getName()});
    }
}

TestTermine
------------------------------------------------------
public class TestTermine extends LvnStrutsTestCase
{
    LvnBenutzer benutzer;

    public TestTermine(String s)
    {
        super(s);
    }

    public void setUp() throws Exception
    {
        super.setUp();
        getLogger().info("TestTermine: Ok jetzt geht's gleich los");
        benutzer = LvnApplication.getBenutzerManager().getBenutzer(1,
"tdak", "-1234567");
        assertNotNull("Der im SetUp geholte Benutzer war null", benutzer);
        session.setAttribute("benutzer", benutzer);
    }

    public void testHoleTdakTermine() throws Exception
    {
        setRequestPathInfo("/jsp/lvn/termine.do");
        request.setAttribute("automaticGeneratedOn", "false");
        request.setAttribute("sterminErledigt", "false");
        actionPerform();
        TerminForm tf = (TerminForm)getActionForm();
        verifyNoActionErrors();
        P_Termin[] termine = tf.getTermine();
        assertNotNull("Das TermineArray war null", termine);
        assertTrue("Es wurden mehr als 30 Termine zurückgegeben",
termine.length < 31);
        for (int i = 0; i < termine.length; i++)
        {
            assertEquals("Termin gehört nicht zur LB von " +
benutzer.getFullName(), termine[i].getLbId(), benutzer.getLbId());
            assertFalse("Termin bereits erledigt",
termine[i].isTerminErledigt());
            assertEquals("Termin gehört nicht " + benutzer.getFullName(),
termine[i].getMitarbId(), benutzer.getBenId());
            // ...
        }
    }

    public void endHoleTdakTermine(WebResponse wr)
    {
        assertEquals("Es wurde eine Fehlermeldung zurückgegeben",
wr.getResponseCode(), 200);
    }

    protected void tearDown() throws Exception
    {
       session.removeAttribute("benutzer");
    }

   public static Test suite()
    {
        TestSuite ts = new TestSuite();
        ts.addTest(new TestTermine("testHoleTdakTermine"));
        return ts;
    }

    public static void main(String[] args)
    {
        junit.textui.TestRunner.main(new
String[]{TestTermine.class.getName()});
    }
}

I use junit 3.8.1, Cactus-13-1.4.1 and StrutsTestCase 1.9.5 with Struts 1.01
Has anyone expierienced a similar Problem?
Thanks for your interrest.



Harald Ring                                                               Am
Kielshof 29
SCOOP GmbH                                                          D-51105
Köln
S o f t w a r e                                      Fon: +49 700 SCOOP GmbH
Entwicklung - Beratung - Bewertung                   +49 221 801916- 0
                                                                         +49
221 801916-25
Email: hring@scoop-gmbh.de                      Mobil +49 178 4599751
-----  Besuchen Sie uns im Internet: http://www.scoop-gmbh.de -----

-


RE: Missing Cactus property [cactus.contextURL]

Posted by Vincent Massol <vm...@octo.com>.
Hi Harald,

First question: what's the relation between the subject of this mail and
your problem? :-)

WRT the ordering of Struts tests, I have no clue. Cactus creates a
different HTTP Session for each test and thus there should be no problem
there. In order for us to help you, we would need to see the error
you're getting (stacktrace, console).

Thanks
-Vincent

> -----Original Message-----
> From: Harald Ring [mailto:hring@scoop-gmbh.de]
> Sent: 07 February 2003 20:28
> To: 'Cactus Users List'
> Subject: Missing Cactus property [cactus.contextURL]
> 
> Hi all,
> I've expirienced some problems by running CactusStrutsTestcases wit
Ant:
> I have 2 TestCases which extend CactusStrutsTestcase.
> TestTermine contains 1 Test and TestLogin contains 2 Tests.
> If I run first TestLogin then TestTermine fails with 1 Error,
> if I run first TestTermine then TestLogin fails with 2 Errors.
> I've setup cactus.properties on the client side.
> 
> Here my Target:
> 
>     <target depends="cleanTestReports" name="runTests">
>         <junit printsummary="yes" haltonfailure="no" fork="no">
>             <formatter type="xml"/>
>             <classpath>
>                 <path id="comp.classpath"/>
>                 <path id="tests.classpath"/>
>                 <pathelement location="${cactus.lvn.classes.dir}"/>
>                 <pathelement location="${lvn.classes.dir}"/>
>             </classpath>
> 
>             <test name="test.testcases.TestTermine"
> todir="${cactus.lvn.dir}/testreports"/>
>             <test name="test.testcases.TestLogin"
> todir="${cactus.lvn.dir}/testreports"/>
> 
>             <batchtest fork="no"
todir="${cactus.lvn.dir}/testreports">
>                 <fileset dir="${cactus.lvn.classes.dir}">
>                     <!--include name="**/testcases/**/*Test*"/-->
>                     <!--include
name="**/testcases/**/*TestTermine*"/-->
>                     <!--include name="**/testcases/**/*TestLogin*"/-->
>                 </fileset>
>             </batchtest>
> 
>         </junit>
>         <junitreport todir="${cactus.lvn.dir}/testreports">
>             <fileset dir="${cactus.lvn.dir}/testreports">
>                 <include name="TEST-*.xml"/>
>             </fileset>
>             <report format="frames"
> todir="${cactus.lvn.dir}/testreports"/>
>         </junitreport>
>     </target>
> 
> TestLogin
> ------------------------------------------------------
> 
> public class TestLogin extends LvnStrutsTestCase
> {
> 
>     public TestLogin(String s)
>     {
>         super(s);
>     }
> 
>     public void setUp() throws Exception
>     {
>         super.setUp();
>         getLogger().info("test.testcases.TestWebLogin: Ok jetzt geht's
> gleich los");
>     }
> 
> 
>     public void testSuccessfulLogin()
>     {
>         setRequestPathInfo("/jsp/lvn/login.do");
>         addRequestParameter("lbId", "1");
>         addRequestParameter("loginname", "tdak");
>         addRequestParameter("button", "anmelden");
>         addRequestParameter("passwort", "-1234567");
>         actionPerform();
>         Benutzer b = (Benutzer) getSession().getAttribute("benutzer");
>         assertNotNull("Der Benutzer ist nicht in der Session", b);
>         if (b.isDez() || b.isSb())
>                 verifyForward("startingPageSbDez");
>         else
>                 verifyForward("doStartingPage");
>         assertEquals("Im Benutzerobjekt ist ein falscher Loginname
> enthalten","tdak", ((Benutzer)
> getSession().getAttribute("benutzer")).getLoginname());
>         verifyNoActionErrors();
>     }
> 
>      public void endSuccessfulLogin(WebResponse theResponse)
>      {
>         String responseString = theResponse.getText();
>         //getLogger().info("Der ResponseString ist: " +
responseString);
>      }
> 
>     public void testFailedLogin()
>     {
>         setRequestPathInfo("/jsp/lvn/login.do");
>         addRequestParameter("lbId", "1");
>         addRequestParameter("loginname", "tdak");
>         addRequestParameter("button", "anmelden");
>         addRequestParameter("passwort", "+12345699");
>         actionPerform();
>         verifyForward("login");
>         verifyActionErrors(new String[]{"error.password.mismatch"});
>         assertNull(getSession().getAttribute("benutzer"));
>     }
> 
>     public static Test suite()
>     {
>         TestSuite ts = new TestSuite();
>         ts.addTest(new TestLogin("testSuccessfulLogin"));
>         ts.addTest(new TestLogin("testFailedLogin"));
>         return ts;
>     }
> 
>     public static void main(String[] args)
>     {
>         junit.textui.TestRunner.main(new
> String[]{TestLogin.class.getName()});
>     }
> }
> 
> TestTermine
> ------------------------------------------------------
> public class TestTermine extends LvnStrutsTestCase
> {
>     LvnBenutzer benutzer;
> 
>     public TestTermine(String s)
>     {
>         super(s);
>     }
> 
>     public void setUp() throws Exception
>     {
>         super.setUp();
>         getLogger().info("TestTermine: Ok jetzt geht's gleich los");
>         benutzer = LvnApplication.getBenutzerManager().getBenutzer(1,
> "tdak", "-1234567");
>         assertNotNull("Der im SetUp geholte Benutzer war null",
benutzer);
>         session.setAttribute("benutzer", benutzer);
>     }
> 
>     public void testHoleTdakTermine() throws Exception
>     {
>         setRequestPathInfo("/jsp/lvn/termine.do");
>         request.setAttribute("automaticGeneratedOn", "false");
>         request.setAttribute("sterminErledigt", "false");
>         actionPerform();
>         TerminForm tf = (TerminForm)getActionForm();
>         verifyNoActionErrors();
>         P_Termin[] termine = tf.getTermine();
>         assertNotNull("Das TermineArray war null", termine);
>         assertTrue("Es wurden mehr als 30 Termine zurückgegeben",
> termine.length < 31);
>         for (int i = 0; i < termine.length; i++)
>         {
>             assertEquals("Termin gehört nicht zur LB von " +
> benutzer.getFullName(), termine[i].getLbId(), benutzer.getLbId());
>             assertFalse("Termin bereits erledigt",
> termine[i].isTerminErledigt());
>             assertEquals("Termin gehört nicht " +
benutzer.getFullName(),
> termine[i].getMitarbId(), benutzer.getBenId());
>             // ...
>         }
>     }
> 
>     public void endHoleTdakTermine(WebResponse wr)
>     {
>         assertEquals("Es wurde eine Fehlermeldung zurückgegeben",
> wr.getResponseCode(), 200);
>     }
> 
>     protected void tearDown() throws Exception
>     {
>        session.removeAttribute("benutzer");
>     }
> 
>    public static Test suite()
>     {
>         TestSuite ts = new TestSuite();
>         ts.addTest(new TestTermine("testHoleTdakTermine"));
>         return ts;
>     }
> 
>     public static void main(String[] args)
>     {
>         junit.textui.TestRunner.main(new
> String[]{TestTermine.class.getName()});
>     }
> }
> 
> I use junit 3.8.1, Cactus-13-1.4.1 and StrutsTestCase 1.9.5 with
Struts
> 1.01
> Has anyone expierienced a similar Problem?
> Thanks for your interrest.
> 
> 
> 
> Harald Ring
> Am
> Kielshof 29
> SCOOP GmbH                                                          D-
> 51105
> Köln
> S o f t w a r e                                      Fon: +49 700
SCOOP
> GmbH
> Entwicklung - Beratung - Bewertung                   +49 221 801916- 0
> 
> +49
> 221 801916-25
> Email: hring@scoop-gmbh.de                      Mobil +49 178 4599751
> -----  Besuchen Sie uns im Internet: http://www.scoop-gmbh.de -----
> 
> -
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: cactus-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: cactus-user-help@jakarta.apache.org