1 64 65 package com.jcorporate.expresso.core.dataobjects.jdbc.tests; 66 67 import com.jcorporate.expresso.core.dataobjects.DataException; 68 import com.jcorporate.expresso.core.dataobjects.Securable; 69 import com.jcorporate.expresso.core.dataobjects.jdbc.JoinedDataObject; 70 import com.jcorporate.expresso.core.db.DBException; 71 import com.jcorporate.expresso.core.misc.ConfigManager; 72 import com.jcorporate.expresso.core.misc.ConfigurationException; 73 import com.jcorporate.expresso.services.test.TestSystemInitializer; 74 import junit.framework.Test; 75 import junit.framework.TestCase; 76 import junit.framework.TestSuite; 77 78 import java.util.ArrayList ; 79 80 81 88 public class JoinedObjectTest 89 extends TestCase { 90 91 92 97 public JoinedObjectTest(String name) { 98 super(name); 99 } 100 101 102 public static void main(String [] args) 103 throws Exception { 104 105 junit.textui.TestRunner.run(suite()); 107 ConfigManager.destroy(); 108 } 109 110 114 public void setUp() 115 throws Exception { 116 TestSystemInitializer.setUp(); 117 118 try { 119 ConfigManager.getContext(TestSystemInitializer.getTestContext()); 120 } catch (ConfigurationException ce) { 121 fail( 122 "Specified context to test:" + TestSystemInitializer.getTestContext() + " but couldn't find that context"); 123 } 124 125 } 126 127 128 132 public void tearDown() 133 throws Exception { 134 135 } 136 137 138 143 public static Test suite() { 144 TestSuite suite = new TestSuite(JoinedObjectTest.class); 145 146 return suite; 147 } 148 149 public void testCount() { 150 try { 151 JoinedDataObject testJoin = new JoinedDataObject(); 152 testJoin.setRequestingUid(Securable.SYSTEM_ACCOUNT); 153 testJoin.setDefinitionName("/com/jcorporate/" + 154 "expresso/core/dataobjects/jdbc/tests/DownloadMimeTypeJoin.xml"); 155 testJoin.set("DownloadLog.LogEntry", "1"); 156 int number = testJoin.count(); 157 System.out.println("Received count result of : " + number); 158 159 JoinedDataObject emptyCount = new JoinedDataObject(); 160 emptyCount.setRequestingUid(Securable.SYSTEM_ACCOUNT); 161 emptyCount.setDefinitionName("/com/jcorporate/" + 162 "expresso/core/dataobjects/jdbc/tests/DownloadMimeTypeJoin.xml"); 163 number = emptyCount.count(); 164 System.out.println("Received count result of : " + number); 165 166 167 } catch (DataException ex) { 168 ex.printStackTrace(); 169 fail("Error testing Joined DataObject"); 170 } catch (DBException ex) { 171 ex.printStackTrace(); 172 fail("Caught DBException testing Joined DataObject"); 173 } catch (Exception ex) { 174 ex.printStackTrace(); 175 fail("Caught Exception testing Joined DataObject"); 176 } 177 178 } 179 180 181 184 public void testClear() { 185 try { 186 JoinedDataObject testJoin = new JoinedDataObject(); 187 testJoin.setRequestingUid(Securable.SYSTEM_ACCOUNT); 188 testJoin.setDefinitionName("/com/jcorporate/" + 189 "expresso/core/dataobjects/jdbc/tests/DownloadMimeTypeJoin.xml"); 190 testJoin.set("DownloadLog.LogEntry", "1"); 191 int number = testJoin.count(); 192 System.out.println("Received count result of : " + number); 193 194 testJoin.clear(); 195 testJoin.setRequestingUid(Securable.SYSTEM_ACCOUNT); 196 testJoin.setDefinitionName("/com/jcorporate/" + 197 "expresso/core/dataobjects/jdbc/tests/DownloadMimeTypeJoin.xml"); 198 number = testJoin.count(); 199 System.out.println("Received count result of : " + number); 200 201 202 } catch (DataException ex) { 203 ex.printStackTrace(); 204 fail("Error testing Joined DataObject"); 205 } catch (DBException ex) { 206 ex.printStackTrace(); 207 fail("Caught DBException testing Joined DataObject"); 208 } catch (Exception ex) { 209 ex.printStackTrace(); 210 fail("Caught Exception testing Joined DataObject"); 211 } 212 213 } 214 215 218 public void testSearchAndRetrieveList() { 219 try { 220 JoinedDataObject testJoin = new JoinedDataObject(); 221 testJoin.setRequestingUid(Securable.SYSTEM_ACCOUNT); 222 testJoin.setDefinitionName("/com/jcorporate/expresso/core/dataobjects/jdbc/tests/DownloadMimeTypeJoin.xml"); 223 testJoin.set("DownloadLog.LogEntry", "1"); 224 ArrayList al = testJoin.searchAndRetrieveList(); 225 System.out.println("Received result of : " + al.size() + " records"); 226 } catch (DataException ex) { 227 ex.printStackTrace(); 228 fail("Error testing Joined DataObject"); 229 } catch (DBException ex) { 230 ex.printStackTrace(); 231 fail("Caught DBException testing Joined DataObject"); 232 } catch (Exception ex) { 233 ex.printStackTrace(); 234 fail("Caught Exception testing Joined DataObject"); 235 } 236 237 } 238 239 public void testOrderBy() { 240 try { 241 JoinedDataObject testJoin = new JoinedDataObject(); 242 testJoin.setRequestingUid(Securable.SYSTEM_ACCOUNT); 243 testJoin.setDefinitionName("/com/jcorporate/expresso/core/dataobjects/jdbc/tests/DownloadMimeTypeJoin.xml"); 244 testJoin.set("DownloadLog.LogEntry", "1"); 245 ArrayList al = testJoin.searchAndRetrieveList("MimeTypes.MimeNumber DESC"); 246 System.out.println("Received result of : " + al.size() + " records"); 247 al = testJoin.searchAndRetrieveList("MimeTypes.MimeNumber"); 248 System.out.println("Received result of : " + al.size() + " records"); 249 al = testJoin.searchAndRetrieveList("Users.ExpUid DESC|MimeTypes.MimeNumber ASC"); 250 System.out.println("Received result of : " + al.size() + " records"); 251 } catch (DataException ex) { 252 ex.printStackTrace(); 253 fail("Error testing Joined DataObject"); 254 } catch (DBException ex) { 255 ex.printStackTrace(); 256 fail("Caught DBException testing Joined DataObject"); 257 } catch (Exception ex) { 258 ex.printStackTrace(); 259 fail("Caught Exception testing Joined DataObject"); 260 } 261 262 } 263 264 265 268 public void testGetSet() { 269 270 } 271 } 272 273 274 | Popular Tags |