1 19 20 package org.netbeans.modules.xml.axi; 21 22 import junit.framework.*; 23 import org.netbeans.modules.xml.axi.util.FileUtil; 24 import org.netbeans.modules.xml.axi.util.ModelValidator; 25 import org.netbeans.modules.xml.schema.model.SchemaComponent; 26 import org.netbeans.modules.xml.schema.model.SchemaModel; 27 28 29 37 public class AXIModelTest extends AbstractTestCase { 38 39 public static final String TEST_XSD = "resources/po.xsd"; 40 public static final String GLOBAL_ELEMENT = "purchaseOrder"; 41 42 43 46 public AXIModelTest(String testName) { 47 super(testName, TEST_XSD, GLOBAL_ELEMENT); 48 } 49 50 53 public AXIModelTest(String testName, String schemaFile, String elementName) { 54 super(testName, schemaFile, elementName); 55 } 56 57 public static Test suite() { 58 TestSuite suite = new TestSuite(AXIModelTest.class); 59 60 return suite; 61 } 62 63 public void testAXIModel() { 64 reverseEngineer(); 65 axiModel.setSchemaDesignPattern(SchemaGenerator.Pattern.GARDEN_OF_EDEN); 66 forwardEngineer(); 67 } 68 69 75 private void forwardEngineer() { 76 if(referenceXML == null) return; 77 FileUtil.parseXMLAndPopulateAXIModel( 78 referenceXML, getAXIModel()); 79 ModelValidator visitor = new ModelValidator(referenceXML); 80 Element po = getAXIModel().getRoot().getElements().get(0); 81 Element first = (Element)po.getChildElements().get(0); 82 assert(first.getParentElement() == po); 83 boolean result = visitor.visitAndCompareAgainstDOMElement(po); 84 this.assertEquals(visitor.getErrorMessage(), true, result); 85 } 86 87 92 public void reverseEngineer() { 93 assertNotNull(globalElement); 94 assertNotNull(getAXIModel().getRoot()); 95 ModelValidator visitor = new ModelValidator(referenceXML); 98 boolean result = visitor.visitAndCompareAgainstDOMElement(globalElement); 99 this.assertEquals(visitor.getErrorMessage(), 100 true, result); 101 } 102 } 103 | Popular Tags |