Hi matt, thanks for following me.
After lots of trying, I had no luck with full-source.
So i am going step by step and following book AppFuse Primer
I have written Vehicle class and VehicleMaintenance class,VehicleDao
interface, VehicleDaoHibernate class
as given in book.
I am getting test errors
Here is a test report
spsarolkar wrote:
>
> -------------------------------------------------------------------------------
> Test set: org.xinus.crud.dao.VehicleDaoTest
> -------------------------------------------------------------------------------
> Tests run: 7, Failures: 2, Errors: 5, Skipped: 0, Time elapsed: 13.35 sec
> <<< FAILURE!
> testAddVehicle(org.xinus.crud.dao.VehicleDaoTest) Time elapsed: 12.186
> sec <<< FAILURE!
> junit.framework.AssertionFailedError: null
> at junit.framework.Assert.fail(Assert.java:47)
> at junit.framework.Assert.assertTrue(Assert.java:20)
> at junit.framework.Assert.assertNotNull(Assert.java:214)
> at junit.framework.Assert.assertNotNull(Assert.java:207)
> at
> org.xinus.crud.dao.VehicleDaoTest.testAddVehicle(VehicleDaoTest.java:36)
> 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 junit.framework.TestCase.runTest(TestCase.java:168)
> at junit.framework.TestCase.runBare(TestCase.java:134)
> at
> org.springframework.test.ConditionalTestCase.runBare(ConditionalTestCase.java:76)
> at junit.framework.TestResult$1.protect(TestResult.java:110)
> at junit.framework.TestResult.runProtected(TestResult.java:128)
> at junit.framework.TestResult.run(TestResult.java:113)
> at junit.framework.TestCase.run(TestCase.java:124)
> at junit.framework.TestSuite.runTest(TestSuite.java:232)
> at junit.framework.TestSuite.run(TestSuite.java:227)
> at
> org.junit.internal.runners.JUnit38ClassRunner.run(JUnit38ClassRunner.java:81)
> at
> org.apache.maven.surefire.junit4.JUnit4TestSet.execute(JUnit4TestSet.java:62)
> at
> org.apache.maven.surefire.suite.AbstractDirectoryTestSuite.executeTestSet(AbstractDirectoryTestSuite.java:140)
> at
> org.apache.maven.surefire.suite.AbstractDirectoryTestSuite.execute(AbstractDirectoryTestSuite.java:127)
> at org.apache.maven.surefire.Surefire.run(Surefire.java:177)
> 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.booter.SurefireBooter.runSuitesInProcess(SurefireBooter.java:345)
> at
> org.apache.maven.surefire.booter.SurefireBooter.main(SurefireBooter.java:1009)
>
> testGetChildren(org.xinus.crud.dao.VehicleDaoTest) Time elapsed: 0.159
> sec <<< ERROR!
> org.springframework.orm.ObjectRetrievalFailureException: Object of class
> [org.xinus.crud.model.Vehicle] with identifier [1]: not found
> at
> org.appfuse.dao.hibernate.GenericDaoHibernate.get(GenericDaoHibernate.java:75)
> at
> org.xinus.crud.dao.hibernate.VehicleDaoHibernate.getAllChildren(VehicleDaoHibernate.java:21)
> at
> org.xinus.crud.dao.VehicleDaoTest.testGetChildren(VehicleDaoTest.java:41)
> 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 junit.framework.TestCase.runTest(TestCase.java:168)
> at junit.framework.TestCase.runBare(TestCase.java:134)
> at
> org.springframework.test.ConditionalTestCase.runBare(ConditionalTestCase.java:76)
> at junit.framework.TestResult$1.protect(TestResult.java:110)
> at junit.framework.TestResult.runProtected(TestResult.java:128)
> at junit.framework.TestResult.run(TestResult.java:113)
> at junit.framework.TestCase.run(TestCase.java:124)
> at junit.framework.TestSuite.runTest(TestSuite.java:232)
> at junit.framework.TestSuite.run(TestSuite.java:227)
> at
> org.junit.internal.runners.JUnit38ClassRunner.run(JUnit38ClassRunner.java:81)
> at
> org.apache.maven.surefire.junit4.JUnit4TestSet.execute(JUnit4TestSet.java:62)
> at
> org.apache.maven.surefire.suite.AbstractDirectoryTestSuite.executeTestSet(AbstractDirectoryTestSuite.java:140)
> at
> org.apache.maven.surefire.suite.AbstractDirectoryTestSuite.execute(AbstractDirectoryTestSuite.java:127)
> at org.apache.maven.surefire.Surefire.run(Surefire.java:177)
> 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.booter.SurefireBooter.runSuitesInProcess(SurefireBooter.java:345)
> at
> org.apache.maven.surefire.booter.SurefireBooter.main(SurefireBooter.java:1009)
>
> testGetVehicle(org.xinus.crud.dao.VehicleDaoTest) Time elapsed: 0.08 sec
> <<< ERROR!
> org.springframework.orm.ObjectRetrievalFailureException: Object of class
> [org.xinus.crud.model.Vehicle] with identifier [1]: not found
> at
> org.appfuse.dao.hibernate.GenericDaoHibernate.get(GenericDaoHibernate.java:75)
> at
> org.xinus.crud.dao.VehicleDaoTest.testGetVehicle(VehicleDaoTest.java:48)
> 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 junit.framework.TestCase.runTest(TestCase.java:168)
> at junit.framework.TestCase.runBare(TestCase.java:134)
> at
> org.springframework.test.ConditionalTestCase.runBare(ConditionalTestCase.java:76)
> at junit.framework.TestResult$1.protect(TestResult.java:110)
> at junit.framework.TestResult.runProtected(TestResult.java:128)
> at junit.framework.TestResult.run(TestResult.java:113)
> at junit.framework.TestCase.run(TestCase.java:124)
> at junit.framework.TestSuite.runTest(TestSuite.java:232)
> at junit.framework.TestSuite.run(TestSuite.java:227)
> at
> org.junit.internal.runners.JUnit38ClassRunner.run(JUnit38ClassRunner.java:81)
> at
> org.apache.maven.surefire.junit4.JUnit4TestSet.execute(JUnit4TestSet.java:62)
> at
> org.apache.maven.surefire.suite.AbstractDirectoryTestSuite.executeTestSet(AbstractDirectoryTestSuite.java:140)
> at
> org.apache.maven.surefire.suite.AbstractDirectoryTestSuite.execute(AbstractDirectoryTestSuite.java:127)
> at org.apache.maven.surefire.Surefire.run(Surefire.java:177)
> 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.booter.SurefireBooter.runSuitesInProcess(SurefireBooter.java:345)
> at
> org.apache.maven.surefire.booter.SurefireBooter.main(SurefireBooter.java:1009)
>
> testGetVehicles(org.xinus.crud.dao.VehicleDaoTest) Time elapsed: 0.437
> sec <<< FAILURE!
> junit.framework.AssertionFailedError: null
> at junit.framework.Assert.fail(Assert.java:47)
> at junit.framework.Assert.assertTrue(Assert.java:20)
> at junit.framework.Assert.assertTrue(Assert.java:27)
> at
> org.xinus.crud.dao.VehicleDaoTest.testGetVehicles(VehicleDaoTest.java:54)
> 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 junit.framework.TestCase.runTest(TestCase.java:168)
> at junit.framework.TestCase.runBare(TestCase.java:134)
> at
> org.springframework.test.ConditionalTestCase.runBare(ConditionalTestCase.java:76)
> at junit.framework.TestResult$1.protect(TestResult.java:110)
> at junit.framework.TestResult.runProtected(TestResult.java:128)
> at junit.framework.TestResult.run(TestResult.java:113)
> at junit.framework.TestCase.run(TestCase.java:124)
> at junit.framework.TestSuite.runTest(TestSuite.java:232)
> at junit.framework.TestSuite.run(TestSuite.java:227)
> at
> org.junit.internal.runners.JUnit38ClassRunner.run(JUnit38ClassRunner.java:81)
> at
> org.apache.maven.surefire.junit4.JUnit4TestSet.execute(JUnit4TestSet.java:62)
> at
> org.apache.maven.surefire.suite.AbstractDirectoryTestSuite.executeTestSet(AbstractDirectoryTestSuite.java:140)
> at
> org.apache.maven.surefire.suite.AbstractDirectoryTestSuite.execute(AbstractDirectoryTestSuite.java:127)
> at org.apache.maven.surefire.Surefire.run(Surefire.java:177)
> 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.booter.SurefireBooter.runSuitesInProcess(SurefireBooter.java:345)
> at
> org.apache.maven.surefire.booter.SurefireBooter.main(SurefireBooter.java:1009)
>
> testAddVehicleMaintenance(org.xinus.crud.dao.VehicleDaoTest) Time
> elapsed: 0.085 sec <<< ERROR!
> org.springframework.orm.ObjectRetrievalFailureException: Object of class
> [org.xinus.crud.model.Vehicle] with identifier [1]: not found
> at
> org.appfuse.dao.hibernate.GenericDaoHibernate.get(GenericDaoHibernate.java:75)
> at
> org.xinus.crud.dao.VehicleDaoTest.testAddVehicleMaintenance(VehicleDaoTest.java:57)
> 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 junit.framework.TestCase.runTest(TestCase.java:168)
> at junit.framework.TestCase.runBare(TestCase.java:134)
> at
> org.springframework.test.ConditionalTestCase.runBare(ConditionalTestCase.java:76)
> at junit.framework.TestResult$1.protect(TestResult.java:110)
> at junit.framework.TestResult.runProtected(TestResult.java:128)
> at junit.framework.TestResult.run(TestResult.java:113)
> at junit.framework.TestCase.run(TestCase.java:124)
> at junit.framework.TestSuite.runTest(TestSuite.java:232)
> at junit.framework.TestSuite.run(TestSuite.java:227)
> at
> org.junit.internal.runners.JUnit38ClassRunner.run(JUnit38ClassRunner.java:81)
> at
> org.apache.maven.surefire.junit4.JUnit4TestSet.execute(JUnit4TestSet.java:62)
> at
> org.apache.maven.surefire.suite.AbstractDirectoryTestSuite.executeTestSet(AbstractDirectoryTestSuite.java:140)
> at
> org.apache.maven.surefire.suite.AbstractDirectoryTestSuite.execute(AbstractDirectoryTestSuite.java:127)
> at org.apache.maven.surefire.Surefire.run(Surefire.java:177)
> 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.booter.SurefireBooter.runSuitesInProcess(SurefireBooter.java:345)
> at
> org.apache.maven.surefire.booter.SurefireBooter.main(SurefireBooter.java:1009)
>
> testSaveVehicle(org.xinus.crud.dao.VehicleDaoTest) Time elapsed: 0.05 sec
> <<< ERROR!
> org.springframework.orm.ObjectRetrievalFailureException: Object of class
> [org.xinus.crud.model.Vehicle] with identifier [1]: not found
> at
> org.appfuse.dao.hibernate.GenericDaoHibernate.get(GenericDaoHibernate.java:75)
> at
> org.xinus.crud.dao.VehicleDaoTest.testSaveVehicle(VehicleDaoTest.java:72)
> 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 junit.framework.TestCase.runTest(TestCase.java:168)
> at junit.framework.TestCase.runBare(TestCase.java:134)
> at
> org.springframework.test.ConditionalTestCase.runBare(ConditionalTestCase.java:76)
> at junit.framework.TestResult$1.protect(TestResult.java:110)
> at junit.framework.TestResult.runProtected(TestResult.java:128)
> at junit.framework.TestResult.run(TestResult.java:113)
> at junit.framework.TestCase.run(TestCase.java:124)
> at junit.framework.TestSuite.runTest(TestSuite.java:232)
> at junit.framework.TestSuite.run(TestSuite.java:227)
> at
> org.junit.internal.runners.JUnit38ClassRunner.run(JUnit38ClassRunner.java:81)
> at
> org.apache.maven.surefire.junit4.JUnit4TestSet.execute(JUnit4TestSet.java:62)
> at
> org.apache.maven.surefire.suite.AbstractDirectoryTestSuite.executeTestSet(AbstractDirectoryTestSuite.java:140)
> at
> org.apache.maven.surefire.suite.AbstractDirectoryTestSuite.execute(AbstractDirectoryTestSuite.java:127)
> at org.apache.maven.surefire.Surefire.run(Surefire.java:177)
> 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.booter.SurefireBooter.runSuitesInProcess(SurefireBooter.java:345)
> at
> org.apache.maven.surefire.booter.SurefireBooter.main(SurefireBooter.java:1009)
>
> testRemoveVehicle(org.xinus.crud.dao.VehicleDaoTest) Time elapsed: 0.023
> sec <<< ERROR!
> org.springframework.orm.ObjectRetrievalFailureException: Object of class
> [org.xinus.crud.model.Vehicle] with identifier [1]: not found
> at
> org.appfuse.dao.hibernate.GenericDaoHibernate.get(GenericDaoHibernate.java:75)
> at
> org.appfuse.dao.hibernate.GenericDaoHibernate.remove(GenericDaoHibernate.java:102)
> at
> org.xinus.crud.dao.VehicleDaoTest.testRemoveVehicle(VehicleDaoTest.java:77)
> 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 junit.framework.TestCase.runTest(TestCase.java:168)
> at junit.framework.TestCase.runBare(TestCase.java:134)
> at
> org.springframework.test.ConditionalTestCase.runBare(ConditionalTestCase.java:76)
> at junit.framework.TestResult$1.protect(TestResult.java:110)
> at junit.framework.TestResult.runProtected(TestResult.java:128)
> at junit.framework.TestResult.run(TestResult.java:113)
> at junit.framework.TestCase.run(TestCase.java:124)
> at junit.framework.TestSuite.runTest(TestSuite.java:232)
> at junit.framework.TestSuite.run(TestSuite.java:227)
> at
> org.junit.internal.runners.JUnit38ClassRunner.run(JUnit38ClassRunner.java:81)
> at
> org.apache.maven.surefire.junit4.JUnit4TestSet.execute(JUnit4TestSet.java:62)
> at
> org.apache.maven.surefire.suite.AbstractDirectoryTestSuite.executeTestSet(AbstractDirectoryTestSuite.java:140)
> at
> org.apache.maven.surefire.suite.AbstractDirectoryTestSuite.execute(AbstractDirectoryTestSuite.java:127)
> at org.apache.maven.surefire.Surefire.run(Surefire.java:177)
> 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.booter.SurefireBooter.runSuitesInProcess(SurefireBooter.java:345)
> at
> org.apache.maven.surefire.booter.SurefireBooter.main(SurefireBooter.java:1009)
>
>
Here is my VehicleDaoTest
spsarolkar wrote:
>
> package org.xinus.crud.dao;
>
> import org.xinus.crud.model.Vehicle;
> import org.xinus.crud.model.VehicleMaintenance;
> import org.appfuse.dao.BaseDaoTestCase;
> import org.springframework.orm.ObjectRetrievalFailureException;
>
> import java.util.List;
> import java.util.Iterator;
>
> /**
> * Created by IntelliJ IDEA.
> * User: mypc
> * Date: Jul 29, 2009
> * Time: 6:59:18 AM
> * To change this template use File | Settings | File Templates.
> */
> public class VehicleDaoTest extends BaseDaoTestCase {
> private Long vehicleId = new Long(1);
> private VehicleDao<Vehicle,Long> vehicleDao = null;
>
> public void setVehicleDao(VehicleDao<Vehicle, Long> vehicleDao) {
> this.vehicleDao = vehicleDao;
> }
> public void testAddVehicle() throws Exception{
> System.out.println("Test: Add Vehicle");
> Vehicle vehicle = new Vehicle();
> vehicle.setName("David's Truck");
> vehicle.setMake("Ford");
> vehicle.setModel("F-150");
> vehicle.setYear("1995");
> vehicle.setVIN("12345ABCDEF");
> vehicleDao.save(vehicle);
>
> System.out.println("Vehicle added "+vehicle.getId());
> assertNotNull(vehicle.getId());
> assertEquals(vehicle.getName(),"David's Truck");
> }
> public void testGetChildren() throws Exception{
> System.out.println("Test: Get children");
> List list = vehicleDao.getAllChildren(vehicleId);
> for(Iterator iter = list.iterator();iter.hasNext();){
> VehicleMaintenance
> vehicleMaintenance=(VehicleMaintenance)iter.next();
> System.out.println("Dao GetChildrenTest:" +
> vehicleMaintenance.getName());
> }
> }
> public void testGetVehicle()throws Exception{
> Vehicle vehicle = (Vehicle) vehicleDao.get(vehicleId);
> assertNotNull(vehicle);
> }
> public void testGetVehicles() throws Exception{
> Vehicle vehicle = new Vehicle();
> List results = vehicleDao.getAll();
> assertTrue(results.size()>0);
> }
> public void testAddVehicleMaintenance()throws Exception{
> Vehicle vehicle = (Vehicle) vehicleDao.get(vehicleId);
> VehicleMaintenance vehicleMaintenance=new VehicleMaintenance();
> vehicleMaintenance.setName("Oil Change");
> vehicle.getVehicleMaintenances().add(vehicleMaintenance);
> vehicleDao.save(vehicle);
> vehicle=null;
> vehicle= (Vehicle) vehicleDao.get(vehicleId);
> List list = vehicle.getVehicleMaintenances();
> assertTrue(list.size()>0);
> }
> public void getVehicleMaintenance() throws Exception{
> List results = vehicleDao.getAllChildren(vehicleId);
> assertTrue(results.size()>0);
> }
> public void testSaveVehicle() throws Exception{
> Vehicle vehicle = (Vehicle) vehicleDao.get(vehicleId);
> vehicleDao.save(vehicle);
> }
> public void testRemoveVehicle() throws Exception{
> Long removeId = new Long("1");
> vehicleDao.remove(removeId);
> try{
> Vehicle vehicle = (Vehicle) vehicleDao.get(removeId);
> fail("Vehicle found in database");
> }catch(ObjectRetrievalFailureException e){
> assertNotNull(e.getMessage());
> }
> }
> }
>
Here is my application context.xml
spsarolkar wrote:
>
> <?xml version="1.0" encoding="UTF-8"?>
> <beans xmlns="http://www.springframework.org/schema/beans"
> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
> xsi:schemaLocation="http://www.springframework.org/schema/beans
> http://www.springframework.org/schema/beans/spring-beans-2.0.xsd"
> default-lazy-init="true">
> <bean class="org.appfuse.dao.spring.HibernateExtensionPostProcessor">
> <property name="annotatedClasses">
> <list>
> <value>org.xinus.crud.model.Vehicle</value>
> <value>org.xinus.crud.model.VehicleMaintenance</value>
> </list>
> </property>
> </bean>
> <bean id="vehicleManager"
> class="org.appfuse.service.impl.GenericManagerImpl">
> <constructor-arg>
> <bean class="org.appfuse.dao.hibernate.GenericDaoHibernate"
> autowire="byType">
> <constructor-arg
> value="org.xinus.crud.model.Vehicle"/>
> </bean>
> </constructor-arg>
> </bean>
> <bean id="vehicleAction" class="org.xinus.crud.action.VehicleAction"
> scope="prototype">
> <property name="vehicleManager" ref="vehicleManager"/>
> </bean>
> <bean id="vehicleDao"
> class="org.xinus.crud.dao.hibernate.VehicleDaoHibernate">
> <property name="sessionFactory" ref="sessionFactory"/>
> </bean>
> <bean id="vehicleActionTest"
> class="org.xinus.crud.dao.VehicleDaoTest">
> <property name="vehicleDao" ref="vehicleDao"/>
> </bean>
> <!-- Add new DAOs here -->
>
> <!-- Add new Managers here -->
>
> <!-- Add new Actions here -->
> </beans>
>
For applicationContext.xml
Idea is showing
.
.
.
<bean id="vehicleActionTest" class="org.xinus.crud.dao.VehicleDaoTest">
<property name="vehicleDao" ref="vehicleDao"/>
</bean>
.
.
.
Cannot resolve property vehicleDao at...name=vehicleDao...
But i have setVehicleDao in my VehicleDaoTest
When i run mvn clean test -Dusefile=false -Dtest="VehicleDaoTest"
I get output as
spsarolkar wrote:
>
> C:\Users\mypc\IdeaProjects\myapp>mvn clean test -Dusefile=false
> -Dtest="VehicleDaoTest"
> [INFO] Scanning for projects...
> [INFO]
> ------------------------------------------------------------------------
> [INFO] Building AppFuse Struts 2 Application
> [INFO] task-segment: [clean, test]
> [INFO]
> ------------------------------------------------------------------------
> [INFO] [clean:clean {execution: default-clean}]
> [INFO] Deleting directory C:\Users\mypc\IdeaProjects\myapp\target
> [WARNING] POM for 'xfire:xfire-jsr181-api:pom:1.0-M1:compile' is invalid.
>
> Its dependencies (if any) will NOT be available to the current build.
> [INFO] [warpath:add-classes {execution: default}]
> [INFO] [aspectj:compile {execution: default}]
> [INFO] [native2ascii:native2ascii {execution: native2ascii-utf8}]
> [INFO] [native2ascii:native2ascii {execution: native2ascii-8859_1}]
> [INFO] [resources:resources {execution: default-resources}]
> [WARNING] File encoding has not been set, using platform encoding Cp1252,
> i.e. build is platform dependent!
> [WARNING] Using platform encoding (Cp1252 actually) to copy filtered
> resources, i.e. build is platform dependent!
> [INFO] Copying 13 resources
> [INFO] Copying 2 resources
> [INFO] Copying 33 resources
> [INFO] Copying 33 resources
> [INFO] [compiler:compile {execution: default-compile}]
> [INFO] Nothing to compile - all classes are up to date
> [INFO] [resources:testResources {execution: default-testResources}]
> [WARNING] File encoding has not been set, using platform encoding Cp1252,
> i.e. build is platform dependent!
> [WARNING] Using platform encoding (Cp1252 actually) to copy filtered
> resources, i.e. build is platform dependent!
> [INFO] Copying 4 resources
> [INFO] Copying 25 resources
> [INFO] Preparing hibernate3:hbm2ddl
> [WARNING] Removing: hbm2ddl from forked lifecycle, to prevent recursive
> invocation.
> [INFO] [warpath:add-classes {execution: default}]
> [INFO] [aspectj:compile {execution: default}]
> [INFO] [native2ascii:native2ascii {execution: native2ascii-utf8}]
> [INFO] [native2ascii:native2ascii {execution: native2ascii-8859_1}]
> [INFO] [resources:resources {execution: default-resources}]
> [WARNING] File encoding has not been set, using platform encoding Cp1252,
> i.e. build is platform dependent!
> [WARNING] Using platform encoding (Cp1252 actually) to copy filtered
> resources, i.e. build is platform dependent!
> [INFO] Copying 13 resources
> [INFO] Copying 2 resources
> [INFO] Copying 33 resources
> [INFO] Copying 33 resources
> [INFO] Copying 33 resources
> [INFO] Copying 33 resources
> [INFO] [hibernate3:hbm2ddl {execution: default}]
> [INFO] Configuration XML file loaded:
> file:/C:/Users/mypc/IdeaProjects/myapp/src/main/resources/hibernate.cfg.xml
> log4j:WARN Continuable parsing error 57 and column 64
> log4j:WARN Attribute value "com.opensymphony.xwork2.util.OgnlValueStack"
> of type ID must be unique within the document.
> [INFO] Configuration XML file loaded:
> file:/C:/Users/mypc/IdeaProjects/myapp/src/main/resources/hibernate.cfg.xml
> [INFO] Configuration Properties file loaded:
> C:\Users\mypc\IdeaProjects\myapp\target\classes\jdbc.properties
> alter table VehicleMaintenance drop foreign key FKD1C1D46712C9F342;
> alter table user_role drop foreign key FK143BF46A4FD90D75;
> alter table user_role drop foreign key FK143BF46AF503D155;
> drop table if exists Vehicle;
> drop table if exists VehicleMaintenance;
> drop table if exists app_user;
> drop table if exists role;
> drop table if exists user_role;
> create table Vehicle (id bigint not null auto_increment, VIN varchar(255),
> make varchar(255), model varchar(255), name varchar(255), year varchar
> (255), primary key (id)) ENGINE=InnoDB;
> create table VehicleMaintenance (id bigint not null auto_increment,
> alarmDate datetime, endDate datetime, name varchar(255), startDate
> datetime,
> vehicle_id bigint, primary key (id)) ENGINE=InnoDB;
> create table app_user (id bigint not null auto_increment, account_expired
> bit not null, account_locked bit not null, address varchar(150), city v
> archar(50) not null, country varchar(100), postal_code varchar(15) not
> null, province varchar(100), credentials_expired bit not null, email varch
> ar(255) not null unique, account_enabled bit, first_name varchar(50) not
> null, last_name varchar(50) not null, password varchar(255) not null, pa
> ssword_hint varchar(255), phone_number varchar(255), username varchar(50)
> not null unique, version integer, website varchar(255), primary key (id
> )) ENGINE=InnoDB;
> create table role (id bigint not null auto_increment, description
> varchar(64), name varchar(20), primary key (id)) ENGINE=InnoDB;
> create table user_role (user_id bigint not null, role_id bigint not null,
> primary key (user_id, role_id)) ENGINE=InnoDB;
> alter table VehicleMaintenance add index FKD1C1D46712C9F342 (vehicle_id),
> add constraint FKD1C1D46712C9F342 foreign key (vehicle_id) references V
> ehicle (id);
> alter table user_role add index FK143BF46A4FD90D75 (role_id), add
> constraint FK143BF46A4FD90D75 foreign key (role_id) references role (id);
> alter table user_role add index FK143BF46AF503D155 (user_id), add
> constraint FK143BF46AF503D155 foreign key (user_id) references app_user
> (id);
> [INFO] [compiler:testCompile {execution: default-testCompile}]
> [INFO] Compiling 2 source files to
> C:\Users\mypc\IdeaProjects\myapp\target\test-classes
> [INFO] [dbunit:operation {execution: test-compile}]
> [INFO] [surefire:test {execution: default-test}]
> [INFO] Surefire report directory:
> C:\Users\mypc\IdeaProjects\myapp\target\surefire-reports
> log4j:WARN Continuable parsing error 57 and column 64
> log4j:WARN Attribute value "com.opensymphony.xwork2.util.OgnlValueStack"
> of type ID must be unique within the document.
>
> -------------------------------------------------------
> T E S T S
> -------------------------------------------------------
> Running org.xinus.crud.dao.VehicleDaoTest
> [myapp] INFO [main] VehicleDaoTest.loadContextLocations(210) | Loading
> context for locations: classpath:/applicationContext-resources.xml,classpa
> th:/applicationContext-dao.xml,classpath*:/applicationContext.xml,classpath:**/applicationContext*.xml
> [myapp] DEBUG [main] VehicleDaoTest.startNewTransaction(392) | Began
> transaction (1): transaction manager
> [org.springframework.orm.hibernate3.Hib
> ernatetransactionmana...@739f3f]; rollback [true].
> Test: Add Vehicle
> Vehicle added null
> [myapp] DEBUG [main] VehicleDaoTest.endTransaction(360) | Rolled back
> transaction after execution of test [testAddVehicle].
> [myapp] DEBUG [main] VehicleDaoTest.startNewTransaction(392) | Began
> transaction (1): transaction manager
> [org.springframework.orm.hibernate3.Hib
> ernatetransactionmana...@739f3f]; rollback [true].
> Test: Get children
> [myapp] WARN [main] VehicleDaoHibernate.get(74) | Uh oh, 'class
> org.xinus.crud.model.Vehicle' object with id '1' not found...
> [myapp] DEBUG [main] VehicleDaoTest.endTransaction(360) | Rolled back
> transaction after execution of test [testGetChildren].
> [myapp] DEBUG [main] VehicleDaoTest.startNewTransaction(392) | Began
> transaction (1): transaction manager
> [org.springframework.orm.hibernate3.Hib
> ernatetransactionmana...@739f3f]; rollback [true].
> [myapp] WARN [main] VehicleDaoHibernate.get(74) | Uh oh, 'class
> org.xinus.crud.model.Vehicle' object with id '1' not found...
> [myapp] DEBUG [main] VehicleDaoTest.endTransaction(360) | Rolled back
> transaction after execution of test [testGetVehicle].
> [myapp] DEBUG [main] VehicleDaoTest.startNewTransaction(392) | Began
> transaction (1): transaction manager
> [org.springframework.orm.hibernate3.Hib
> ernatetransactionmana...@739f3f]; rollback [true].
> [myapp] DEBUG [main] VehicleDaoTest.endTransaction(360) | Rolled back
> transaction after execution of test [testGetVehicles].
> [myapp] DEBUG [main] VehicleDaoTest.startNewTransaction(392) | Began
> transaction (1): transaction manager
> [org.springframework.orm.hibernate3.Hib
> ernatetransactionmana...@739f3f]; rollback [true].
> [myapp] WARN [main] VehicleDaoHibernate.get(74) | Uh oh, 'class
> org.xinus.crud.model.Vehicle' object with id '1' not found...
> [myapp] DEBUG [main] VehicleDaoTest.endTransaction(360) | Rolled back
> transaction after execution of test [testAddVehicleMaintenance].
> [myapp] DEBUG [main] VehicleDaoTest.startNewTransaction(392) | Began
> transaction (1): transaction manager
> [org.springframework.orm.hibernate3.Hib
> ernatetransactionmana...@739f3f]; rollback [true].
> [myapp] WARN [main] VehicleDaoHibernate.get(74) | Uh oh, 'class
> org.xinus.crud.model.Vehicle' object with id '1' not found...
> [myapp] DEBUG [main] VehicleDaoTest.endTransaction(360) | Rolled back
> transaction after execution of test [testSaveVehicle].
> [myapp] DEBUG [main] VehicleDaoTest.startNewTransaction(392) | Began
> transaction (1): transaction manager
> [org.springframework.orm.hibernate3.Hib
> ernatetransactionmana...@739f3f]; rollback [true].
> [myapp] WARN [main] VehicleDaoHibernate.get(74) | Uh oh, 'class
> org.xinus.crud.model.Vehicle' object with id '1' not found...
> [myapp] DEBUG [main] VehicleDaoTest.endTransaction(360) | Rolled back
> transaction after execution of test [testRemoveVehicle].
> Tests run: 7, Failures: 2, Errors: 5, Skipped: 0, Time elapsed: 15.952 sec
> <<< FAILURE!
>
> Results :
>
> Failed tests:
> testAddVehicle(org.xinus.crud.dao.VehicleDaoTest)
> testGetVehicles(org.xinus.crud.dao.VehicleDaoTest)
>
> Tests in error:
> testGetChildren(org.xinus.crud.dao.VehicleDaoTest)
> testGetVehicle(org.xinus.crud.dao.VehicleDaoTest)
> testAddVehicleMaintenance(org.xinus.crud.dao.VehicleDaoTest)
> testSaveVehicle(org.xinus.crud.dao.VehicleDaoTest)
> testRemoveVehicle(org.xinus.crud.dao.VehicleDaoTest)
>
> Tests run: 7, Failures: 2, Errors: 5, Skipped: 0
>
> [INFO]
> ------------------------------------------------------------------------
> [ERROR] BUILD FAILURE
> [INFO]
> ------------------------------------------------------------------------
> [INFO] There are test failures.
>
> Please refer to C:\Users\mypc\IdeaProjects\myapp\target\surefire-reports
> for the individual test results.
> [INFO]
> ------------------------------------------------------------------------
> [INFO] For more information, run Maven with the -e switch
> [INFO]
> ------------------------------------------------------------------------
> [INFO] Total time: 1 minute 22 seconds
> [INFO] Finished at: Wed Jul 29 09:59:40 PDT 2009
> [INFO] Final Memory: 33M/59M
> [INFO]
> ------------------------------------------------------------------------
> C:\Users\mypc\IdeaProjects\myapp>
>
When i printed id of saved vehicle in testSaveVehicle it is coming as null.
At console it is showing as rolling back
here it is
.
.
.
Vehicle added null
myapp] DEBUG [main] VehicleDaoTest.endTransaction(360) | Rolled back
transaction after execution of test [testAddVehicle].
.
.
.
--
View this message in context:
http://www.nabble.com/Problems-after-running-appfuse%3Afull-source-tp24696222s2369p24723609.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]