jakarta-cactus-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Sachin" <csac...@pisoftek.com>
Subject RE: About TestCases
Date Mon, 04 Aug 2003 12:27:52 GMT
Hi Stefan,
         I have tested my code it is just a Action which is passing control
to Another simple page.

My Actions is in logic.struts.actions
My Forms is in logic.struts.forms
My struts-config.xml is in WEB-INF directory

And Action is passing control to new page.

But when i am running it with mocktestcase or Cactus it is giving error.


I am working on IDEA and direct runnning TestCase...

Can you provide any help i am tired of searching on Net and ALL are
providing same example


public class LoginAction extends Action {
    public ActionForward execute(ActionMapping mapping,ActionForm
form,HttpServletRequest request,

HttpServletResponse response)
        {
            String username = ((LoginForm) form).getFirstName();
            String password = ((LoginForm) form).getLastName();

            ActionErrors errors = new ActionErrors();
            return mapping.findForward("success");
    }
}

this is same as example in StrutsTestCase doc... & tried both with
CactusStrutsTestCase..

public class TestLoginAction extends MockStrutsTestCase {

    public TestLoginAction(String testName) { super(testName); }

    public void testSuccessfulLogin() {
       setRequestPathInfo("/login");
       addRequestParameter("username","deryl");
       addRequestParameter("password","radar");
       actionPerform();
       verifyForward("success");
    }
}


Error:
0 [main] INFO util.PropertyMessageResources  - Initializing,
config='org.apache.struts.util.LocalStrings', returnNull=true
16 [main] INFO util.PropertyMessageResources  - Initializing,
config='org.apache.struts.action.ActionResources', returnNull=true
.F
Time: 0.718
There was 1 failure:
1)
testSuccessfulLogin(logic.struts.actions.TestLoginAction)junit.framework.Ass
ertionFailedError: Error running action.perform(): class
java.lang.NullPointerException - null
	at
servletunit.struts.MockStrutsTestCase.actionPerform(MockStrutsTestCase.java:
339)
	at
logic.struts.actions.TestLoginAction.testSuccessfulLogin(TestLoginAction.jav
a:32)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39
)
	at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl
.java:25)
	at
com.intellij.rt.execution.junit.TextTestRunner.main(TextTestRunner.java:12)

FAILURES!!!
Tests run: 1,  Failures: 1,  Errors: 0

-----Original Message-----
From: Stefan Groschupf [mailto:sg@media-style.com]
Sent: Monday, August 04, 2003 4:56 PM
To: Cactus Users List; csachin@pisoftek.com
Subject: AW: About TestCases


Looks like your test failed since you have an nullpointer exception in your
struts action.
So your test runs but your code not.

May be it make sense to use container tests for your struts class?

Greetings
Stefan

-----Urspr√ľngliche Nachricht-----
Von: Sachin [mailto:csachin@pisoftek.com]
Gesendet: 04 August 2003 12:19
An: Kumar_maniranjan@infosys.com
Betreff: About TestCases

Hello Kumar..

I am part of this forum for 3-4 days but i have as feeling that as compare
to other here activity is too slow and
I am not getting reponse for my question.

I have posted 3 Questions but got no reponse.well ia have just started
testCases with StrutsTestCase which has facility
to write TestCases with cactus but i am not able to test Struts Action with
cactus or with mockObject based approach

Well then i have tried to run Example with testCase but not successful..

So could you guide me where i can get proper feedback on testCases of Struts
with Catus Approach....


if Any body have Any suggestion then plz help me



So can Any body help me in this..


public class TestSampleAction extends MockStrutsTestCase {

    public TestLoginAction(String testName) { super(testName); }

    public void testSuccessfulLogin() {
       setRequestPathInfo("/login");
       addRequestParameter("username","deryl");
       addRequestParameter("password","radar");
       actionPerform();
    }
}


[main] INFO util.PropertyMessageResources  -
Initializing,config='org.apache.struts.util.LocalStrings', returnNull=true
[main] INFO util.PropertyMessageResources  -
Initializing,config='org.apache.struts.action.ActionResources',
returnNull=true

Time: 0.625
There was 1 failure:
1)testAction(logic.struts.actions.TestFirstAction)
junit.framework.AssertionFailedError: Error running action.perform():
classjava.lang.NullPointerException - null
        at
servletunit.struts.MockStrutsTestCase.actionPerform(MockStrutsTestCase.java:
339)
        at
logic.struts.actions.TestFirstAction.testAction(TestFirstAction.java:47)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39
)
        at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl
.java:25)
        at
com.intellij.rt.execution.junit.TextTestRunner.main(TextTestRunner.java:12)
FAILURES!!!




---------------------------------------------------------------------
To unsubscribe, e-mail: cactus-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: cactus-user-help@jakarta.apache.org







Mime
View raw message