I have resolved all NPEs and such and am now able to execute my tests without any errors. BUT, it doesn't look like my action class is even getting called. I have a System.out.println statement at the beginning of the class that should print out but is not.
We are extending the Struts ActionServlet, and I am calling
this.setActionServlet(new CustomActionServlet());
in the setup method. All I get in the output is this:
- ActionServlet: init
- Initializing, config='org.apache.struts.util.LocalStrings', returnNull=true
- Initializing, config='org.apache.struts.action.ActionResources', returnNull=true
- Initializing, config='com.uhg.ut.pbd.bq.standalone.resources.ApplicationResources', returnNull=true
- Tiles definition factory loaded for module ''.
- Loading validation rules file from '/WEB-INF/validator-rules.xml'
- Loading validation rules file from '/WEB-INF/validation.xml'
- Tiles definition factory found for request processor ''.
And the trace is showing:
junit.framework.AssertionFailedError: expected:<0> but was:<>
at junit.framework.Assert.fail(Assert.java:51)
at junit.framework.Assert.failNotEquals(Assert.java:234)
at junit.framework.Assert.assertEquals(Assert.java:68)
at junit.framework.Assert.assertEquals(Assert.java:75)
at test.com.uhg.ut.pbd.bq.standalone.actions.PlanSearchActionTest.testAction(PlanSearchActionTest.java:101)
at java.lang.reflect.Method.invoke(Native Method)
at junit.framework.TestCase.runTest(TestCase.java:166)
at junit.framework.TestCase.runBare(TestCase.java:140)
at junit.framework.TestResult$1.protect(TestResult.java:106)
at junit.framework.TestResult.runProtected(TestResult.java:124)
at junit.framework.TestResult.run(TestResult.java:109)
at junit.framework.TestCase.run(TestCase.java:131)
at junit.framework.TestSuite.runTest(TestSuite.java:173)
at junit.framework.TestSuite.run(TestSuite.java:168)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:392)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:276)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:167)
It tries to evaluate even though it doesn't even call m action class...What am I doing wrong here??
BTW, my web.xml is also set up properly for the custom ActionServlet.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I'm sorry, but this is just wrong. StrutsTestCase works regardless of whether or not you use Action.peform() or Action.execute(). That the method is called actionPerform() is entirely a red herring -- it does not directly call Action.perform() or Action.execute(), but rather delegates to ActionServlet which does its normal thing.
Please clarify your point, because on the surface this seems like dubious advice.
-d.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I have resolved all NPEs and such and am now able to execute my tests without any errors. BUT, it doesn't look like my action class is even getting called. I have a System.out.println statement at the beginning of the class that should print out but is not.
We are extending the Struts ActionServlet, and I am calling
this.setActionServlet(new CustomActionServlet());
in the setup method. All I get in the output is this:
- ActionServlet: init
- Initializing, config='org.apache.struts.util.LocalStrings', returnNull=true
- Initializing, config='org.apache.struts.action.ActionResources', returnNull=true
- Initializing, config='com.uhg.ut.pbd.bq.standalone.resources.ApplicationResources', returnNull=true
- Tiles definition factory loaded for module ''.
- Loading validation rules file from '/WEB-INF/validator-rules.xml'
- Loading validation rules file from '/WEB-INF/validation.xml'
- Tiles definition factory found for request processor ''.
And the trace is showing:
junit.framework.AssertionFailedError: expected:<0> but was:<>
at junit.framework.Assert.fail(Assert.java:51)
at junit.framework.Assert.failNotEquals(Assert.java:234)
at junit.framework.Assert.assertEquals(Assert.java:68)
at junit.framework.Assert.assertEquals(Assert.java:75)
at test.com.uhg.ut.pbd.bq.standalone.actions.PlanSearchActionTest.testAction(PlanSearchActionTest.java:101)
at java.lang.reflect.Method.invoke(Native Method)
at junit.framework.TestCase.runTest(TestCase.java:166)
at junit.framework.TestCase.runBare(TestCase.java:140)
at junit.framework.TestResult$1.protect(TestResult.java:106)
at junit.framework.TestResult.runProtected(TestResult.java:124)
at junit.framework.TestResult.run(TestResult.java:109)
at junit.framework.TestCase.run(TestCase.java:131)
at junit.framework.TestSuite.runTest(TestSuite.java:173)
at junit.framework.TestSuite.run(TestSuite.java:168)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:392)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:276)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:167)
It tries to evaluate even though it doesn't even call m action class...What am I doing wrong here??
BTW, my web.xml is also set up properly for the custom ActionServlet.
Can you post your test case here for us to review?
Could you send me an email of how you got it working? I can't get rid of NPE...
Your action should use perform() method,not excute().
I'm sorry, but this is just wrong. StrutsTestCase works regardless of whether or not you use Action.peform() or Action.execute(). That the method is called actionPerform() is entirely a red herring -- it does not directly call Action.perform() or Action.execute(), but rather delegates to ActionServlet which does its normal thing.
Please clarify your point, because on the surface this seems like dubious advice.
-d.
How did you get rid of NPE ??
Please, send me a e-mail too.
Thanks !
cmagno