# This patch file was generated by NetBeans IDE # This patch can be applied using context Tools: Apply Diff Patch action on respective folder. # It uses platform neutral UTF-8 encoding. # Above lines and this line are ignored by the patching process. Index: xml/xdm/nbproject/project.xml --- xml/xdm/nbproject/project.xml Base (1.8) +++ xml/xdm/nbproject/project.xml Locally Modified (Based On 1.8) @@ -45,6 +45,13 @@ org.netbeans.modules.xml.xdm + + org.netbeans.modules.xml.xdm + org.netbeans.modules.xml.xdm.diff + org.netbeans.modules.xml.xdm.nodes + org.netbeans.modules.xml.xdm.visitor + org.netbeans.modules.xml.xdm.xam + org.netbeans.modules.editor.lib @@ -56,6 +63,15 @@ + org.netbeans.modules.lexer + + + + 2 + 1.26 + + + org.netbeans.modules.xml.core @@ -65,6 +81,14 @@ + org.netbeans.modules.xml.lexer + + + + 1.2 + + + org.netbeans.modules.xml.text @@ -121,13 +145,6 @@ - - org.netbeans.modules.xml.xdm - org.netbeans.modules.xml.xdm.diff - org.netbeans.modules.xml.xdm.nodes - org.netbeans.modules.xml.xdm.visitor - org.netbeans.modules.xml.xdm.xam - unit Index: xml/xdm/src/org/netbeans/modules/xml/xdm/diff/XDMUtil.java --- xml/xdm/src/org/netbeans/modules/xml/xdm/diff/XDMUtil.java Base (1.6) +++ xml/xdm/src/org/netbeans/modules/xml/xdm/diff/XDMUtil.java Locally Modified (Based On 1.6) @@ -44,9 +44,7 @@ import java.io.IOException; import java.io.UnsupportedEncodingException; import java.util.ArrayList; -import java.util.HashMap; import java.util.List; -import java.util.Map; import javax.swing.text.BadLocationException; import org.netbeans.editor.BaseDocument; import org.netbeans.modules.xml.text.syntax.XMLKit; @@ -63,7 +61,6 @@ import org.openide.util.Lookup; import org.openide.util.lookup.Lookups; import javax.swing.text.Document; -import org.netbeans.modules.xml.xdm.nodes.Token; import org.w3c.dom.NamedNodeMap; import org.w3c.dom.NodeList; Index: xml/xdm/src/org/netbeans/modules/xml/xdm/nodes/Token.java --- xml/xdm/src/org/netbeans/modules/xml/xdm/nodes/Token.java Base (1.8) +++ xml/xdm/src/org/netbeans/modules/xml/xdm/nodes/Token.java Locally Modified (Based On 1.8) @@ -41,9 +41,6 @@ package org.netbeans.modules.xml.xdm.nodes; -import java.util.HashMap; -import java.util.Map; - /** * * @author Ajit Bhate @@ -87,17 +84,19 @@ case TOKEN_ATTR_EQUAL: { t = EQUALS_TOKEN; break; - } case TOKEN_ELEMENT_END_TAG: { + } + case TOKEN_ELEMENT_END_TAG: { t = value.length() == 1 ? CLOSE_ELEMENT:SELF_CLOSE_ELEMENT; break; - } case TOKEN_WHITESPACE: { + } + case TOKEN_WHITESPACE: { if(value.equals(" ")){ t = WHITESPACE_TOKEN; break; } } default: { - t = new Token(value,type); + t = new Token(value.intern(),type); } } assert t != null; @@ -123,13 +122,12 @@ new Token("]]>", TokenType.TOKEN_CDATA_VAL); //NOI18N public static final Token COMMENT_START = - new Token("", TokenType.TOKEN_CDATA_VAL); //NOI18N + new Token("-->", TokenType.TOKEN_COMMENT); //NOI18N - // private static Map tokenMap = new HashMap(); - private final String value; private final TokenType type; + //private static Map tokenPool = new HashMap(); } Index: xml/xdm/src/org/netbeans/modules/xml/xdm/nodes/XMLSyntaxParser.java --- xml/xdm/src/org/netbeans/modules/xml/xdm/nodes/XMLSyntaxParser.java Base (1.8) +++ xml/xdm/src/org/netbeans/modules/xml/xdm/nodes/XMLSyntaxParser.java Locally Modified (Based On 1.8) @@ -41,72 +41,81 @@ package org.netbeans.modules.xml.xdm.nodes; -import java.io.ByteArrayInputStream; -import java.io.CharConversionException; -import java.io.EOFException; import java.io.IOException; -import java.io.InputStream; -import java.io.InputStreamReader; -import java.io.Reader; -import java.io.UnsupportedEncodingException; import java.util.List; import java.util.ArrayList; import java.util.Stack; import javax.swing.text.BadLocationException; import org.netbeans.editor.BaseDocument; -import org.netbeans.editor.TokenID; -import org.netbeans.editor.TokenItem; -import org.netbeans.editor.ext.ExtSyntaxSupport; -import org.netbeans.modules.xml.text.syntax.XMLTokenIDs; +import org.netbeans.api.lexer.TokenSequence; +import org.netbeans.api.lexer.TokenHierarchy; +import org.netbeans.api.xml.lexer.XMLTokenId; public class XMLSyntaxParser { public Document parse(BaseDocument basedoc) throws IOException, BadLocationException { - - // get syntax and get token chain - ExtSyntaxSupport sup = (ExtSyntaxSupport)basedoc.getSyntaxSupport(); - TokenItem token = sup.getTokenChain(0, basedoc.getLength()); - // create the core model Stack stack = new Stack(); Document doc = new Document(); stack.push(doc); NodeImpl currentNode = doc; List currentTokens = new ArrayList(); + + TokenHierarchy th = TokenHierarchy.get(basedoc); + TokenSequence tokenSequence = th.tokenSequence(); + org.netbeans.api.lexer.Token token = tokenSequence.token(); // Add the text token, if any, before xml decalration to document node - if(isValid(token) && token.getTokenID().getNumericID() == XMLTokenIDs.TEXT_ID) { - currentTokens.add(Token.create(token.getImage(),TokenType.TOKEN_CHARACTER_DATA)); - token = token.getNext(); + if(token != null && token.id() == XMLTokenId.TEXT) { + currentTokens.add(Token.create(token.text().toString(),TokenType.TOKEN_CHARACTER_DATA)); + if(tokenSequence.moveNext()) { + token = tokenSequence.token(); + } // if the xml decalration is not there assign this token to document - if(isValid(token) && token.getTokenID().getNumericID() != XMLTokenIDs.PI_START_ID) { + if(token.id() != XMLTokenId.PI_START) { currentNode.setTokens(new ArrayList(currentTokens)); currentTokens.clear(); } } - while (token != null) { - isValid(token); - TokenID tokenId = token.getTokenID(); - int numericId = tokenId.getNumericID(); - String image = token.getImage(); - TokenType coreTokenId = TokenType.TOKEN_WHITESPACE; - switch(numericId) { - case XMLTokenIDs.PI_START_ID: + while (tokenSequence.moveNext()) { + token = tokenSequence.token(); + XMLTokenId tokenId = token.id(); + String image = token.text().toString(); + TokenType tokenType = TokenType.TOKEN_WHITESPACE; + switch(tokenId) { + case PI_START: { - coreTokenId = TokenType.TOKEN_PI_START_TAG; - currentTokens.add(Token.create(image,coreTokenId)); + tokenType = TokenType.TOKEN_PI_START_TAG; + currentTokens.add(Token.create(image,tokenType)); break; } - case XMLTokenIDs.PI_END_ID: + case PI_TARGET: { - coreTokenId = TokenType.TOKEN_PI_END_TAG; - currentTokens.add(Token.create(image,coreTokenId)); + tokenType = TokenType.TOKEN_PI_NAME; + currentTokens.add(Token.create(image, tokenType)); + break; + } + case PI_CONTENT: + { + tokenType = TokenType.TOKEN_PI_VAL; + currentTokens.add(Token.create(image, tokenType)); + break; + } + case PI_END: + { + tokenType = TokenType.TOKEN_PI_END_TAG; + currentTokens.add(Token.create(image,tokenType)); if(currentNode instanceof Document) { - if(token.getNext().getTokenID().getNumericID() == XMLTokenIDs.TEXT_ID) { - token = token.getNext(); - currentTokens.add(Token.create(token.getImage(),TokenType.TOKEN_CHARACTER_DATA)); + if(tokenSequence.moveNext()) { + org.netbeans.api.lexer.Token t = tokenSequence.token(); + if(t.id() == XMLTokenId.TEXT) { + currentTokens.add(Token.create(t.text().toString(),TokenType.TOKEN_CHARACTER_DATA)); + } else { + tokenSequence.movePrevious(); } + } + if(stack.peek() != currentNode) stack.push(currentNode); } List list = new ArrayList(currentNode.getTokens()); @@ -115,7 +124,7 @@ currentTokens.clear(); break; } - case XMLTokenIDs.TAG_ID: + case TAG: { int len = image.length(); if (image.charAt(len-1) == '>') { @@ -132,7 +141,7 @@ currentNode.getTokensForWrite().addAll(currentTokens); currentTokens.clear(); } else { - coreTokenId = TokenType.TOKEN_ELEMENT_START_TAG; + tokenType = TokenType.TOKEN_ELEMENT_START_TAG; if(image.startsWith(" t = tokenSequence.token(); + while(t != null) { + if(t.id() != XMLTokenId.WS) { + tokenSequence.movePrevious(); break; - coreTokenId = TokenType.TOKEN_WHITESPACE; - currentTokens.add(Token.create(token.getImage(), coreTokenId)); - token = token.getNext(); } - if(token == null || !token.getImage().equals(">")) + tokenType = TokenType.TOKEN_WHITESPACE; + currentTokens.add(Token.create(t.text().toString(), tokenType)); + if(!tokenSequence.moveNext()) + break; + t = tokenSequence.token(); + } + if(t == null || !t.text().toString().equals(">")) throw new IOException("Invalid token '" + saveTokenImage + "' does not end with '>': Please use the " + "text editor to resolve the issues..."); @@ -163,51 +176,51 @@ Node parent = stack.peek(); parent.appendChild(currentNode); stack.push(currentNode); - currentTokens.add(Token.create(image,coreTokenId)); + currentTokens.add(Token.create(image,tokenType)); currentNode.setTokens(new ArrayList(currentTokens)); currentTokens.clear(); } } break; } - case XMLTokenIDs.ARGUMENT_ID: + case ARGUMENT: //attribute of an element { - coreTokenId = TokenType.TOKEN_ATTR_NAME; + tokenType = TokenType.TOKEN_ATTR_NAME; currentNode = new Attribute(); Element parent = (Element)stack.peek(); parent.appendAttribute((Attribute)currentNode); - currentTokens.add(Token.create(image,coreTokenId)); + currentTokens.add(Token.create(image,tokenType)); break; } - case XMLTokenIDs.VALUE_ID: + case VALUE: { - TokenItem nextToken = token.getNext(); - isValid(nextToken); - int nextNumericId = nextToken.getTokenID().getNumericID(); - while(nextNumericId == XMLTokenIDs.VALUE_ID || nextNumericId == XMLTokenIDs.CHARACTER_ID) { - token = token.getNext(); - image = image.concat(token.getImage()); - nextNumericId = token.getNext().getTokenID().getNumericID(); - } - coreTokenId = TokenType.TOKEN_ATTR_VAL; - currentTokens.add(Token.create(image,coreTokenId)); +// tokenSequence.moveNext(); +// org.netbeans.api.lexer.Token t = tokenSequence.token(); +// while(t.id() == XMLTokenId.VALUE || t.id() == XMLTokenId.CHARACTER) { +// image = image.concat(t.text().toString()); +// tokenSequence.moveNext(); +// t = tokenSequence.token(); +// } + tokenType = TokenType.TOKEN_ATTR_VAL; + currentTokens.add(Token.create(image,tokenType)); currentNode.setTokens(new ArrayList(currentTokens)); currentTokens.clear(); break; } - case XMLTokenIDs.BLOCK_COMMENT_ID: + case BLOCK_COMMENT: { + tokenType = TokenType.TOKEN_COMMENT; Node parent = stack.peek(); - currentTokens.add(Token.create(image, coreTokenId)); + currentTokens.add(Token.create(image, tokenType)); if (image.endsWith(Token.COMMENT_END.getValue())) { String combinedString = combineString(currentTokens); Comment comment = new Comment(combinedString); if (parent instanceof Element) { ((Element)parent).appendChild(comment, false); } else {//parent is Document - if(numericId != XMLTokenIDs.BLOCK_COMMENT_ID && - token.getImage().trim().length() > 0) { - throw new IOException("Invalid token '" + token.getImage() + + if(token.id() != XMLTokenId.BLOCK_COMMENT && + token.text().toString().trim().length() > 0) { + throw new IOException("Invalid token '" + token.text() + "' found in document: " + "Please use the text editor to resolve the issues..."); } @@ -217,29 +230,30 @@ } break; } - case XMLTokenIDs.TEXT_ID: - case XMLTokenIDs.CHARACTER_ID: + case TEXT: + case CHARACTER: { - coreTokenId = TokenType.TOKEN_CHARACTER_DATA; + tokenType = TokenType.TOKEN_CHARACTER_DATA; currentNode = new Text(); - currentTokens.add(Token.create(image,coreTokenId)); - if(numericId == XMLTokenIDs.TEXT_ID) { - while(token.getNext() != null) { - int nextNumericId = token.getNext().getTokenID().getNumericID(); - if(nextNumericId != XMLTokenIDs.TEXT_ID && nextNumericId != XMLTokenIDs.CHARACTER_ID) + currentTokens.add(Token.create(image,tokenType)); + if(token.id() == XMLTokenId.TEXT) { + while(tokenSequence.moveNext()) { + org.netbeans.api.lexer.Token t = tokenSequence.offsetToken(); + if(t.id() != XMLTokenId.TEXT && t.id() != XMLTokenId.CHARACTER) { + tokenSequence.movePrevious(); break; - token = token.getNext(); - currentTokens.add(Token.create(token.getImage(),coreTokenId)); } + currentTokens.add(Token.create(t.text().toString(), tokenType)); } + } currentNode.setTokens(new ArrayList(currentTokens)); Node parent = stack.peek(); if (parent instanceof Element) { ((Element)parent).appendChild(currentNode, false); } else {//parent is Document - if(numericId != XMLTokenIDs.BLOCK_COMMENT_ID && - token.getImage().trim().length() > 0) { - throw new IOException("Invalid token '" + token.getImage() + + if(token.id() != XMLTokenId.BLOCK_COMMENT && + token.text().toString().trim().length() > 0) { + throw new IOException("Invalid token '" + token.text() + "' found in document: " + "Please use the text editor to resolve the issues..."); } @@ -248,45 +262,35 @@ currentTokens.clear(); break; } - case XMLTokenIDs.WS_ID: + case WS: { - coreTokenId = TokenType.TOKEN_WHITESPACE; - currentTokens.add(Token.create(image, coreTokenId)); + tokenType = TokenType.TOKEN_WHITESPACE; + currentTokens.add(Token.create(image, tokenType)); break; } - case XMLTokenIDs.OPERATOR_ID: + case OPERATOR: { - coreTokenId = TokenType.TOKEN_ATTR_EQUAL; - currentTokens.add(Token.create(image,coreTokenId)); + tokenType = TokenType.TOKEN_ATTR_EQUAL; + currentTokens.add(Token.create(image,tokenType)); break; } - case XMLTokenIDs.DECLARATION_ID: + case DECLARATION: { - coreTokenId = TokenType.TOKEN_DTD_VAL; - currentTokens.add(Token.create(image, coreTokenId)); - while(token.getNext() != null) { - int nextNumericId = token.getNext().getTokenID().getNumericID(); - if(nextNumericId != XMLTokenIDs.DECLARATION_ID && nextNumericId != XMLTokenIDs.VALUE_ID) + tokenType = TokenType.TOKEN_DTD_VAL; + currentTokens.add(Token.create(image, tokenType)); + while(tokenSequence.moveNext()) { + org.netbeans.api.lexer.Token t = tokenSequence.token(); + XMLTokenId id = t.id(); + if(id != XMLTokenId.DECLARATION && id != XMLTokenId.VALUE) { + tokenSequence.movePrevious(); break; - token = token.getNext(); - currentTokens.add(Token.create(token.getImage(),coreTokenId)); } - break; + currentTokens.add(Token.create(t.text().toString(), tokenType)); } - case XMLTokenIDs.PI_CONTENT_ID: - { - coreTokenId = TokenType.TOKEN_PI_VAL; - currentTokens.add(Token.create(image, coreTokenId)); break; } - case XMLTokenIDs.PI_TARGET_ID: + case CDATA_SECTION: { - coreTokenId = TokenType.TOKEN_PI_NAME; - currentTokens.add(Token.create(image, coreTokenId)); - break; - } - case XMLTokenIDs.CDATA_SECTION_ID: - { Node parent = stack.peek(); CData cdata = new CData(image); if (parent instanceof Element) { @@ -295,30 +299,27 @@ throw new IOException("CDATA is not valid as direct child of document" + "Please use the text editor to resolve the issues..."); } - coreTokenId = TokenType.TOKEN_CDATA_VAL; + tokenType = TokenType.TOKEN_CDATA_VAL; break; } - case XMLTokenIDs.ERROR_ID: - case XMLTokenIDs.EOL_ID: + case ERROR: + case EOL: default: - //throw new IllegalArgumentException(); - throw new IOException("Invalid token '" + token.getImage() + "' found in document: " + + throw new IOException("Invalid token found in document: " + "Please use the text editor to resolve the issues..."); } - token = token.getNext(); } Node result = stack.pop(); if(result instanceof Document) { return (Document)result; - } - else - //throw new IllegalArgumentException(); + } else { throw new IOException("Document not well formed/Invalid: " + "Please use the text editor to resolve the issues..."); } + } - private boolean isValid(TokenItem token) throws IOException { - if(token!=null && token.getTokenID()!=null) + private boolean isValid(org.netbeans.api.lexer.Token token) throws IOException { + if(token!=null && token.id() != null) return true; else throw new IOException("Document parsed is invalid: Please use the text " + Index: xml/xdm/src/org/netbeans/modules/xml/xdm/visitor/Utils.java --- xml/xdm/src/org/netbeans/modules/xml/xdm/visitor/Utils.java Base (1.6) +++ xml/xdm/src/org/netbeans/modules/xml/xdm/visitor/Utils.java Locally Modified (Based On 1.6) @@ -44,6 +44,8 @@ import javax.swing.text.AbstractDocument; import java.io.IOException; import javax.swing.text.BadLocationException; +import org.netbeans.api.lexer.Language; +import org.netbeans.api.xml.lexer.XMLTokenId; import org.netbeans.editor.BaseDocument; import org.netbeans.modules.xml.text.syntax.XMLKit; import org.netbeans.modules.xml.xdm.nodes.Document; @@ -142,6 +144,7 @@ public static BaseDocument loadDocument(String text) throws IOException { BaseDocument sd = new BaseDocument(XMLKit.class, false); + sd.putProperty(Language.class, XMLTokenId.language()); try { sd.insertString(0, text, null); return sd; Index: xml/xdm/src/org/netbeans/modules/xml/xdm/XDMModel.java --- xml/xdm/src/org/netbeans/modules/xml/xdm/XDMModel.java Base (1.15) +++ xml/xdm/src/org/netbeans/modules/xml/xdm/XDMModel.java Locally Modified (Based On 1.15) @@ -47,8 +47,6 @@ import java.util.Collection; import java.util.List; import java.util.Map; -import java.util.logging.Level; -import java.util.logging.Logger; import javax.swing.event.UndoableEditEvent; import javax.swing.event.UndoableEditListener; import javax.swing.text.BadLocationException; @@ -57,6 +55,8 @@ import javax.swing.undo.UndoableEditSupport; import javax.xml.XMLConstants; import javax.xml.namespace.QName; +import org.netbeans.api.lexer.Language; +import org.netbeans.api.xml.lexer.XMLTokenId; import org.netbeans.editor.BaseDocument; import org.netbeans.modules.xml.xam.ModelSource; import org.netbeans.modules.xml.xam.dom.ElementIdentity; @@ -162,6 +162,8 @@ Status oldStat = getStatus(); try { setStatus(Status.PARSING); // to access in case old broken tree + //must set the language for XML lexer to work. + getSwingDocument().putProperty(Language.class, XMLTokenId.language()); Document newDoc = parser.parse(getSwingDocument()); Document oldDoc = getCurrentDocument(); if (oldDoc == null) { Index: xml/xdm/test/unit/src/org/netbeans/modules/xml/xdm/nodes/XMLSyntaxParserTest.java --- xml/xdm/test/unit/src/org/netbeans/modules/xml/xdm/nodes/XMLSyntaxParserTest.java Base (1.5) +++ xml/xdm/test/unit/src/org/netbeans/modules/xml/xdm/nodes/XMLSyntaxParserTest.java Locally Modified (Based On 1.5) @@ -50,6 +50,8 @@ import java.util.List; import junit.framework.*; +import org.netbeans.api.lexer.Language; +import org.netbeans.api.xml.lexer.XMLTokenId; import org.netbeans.editor.BaseDocument; import org.netbeans.modules.xml.xdm.visitor.FlushVisitor; import org.netbeans.modules.xml.xdm.Util; @@ -70,15 +72,30 @@ public static Test suite() { TestSuite suite = new TestSuite(XMLSyntaxParserTest.class); - + suite.addTest(new XMLSyntaxParserTest("testParse")); + suite.addTest(new XMLSyntaxParserTest("testParseDoctype")); + suite.addTest(new XMLSyntaxParserTest("testParseInvalid")); + suite.addTest(new XMLSyntaxParserTest("testParseInvalidTag")); + suite.addTest(new XMLSyntaxParserTest("testParseInvalidTag2")); + suite.addTest(new XMLSyntaxParserTest("testParseInvalidTag3")); + suite.addTest(new XMLSyntaxParserTest("testParseInvalidTag4")); + suite.addTest(new XMLSyntaxParserTest("testParsePI")); + suite.addTest(new XMLSyntaxParserTest("testParseValidTag")); return suite; } + private BaseDocument getDocument(String path) throws Exception { + BaseDocument basedoc = (BaseDocument)Util.getResourceAsDocument(path); + //must set the language for XML lexer to work. + basedoc.putProperty(Language.class, XMLTokenId.language()); + return basedoc; + } + /** * Test of parse method, of class org.netbeans.modules.xmltools.xmlmodel.nodes.XMLSyntaxParser. */ public void testParse() throws Exception { - BaseDocument basedoc = (BaseDocument)Util.getResourceAsDocument("nodes/test.xml"); + BaseDocument basedoc = getDocument("nodes/test.xml"); XMLSyntaxParser parser = new XMLSyntaxParser(); Document doc = parser.parse(basedoc); assertNotNull("Document can not be null", doc); @@ -91,7 +108,7 @@ * Test of parse method, of class org.netbeans.modules.xmltools.xmlmodel.nodes.XMLSyntaxParser. */ public void testParseInvalid() throws Exception { - BaseDocument basedoc = (BaseDocument)Util.getResourceAsDocument("nodes/invalid.xml"); + BaseDocument basedoc = getDocument("nodes/invalid.xml"); XMLSyntaxParser parser = new XMLSyntaxParser(); try { Document doc = parser.parse(basedoc); @@ -106,7 +123,7 @@ * Test of parse method, of class org.netbeans.modules.xmltools.xmlmodel.nodes.XMLSyntaxParser. */ public void testParseInvalidTag() throws Exception { - BaseDocument basedoc = (BaseDocument)Util.getResourceAsDocument("nodes/invalidtag.xml"); + BaseDocument basedoc = getDocument("nodes/invalidtag.xml"); XMLSyntaxParser parser = new XMLSyntaxParser(); try { Document doc = parser.parse(basedoc); @@ -121,7 +138,7 @@ * Test of parse method, of class org.netbeans.modules.xmltools.xmlmodel.nodes.XMLSyntaxParser. */ public void testParseInvalidTag2() throws Exception { - BaseDocument basedoc = (BaseDocument)Util.getResourceAsDocument("nodes/invalidtag2.xml"); + BaseDocument basedoc = getDocument("nodes/invalidtag2.xml"); XMLSyntaxParser parser = new XMLSyntaxParser(); try { Document doc = parser.parse(basedoc); @@ -136,14 +153,14 @@ * Test of parse method, of class org.netbeans.modules.xmltools.xmlmodel.nodes.XMLSyntaxParser. */ public void testParseInvalidTag3() throws Exception { - BaseDocument basedoc = (BaseDocument)Util.getResourceAsDocument("nodes/invalidtag3.xml"); + BaseDocument basedoc = getDocument("nodes/invalidtag3.xml"); XMLSyntaxParser parser = new XMLSyntaxParser(); try { Document doc = parser.parse(basedoc); assertTrue("Should not come here", false); } catch(Exception ex) { assertTrue("Invalid Token exception" , - ex.getMessage().contains("Invalid token '<' found in document")); + ex.getMessage().contains("Invalid token found in document")); } } @@ -151,7 +168,7 @@ * Test of parse method, of class org.netbeans.modules.xmltools.xmlmodel.nodes.XMLSyntaxParser. */ public void testParseInvalidTag4() throws Exception { - BaseDocument basedoc = (BaseDocument)Util.getResourceAsDocument("nodes/invalidtag4.xml"); + BaseDocument basedoc = getDocument("nodes/invalidtag4.xml"); XMLSyntaxParser parser = new XMLSyntaxParser(); try { Document doc = parser.parse(basedoc); @@ -166,7 +183,7 @@ * Test of parse method, of class org.netbeans.modules.xmltools.xmlmodel.nodes.XMLSyntaxParser. */ public void testParseValidTag() throws Exception { - BaseDocument basedoc = (BaseDocument)Util.getResourceAsDocument("nodes/validtag.xml"); + BaseDocument basedoc = getDocument("nodes/validtag.xml"); XMLSyntaxParser parser = new XMLSyntaxParser(); try { Document doc = parser.parse(basedoc); @@ -176,7 +193,7 @@ } public void testParsePI() throws Exception { - BaseDocument basedoc = (BaseDocument)Util.getResourceAsDocument("resources/PI_after_prolog.xml"); + BaseDocument basedoc = getDocument("resources/PI_after_prolog.xml"); XMLSyntaxParser parser = new XMLSyntaxParser(); Document doc = parser.parse(basedoc); @@ -197,7 +214,7 @@ * Test the parsing of doctype */ public void testParseDoctype() throws Exception { - BaseDocument basedoc = (BaseDocument)Util.getResourceAsDocument("nodes/testDoctype.xml"); + BaseDocument basedoc = getDocument("nodes/testDoctype.xml"); XMLSyntaxParser parser = new XMLSyntaxParser(); Document doc = parser.parse(basedoc); assertNotNull("Document can not be null", doc);