1 21 22 package org.dbunit.dataset; 23 24 import org.dbunit.dataset.xml.FlatXmlDataSet; 25 import org.dbunit.dataset.xml.XmlDataSet; 26 27 import java.io.FileReader ; 28 29 34 public class CompositeDataSetTest extends AbstractDataSetTest 35 { 36 public CompositeDataSetTest(String s) 37 { 38 super(s); 39 } 40 41 protected IDataSet createDataSet() throws Exception 42 { 43 IDataSet dataSet1 = new XmlDataSet( 44 new FileReader ("src/xml/compositeDataSetTest1.xml")); 45 assertTrue("count before combine (1)", 46 dataSet1.getTableNames().length < getExpectedNames().length); 47 48 IDataSet dataSet2 = new XmlDataSet( 49 new FileReader ("src/xml/compositeDataSetTest2.xml")); 50 assertTrue("count before combine (2)", 51 dataSet2.getTableNames().length < getExpectedNames().length); 52 53 return new CompositeDataSet(dataSet1, dataSet2); 54 } 55 56 protected IDataSet createDuplicateDataSet() throws Exception 57 { 58 IDataSet dataSet1 = new FlatXmlDataSet( 59 new FileReader ("src/xml/compositeDataSetDuplicateTest1.xml")); 60 assertTrue("count before combine (1)", 61 dataSet1.getTableNames().length < getExpectedDuplicateNames().length); 62 63 IDataSet dataSet2 = new FlatXmlDataSet( 64 new FileReader ("src/xml/compositeDataSetDuplicateTest2.xml")); 65 assertTrue("count before combine (2)", 66 dataSet2.getTableNames().length < getExpectedDuplicateNames().length); 67 68 return new CompositeDataSet(dataSet1, dataSet2, false); 69 } 70 71 public void testCombineTables() throws Exception 72 { 73 IDataSet originaldataSet = createMultipleCaseDuplicateDataSet(); 74 assertEquals("table count before", 3, originaldataSet.getTableNames().length); 75 76 IDataSet combinedDataSet = new CompositeDataSet(originaldataSet); 77 assertEquals("table count combined", 2, combinedDataSet.getTableNames().length); 78 } 79 80 } 81 82 83 84 85 | Popular Tags |