1 64 65 package com.jcorporate.expresso.core.dataobjects.jdbc.tests; 66 67 import com.jcorporate.expresso.core.dataobjects.jdbc.JoinedDigesterBean; 68 import junit.framework.TestCase; 69 import org.apache.commons.digester.Digester; 70 71 import java.net.URL ; 72 import java.util.List ; 73 74 77 public class TestJoinedDigesterBean extends TestCase { 78 79 private static final String TEST_FILE = "/com/jcorporate/" + 80 "expresso/core/dataobjects/jdbc/tests/DownloadMimeTypeJoin.xml"; 81 82 public TestJoinedDigesterBean(String _name) { 83 super(_name); 84 } 85 86 89 public void testBuildDigester() { 90 try { 91 JoinedDigesterBean bean = new JoinedDigesterBean(); 92 Digester d = bean.buildDigester(); 93 } catch (Exception ex) { 94 ex.printStackTrace(); 95 fail("Error building digester"); 96 } 97 } 98 99 100 103 public void testDigest() { 104 JoinedDigesterBean bean = new JoinedDigesterBean(); 105 Digester d = bean.buildDigester(); 106 URL file = TestJoinedDigesterBean.class.getResource(TEST_FILE); 107 108 if (file == null) { 109 throw new IllegalArgumentException ("Error getting Test join xml file"); 110 } 111 112 try { 113 bean.digest(d, file); 114 } catch (Exception ex) { 115 ex.printStackTrace(); 116 fail("Error digesting data"); 117 } 118 runDataIntegrityTest(bean); 119 120 } 121 122 123 126 public void testLoadJoinData() { 127 JoinedDigesterBean bean = new JoinedDigesterBean(); 128 URL file = TestJoinedDigesterBean.class.getResource(TEST_FILE); 129 130 if (file == null) { 131 throw new IllegalArgumentException ("Error getting Test join xml file"); 132 } 133 134 try { 135 bean.loadJoinData(file); 136 } catch (Exception ex) { 137 ex.printStackTrace(); 138 fail("Error digesting data"); 139 } 140 141 runDataIntegrityTest(bean); 142 } 143 144 private void runDataIntegrityTest(JoinedDigesterBean theBean) { 145 assertTrue("Download Log View".equals(theBean.getDescription())); 146 assertTrue(theBean.isDistinct() == false); 147 List dataobjects = theBean.getDataObjects(); 148 List relations = theBean.getRelations(); 149 150 assertTrue("dataobjects should not be null", dataobjects != null); 151 assertTrue("relations should not be null", relations != null); 152 153 assertTrue("dataobjects should have elements", dataobjects.size() > 0); 154 assertTrue("relations should have elements", relations.size() > 0); 155 } 156 157 160 public static void main(String [] argv) { 161 String [] testCaseList = {TestJoinedDigesterBean.class.getName()}; 162 junit.textui.TestRunner.main(testCaseList); 163 } 164 } 165 | Popular Tags |