The test cases always roll back the transaction immediately after executing a test. All manager test cases extend BaseManagerTestCase which in turn extends AbstractTransactionalDataSourceSpringContextTests. See the Spring Javadoc which explains how to set transactions to commit.
In terms of checking to see if the timestamp is set be sure you are calling the object returned by the save method, not the one you passed in. They are not always the same. Mike On 27 January 2010 07:09, Arash <rakhs...@gmail.com> wrote: > > Hello, > > My project is appFuse backend only (not modular). I am trying to add the > following method to BaseObject so that "Date createdTimestamp" field (also > defined in BaseObject) would automatically get populated. > > �...@prepersist > private void fillCreatedTimestamp(){ > this.createdTimestamp = Calendar.getInstance().getTime(); > } > > When I run the test cases via running "mvn", this method gets called but I > have faced some confusion: > > 1. In "UserManagerImplTest".testSaveUser(), right after saving user when I > test the user.getCreatedTimestamp() it reads null > > 2. If I create another POJO say Address and corresponding DAO, Service and > test cases and run "mvn" the test shows that the field gets populated. > [I'm not quite sure if this difference is because UserSecurityAdvice or not] > > 3. No matter what, I don't see the saved object in database. > > I have a feeling that test cases is not touching the actual database where > the tables are created and all the initial data in sample-data.xml is > loaded, am I right? We grab an entity from the populated database and > manipulate a field and the test cases prove that the field has changed but > does it actually affect the database. If not, how can I actually change the > data through test cases ( I know this is not desired but for my sanity) > > In the process of debugging this issue I have another confusion: > I put a simple log statement in "GenericManagerImpl": save() > public T save(T object) { > System.out.println("Something") > return dao.save(object); > } > and ran "mvn". There is no sign of "save" actually getting called although > all managers supposedly extend this class and hence should be calling this > method in order to save. > > Of course it would really help if I could run the test cases individually > through Eclipse "Debug as test" but the only topic in forum I found was > related to Ant not Maven or Eclipse setUp > > Any help would be greatly appreciated > Thank, > Arash > > Here is my sample AddressDaoTest class > > public class AddressDaoTest extends BaseDaoTestCase { > > �...@autowired > private IAddressDao addressDao; > > �...@test > public void testSaveAddress(){ > Address address = new Address(); > address.setStreet("5104 Old Street"); > address.setCity("Santa Clara"); > address.setState("CA"); > address.setZip("94040"); > > Address savedAddress; > savedAddress = addressDao.save(address); > assertNotNull(savedAddress.getId()); > assertNotNull(savedAddress.getCreatedTimestamp()); > } > > �...@test > public void testExists() throws Exception { > Long id = new Long(1); > assertTrue(addressDao.exists(id)); > } > } > -- > View this message in context: > http://n4.nabble.com/Understanding-Test-Cases-Tables-State-tp1311281p1311281.html > Sent from the AppFuse - User mailing list archive at Nabble.com. > > --------------------------------------------------------------------- > To unsubscribe, e-mail: users-unsubscr...@appfuse.dev.java.net > For additional commands, e-mail: users-h...@appfuse.dev.java.net > > --------------------------------------------------------------------- To unsubscribe, e-mail: users-unsubscr...@appfuse.dev.java.net For additional commands, e-mail: users-h...@appfuse.dev.java.net