1 19 20 package org.netbeans.modules.xml.schema.cookies; 21 22 import java.net.URL ; 23 import junit.framework.TestCase; 24 import org.netbeans.api.xml.cookies.CookieMessage; 25 import org.netbeans.api.xml.cookies.CookieObserver; 26 import org.xml.sax.InputSource ; 27 28 33 public class ValidateSchemaSupportTest extends TestCase { 34 35 public ValidateSchemaSupportTest(String testName) { 36 super(testName); 37 } 38 39 40 public void testSchemaSupport() throws Exception { 41 System.out.println("testSchemaSupport"); 42 43 URL invalid = getClass().getResource("data/Invalid.xsd"); 44 URL simple = getClass().getResource("data/Simple.xsd"); 45 URL chameleon = getClass().getResource("data/Chameleon.xsd"); 46 URL imports = getClass().getResource("data/Import.xsd"); 47 URL include = getClass().getResource("data/Include.xsd"); 48 49 assertTrue("Invalid.xsd must not pass!", validate(invalid) == false); 50 assertTrue("Simple.xsd was marked as invalid!", validate(simple)); 51 assertTrue("Chameleon.xsd was marked as invalid!", validate(chameleon)); 52 assertTrue("Import.xsd was marked as invalid!", validate(imports)); 53 assertTrue("Include.xsd was marked as invalid!", validate(include)); 54 } 55 56 public boolean validate(URL schema) throws Exception { 57 InputSource in = new InputSource (schema.toExternalForm()); 58 ValidateSchemaSupport support = new ValidateSchemaSupport(in); 59 return support.validateXML(new CookieObserver() { 60 public void receive(CookieMessage msg) { 61 System.out.println("MSG: " + msg.getMessage()); 62 } 63 }); 64 } 65 66 } 67 | Popular Tags |