Hi,
I was hoping that someone might help me with at least one of the following 2 problems. I'm hoping that I might just be doing something stupid that is easy to fix! :)
I migrated a play 1.1 project that uses Morphia to play 1.2. One of the new features in play 1.2 is that it allows you to run the unit tests from inside Eclipse - I was quite excited and tried running the very few tests that I had previously created and they worked nicely. I then created a few more tests (everything worked) and then decided to split them up into two separate classes that extend UnitTest. At that point, the tests would fail with the following exception:
> java.lang.UnsupportedOperationException: Please annotate your model with @com.google.code.morphia.annotations.Entity annotation.
> at play.modules.morphia.Model.count(Model.java:399)
> at ModelTest.client(ModelTest.java:20)
> [...]
I thought this was strange and so moved the test back into the other class, where it works just fine. In fact, having the same code in two different test classes makes it work in BasicTest and fail in ModelTest (my new class). This is my first problem, which I can't seem to solve. It is worth mentioning that when using the play testrunner ("play test" and then running the tests in a browser) they all work! Therefore I would argue that this is not Morphia-related. However, if I just copy the existing BasicTest.java the copy runs just fine... does anyone have any ideas?
Now on to my second problem: I thought that maybe the new test file needed to be included in some configuration and so ran "play eclipsify". The result of this was that when I now right-click my project and select run as -> JUnit test, no tests are executed and I receive the following exceptions for all of the present test classes:
> Class not found BasicTest
> java.lang.ClassNotFoundException: BasicTest
> at java.net.URLClassLoader$1.run(Unknown Source)
> at java.security.AccessController.doPrivileged(Native Method)
> at java.net.URLClassLoader.findClass(Unknown Source)
> at java.lang.ClassLoader.loadClass(Unknown Source)
> at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
> at java.lang.ClassLoader.loadClass(Unknown Source)
> at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.loadClass(RemoteTestRunner.java:693)
> at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.loadClasses(RemoteTestRunner.java:429)
> at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:452)
> at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)
> at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)
> at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)
This problem disappears when I select Project -> clean. Running eclipsify again will ruin my test setup again. This problem can also be observed with a new empty project. Steps to reproduce:
"play new myproj"
"play eclipsify myproy"
(import project into eclipse, junit works nicely)
"play eclipsify myproy"
(update eclipse, junit is broken)
Indeed, deleting the project and importing it again fixes the setup (and that is what the message says I should do) - but given that NOTHING has changed in the project between the two runs of "play eclipsify" it seems very difficult to believe that it would have anything to do with dirty caches... cleaning the project also works, but it still seems like odd behaviour. What am I doing wrong here? I'm running Eclipse Helios if that makes any difference.
If anyone could help me with my first problem that would be fantastic and of course if you have some idea what I'm doing wrong with my second problem that would be helpful too :)
Thanks,
Daniel