Hi Bernd Most likely the error occurs because you trying to do something like resident = dao.getResident(new Long(1)); in your testSaveResident method. But there is no Resident in your dao object. Instead you have to create a Resident to be saved by writing resident = new Resident();
Hope that helps. Stefan cosmonate cosmo wrote: > > well now i get another error :-( > > tests 1 and 3 run successful , but 2 ( testSaveResident in my case) > fails when retrieving object with identifier 1 > > the class is called Resident and getResident() works in test 1 and 3, > but fails in test 2! > > OUTPUT: > test-dao: > [echo] Testing dao... > [junit] [carenet] INFO [main] > ResidentDaoTest.loadContextLocations(136) | Loading context for: > classpath*:/**/dao/applicationContext-*.xml,classpath*:META-INF/ > applicationContext-*.xml > [junit] [carenet] INFO [main] ResidentDaoTest.startNewTransaction > (309) | Began transaction (1): transaction manager > [EMAIL PROTECTED]; > default rollback = true > [junit] [carenet] INFO [main] ResidentDaoTest.endTransaction > (275) | Rolled back transaction after test execution > [junit] [carenet] INFO [main] ResidentDaoTest.startNewTransaction > (309) | Began transaction (1): transaction manager > [EMAIL PROTECTED]; > default rollback = true > [junit] [carenet] INFO [main] ResidentDaoTest.endTransaction > (275) | Rolled back transaction after test execution > [junit] [carenet] INFO [main] ResidentDaoTest.startNewTransaction > (309) | Began transaction (1): transaction manager > [EMAIL PROTECTED]; > default rollback = true > [junit] [carenet] DEBUG [main] > ResidentDaoTest.testAddAndRemoveResident(55) | removing person... > [junit] [carenet] DEBUG [main] > ResidentDaoTest.testAddAndRemoveResident(64) | Expected exception: > Object of class [at.carenet.model.Resident] with identifier [2]: not > found > [junit] [carenet] INFO [main] ResidentDaoTest.endTransaction > (275) | Rolled back transaction after test execution > [junit] Testsuite: at.carenet.dao.ResidentDaoTest > [junit] Tests run: 3, Failures: 0, Errors: 1, Time elapsed: > 7.933 sec > > [junit] ------------- Standard Output --------------- > [junit] [carenet] INFO [main] > ResidentDaoTest.loadContextLocations(136) | Loading context for: > classpath*:/**/dao/applicationContext-*.xml,classpath*:META-INF/ > applicationContext-*.xml > [junit] [carenet] INFO [main] ResidentDaoTest.startNewTransaction > (309) | Began transaction (1): transaction manager > [EMAIL PROTECTED]; > default rollback = true > [junit] [carenet] INFO [main] ResidentDaoTest.endTransaction > (275) | Rolled back transaction after test execution > [junit] [carenet] INFO [main] ResidentDaoTest.startNewTransaction > (309) | Began transaction (1): transaction manager > [EMAIL PROTECTED]; > default rollback = true > [junit] [carenet] INFO [main] ResidentDaoTest.endTransaction > (275) | Rolled back transaction after test execution > [junit] [carenet] INFO [main] ResidentDaoTest.startNewTransaction > (309) | Began transaction (1): transaction manager > [EMAIL PROTECTED]; > default rollback = true > [junit] [carenet] DEBUG [main] > ResidentDaoTest.testAddAndRemoveResident(55) | removing person... > [junit] [carenet] DEBUG [main] > ResidentDaoTest.testAddAndRemoveResident(64) | Expected exception: > Object of class [at.carenet.model.Resident] with identifier [2]: not > found > [junit] [carenet] INFO [main] ResidentDaoTest.endTransaction > (275) | Rolled back transaction after test execution > [junit] ------------- ---------------- --------------- > [junit] Testcase: testSaveResident > (at.carenet.dao.ResidentDaoTest): Caused an ERROR > [junit] Object of class [at.carenet.model.Resident] with > identifier [1]: not found > [junit] org.springframework.orm.ObjectRetrievalFailureException: > Object of class [at.carenet.model.Resident] with identifier [1]: not > found > [junit] at > at.carenet.dao.hibernate.ResidentDaoHibernate.getResident > (ResidentDaoHibernate.java:13) > [junit] at at.carenet.dao.ResidentDaoTest.testSaveResident > (ResidentDaoTest.java:29) > [junit] at > org.springframework.test.ConditionalTestCase.runBare > (ConditionalTestCase.java:69) > > > [junit] Test at.carenet.dao.ResidentDaoTest FAILED > > BUILD FAILED > /Users/bernd/Projects/carenet/build.xml:269: The following error > occurred while executing this line: > /Users/bernd/Projects/carenet/build.xml:540: Unit tests failed. For > error messages, check the log files in > /Users/bernd/Projects/carenet/build/test/data or run > "ant test-reports" > to generate reports at /Users/bernd/Projects/carenet/ > build/test/reports. > > > i checked if the id of the object created in test 1 is 1 and it > seemed so when calling resident.getId() after dao.getResident() > could it be that due to the rollback after test 1 the object is > removed from the dabase so there is no object in the database with > identifier 1 or what else could cause this error? > > bernd > > --------------------------------------------------------------------- > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > > > -- View this message in context: http://www.nabble.com/testSave-fails%3A-ObjectRetrievalFailureException-tf2944871s2369.html#a8297472 Sent from the AppFuse - User mailing list archive at Nabble.com. --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
