1 7 8 package org.dom4j.datatype; 9 10 import junit.textui.TestRunner; 11 12 import java.math.BigInteger ; 13 import java.util.Calendar ; 14 15 import org.dom4j.DocumentFactory; 16 import org.dom4j.io.SAXReader; 17 18 25 public class AutoSchemaTest extends AbstractDataTypeTestCase { 26 public static void main(String [] args) { 27 TestRunner.run(AutoSchemaTest.class); 28 } 29 30 public void testIntAttribute() throws Exception { 33 testNodes("//person/@x", Integer .class); 34 } 35 36 public void testIntElement() throws Exception { 37 testNodes("//person/salary", Integer .class); 38 } 39 40 public void testString() throws Exception { 41 testNodes("//person/note", String .class); 42 } 43 44 public void testDate() throws Exception { 45 testNodes("//person/@d", Calendar .class); 46 } 47 48 public void testDateTime() throws Exception { 49 testNodes("//person/@dt", Calendar .class); 50 } 51 52 public void testInteger() throws Exception { 53 testNodes("//person/@age", BigInteger .class); 54 } 55 56 protected void setUp() throws Exception { 59 super.setUp(); 60 61 DocumentFactory factory = loadDocumentFactory(); 62 SAXReader reader = new SAXReader(factory); 63 document = getDocument(getDocumentURI(), reader); 64 } 65 66 protected String getDocumentURI() { 67 return "/xml/test/schema/personal-schema.xml"; 68 } 69 70 protected DocumentFactory loadDocumentFactory() throws Exception { 71 return DatatypeDocumentFactory.getInstance(); 72 } 73 } 74 75 111 | Popular Tags |