01: /*
02: * User: mrettig
03: * Date: Jun 26, 2002
04: * Time: 5:46:48 PM
05: */
06: package net.sourceforge.jaxor.tests;
07:
08: import net.sourceforge.jaxor.MetaRow;
09: import net.sourceforge.jaxor.JaxorContextImpl;
10: import net.sourceforge.jaxor.api.EntityInterface;
11: import net.sourceforge.jaxor.example.domain.AddressEntity;
12: import net.sourceforge.jaxor.example.domain.AddressMetaRow;
13: import net.sourceforge.jaxor.example.domain.ObjectFactory;
14: import net.sourceforge.jaxor.example.tests.TableTestCase;
15:
16: /**
17: * Created By: mrettig
18: * Date: 09-aug-2002
19: * Time: 12.20.06
20: *
21: * Last Checkin: $Author: mrettig $
22: * Date: $Date: 2004/03/03 03:59:19 $
23: * Revision: $Revision: 1.19 $
24: */
25: public class AbstractEntityTest extends TableTestCase {
26:
27: protected MetaRow getRow() {
28: return new AddressMetaRow();
29: }
30:
31: public void testEquals() {
32: AddressEntity address = ObjectFactory
33: .createAddress(new Long(1));
34: AddressEntity address2 = ObjectFactory
35: .createAddress(new Long(2));
36: assertFalse(address.equals(address2));
37: address2.setAddressId(new Long(1));
38: assertEquals(address, address2);
39: }
40:
41: public void testChangesGetsRegistered() {
42: final boolean[] called = new boolean[] { false };
43: AddressEntity address = ObjectFactory.createAddress(new Long(
44: 1234));
45: address.setJaxorContext(new JaxorContextImpl(getConnection()) {
46: public void registerUpdate(EntityInterface entity) {
47: called[0] = true;
48: }
49: });
50: address.registerLoad();
51: address.setState(address.getState());
52: address.setState("Foo");
53: assertTrue(called[0]);
54: }
55:
56: }
|