1 16 17 package org.apache.commons.betwixt; 18 19 import java.io.FileInputStream ; 20 import java.io.InputStream ; 21 22 import junit.framework.Test; 23 import junit.framework.TestSuite; 24 import junit.textui.TestRunner; 25 26 import org.apache.commons.betwixt.digester.XMLBeanInfoDigester; 27 28 33 public class TestXMLBeanInfoDigester extends AbstractTestCase { 34 35 public static void main( String [] args ) { 36 TestRunner.run( suite() ); 37 } 38 39 public static Test suite() { 40 return new TestSuite(TestXMLBeanInfoDigester.class); 41 } 42 43 public TestXMLBeanInfoDigester(String testName) { 44 super(testName); 45 } 46 47 public void testDigester() throws Exception { 48 XMLBeanInfoDigester digester = new XMLBeanInfoDigester(); 49 digester.setXMLIntrospector(new XMLIntrospector()); 53 54 InputStream in = new FileInputStream ( getTestFile("src/test/org/apache/commons/digester/rss/Channel.betwixt") ); 55 56 assertTrue( "Found betwixt config file", in != null ); 57 58 XMLBeanInfo info = (XMLBeanInfo) digester.parse( in ); 59 60 assertTrue( "Found XMLBeanInfo", info != null ); 61 62 ElementDescriptor descriptor = info.getElementDescriptor(); 63 64 assertTrue( "Found root element descriptor", descriptor != null ); 65 assertEquals( "Element name correct", "rss", descriptor.getLocalName() ); 66 67 ElementDescriptor[] elements = descriptor.getElementDescriptors(); 68 69 assertTrue( "Found elements", elements != null && elements.length > 0 ); 70 71 descriptor = elements[0]; 72 assertEquals( "Element name correct", "channel", descriptor.getLocalName() ); 73 74 } 75 } 76 77 | Popular Tags |