[NETBEANS-54] Module review xml.text - no external library - checked Rat report; added license to many test files and adjusted tests to match these; exclude GUI visible sample data and special test data - skimmed through the module, did not notice additional problems
Project: http://git-wip-us.apache.org/repos/asf/incubator-netbeans/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-netbeans/commit/00155f15 Tree: http://git-wip-us.apache.org/repos/asf/incubator-netbeans/tree/00155f15 Diff: http://git-wip-us.apache.org/repos/asf/incubator-netbeans/diff/00155f15 Branch: refs/heads/master Commit: 00155f15e55969a636a395fd7f912708c1928bd6 Parents: 498cc4f Author: Matthias Bläsing <[email protected]> Authored: Tue Oct 3 21:17:52 2017 +0200 Committer: Matthias Bläsing <[email protected]> Committed: Wed Oct 11 19:04:53 2017 +0200 ---------------------------------------------------------------------- nbbuild/build.xml | 3 + .../XMLFormatterTest/testReformatSample1.pass | 19 +++++++ .../XMLFormatterTest/testReformatSample2.pass | 28 ++++----- .../input/XMLFormatterTest/testReformat/web.xml | 19 +++++++ .../modules/xml/text/AbstractTestCase.java | 22 +++---- .../text/bracematch/XMLBraceMatcherTest.java | 60 ++++++++++---------- .../modules/xml/text/bracematch/test.xml | 20 +++++++ .../ElementResultItemDocumentationTest.java | 4 +- .../modules/xml/text/completion/parentDoc.html | 20 +++++++ .../xml/text/completion/res/docResource.html | 20 +++++++ .../xml/text/completion/res/relativeLink1.html | 20 +++++++ .../xml/text/dom/XMLSyntaxSupportTest.java | 18 +++--- .../netbeans/modules/xml/text/dom/result1.txt | 52 +++++++++++------ .../netbeans/modules/xml/text/dom/result2.txt | 48 ++++++++++------ .../modules/xml/text/indent/1998stats.xml | 19 +++++++ .../xml/text/indent/XMLLexerFormatterTest.java | 10 ++-- .../netbeans/modules/xml/text/indent/input.xml | 21 ++++++- .../netbeans/modules/xml/text/indent/input2.xsd | 19 +++++++ .../xml/text/indent/input_attrsIndent.xml | 20 +++++++ .../text/indent/input_breaksMixedContent.xml | 19 +++++++ .../xml/text/indent/input_cdataContent.xml | 20 +++++++ .../xml/text/indent/input_contentIndent.xml | 20 +++++++ .../xml/text/indent/input_emptyComment.xml | 20 +++++++ .../xml/text/indent/input_nestedSame.xml | 20 +++++++ .../xml/text/indent/input_newlineInTags.xml | 20 +++++++ .../modules/xml/text/indent/input_preserve.xml | 20 +++++++ .../xml/text/indent/input_processingXml.xml | 20 +++++++ .../modules/xml/text/indent/input_sub.xml | 21 ++++++- .../modules/xml/text/indent/input_sub1.xml | 20 +++++++ .../modules/xml/text/indent/input_sub2.xml | 20 +++++++ .../xml/text/indent/input_tagAtStatOfLine.xml | 20 +++++++ .../xml/text/indent/input_withpreserve.xml | 20 +++++++ .../netbeans/modules/xml/text/indent/output.xml | 21 ++++++- .../modules/xml/text/indent/output2.xsd | 19 +++++++ .../xml/text/indent/output_attrsIndent.xml | 20 +++++++ .../text/indent/output_breaksMixedContent.xml | 19 +++++++ .../xml/text/indent/output_cdataContent.xml | 20 +++++++ .../xml/text/indent/output_contentIndent.xml | 20 +++++++ .../xml/text/indent/output_emptyComment.xml | 20 +++++++ .../xml/text/indent/output_nestedSame.xml | 20 +++++++ .../xml/text/indent/output_newlineInTags.xml | 20 +++++++ .../modules/xml/text/indent/output_preserve.xml | 22 ++++++- .../xml/text/indent/output_processingXml.xml | 20 +++++++ .../modules/xml/text/indent/output_sub.xml | 21 ++++++- .../modules/xml/text/indent/output_sub1.xml | 20 +++++++ .../modules/xml/text/indent/output_sub2.xml | 20 +++++++ .../xml/text/indent/output_tagAtStatOfLine.xml | 20 +++++++ .../xml/text/indent/output_withpreserve.xml | 20 +++++++ .../modules/xml/text/syntax/invalid.xml | 20 +++++++ .../netbeans/modules/xml/text/syntax/test.xml | 20 +++++++ 50 files changed, 953 insertions(+), 111 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-netbeans/blob/00155f15/nbbuild/build.xml ---------------------------------------------------------------------- diff --git a/nbbuild/build.xml b/nbbuild/build.xml index 61679db..7a59cc1 100644 --- a/nbbuild/build.xml +++ b/nbbuild/build.xml @@ -1972,6 +1972,9 @@ It is possible to use -Ddebug.port=3234 -Ddebug.pause=y to start the system in d <exclude name="utilities/test/unit/src/org/netbeans/modules/openfile/resources/recent_files/*" /> <!--test data--> <exclude name="**/*.url" /> <!--no degree of creativity--> <exclude name="spi.navigator/test/unit/src/org/netbeans/modules/navigator/resources/lastsel/file.lastsel_mime1" /> <!--empty file--> + <exclude name="xml.text/src/org/netbeans/modules/xml/text/resources/DTDExample" /> <!-- GUI sample file to demonstrate syntax highlighting --> + <exclude name="xml.text/src/org/netbeans/modules/xml/text/resources/XMLExample" /> <!-- GUI sample file to demonstrate syntax highlighting --> + <exclude name="xml.text/test/qa-functional/src/org/netbeans/modules/xml/text/**/data/**" /> <!-- test data --> <exclude name="xsl/src/org/netbeans/modules/xsl/resources/templates/stylesheet.xsl" /> <!-- Template for user - very limited degree of creativity --> <exclude name="xsl/test/unit/src/org/netbeans/modules/xsl/utils/data/*" /> <!--test data--> <exclude name="spi.navigator/test/unit/src/org/netbeans/modules/navigator/resources/lastsel/file.lastsel_mime1" /> <!--empty file--> http://git-wip-us.apache.org/repos/asf/incubator-netbeans/blob/00155f15/xml.text/test/unit/data/goldenfiles/org/netbeans/modules/xml/text/indent/XMLFormatterTest/testReformatSample1.pass ---------------------------------------------------------------------- diff --git a/xml.text/test/unit/data/goldenfiles/org/netbeans/modules/xml/text/indent/XMLFormatterTest/testReformatSample1.pass b/xml.text/test/unit/data/goldenfiles/org/netbeans/modules/xml/text/indent/XMLFormatterTest/testReformatSample1.pass index 11e1b78..46cdf92 100644 --- a/xml.text/test/unit/data/goldenfiles/org/netbeans/modules/xml/text/indent/XMLFormatterTest/testReformatSample1.pass +++ b/xml.text/test/unit/data/goldenfiles/org/netbeans/modules/xml/text/indent/XMLFormatterTest/testReformatSample1.pass @@ -1,5 +1,24 @@ <?xml version="1.0" encoding="UTF-8"?> +<!-- + Licensed to the Apache Software Foundation (ASF) under one + or more contributor license agreements. See the NOTICE file + distributed with this work for additional information + regarding copyright ownership. The ASF licenses this file + to you under the Apache License, Version 2.0 (the + "License"); you may not use this file except in compliance + with the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, + software distributed under the License is distributed on an + "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + KIND, either express or implied. See the License for the + specific language governing permissions and limitations + under the License. + +--> <web-app xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd" http://git-wip-us.apache.org/repos/asf/incubator-netbeans/blob/00155f15/xml.text/test/unit/data/goldenfiles/org/netbeans/modules/xml/text/indent/XMLFormatterTest/testReformatSample2.pass ---------------------------------------------------------------------- diff --git a/xml.text/test/unit/data/goldenfiles/org/netbeans/modules/xml/text/indent/XMLFormatterTest/testReformatSample2.pass b/xml.text/test/unit/data/goldenfiles/org/netbeans/modules/xml/text/indent/XMLFormatterTest/testReformatSample2.pass index a52e983..e4d15eb 100644 --- a/xml.text/test/unit/data/goldenfiles/org/netbeans/modules/xml/text/indent/XMLFormatterTest/testReformatSample2.pass +++ b/xml.text/test/unit/data/goldenfiles/org/netbeans/modules/xml/text/indent/XMLFormatterTest/testReformatSample2.pass @@ -1,21 +1,23 @@ <?xml version="1.0" encoding="UTF-8"?> <!-- -*- sgml-indent-step: 2 -*- --> <!-- -The contents of this file are subject to the terms of the Common Development -and Distribution License (the License). You may not use this file except in -compliance with the License. -You can obtain a copy of the License at http://www.netbeans.org/cddl.html -or http://www.netbeans.org/cddl.txt. + Licensed to the Apache Software Foundation (ASF) under one + or more contributor license agreements. See the NOTICE file + distributed with this work for additional information + regarding copyright ownership. The ASF licenses this file + to you under the Apache License, Version 2.0 (the + "License"); you may not use this file except in compliance + with the License. You may obtain a copy of the License at -When distributing Covered Code, include this CDDL Header Notice in each file -and include the License file at http://www.netbeans.org/cddl.txt. -If applicable, add the following below the CDDL Header, with the fields -enclosed by brackets [] replaced by your own identifying information: -"Portions Copyrighted [year] [name of copyright owner]" + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, + software distributed under the License is distributed on an + "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + KIND, either express or implied. See the License for the + specific language governing permissions and limitations + under the License. -The Original Software is NetBeans. The Initial Developer of the Original -Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun -Microsystems, Inc. All Rights Reserved. --> <project name="nbbuild" default="all" basedir="."> http://git-wip-us.apache.org/repos/asf/incubator-netbeans/blob/00155f15/xml.text/test/unit/data/input/XMLFormatterTest/testReformat/web.xml ---------------------------------------------------------------------- diff --git a/xml.text/test/unit/data/input/XMLFormatterTest/testReformat/web.xml b/xml.text/test/unit/data/input/XMLFormatterTest/testReformat/web.xml index 65c9467..cacd1df 100644 --- a/xml.text/test/unit/data/input/XMLFormatterTest/testReformat/web.xml +++ b/xml.text/test/unit/data/input/XMLFormatterTest/testReformat/web.xml @@ -1,5 +1,24 @@ <?xml version="1.0" encoding="UTF-8"?> +<!-- + Licensed to the Apache Software Foundation (ASF) under one + or more contributor license agreements. See the NOTICE file + distributed with this work for additional information + regarding copyright ownership. The ASF licenses this file + to you under the Apache License, Version 2.0 (the + "License"); you may not use this file except in compliance + with the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, + software distributed under the License is distributed on an + "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + KIND, either express or implied. See the License for the + specific language governing permissions and limitations + under the License. + +--> <web-app xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd" http://git-wip-us.apache.org/repos/asf/incubator-netbeans/blob/00155f15/xml.text/test/unit/src/org/netbeans/modules/xml/text/AbstractTestCase.java ---------------------------------------------------------------------- diff --git a/xml.text/test/unit/src/org/netbeans/modules/xml/text/AbstractTestCase.java b/xml.text/test/unit/src/org/netbeans/modules/xml/text/AbstractTestCase.java index 98ba328..037582e 100644 --- a/xml.text/test/unit/src/org/netbeans/modules/xml/text/AbstractTestCase.java +++ b/xml.text/test/unit/src/org/netbeans/modules/xml/text/AbstractTestCase.java @@ -114,20 +114,16 @@ public class AbstractTestCase extends NbTestCase { /** * Converts expected result data into a string. See result*.txt files. */ - protected String getExpectedResultAsString(String resultFile) { + protected String getExpectedResultAsString(String resultFile) throws IOException { StringBuilder expectedResult = new StringBuilder(); - InputStream in = AbstractTestCase.class.getResourceAsStream(resultFile); - Scanner scanner = new Scanner(in); - try { - while(scanner.hasNextLine()) { - expectedResult.append(scanner.nextLine()); - } - } finally { - scanner.close(); - try { - in.close(); - } catch (IOException ex) { - //stupid catch + try (InputStream in = AbstractTestCase.class.getResourceAsStream(resultFile); + Scanner scanner = new Scanner(in)) { + while (scanner.hasNextLine()) { + String line = scanner.nextLine(); + if (!line.trim().startsWith("#")) { + expectedResult.append(line); + expectedResult.append("\n"); + } } } return expectedResult.toString(); http://git-wip-us.apache.org/repos/asf/incubator-netbeans/blob/00155f15/xml.text/test/unit/src/org/netbeans/modules/xml/text/bracematch/XMLBraceMatcherTest.java ---------------------------------------------------------------------- diff --git a/xml.text/test/unit/src/org/netbeans/modules/xml/text/bracematch/XMLBraceMatcherTest.java b/xml.text/test/unit/src/org/netbeans/modules/xml/text/bracematch/XMLBraceMatcherTest.java index b8f03c9..d98821a 100644 --- a/xml.text/test/unit/src/org/netbeans/modules/xml/text/bracematch/XMLBraceMatcherTest.java +++ b/xml.text/test/unit/src/org/netbeans/modules/xml/text/bracematch/XMLBraceMatcherTest.java @@ -72,88 +72,88 @@ public class XMLBraceMatcherTest extends AbstractTestCase { public void testDeclaration() throws Exception { BaseDocument doc = getDocument("bracematch/test.xml"); //inside "<!DOCTYPE" - XMLBraceMatcher instance = new XMLBraceMatcher(doc, 44); + XMLBraceMatcher instance = new XMLBraceMatcher(doc, 866); int[] origin = instance.doFindOrigin(); - assert(origin[0] == 39 && origin[1] == 48); + assert(origin[0] == 861 && origin[1] == 870); int[] match = instance.doFindMatches(); - assert(match[0] == 78 && match[1] == 79); + assert(match[0] == 900 && match[1] == 901); //between "<!DOCTYPE" and ">" - instance = new XMLBraceMatcher(doc, 65); + instance = new XMLBraceMatcher(doc, 887); origin = instance.doFindOrigin(); assert(origin == null); match = instance.doFindMatches(); //in declaration end i.e. ">" - instance = new XMLBraceMatcher(doc, 79); + instance = new XMLBraceMatcher(doc, 901); origin = instance.doFindOrigin(); - assert(origin[0] == 78 && origin[1] == 79); + assert(origin[0] == 900 && origin[1] == 901); match = instance.doFindMatches(); - assert(match[0] == 39 && match[1] == 48); + assert(match[0] == 861 && match[1] == 870); } public void testComment() throws Exception { BaseDocument doc = getDocument("bracematch/test.xml"); //inside start of comment i.e "<!--" - XMLBraceMatcher instance = new XMLBraceMatcher(doc, 81); + XMLBraceMatcher instance = new XMLBraceMatcher(doc, 903); int[] origin = instance.doFindOrigin(); - assert(origin[0] == 80 && origin[1] == 84); + assert(origin[0] == 902 && origin[1] == 906); int[] match = instance.doFindMatches(); - assert(match[0] == 103 && match[1] == 106); + assert(match[0] == 925 && match[1] == 928); //somewhere between "<!--" and "-->" - instance = new XMLBraceMatcher(doc, 95); + instance = new XMLBraceMatcher(doc, 917); origin = instance.doFindOrigin(); assert(origin == null); match = instance.doFindMatches(); //inside "-->" - instance = new XMLBraceMatcher(doc, 105); + instance = new XMLBraceMatcher(doc, 927); origin = instance.doFindOrigin(); - assert(origin[0] == 103 && origin[1] == 106); + assert(origin[0] == 925 && origin[1] == 928); match = instance.doFindMatches(); - assert(match[0] == 80 && match[1] == 84); + assert(match[0] == 902 && match[1] == 906); } public void testTag1() throws Exception { BaseDocument doc = getDocument("bracematch/test.xml"); //inside start of root tag "<root" - XMLBraceMatcher instance = new XMLBraceMatcher(doc, 110); + XMLBraceMatcher instance = new XMLBraceMatcher(doc, 932); int[] origin = instance.doFindOrigin(); - assert(origin[0] == 107 && origin[1] == 126); + assert(origin[0] == 929 && origin[1] == 948); int[] match = instance.doFindMatches(); - assert(match[0] == 204 && match[1] == 211); + assert(match[0] == 1026 && match[1] == 1033); //somewhere between "<root" and ">" - instance = new XMLBraceMatcher(doc, 120); + instance = new XMLBraceMatcher(doc, 942); origin = instance.doFindOrigin(); - assert(origin[0] == 107 && origin[1] == 126); + assert(origin[0] == 929 && origin[1] == 948); match = instance.doFindMatches(); //inside "</root>" - instance = new XMLBraceMatcher(doc, 207); + instance = new XMLBraceMatcher(doc, 1029); origin = instance.doFindOrigin(); - assert(origin[0] == 204 && origin[1] == 211); + assert(origin[0] == 1026 && origin[1] == 1033); match = instance.doFindMatches(); - assert(match[0] == 107 && match[1] == 112); - assert(match[2] == 125 && match[3] == 126); + assert(match[0] == 929 && match[1] == 934); + assert(match[2] == 947 && match[3] == 948); } public void testTag2() throws Exception { BaseDocument doc = getDocument("bracematch/test.xml"); //just before > in "<root...>" - XMLBraceMatcher instance = new XMLBraceMatcher(doc, 125); + XMLBraceMatcher instance = new XMLBraceMatcher(doc, 947); int[] origin = instance.doFindOrigin(); - assert(origin[0] == 107 && origin[1] == 126); + assert(origin[0] == 929 && origin[1] == 948); int[] match = instance.doFindMatches(); - assert(match[0] == 204 && match[1] == 211); + assert(match[0] == 1026 && match[1] == 1033); //just before > in "</root...>" - instance = new XMLBraceMatcher(doc, 210); + instance = new XMLBraceMatcher(doc, 1032); origin = instance.doFindOrigin(); - assert(origin[0] == 204 && origin[1] == 211); + assert(origin[0] == 1026 && origin[1] == 1033); match = instance.doFindMatches(); - assert(match[0] == 107 && match[1] == 112); - assert(match[2] == 125 && match[3] == 126); + assert(match[0] == 929 && match[1] == 934); + assert(match[2] == 947 && match[3] == 948); } } http://git-wip-us.apache.org/repos/asf/incubator-netbeans/blob/00155f15/xml.text/test/unit/src/org/netbeans/modules/xml/text/bracematch/test.xml ---------------------------------------------------------------------- diff --git a/xml.text/test/unit/src/org/netbeans/modules/xml/text/bracematch/test.xml b/xml.text/test/unit/src/org/netbeans/modules/xml/text/bracematch/test.xml index 09ef08d..478877d 100644 --- a/xml.text/test/unit/src/org/netbeans/modules/xml/text/bracematch/test.xml +++ b/xml.text/test/unit/src/org/netbeans/modules/xml/text/bracematch/test.xml @@ -1,4 +1,24 @@ <?xml version="1.0" encoding="UTF-8"?> +<!-- + + Licensed to the Apache Software Foundation (ASF) under one + or more contributor license agreements. See the NOTICE file + distributed with this work for additional information + regarding copyright ownership. The ASF licenses this file + to you under the Apache License, Version 2.0 (the + "License"); you may not use this file except in compliance + with the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, + software distributed under the License is distributed on an + "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + KIND, either express or implied. See the License for the + specific language governing permissions and limitations + under the License. + +--> <!DOCTYPE taglib PUBLIC "hello" "hello"> <!-- Hello World. http://git-wip-us.apache.org/repos/asf/incubator-netbeans/blob/00155f15/xml.text/test/unit/src/org/netbeans/modules/xml/text/completion/ElementResultItemDocumentationTest.java ---------------------------------------------------------------------- diff --git a/xml.text/test/unit/src/org/netbeans/modules/xml/text/completion/ElementResultItemDocumentationTest.java b/xml.text/test/unit/src/org/netbeans/modules/xml/text/completion/ElementResultItemDocumentationTest.java index b3dffb6..05e770f 100644 --- a/xml.text/test/unit/src/org/netbeans/modules/xml/text/completion/ElementResultItemDocumentationTest.java +++ b/xml.text/test/unit/src/org/netbeans/modules/xml/text/completion/ElementResultItemDocumentationTest.java @@ -199,7 +199,7 @@ public class ElementResultItemDocumentationTest extends NbTestCase { CompletionDocumentation file = doc.resolveLink(url.toString()); assertNotNull(file); assertEquals("URL must be openable in browser", url, file.getURL()); - assertTrue("Invalid content of the linked doc", file.getText().startsWith("This is an URL resource with <a href=")); + assertTrue("Invalid content of the linked doc", file.getText().contains("This is an URL resource with <a href=")); } /** @@ -283,7 +283,7 @@ public class ElementResultItemDocumentationTest extends NbTestCase { assertNull("Must not be openable in browser", resolved.getURL()); // fwk is able to fetch contents assertTrue("Framework must fetch contents of linked URL", - resolved.getText().startsWith("Resource referenced by relative link")); + resolved.getText().contains("Resource referenced by relative link")); CompletionDocumentation parent = doc.resolveLink("customContent"); assertEquals(PLAIN_DESCRIPTION_TEXT, parent.getText()); http://git-wip-us.apache.org/repos/asf/incubator-netbeans/blob/00155f15/xml.text/test/unit/src/org/netbeans/modules/xml/text/completion/parentDoc.html ---------------------------------------------------------------------- diff --git a/xml.text/test/unit/src/org/netbeans/modules/xml/text/completion/parentDoc.html b/xml.text/test/unit/src/org/netbeans/modules/xml/text/completion/parentDoc.html index e34fbd2..90a539a 100644 --- a/xml.text/test/unit/src/org/netbeans/modules/xml/text/completion/parentDoc.html +++ b/xml.text/test/unit/src/org/netbeans/modules/xml/text/completion/parentDoc.html @@ -1 +1,21 @@ +<!-- + + Licensed to the Apache Software Foundation (ASF) under one + or more contributor license agreements. See the NOTICE file + distributed with this work for additional information + regarding copyright ownership. The ASF licenses this file + to you under the Apache License, Version 2.0 (the + "License"); you may not use this file except in compliance + with the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, + software distributed under the License is distributed on an + "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + KIND, either express or implied. See the License for the + specific language governing permissions and limitations + under the License. + +--> Document in parent directory \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-netbeans/blob/00155f15/xml.text/test/unit/src/org/netbeans/modules/xml/text/completion/res/docResource.html ---------------------------------------------------------------------- diff --git a/xml.text/test/unit/src/org/netbeans/modules/xml/text/completion/res/docResource.html b/xml.text/test/unit/src/org/netbeans/modules/xml/text/completion/res/docResource.html index 6170619..94d1b84 100644 --- a/xml.text/test/unit/src/org/netbeans/modules/xml/text/completion/res/docResource.html +++ b/xml.text/test/unit/src/org/netbeans/modules/xml/text/completion/res/docResource.html @@ -1,2 +1,22 @@ +<!-- + + Licensed to the Apache Software Foundation (ASF) under one + or more contributor license agreements. See the NOTICE file + distributed with this work for additional information + regarding copyright ownership. The ASF licenses this file + to you under the Apache License, Version 2.0 (the + "License"); you may not use this file except in compliance + with the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, + software distributed under the License is distributed on an + "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + KIND, either express or implied. See the License for the + specific language governing permissions and limitations + under the License. + +--> This is an URL resource with <a href="relativeLink1.html">relative link</a> and <a href="http://www.seznam.cz">absolute link</a> http://git-wip-us.apache.org/repos/asf/incubator-netbeans/blob/00155f15/xml.text/test/unit/src/org/netbeans/modules/xml/text/completion/res/relativeLink1.html ---------------------------------------------------------------------- diff --git a/xml.text/test/unit/src/org/netbeans/modules/xml/text/completion/res/relativeLink1.html b/xml.text/test/unit/src/org/netbeans/modules/xml/text/completion/res/relativeLink1.html index c9215a0..52648c7 100644 --- a/xml.text/test/unit/src/org/netbeans/modules/xml/text/completion/res/relativeLink1.html +++ b/xml.text/test/unit/src/org/netbeans/modules/xml/text/completion/res/relativeLink1.html @@ -1 +1,21 @@ +<!-- + + Licensed to the Apache Software Foundation (ASF) under one + or more contributor license agreements. See the NOTICE file + distributed with this work for additional information + regarding copyright ownership. The ASF licenses this file + to you under the Apache License, Version 2.0 (the + "License"); you may not use this file except in compliance + with the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, + software distributed under the License is distributed on an + "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + KIND, either express or implied. See the License for the + specific language governing permissions and limitations + under the License. + +--> Resource referenced by relative link \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-netbeans/blob/00155f15/xml.text/test/unit/src/org/netbeans/modules/xml/text/dom/XMLSyntaxSupportTest.java ---------------------------------------------------------------------- diff --git a/xml.text/test/unit/src/org/netbeans/modules/xml/text/dom/XMLSyntaxSupportTest.java b/xml.text/test/unit/src/org/netbeans/modules/xml/text/dom/XMLSyntaxSupportTest.java index d1c3f14..bbfe81c 100644 --- a/xml.text/test/unit/src/org/netbeans/modules/xml/text/dom/XMLSyntaxSupportTest.java +++ b/xml.text/test/unit/src/org/netbeans/modules/xml/text/dom/XMLSyntaxSupportTest.java @@ -39,8 +39,8 @@ public class XMLSyntaxSupportTest extends AbstractTestCase { public static Test suite() { TestSuite suite = new TestSuite(); -// suite.addTest(new XMLSyntaxSupportTest("testParseForeward")); -// suite.addTest(new XMLSyntaxSupportTest("testParseBackward")); + suite.addTest(new XMLSyntaxSupportTest("testParseForeward")); + suite.addTest(new XMLSyntaxSupportTest("testParseBackward")); suite.addTest(new XMLSyntaxSupportTest("testTokens")); return suite; } @@ -53,10 +53,10 @@ public class XMLSyntaxSupportTest extends AbstractTestCase { SyntaxElement se = support.getElementChain(1); StringBuilder actualResult = new StringBuilder(); while( se != null) { - actualResult.append("Class: " + se.getClass().getSimpleName() + " Offset: " + se.getElementOffset() + " Length: "+ se.getElementLength()); + actualResult.append("Class: " + se.getClass().getSimpleName() + " Offset: " + se.getElementOffset() + " Length: "+ se.getElementLength() + "\n"); se = se.getNext(); } - assert(getExpectedResultAsString("dom/result1.txt").equals(actualResult.toString())); + assertEquals(getExpectedResultAsString("dom/result1.txt"), actualResult.toString()); } public void testParseBackward() throws Exception { @@ -65,20 +65,20 @@ public class XMLSyntaxSupportTest extends AbstractTestCase { SyntaxElement se = support.getElementChain(doc.getLength()-1); StringBuilder actualResult = new StringBuilder(); while( se != null) { - actualResult.append("Class: " + se.getClass().getSimpleName() + " Offset: " + se.getElementOffset() + " Length: "+ se.getElementLength()); + actualResult.append("Class: " + se.getClass().getSimpleName() + " Offset: " + se.getElementOffset() + " Length: "+ se.getElementLength() + "\n"); se = se.getPrevious(); } - assert(getExpectedResultAsString("dom/result2.txt").equals(actualResult.toString())); + assertEquals(getExpectedResultAsString("dom/result2.txt"), actualResult.toString()); } public void testTokens() throws Exception { BaseDocument doc = getDocument("syntax/test.xml"); XMLSyntaxSupport support = XMLSyntaxSupport.getSyntaxSupport(doc); - Token token = support.getPreviousToken(30); + Token token = support.getPreviousToken(852); System.out.println("Token: " + token.id() + " Text: " + token.text()); - token = support.getPreviousToken(31); + token = support.getPreviousToken(852 + 1); System.out.println("Token: " + token.id() + " Text: " + token.text()); - token = support.getPreviousToken(32); + token = support.getPreviousToken(852 + 2); System.out.println("Token: " + token.id() + " Text: " + token.text()); } http://git-wip-us.apache.org/repos/asf/incubator-netbeans/blob/00155f15/xml.text/test/unit/src/org/netbeans/modules/xml/text/dom/result1.txt ---------------------------------------------------------------------- diff --git a/xml.text/test/unit/src/org/netbeans/modules/xml/text/dom/result1.txt b/xml.text/test/unit/src/org/netbeans/modules/xml/text/dom/result1.txt index 7e03686..795d404 100644 --- a/xml.text/test/unit/src/org/netbeans/modules/xml/text/dom/result1.txt +++ b/xml.text/test/unit/src/org/netbeans/modules/xml/text/dom/result1.txt @@ -1,18 +1,36 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. Class: ProcessingInstruction Offset: 0 Length: 21 -Class: Text Offset: 21 Length: 1 -Class: StartTag Offset: 22 Length: 38 -Class: Text Offset: 60 Length: 5 -Class: StartTag Offset: 65 Length: 103 -Class: Text Offset: 168 Length: 13 -Class: EndTag Offset: 181 Length: 11 -Class: Text Offset: 192 Length: 5 -Class: StartTag Offset: 197 Length: 10 -Class: CDATASection Offset: 207 Length: 37 -Class: EndTag Offset: 244 Length: 11 -Class: Text Offset: 255 Length: 5 -Class: Comment Offset: 260 Length: 40 -Class: Text Offset: 300 Length: 5 -Class: EmptyTag Offset: 305 Length: 11 -Class: Text Offset: 316 Length: 1 -Class: EndTag Offset: 317 Length: 10 -Class: Text Offset: 327 Length: 1 +Class: TextImpl Offset: 21 Length: 1 +Class: Comment Offset: 22 Length: 821 +Class: TextImpl Offset: 843 Length: 1 +Class: StartTag Offset: 844 Length: 38 +Class: TextImpl Offset: 882 Length: 5 +Class: StartTag Offset: 887 Length: 103 +Class: TextImpl Offset: 990 Length: 13 +Class: EndTag Offset: 1003 Length: 11 +Class: TextImpl Offset: 1014 Length: 5 +Class: StartTag Offset: 1019 Length: 10 +Class: CDATASection Offset: 1029 Length: 37 +Class: EndTag Offset: 1066 Length: 11 +Class: TextImpl Offset: 1077 Length: 5 +Class: Comment Offset: 1082 Length: 40 +Class: TextImpl Offset: 1122 Length: 5 +Class: EmptyTag Offset: 1127 Length: 11 +Class: TextImpl Offset: 1138 Length: 1 +Class: EndTag Offset: 1139 Length: 10 +Class: TextImpl Offset: 1149 Length: 2 http://git-wip-us.apache.org/repos/asf/incubator-netbeans/blob/00155f15/xml.text/test/unit/src/org/netbeans/modules/xml/text/dom/result2.txt ---------------------------------------------------------------------- diff --git a/xml.text/test/unit/src/org/netbeans/modules/xml/text/dom/result2.txt b/xml.text/test/unit/src/org/netbeans/modules/xml/text/dom/result2.txt index 46ee555..a1467ac 100644 --- a/xml.text/test/unit/src/org/netbeans/modules/xml/text/dom/result2.txt +++ b/xml.text/test/unit/src/org/netbeans/modules/xml/text/dom/result2.txt @@ -1,18 +1,32 @@ -Class: Text Offset: 327 Length: 1 -Class: EndTag Offset: 317 Length: 10 -Class: Text Offset: 316 Length: 1 -Class: EmptyTag Offset: 305 Length: 11 -Class: Text Offset: 300 Length: 5 -Class: Comment Offset: 260 Length: 40 -Class: Text Offset: 255 Length: 5 -Class: EndTag Offset: 244 Length: 11 -Class: CDATASection Offset: 207 Length: 37 -Class: StartTag Offset: 197 Length: 10 -Class: Text Offset: 192 Length: 5 -Class: EndTag Offset: 181 Length: 11 -Class: Text Offset: 168 Length: 13 -Class: StartTag Offset: 65 Length: 103 -Class: Text Offset: 60 Length: 5 -Class: StartTag Offset: 22 Length: 38 -Class: Text Offset: 21 Length: 1 +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. +Class: EndTag Offset: 1139 Length: 10 +Class: EmptyTag Offset: 1127 Length: 11 +Class: TextImpl Offset: 1122 Length: 5 +Class: Comment Offset: 1082 Length: 40 +Class: TextImpl Offset: 1077 Length: 5 +Class: EndTag Offset: 1066 Length: 11 +Class: CDATASection Offset: 1029 Length: 37 +Class: StartTag Offset: 1019 Length: 10 +Class: TextImpl Offset: 1014 Length: 5 +Class: EndTag Offset: 1003 Length: 11 +Class: TextImpl Offset: 990 Length: 13 +Class: StartTag Offset: 887 Length: 103 +Class: TextImpl Offset: 882 Length: 5 +Class: StartTag Offset: 844 Length: 38 +Class: Comment Offset: 22 Length: 821 Class: ProcessingInstruction Offset: 0 Length: 21 http://git-wip-us.apache.org/repos/asf/incubator-netbeans/blob/00155f15/xml.text/test/unit/src/org/netbeans/modules/xml/text/indent/1998stats.xml ---------------------------------------------------------------------- diff --git a/xml.text/test/unit/src/org/netbeans/modules/xml/text/indent/1998stats.xml b/xml.text/test/unit/src/org/netbeans/modules/xml/text/indent/1998stats.xml index ffc426c..a93b56d 100644 --- a/xml.text/test/unit/src/org/netbeans/modules/xml/text/indent/1998stats.xml +++ b/xml.text/test/unit/src/org/netbeans/modules/xml/text/indent/1998stats.xml @@ -1,5 +1,24 @@ <?xml version="1.0" encoding="UTF-8"?> +<!-- + Licensed to the Apache Software Foundation (ASF) under one + or more contributor license agreements. See the NOTICE file + distributed with this work for additional information + regarding copyright ownership. The ASF licenses this file + to you under the Apache License, Version 2.0 (the + "License"); you may not use this file except in compliance + with the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, + software distributed under the License is distributed on an + "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + KIND, either express or implied. See the License for the + specific language governing permissions and limitations + under the License. + +--> <SEASON> <YEAR>1998</YEAR> http://git-wip-us.apache.org/repos/asf/incubator-netbeans/blob/00155f15/xml.text/test/unit/src/org/netbeans/modules/xml/text/indent/XMLLexerFormatterTest.java ---------------------------------------------------------------------- diff --git a/xml.text/test/unit/src/org/netbeans/modules/xml/text/indent/XMLLexerFormatterTest.java b/xml.text/test/unit/src/org/netbeans/modules/xml/text/indent/XMLLexerFormatterTest.java index bbd7e0c..43017ee 100644 --- a/xml.text/test/unit/src/org/netbeans/modules/xml/text/indent/XMLLexerFormatterTest.java +++ b/xml.text/test/unit/src/org/netbeans/modules/xml/text/indent/XMLLexerFormatterTest.java @@ -86,7 +86,7 @@ public class XMLLexerFormatterTest extends AbstractTestCase { BaseDocument inputDoc = getDocument("indent/input_sub.xml"); //format a subsection of the inputDoc XMLLexerFormatter formatter = new XMLLexerFormatter(null); - LineDocument formattedDoc = formatter.doReformat(inputDoc, 72, 97); + LineDocument formattedDoc = formatter.doReformat(inputDoc, 893, 918); System.out.println(formattedDoc.getText(0, formattedDoc.getLength())); LineDocument outputDoc = getDocument("indent/output_sub.xml"); assertTrue (compare(formattedDoc, outputDoc)); @@ -126,7 +126,7 @@ public class XMLLexerFormatterTest extends AbstractTestCase { BaseDocument inputDoc = getDocument("indent/input_sub1.xml"); //format a subsection of the inputDoc XMLLexerFormatter formatter = new XMLLexerFormatter(null); - LineDocument formattedDoc = formatter.doReformat(inputDoc, 46, 74); + LineDocument formattedDoc = formatter.doReformat(inputDoc, 868, 896); System.out.println(formattedDoc.getText(0, formattedDoc.getLength())); LineDocument outputDoc = getDocument("indent/output_sub1.xml"); assertTrue (compare(formattedDoc, outputDoc)); @@ -136,7 +136,7 @@ public class XMLLexerFormatterTest extends AbstractTestCase { BaseDocument inputDoc = getDocument("indent/input_sub2.xml"); //format a subsection of the inputDoc XMLLexerFormatter formatter = new XMLLexerFormatter(null); - LineDocument formattedDoc = formatter.doReformat(inputDoc, 63, 80); + LineDocument formattedDoc = formatter.doReformat(inputDoc, 885, 899); System.out.println(formattedDoc.getText(0, formattedDoc.getLength())); LineDocument outputDoc = getDocument("indent/output_sub2.xml"); assertTrue (compare(formattedDoc, outputDoc)); @@ -169,8 +169,8 @@ public class XMLLexerFormatterTest extends AbstractTestCase { BaseDocument inputDoc = getDocument("indent/input_preserve.xml"); //format the inputDoc XMLLexerFormatter formatter = new XMLLexerFormatter(null); - System.out.println("SECTION:" + inputDoc.getText(91, 87)); - LineDocument formattedDoc = formatter.doReformat(inputDoc, 91, 91 + 87); + System.out.println("SECTION:" + inputDoc.getText(913, 87)); + LineDocument formattedDoc = formatter.doReformat(inputDoc, 913, 913 + 87); System.out.println(formattedDoc.getText(0, formattedDoc.getLength())); LineDocument outputDoc = getDocument("indent/output_preserve.xml"); assertTrue(compare(formattedDoc, outputDoc)); http://git-wip-us.apache.org/repos/asf/incubator-netbeans/blob/00155f15/xml.text/test/unit/src/org/netbeans/modules/xml/text/indent/input.xml ---------------------------------------------------------------------- diff --git a/xml.text/test/unit/src/org/netbeans/modules/xml/text/indent/input.xml b/xml.text/test/unit/src/org/netbeans/modules/xml/text/indent/input.xml index 09514e2..5c94a6a 100644 --- a/xml.text/test/unit/src/org/netbeans/modules/xml/text/indent/input.xml +++ b/xml.text/test/unit/src/org/netbeans/modules/xml/text/indent/input.xml @@ -1,5 +1,24 @@ <?xml version="1.0" encoding="UTF-8"?> - +<!-- + + Licensed to the Apache Software Foundation (ASF) under one + or more contributor license agreements. See the NOTICE file + distributed with this work for additional information + regarding copyright ownership. The ASF licenses this file + to you under the Apache License, Version 2.0 (the + "License"); you may not use this file except in compliance + with the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, + software distributed under the License is distributed on an + "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + KIND, either express or implied. See the License for the + specific language governing permissions and limitations + under the License. + +--> <!-- hello world --> <wrap> <root> http://git-wip-us.apache.org/repos/asf/incubator-netbeans/blob/00155f15/xml.text/test/unit/src/org/netbeans/modules/xml/text/indent/input2.xsd ---------------------------------------------------------------------- diff --git a/xml.text/test/unit/src/org/netbeans/modules/xml/text/indent/input2.xsd b/xml.text/test/unit/src/org/netbeans/modules/xml/text/indent/input2.xsd index 74ccbbc..1254fd5 100644 --- a/xml.text/test/unit/src/org/netbeans/modules/xml/text/indent/input2.xsd +++ b/xml.text/test/unit/src/org/netbeans/modules/xml/text/indent/input2.xsd @@ -1,5 +1,24 @@ <?xml version="1.0" encoding="UTF-8"?> +<!-- + Licensed to the Apache Software Foundation (ASF) under one + or more contributor license agreements. See the NOTICE file + distributed with this work for additional information + regarding copyright ownership. The ASF licenses this file + to you under the Apache License, Version 2.0 (the + "License"); you may not use this file except in compliance + with the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, + software distributed under the License is distributed on an + "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + KIND, either express or implied. See the License for the + specific language governing permissions and limitations + under the License. + +--> <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" targetNamespace="http://xml.netbeans.org/schema/Namespace2" xmlns:tns="http://xml.netbeans.org/schema/Namespace2" http://git-wip-us.apache.org/repos/asf/incubator-netbeans/blob/00155f15/xml.text/test/unit/src/org/netbeans/modules/xml/text/indent/input_attrsIndent.xml ---------------------------------------------------------------------- diff --git a/xml.text/test/unit/src/org/netbeans/modules/xml/text/indent/input_attrsIndent.xml b/xml.text/test/unit/src/org/netbeans/modules/xml/text/indent/input_attrsIndent.xml index 5452540..6a4399d 100644 --- a/xml.text/test/unit/src/org/netbeans/modules/xml/text/indent/input_attrsIndent.xml +++ b/xml.text/test/unit/src/org/netbeans/modules/xml/text/indent/input_attrsIndent.xml @@ -1,4 +1,24 @@ <?xml version="1.0" encoding="UTF-8"?> +<!-- + + Licensed to the Apache Software Foundation (ASF) under one + or more contributor license agreements. See the NOTICE file + distributed with this work for additional information + regarding copyright ownership. The ASF licenses this file + to you under the Apache License, Version 2.0 (the + "License"); you may not use this file except in compliance + with the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, + software distributed under the License is distributed on an + "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + KIND, either express or implied. See the License for the + specific language governing permissions and limitations + under the License. + +--> <root var1="not indented" var2="aligned with var1"> <child http://git-wip-us.apache.org/repos/asf/incubator-netbeans/blob/00155f15/xml.text/test/unit/src/org/netbeans/modules/xml/text/indent/input_breaksMixedContent.xml ---------------------------------------------------------------------- diff --git a/xml.text/test/unit/src/org/netbeans/modules/xml/text/indent/input_breaksMixedContent.xml b/xml.text/test/unit/src/org/netbeans/modules/xml/text/indent/input_breaksMixedContent.xml index 31f3a28..0cc53b7 100644 --- a/xml.text/test/unit/src/org/netbeans/modules/xml/text/indent/input_breaksMixedContent.xml +++ b/xml.text/test/unit/src/org/netbeans/modules/xml/text/indent/input_breaksMixedContent.xml @@ -1,5 +1,24 @@ <?xml version="1.0" encoding="UTF-8"?> +<!-- + Licensed to the Apache Software Foundation (ASF) under one + or more contributor license agreements. See the NOTICE file + distributed with this work for additional information + regarding copyright ownership. The ASF licenses this file + to you under the Apache License, Version 2.0 (the + "License"); you may not use this file except in compliance + with the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, + software distributed under the License is distributed on an + "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + KIND, either express or implied. See the License for the + specific language governing permissions and limitations + under the License. + +--> <root> <para> This is one sentence. http://git-wip-us.apache.org/repos/asf/incubator-netbeans/blob/00155f15/xml.text/test/unit/src/org/netbeans/modules/xml/text/indent/input_cdataContent.xml ---------------------------------------------------------------------- diff --git a/xml.text/test/unit/src/org/netbeans/modules/xml/text/indent/input_cdataContent.xml b/xml.text/test/unit/src/org/netbeans/modules/xml/text/indent/input_cdataContent.xml index 2bd299e..f02a0a5 100644 --- a/xml.text/test/unit/src/org/netbeans/modules/xml/text/indent/input_cdataContent.xml +++ b/xml.text/test/unit/src/org/netbeans/modules/xml/text/indent/input_cdataContent.xml @@ -1,4 +1,24 @@ <?xml version="1.0" encoding="UTF-8"?> +<!-- + + Licensed to the Apache Software Foundation (ASF) under one + or more contributor license agreements. See the NOTICE file + distributed with this work for additional information + regarding copyright ownership. The ASF licenses this file + to you under the Apache License, Version 2.0 (the + "License"); you may not use this file except in compliance + with the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, + software distributed under the License is distributed on an + "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + KIND, either express or implied. See the License for the + specific language governing permissions and limitations + under the License. + +--> <root> <a> <b><