1 19 20 package org.netbeans.modules.xml.tools.actions; 21 22 import junit.framework.Test; 23 import junit.textui.TestRunner; 24 import org.netbeans.api.xml.cookies.ValidateXMLCookie; 25 import org.netbeans.junit.NbTestSuite; 26 import org.openide.nodes.Node; 27 28 public class ValidateActionTest extends AbstractCheckTest { 29 30 31 public ValidateActionTest(String testName) { 32 super(testName); 33 } 34 35 37 39 40 public void testIncorrectlyNestedTags() throws Exception { 41 performAction("IncorrectlyNestedTags.xml", new int[] {6}); 42 } 43 44 45 public void testMissingClosingTag() throws Exception { 46 performAction("MissingClosingTag.xml", new int[] {7}); 47 } 48 49 50 public void testMissingRootElement() throws Exception { 51 performAction("MissingRootElement.xml", new int[] {-1}); 52 } 53 54 56 57 public void testInvalidElementName() throws Exception { 58 performAction("InvalidElementName.xml", new int[] {9, 11}); 59 } 60 61 62 public void testInaccessbleDTD() throws Exception { 63 performAction("InaccessbleDTD.xml", new int[] {3}); 64 } 65 66 68 69 public void testInvalidElementNameSD() throws Exception { 70 performAction("InvalidElementNameSD.xml", new int[] {15}); 71 } 72 73 74 public void testInvalidSchemaLocationSD() throws Exception { 75 performAction("InvalidSchemaLocationSD.xml", new int[] {6}); 76 } 77 78 80 81 public void testDistributedDTD() throws Exception { 82 performAction("DistributedDTD.xml", 0); 83 } 84 85 87 88 public void testValidSD() throws Exception { 89 performAction("ValidSD.xml", 0); 90 } 91 92 94 95 protected QaIOReporter performAction(Node[] nodes) { 96 if ((nodes == null) || (nodes.length == 0)) 97 fail("Ileegal argumet 'null'"); 98 99 QaIOReporter reporter = new QaIOReporter(); 100 for (int i = 0; i<nodes.length; i++) { 101 ValidateXMLCookie cake = (ValidateXMLCookie) nodes[i].getCookie(ValidateXMLCookie.class); 102 if (cake == null) fail("Cannot get 'ValidateXMLCookie'.");; 103 cake.validateXML(reporter); 104 } 105 return reporter; 106 } 107 108 110 116 120 public static void main(String [] args) { 121 DEBUG = true; 122 TestRunner.run(ValidateActionTest.class); 124 } 125 } 126 | Popular Tags |