1 | public class PersistentBagTest extends FunctionalTestCase {↵ | | 1 | public class PersistentListTest extends FunctionalTestCase {↵
|
2 | public PersistentBagTest(String name) {↵ | | 2 | public PersistentListTest(String name) {↵
|
3 | super( name );↵ | | 3 | super( name );↵
|
4 | }↵ | | 4 | }↵
|
|
5 | public String[] getMappings() {↵ | | 5 | public String[] getMappings() {↵
|
6 | return new String[] { "collection/bag/Mappings.hbm.xml" };↵ | | 6 | return new String[] { "collection/list/Mappings.hbm.xml" };↵
|
7 | }↵ | | 7 | }↵
|
|
8 | public static Test suite() {↵ | | 8 | public static Test suite() {↵
|
9 | return new FunctionalTestClassTestSuite( PersistentBagTest.class );↵ | | 9 | return new FunctionalTestClassTestSuite( PersistentListTest.class );↵
|
10 | }↵ | | 10 | }↵
|
|
11 | public void testWriteMethodDirtying() {↵ | | 11 | public void testWriteMethodDirtying() {↵
|
12 | BagOwner parent = new BagOwner( "root" );↵ | | 12 | ListOwner parent = new ListOwner( "root" );↵
|
13 | BagOwner child = new BagOwner( "c1" );↵ | | 13 | ListOwner child = new ListOwner( "c1" );↵
|
14 | parent.getChildren().add( child );↵ | | 14 | parent.getChildren().add( child );↵
|
15 | child.setParent( parent );↵ | | 15 | child.setParent( parent );↵
|
16 | BagOwner otherChild = new BagOwner( "c2" );↵ | | 16 | ListOwner otherChild = new ListOwner( "c2" );↵
|
|
17 | Session session = openSession();↵ | | 17 | Session session = openSession();↵
|
18 | session.beginTransaction();↵ | | 18 | session.beginTransaction();↵
|
19 | session.save( parent );↵ | | 19 | session.save( parent );↵
|
20 | session.flush();↵ | | 20 | session.flush();↵
|
21 | // at this point, the list on parent has now been replaced with a PersistentBag...↵ | | 21 | // at this point, the list on parent has now been replaced with a PersistentList...↵
|
22 | PersistentBag children = ( PersistentBag ) parent.getChildren();↵ | | 22 | PersistentList children = ( PersistentList ) parent.getChildren();↵
|
|
23 | assertFalse( children.remove( otherChild ) );↵ | | 23 | assertFalse( children.remove( otherChild ) );↵
|
24 | assertFalse( children.isDirty() );↵ | | 24 | assertFalse( children.isDirty() );↵
|
|
25 | ArrayList otherCollection = new ArrayList();↵ | | 25 | ArrayList otherCollection = new ArrayList();↵
|
26 | otherCollection.add( child );↵ | | 26 | otherCollection.add( child );↵
|
27 | assertFalse( children.retainAll( otherCollection ) );↵ | | 27 | assertFalse( children.retainAll( otherCollection ) );↵
|
28 | assertFalse( children.isDirty() );↵ | | 28 | assertFalse( children.isDirty() );↵
|
|
29 | otherCollection = new ArrayList();↵ | | 29 | otherCollection = new ArrayList();↵
|
30 | otherCollection.add( otherChild );↵ | | 30 | otherCollection.add( otherChild );↵
|
31 | assertFalse( children.removeAll( otherCollection ) );↵ | | 31 | assertFalse( children.removeAll( otherCollection ) );↵
|
32 | assertFalse( children.isDirty() );↵ | | 32 | assertFalse( children.isDirty() );↵
|
|
33 | children.clear();↵ | | 33 | children.clear();↵
|
34 | session.delete( child );↵ | | 34 | session.delete( child );↵
|
35 | assertTrue( children.isDirty() );↵ | | 35 | assertTrue( children.isDirty() );↵
|
|
36 | session.flush();↵ | | 36 | session.flush();↵
|
|
37 | children.clear();↵ | | 37 | children.clear();↵
|
38 | assertFalse( children.isDirty() );↵ | | 38 | assertFalse( children.isDirty() );↵
|
|
39 | session.delete( parent );↵ | | 39 | session.delete( parent );↵
|
40 | session.getTransaction().commit();↵ | | 40 | session.getTransaction().commit();↵
|
41 | session.close();↵ | | 41 | session.close();↵
|
42 | | | 42 |
|