1 package org.exoplatform.services.xml.querying.impl.xtas; 2 3 import junit.framework.TestCase; 4 import junit.framework.Test; 5 import junit.framework.TestSuite; 6 7 import org.xml.sax.InputSource ; 8 import java.io.*; 9 import java.util.Iterator ; 10 import java.util.ArrayList ; 11 import org.exoplatform.services.xml.querying.impl.xtas.BaseStatement; 12 import org.exoplatform.services.xml.querying.impl.xtas.Query; 13 import org.exoplatform.services.xml.querying.impl.xtas.UniFormTreeFragment; 14 import org.exoplatform.services.xml.querying.impl.xtas.XTASMLStatement; 15 import org.w3c.dom.Node ; 16 import org.w3c.dom.NodeList ; 17 import org.w3c.dom.Document ; 18 26 30 public class TestObjectMarshalling extends TestCase { 31 32 public TestObjectMarshalling(String name) 33 { 34 super(name); 35 } 36 public static Test suite() 37 { 38 return new TestSuite(TestObjectMarshalling.class); 39 } 40 41 42 public void testSimpleBeanWMapping() 43 { 44 ArrayList list = new ArrayList (); 45 86 87 } 88 89 90 91 public void testSimpleBeanWOMapping() 92 { 93 ArrayList list = new ArrayList (); 94 try { 95 96 BaseStatement qc = new XTASMLStatement ("tmp/test-bean-query.xml"); 97 Query q = new Query (qc); 98 q.execute(); 99 100 102 103 UniFormTreeFragment ro = (UniFormTreeFragment)q.getResult(); 104 105 107 108 Iterator i = ro.getAsCollection( TmpBean.class ).iterator(); 109 110 while(i.hasNext()) { 111 112 TmpBean tb = (TmpBean)i.next(); 113 list.add(tb); 114 115 } 116 117 } catch ( Exception e ) { 118 fail( " testSimpleBeanWOMapping() failed ! "+e.toString()); 120 121 } 122 123 assertEquals("Bean(0).property not equal",((TmpBean)list.get(0)).getProperty(),"Test String#1"); 124 assertEquals("Bean(0).e1 not equal",((TmpBean)list.get(0)).getE1(),new Integer (1)); 125 assertNull("Bean(0).f2 not null",((TmpBean)list.get(0)).getF2()); 126 127 assertEquals("Bean(1).property not equal",((TmpBean)list.get(1)).getProperty(),"Test String#2"); 128 assertEquals("Bean(1).e1 not equal",((TmpBean)list.get(1)).getE1(),new Integer (2)); 129 assertEquals("Bean(1).f2 not equal",((TmpBean)list.get(1)).getF2(),new Float (2.22f)); 130 131 assertNull("Bean(4).property not null",((TmpBean)list.get(4)).getProperty()); 132 133 } 134 135 public void testSimpleBeanWOMapping1() 136 { 137 138 ArrayList list = new ArrayList (); 139 try { 140 141 BaseStatement qc = new XTASMLStatement ("tmp/test-addresses.xml"); 142 Query q = new Query (qc); 143 q.execute(); 144 145 UniFormTreeFragment ro = (UniFormTreeFragment)q.getResult(); 147 148 Addresses a = (Addresses) ro.getAsCollection( Addresses.class ).iterator().next(); 149 150 Address[] a1 = a.getAddresses(); 152 154 157 assertEquals("","Ukraine",a.getCountry()); 158 assertEquals("","Kiev",a1[0].getCity()); 159 assertEquals("","Cherkassy",a1[1].getCity()); 160 161 162 } catch ( Exception e ) { 163 fail( " testSimpleBeanWOMapping1() failed ! "+e.toString()); 165 166 } 167 168 } 169 170 171 public void testMarshallingWOMapping() 172 { 173 194 195 } 196 197 198 public void testMarshallingWMapping() 199 { 200 221 222 } 223 224 225 public void testMarshallingWMapping1() 226 { 227 256 257 } 258 259 260 } 261 | Popular Tags |