Skip to content

Commit 2360f53

Browse files
authored
Don't ignore case in xml validation (#1590)
* Don't ignore case in xml validation * don't ignore case in WebXmlScanner * add tests * change assertion
1 parent 39c8bcc commit 2360f53

4 files changed

Lines changed: 22 additions & 6 deletions

File tree

plugins/com.google.cloud.tools.eclipse.appengine.validation.test/src/com/google/cloud/tools/eclipse/appengine/validation/PomXmlScannerTest.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,13 @@ public void setUp() throws SAXException {
3737
scanner.startDocument();
3838
}
3939

40+
@Test
41+
public void testCaseSensitive() throws SAXException {
42+
scanner.startElement("", "Plugin", "", new AttributesImpl());
43+
assertEquals(0, scanner.getBlacklist().size());
44+
assertFalse(scanner.getInsidePlugin());
45+
}
46+
4047
@Test
4148
public void testStartElement_build() throws SAXException {
4249
scanner.startElement("", "plugin", "", new AttributesImpl());

plugins/com.google.cloud.tools.eclipse.appengine.validation.test/src/com/google/cloud/tools/eclipse/appengine/validation/WebXmlScannerTest.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
package com.google.cloud.tools.eclipse.appengine.validation;
1818

1919
import static org.junit.Assert.assertEquals;
20+
import static org.junit.Assert.assertTrue;
2021

2122
import org.junit.Before;
2223
import org.junit.Test;
@@ -34,6 +35,14 @@ public void setUp() throws SAXException {
3435
scanner.startDocument();
3536
}
3637

38+
@Test
39+
public void testCaseSensitive() throws SAXException {
40+
AttributesImpl attributes = new AttributesImpl();
41+
attributes.addAttribute("", "", "version", "", "3.1");
42+
scanner.startElement("http://xmlns.jcp.org/xml/ns/javaee", "Web-App", "", attributes);
43+
assertTrue(scanner.getBlacklist().isEmpty());
44+
}
45+
3746
@Test
3847
public void testStartElement_jcpNamespace() throws SAXException {
3948
AttributesImpl attributes = new AttributesImpl();

plugins/com.google.cloud.tools.eclipse.appengine.validation/src/com/google/cloud/tools/eclipse/appengine/validation/PomXmlScanner.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -42,12 +42,12 @@ class PomXmlScanner extends AbstractScanner {
4242
@Override
4343
public void startElement(String uri, String localName, String qName, Attributes attributes)
4444
throws SAXException {
45-
if ("plugin".equalsIgnoreCase(localName)) {
45+
if ("plugin".equals(localName)) {
4646
insidePlugin = true;
47-
} else if (insidePlugin && "artifactId".equalsIgnoreCase(localName)) {
47+
} else if (insidePlugin && "artifactId".equals(localName)) {
4848
saveContents = true;
4949
elementContents = new StringBuilder();
50-
} else if (insidePlugin && "groupId".equalsIgnoreCase(localName)) {
50+
} else if (insidePlugin && "groupId".equals(localName)) {
5151
Locator2 locator = getLocator();
5252
saveContents = true;
5353
elementContents = new StringBuilder();
@@ -76,7 +76,7 @@ public void characters (char ch[], int start, int length)
7676
@Override
7777
public void endElement (String uri, String localName, String qName)
7878
throws SAXException {
79-
if ("plugin".equalsIgnoreCase(localName)) {
79+
if ("plugin".equals(localName)) {
8080
// Found closing <plugin> tag
8181
resetFlags();
8282
} else if (insidePlugin && "groupId".equals(localName)) {
@@ -85,7 +85,7 @@ public void endElement (String uri, String localName, String qName)
8585
if ("com.google.appengine".equals(elementContents.toString())) {
8686
foundAppEngineGroupId = true;
8787
}
88-
} else if (insidePlugin && "artifactId".equalsIgnoreCase(localName)) {
88+
} else if (insidePlugin && "artifactId".equals(localName)) {
8989
// Found closing <artifactId> tag with parent <plugin>
9090
saveContents = false;
9191
if ("appengine-maven-plugin".equals(elementContents.toString()) ||

plugins/com.google.cloud.tools.eclipse.appengine.validation/src/com/google/cloud/tools/eclipse/appengine/validation/WebXmlScanner.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ public void startElement(String uri, String localName, String qName, Attributes
3030
throws SAXException {
3131
// Checks for expected namespace URI. Assume something else is going on if
3232
// web.xml has an unexpected root namespace.
33-
if ("web-app".equalsIgnoreCase(localName) && ("http://xmlns.jcp.org/xml/ns/javaee".equals(uri)
33+
if ("web-app".equals(localName) && ("http://xmlns.jcp.org/xml/ns/javaee".equals(uri)
3434
|| "http://java.sun.com/xml/ns/javaee".equals(uri))) {
3535
String version = attributes.getValue("version");
3636
if (!version.equals("2.5")) {

0 commit comments

Comments
 (0)