1 7 8 package org.dom4j.xpath; 9 10 import junit.textui.TestRunner; 11 12 import java.io.File ; 13 import java.util.List ; 14 15 import org.dom4j.AbstractTestCase; 16 import org.dom4j.io.SAXReader; 17 18 24 public class MatrixConcatTest extends AbstractTestCase { 25 public static void main(String [] args) { 26 TestRunner.run(MatrixConcatTest.class); 27 } 28 29 public void testMatrixConcat() throws Exception { 32 String [] exp1 = {"EQUITY_CF1", "EQUITY_CF2", "EQUITY_CF3"}; 33 34 String [] exp2 = {"EQUITY_BAR_CF1", "EQUITY_BAR_CF2", "EQUITY_BAR_CF3"}; 35 36 testMatrixConcat("'EQUITY_',/product/cashflows/CashFlow/XREF", exp1); 37 testMatrixConcat("'EQUITY_','BAR_',/product/cashflows/CashFlow/XREF", 38 exp2); 39 } 40 41 protected void testMatrixConcat(String path, String [] results) 44 throws Exception { 45 log("Using XPath: " + path); 46 47 List list = document.selectNodes("matrix-concat(" + path + ")"); 48 49 log("Found: " + list); 50 51 int size = results.length; 54 assertTrue("List should contain " + size + " results: " + list, list 55 .size() == size); 56 57 for (int i = 0; i < size; i++) { 58 assertEquals(list.get(i), results[i]); 59 } 60 } 61 62 protected void setUp() throws Exception { 63 super.setUp(); 64 document = new SAXReader().read(new File ("xml/test/product.xml")); 65 } 66 } 67 68 104 | Popular Tags |