1 9 10 package org.netbeans.modules.xml.schema.model; 11 12 import java.util.Collection ; 13 import junit.framework.TestCase; 14 import org.netbeans.modules.xml.xam.dom.NamedComponentReference; 15 16 20 public class SchemaComponentTest extends TestCase{ 21 public static final String TEST_XSD = "resources/PurchaseOrder.xsd"; 22 public static final String EMPTY_XSD = "resources/Empty.xsd"; 23 24 Schema schema = null; 25 28 public SchemaComponentTest(String testcase) { 29 super(testcase); 30 } 31 32 33 protected void setUp() throws Exception { 34 SchemaModel model = Util.loadSchemaModel(TEST_XSD); 35 schema = model.getSchema(); 36 } 37 38 public void testPosition(){ 39 this.assertEquals("<schema> position ", 40, schema.findPosition()); 41 System.out.println("schema position: " + schema.findPosition()); 42 43 Collection <GlobalElement> elements = schema.getElements(); 45 GlobalElement element = elements.iterator().next(); 46 System.out.println("position of first element: " + element.findPosition()); 47 this.assertEquals("<purchaseorder> element position ", 276, element.findPosition()); 48 49 NamedComponentReference<? extends GlobalType> ref = element.getType(); 51 GlobalType type = ref.get(); 52 System.out.println("Position of referenced type: " + type.getName() + ": " + type.findPosition()); 53 assertEquals("referenced PurchaseType position ", 387, type.findPosition() ); 54 55 GlobalComplexType gct = (GlobalComplexType)type; 57 ComplexTypeDefinition def = gct.getDefinition(); 58 System.out.println("Sequence under PurchaseType position: " + def.findPosition()); 59 assertEquals("sequence under PurchaseType position ", 430, def.findPosition() ); 60 61 Collection <GlobalSimpleType> simpleTypes = schema.getSimpleTypes(); 62 GlobalSimpleType simpleType = simpleTypes.iterator().next(); 63 System.out.println("Position of simple Type: " + simpleType.findPosition()); 64 assertEquals("simple type allNNI position ", 865, simpleType.findPosition()); 65 } 66 67 } 68 | Popular Tags |