01: package net.sourceforge.jaxor.example.users.tests;
02:
03: import net.sourceforge.jaxor.ConcurrencyException;
04: import net.sourceforge.jaxor.MetaRow;
05: import net.sourceforge.jaxor.example.tests.TableTestCase;
06: import net.sourceforge.jaxor.example.users.UserEntity;
07: import net.sourceforge.jaxor.example.users.UserFinder;
08: import net.sourceforge.jaxor.example.users.UserMetaRow;
09:
10: import java.sql.Timestamp;
11:
12: /**
13: * Created By: Mike
14: * Date: Nov 27, 2003
15: * Time: 10:43:27 PM
16: *
17: * Last Checkin: $Author: mrettig $
18: * Date: $Date: 2004/02/13 03:27:57 $
19: * Revision: $Revision: 1.8 $
20: */
21: public class TimestampConcurrencyTest extends TableTestCase {
22:
23: protected MetaRow getRow() {
24: return new UserMetaRow();
25: }
26:
27: public void testConcurrency() {
28: UserFinder.newInstance("user");
29: commit();
30: UserEntity user = UserFinder.selectByPrimaryKey("user");
31: java.sql.Timestamp modifyDate = user.getModifyDate();
32: assertNotNull(modifyDate);
33: user.setFullName("the users full name");
34: assertNotNull(user.getMetaRow());
35: getJaxor().setUser("otherUser");
36: commit();
37: assertTrue(modifyDate != user.getModifyDate());
38: user = UserFinder.selectByPrimaryKey("user");
39: assertTrue(modifyDate != user.getModifyDate());
40: assertEquals("otherUser", user.getModifyUser());
41: user.setModifyDate(new Timestamp(
42: System.currentTimeMillis() + 123456));
43: try {
44: commit();
45: } catch (ConcurrencyException e) {
46: assertEquals(user, e.getEntity());
47: }
48: }
49: }
|