I was having the same problem though my stacktrace did not include any references to the surefire libs. Somebody else on this thread had the right instincts I think in that they wondered about whether or not the setUp() method existed.
I don't think it's being executed. I tried with two jdks, jrockit 1.5.1_12 and java 1.6.0_07 to no avail. It wasn't until I included a call to setUp() in the first test that the PersonManagerImplTest would pass. I think there's something fundamentally wrong with the annotations @Before/@After in that they're being ignored apparently in some circumstances. I use Idea and had some issues with Maven until I configured it to use an external version of Maven (2.0.7) for execution. The internal version didn't work well with appfuse. I wonder if there's still some issue with Maven and the Jmock version used? It would seem as though the compiler would be the culprit here but I am not experienced enough to provide anything more substantive to prove it. angela leo wrote: > > Hai, > > I started just few days ago to work with AppFuse.I followed all tutorials > starting from persistence to web.I am using the Appfuse 2.0.2 version and > jmock.version 2.4.0.When running the mvn test -Dtest=PersonManagerImplTest > in the appfuse tutorial, it is showing failure as shown below. Am I > missing something ? > Tests run: 4, Failures: 4, Errors: 0, Time elapsed: 0.095 sec > > class org.apache.maven.surefire.battery.JUnitBattery.testGetPerson() Time > elapsed: 0.034 sec <<< FAILURE! > > [ stdout ] --------------------------------------------------------------- > > [ stderr ] --------------------------------------------------------------- > > [ stacktrace ] ----------------------------------------------------------- > > java.lang.IllegalArgumentException: can only set expectations on mock > objects > at > org.jmock.internal.InvocationExpectationBuilder.captureExpectedObject(InvocationExpectationBuilder.java:67) > at > org.jmock.internal.InvocationExpectationBuilder.of(InvocationExpectationBuilder.java:107) > at org.jmock.Expectations.one(Expectations.java:89) > at > org.appfuse.tutorial.service.impl.PersonManagerImplTest$1.<init>(PersonManagerImplTest.java:53) > at > org.appfuse.tutorial.service.impl.PersonManagerImplTest.testGetPerson(PersonManagerImplTest.java:52) > at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) > at > sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) > at > sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) > at java.lang.reflect.Method.invoke(Method.java:597) > at > org.apache.maven.surefire.battery.AbstractBattery.executeTestMethod(AbstractBattery.java:124) > at > org.apache.maven.surefire.battery.AbstractBattery.executeTestMethods(AbstractBattery.java:70) > at > org.apache.maven.surefire.battery.AbstractBattery.execute(AbstractBattery.java:49) > at > org.apache.maven.surefire.battery.JUnitBattery.execute(JUnitBattery.java:208) > at > org.apache.maven.surefire.Surefire.executeBattery(Surefire.java:217) > at org.apache.maven.surefire.Surefire.run(Surefire.java:165) > at org.apache.maven.surefire.Surefire.run(Surefire.java:89) > at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) > at > sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) > at > sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) > at java.lang.reflect.Method.invoke(Method.java:597) > at > org.apache.maven.surefire.SurefireBooter.runTestsInProcess(SurefireBooter.java:246) > at > org.apache.maven.surefire.SurefireBooter.run(SurefireBooter.java:195) > at > org.apache.maven.test.SurefirePlugin.execute(SurefirePlugin.java:366) > at > org.apache.maven.plugin.DefaultPluginManager.executeMojo(DefaultPluginManager.java:443) > at > org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoals(DefaultLifecycleExecutor.java:539) > at > org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoalWithLifecycle(DefaultLifecycleExecutor.java:480) > at > org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoal(DefaultLifecycleExecutor.java:459) > at > org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoalAndHandleFailures(DefaultLifecycleExecutor.java:311) > at > org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeTaskSegments(DefaultLifecycleExecutor.java:278) > at > org.apache.maven.lifecycle.DefaultLifecycleExecutor.execute(DefaultLifecycleExecutor.java:143) > at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:334) > at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:125) > at org.apache.maven.cli.MavenCli.main(MavenCli.java:280) > at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) > at > sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) > at > sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) > at java.lang.reflect.Method.invoke(Method.java:597) > at > org.codehaus.classworlds.Launcher.launchEnhanced(Launcher.java:315) > at org.codehaus.classworlds.Launcher.launch(Launcher.java:255) > at > org.codehaus.classworlds.Launcher.mainWithExitCode(Launcher.java:430) > at org.codehaus.classworlds.Launcher.main(Launcher.java:375) > > Any ideas or help? Thanks a lot. > Regards. > Angela > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > > > -- View this message in context: http://www.nabble.com/can-only-set-expectations-on-mock-objects-failure-tp19156075s2369p19303420.html Sent from the AppFuse - User mailing list archive at Nabble.com. --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]