01: /*
02: * Created by IntelliJ IDEA.
03: * User: mrettig
04: * Date: Aug 9, 2002
05: * Time: 11:42:12 PM
06: * To change template for new class use
07: * Code Style | Class Templates options (Tools | IDE Options).
08: */
09: package net.sourceforge.jaxor.example.tests;
10:
11: import net.sourceforge.jaxor.example.domain.*;
12: import net.sourceforge.jaxor.example.simple.*;
13:
14: import java.sql.SQLException;
15: import java.util.ArrayList;
16: import java.util.List;
17:
18: public class HsqldbTest extends MultiTableTestCase {
19:
20: protected List getRows() {
21: List all = new ArrayList();
22: all.add(new AddressMetaRow());
23: all.add(new ParentMetaRow());
24: all.add(new ChildMetaRow());
25: return all;
26: }
27:
28: public void testGetConnection() throws ClassNotFoundException,
29: SQLException {
30: AddressList all = AddressFinder.selectAll();
31: assertEquals(all.size(), 0);
32:
33: AddressEntity addressEntity = ObjectFactory.createAddress();
34: addressEntity.insert();
35: AddressEntity loaded = AddressFinder
36: .selectByPrimaryKey(new Long(123));
37: assertEquals(addressEntity, loaded);
38: }
39:
40: public void testCircularReferences() {
41: ParentEntity parent = ParentFinder.newInstance(new Long(123));
42: ChildEntity child = ChildFinder.newInstance(new Long(345));
43: child.setParentEntity(parent);
44: child.setParentEntity(parent);
45: parent.insert();
46: child.insert();
47: ParentEntity found = ParentFinder.selectByPrimaryKey(new Long(
48: 123));
49: ParentEntity backRef = found.getChildList().get(0)
50: .getParentEntity();
51: /**
52: * This is only true if you do not use proxies. If you use proxies, then the parent and child
53: * will be referencing proxies and not the actual objects.
54: */
55: assertTrue(backRef == found);
56: }
57:
58: }
|