May 20th, 2010, 04:46 PM
Integration Tests and DataOnDemand classes
I'm new to pretty much everything Roo and am having trouble with an integration test. I've searched the Roo docs and this forum, but can't find anything that seems related.
I can see in the .aj file that the tested entity's DataOnDemand class is being autowired in to the basic integration tests that Roo provides, but I don't seem to have access to it in the base *IntegrationTest.java file. Every time I try to access the dod object, STS(eclipse) tells me that is isn't visible to me.
If I push-in the aspects, I can use it with no problems. Is this an intended behavior? Or am I missing something trivial?
I can provide more info, if needed.
May 23rd, 2010, 07:06 PM
You should be able to open/edit the *IntegrationTest and *DataOnDemand Java files. It could be a glitch in AJDT if you're on an old version. Are you on STS 2.3.3.M1 (which has the latest AJDT)? Also ensure you have switched on JDT weaving (you can check this under Window > Preferences by searching for JDT).
May 23rd, 2010, 08:17 PM
Just FYI, I have STS 2.3.3.M1 and Spring Roo 1.1.0.M1, and I cannot access the DataOnDemand feature.
So, in that same vein…
I wanted to write an integration test that exercised a ManyToMany relationship - the current DataOnDemand structure doesn't do this.
I tried several things with my own JUnit test, including:
- @RooIntegrationTest, this only allows a single entity = parameter
- Accessing the DataOnDemand class directly - none of the static methods were woven into the IDE - they may have worked from a Maven build, but I am unclear on why they were not accessible.
Finally, I was able to use the Spring JUnit 4 testing framework, inject an EntityManager, and everything worked just fine.
Is this related to the original poster's question? How can we create tests that have access to the DataOnDemand classes directly for our own testing purposes (or should we)? Or, are you planning on supporting @RooIntegrationTest methods for ManyToMany associations automatically in a future release?
May 23rd, 2010, 10:16 PM
Thanks for replying, turns out the disconnect was in my way of thinking. I looked into the *_Roo_IntegrationTest.aj file for "inspiration" on how Spring/Roo was expecting me to build these tests.
In this file was an @autowired DoD object named *.dod ( say @Autowired TestUserDataOnDemaned TestUserIntegrationTest.dod ). I was trying to directly use that *.dod object in the TestUserIntegrationTest.java, where I kept getting told it was invisible.
By instantiating a TestUserDataOnDemand object of my own in the TestUserIntegration.java file, I found that I could indeed use it with no issues. Looks like I'll be reading more on Spring's AOP, DI, and @Autowired, and JUnit testing soon
Thanks again, and sorry to bother you!
BTW, Roo is a really great piece of work, thanks!
May 25th, 2010, 06:34 PM
Morgan, glad you got it working. Thanks for your nice comments about Roo, too. :-)
Ken, the use case of using data on demand for your own tests is not presently supported. There's a Wave going on where I brainstormed some alternative ideas for seed data generation and population - much better than what we presently do in DOD. The real problem is I'm flooded with other work for a while. So you can likely expect to see a seriously better DOD model in a future version, but for Roo 1.1.0 it'll very likely stay as-is.
Tags for this Thread