Issue Details (XML | Word | Printable)

Key: GRAILS-1642
Type: Bug Bug
Status: Open Open
Priority: Major Major
Assignee: Graeme Rocher
Reporter: streborc@gmail.com
Votes: 0
Watchers: 0
Operations

If you were logged in you would be able to see more operations.
Grails

Integration Test not working with existing Tables using hibernate hbm files

Created: 24/Sep/07 10:27 AM   Updated: 24/Sep/07 10:27 AM
Component/s: Testing
Affects Version/s: 0.6-RC1
Fix Version/s: None

Time Tracking:
Not Specified

File Attachments: 1. File myApp.rar (9 kB)

Environment: OS xp 64 bit, java 1.5

Testcase included: yes


 Description  « Hide
When trying to create integration test for existing legacy database schema I cannot instantiate the domain class inside the integration test or with the controller class itself.

ex:
I have a County Domain Class with a corresponding hbm file located in the hiberate directory.
I also have the crud created with generate-all CountyController plus views.
I also have an Integration Test CountyTest that call a method on the CountyController .countyCombo.
The problem is that I cannot create/instantiate the County Object from within the CountyTest integration test and also the countyCombo will not let me create
a County object either. Files are attached but here is the example code from the Integration test CountyTest and the CountyController countyCombo method
I think this must have to do something with the hibernate hbm and how spring is loading it in the context. If I create just a plain domain object using grails it allows me to instantiate it both in the Integration test and the Controller.

class CountyTests extends GroovyTestCase {

void testSomething() { def cc = new CountyController() def cty = new County() // this is not working. Always is null println(cc) def aList = cc.countyCombo() assert(aList.size() == 100) }
}

//CountyController class

def countyCombo = {
def countyList = new ArrayList()
def county = new County() // This does not create a County either
println(county)
countyList = County.findAll() // Here is where I am getting the NullPointerException

LabelValueBean lvb = new LabelValueBean("*Select*", null);
List aList = new ArrayList();
for(County in countyList){ aList.add(new LabelValueBean(County.getName(), County.getId())); }
return aList
}



 All   Comments   Work Log   Change History      Sort Order: Ascending order - Click to sort in descending order
There are no comments yet on this issue.