1 package org.apache.ojb.broker; 2 3 import org.apache.ojb.broker.query.QueryByIdentity; 4 import org.apache.ojb.junit.PBTestCase; 5 6 8 public class TypedCollectionsTest extends PBTestCase 9 { 10 public static void main(String [] args) 11 { 12 String [] arr = {TypedCollectionsTest.class.getName()}; 13 junit.textui.TestRunner.main(arr); 14 } 15 16 public TypedCollectionsTest(String name) 17 18 { 19 super(name); 20 } 21 22 23 public void testArray() throws Exception 24 { 25 int i; 26 broker.beginTransaction(); 27 for (i = 1; i < 4; i++) 28 { 29 ProductGroupWithArray example = new ProductGroupWithArray(); 30 example.setId(i); 31 ProductGroupWithArray group = 32 (ProductGroupWithArray) broker.getObjectByQuery(new QueryByIdentity(example)); 33 assertEquals("should be equal", i, group.getId()); 34 36 broker.delete(group); 37 broker.store(group); 38 } 39 broker.commitTransaction(); 40 } 41 42 43 public void testTypedCollection() 44 { 45 broker.beginTransaction(); 46 for (int i = 1; i < 4; i++) 47 { 48 ProductGroupWithTypedCollection example = new ProductGroupWithTypedCollection(); 49 example.setId(i); 50 ProductGroupWithTypedCollection group = 51 (ProductGroupWithTypedCollection) broker.getObjectByQuery( 52 new QueryByIdentity(example)); 53 assertEquals("should be equal", i, group.getId()); 54 56 broker.delete(group); 57 broker.store(group); 58 } 59 broker.commitTransaction(); 60 } 61 } 62 | Popular Tags |