tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ma...@apache.org
Subject svn commit: r1547931 - in /tomcat/tc7.0.x/trunk: ./ java/org/apache/catalina/core/ java/org/apache/catalina/deploy/ java/org/apache/tomcat/util/digester/ test/javax/servlet/resources/ test/org/apache/catalina/deploy/
Date Wed, 04 Dec 2013 22:17:03 GMT
Author: markt
Date: Wed Dec  4 22:17:03 2013
New Revision: 1547931

URL: http://svn.apache.org/r1547931
Log:
Fix https://issues.apache.org/bugzilla/show_bug.cgi?id=55218 and https://issues.apache.org/bugzilla/show_bug.cgi?id=55219
Upgrade digester to use DefaultHandler2 and use LexicalHandler to detect publicId.
Simplify web application version detection in web.xml
Extracted from a patch by Jeremy Boynes.

Modified:
    tomcat/tc7.0.x/trunk/   (props changed)
    tomcat/tc7.0.x/trunk/java/org/apache/catalina/core/StandardContext.java
    tomcat/tc7.0.x/trunk/java/org/apache/catalina/deploy/LocalStrings.properties
    tomcat/tc7.0.x/trunk/java/org/apache/catalina/deploy/WebXml.java
    tomcat/tc7.0.x/trunk/java/org/apache/tomcat/util/digester/Digester.java
    tomcat/tc7.0.x/trunk/test/javax/servlet/resources/TestSchemaValidation.java   (contents,
props changed)
    tomcat/tc7.0.x/trunk/test/org/apache/catalina/deploy/TestWebXml.java

Propchange: tomcat/tc7.0.x/trunk/
------------------------------------------------------------------------------
  Merged /tomcat/trunk:r1501176

Modified: tomcat/tc7.0.x/trunk/java/org/apache/catalina/core/StandardContext.java
URL: http://svn.apache.org/viewvc/tomcat/tc7.0.x/trunk/java/org/apache/catalina/core/StandardContext.java?rev=1547931&r1=1547930&r2=1547931&view=diff
==============================================================================
--- tomcat/tc7.0.x/trunk/java/org/apache/catalina/core/StandardContext.java (original)
+++ tomcat/tc7.0.x/trunk/java/org/apache/catalina/core/StandardContext.java Wed Dec  4 22:17:03
2013
@@ -126,6 +126,7 @@ import org.apache.naming.resources.WARDi
 import org.apache.tomcat.InstanceManager;
 import org.apache.tomcat.JarScanner;
 import org.apache.tomcat.util.ExceptionUtils;
+import org.apache.tomcat.util.descriptor.XmlIdentifiers;
 import org.apache.tomcat.util.modeler.Registry;
 import org.apache.tomcat.util.scan.StandardJarScanner;
 
@@ -5835,17 +5836,10 @@ public class StandardContext extends Con
      */
     @Override
     public boolean isServlet22() {
-
-        if (this.publicId == null)
-            return (false);
-        if (this.publicId.equals
-            (org.apache.catalina.startup.Constants.WebDtdPublicId_22))
-            return (true);
-        else
-            return (false);
-
+        return XmlIdentifiers.WEB_22_PUBLIC.equals(publicId);
     }
 
+
     @Override
     public Set<String> addServletSecurity(
             ApplicationServletRegistration registration,

Modified: tomcat/tc7.0.x/trunk/java/org/apache/catalina/deploy/LocalStrings.properties
URL: http://svn.apache.org/viewvc/tomcat/tc7.0.x/trunk/java/org/apache/catalina/deploy/LocalStrings.properties?rev=1547931&r1=1547930&r2=1547931&view=diff
==============================================================================
--- tomcat/tc7.0.x/trunk/java/org/apache/catalina/deploy/LocalStrings.properties (original)
+++ tomcat/tc7.0.x/trunk/java/org/apache/catalina/deploy/LocalStrings.properties Wed Dec 
4 22:17:03 2013
@@ -44,7 +44,7 @@ webXml.mergeConflictSessionTrackingMode=
 webXml.mergeConflictString=The [{0}] with name [{1}] was defined inconsistently in multiple
fragments including fragment with name [{2}] located at [{3}]
 webXml.multipleOther=Multiple others entries in ordering
 webxml.unrecognisedPublicId=The public ID [{0}] did not match any of the known public ID's
for web.xml files so the version could not be identified
-webXml.version.nfe=Unable to parse [{0}] from the version string [{1}]. This component of
the version string will be ignored.
+webXml.version.unknown=Unknown version string [{0}]. Default version will be used.\u03A9
 webXml.wrongFragmentName=Used a wrong fragment name {0} at web.xml absolute-ordering tag!
 
 namingResources.cleanupCloseFailed=Failed to invoke method [{0}] for resource [{1}] in container
[{2}] so no cleanup was performed for that resource

Modified: tomcat/tc7.0.x/trunk/java/org/apache/catalina/deploy/WebXml.java
URL: http://svn.apache.org/viewvc/tomcat/tc7.0.x/trunk/java/org/apache/catalina/deploy/WebXml.java?rev=1547931&r1=1547930&r2=1547931&view=diff
==============================================================================
--- tomcat/tc7.0.x/trunk/java/org/apache/catalina/deploy/WebXml.java (original)
+++ tomcat/tc7.0.x/trunk/java/org/apache/catalina/deploy/WebXml.java Wed Dec  4 22:17:03 2013
@@ -42,6 +42,7 @@ import org.apache.catalina.Context;
 import org.apache.catalina.Wrapper;
 import org.apache.catalina.core.ApplicationJspPropertyGroupDescriptor;
 import org.apache.catalina.core.ApplicationTaglibDescriptor;
+import org.apache.tomcat.util.descriptor.XmlIdentifiers;
 import org.apache.tomcat.util.res.StringManager;
 
 /**
@@ -137,42 +138,20 @@ public class WebXml {
      * @param version   Values of <code>null</code> will be ignored
      */
     public void setVersion(String version) {
-        if (version == null) return;
-
-        // Update major and minor version
-        // Expected format is n.n - allow for any number of digits just in case
-        String major = null;
-        String minor = null;
-        int split = version.indexOf('.');
-        if (split < 0) {
-            // Major only
-            major = version;
-        } else {
-            major = version.substring(0, split);
-            minor = version.substring(split + 1);
+        if (version == null) {
+            return;
         }
-        if (major == null || major.length() == 0) {
-            majorVersion = 0;
-        } else {
-            try {
-                majorVersion = Integer.parseInt(major);
-            } catch (NumberFormatException nfe) {
-                log.warn(sm.getString("webXml.version.nfe", major, version),
-                        nfe);
-                majorVersion = 0;
-            }
-        }
-
-        if (minor == null || minor.length() == 0) {
+        if ("2.4".equals(version)) {
+            majorVersion = 2;
+            minorVersion = 4;
+        } else if ("2.5".equals(version)) {
+            majorVersion = 2;
+            minorVersion = 5;
+        } else if ("3.0".equals(version)) {
+            majorVersion = 3;
             minorVersion = 0;
         } else {
-            try {
-                minorVersion = Integer.parseInt(minor);
-            } catch (NumberFormatException nfe) {
-                log.warn(sm.getString("webXml.version.nfe", minor, version),
-                        nfe);
-                minorVersion = 0;
-            }
+            log.warn(sm.getString("webXml.version.unknown", version));
         }
     }
 
@@ -183,40 +162,18 @@ public class WebXml {
     public void setPublicId(String publicId) {
         // Update major and minor version
         if (publicId == null) {
-            // skip
-        } else if (org.apache.catalina.startup.Constants.WebSchemaPublicId_30.
-                equalsIgnoreCase(publicId) ||
-                org.apache.catalina.startup.Constants.WebFragmentSchemaPublicId_30.
-                equalsIgnoreCase(publicId)) {
-            majorVersion = 3;
-            minorVersion = 0;
-            this.publicId = publicId;
-        } else if (org.apache.catalina.startup.Constants.WebSchemaPublicId_25.
-                equalsIgnoreCase(publicId)) {
-            majorVersion = 2;
-            minorVersion = 5;
-            this.publicId = publicId;
-        } else if (org.apache.catalina.startup.Constants.WebSchemaPublicId_24.
-                equalsIgnoreCase(publicId)) {
+            return;
+        }
+        if (XmlIdentifiers.WEB_22_PUBLIC.equals(publicId)) {
             majorVersion = 2;
-            minorVersion = 4;
+            minorVersion = 2;
             this.publicId = publicId;
-        } else if (org.apache.catalina.startup.Constants.WebDtdPublicId_23.
-                equalsIgnoreCase(publicId)) {
+        } else if (XmlIdentifiers.WEB_23_PUBLIC.equals(publicId)) {
             majorVersion = 2;
             minorVersion = 3;
             this.publicId = publicId;
-        } else if (org.apache.catalina.startup.Constants.WebDtdPublicId_22.
-                equalsIgnoreCase(publicId)) {
-            majorVersion = 2;
-            minorVersion = 2;
-            this.publicId = publicId;
-        } else if ("datatypes".equals(publicId)) {
-            // Will occur when validation is enabled and dependencies are
-            // traced back. Ignore it.
         } else {
-            // Unrecognised publicId
-            log.warn(sm.getString("webxml.unrecognisedPublicId", publicId));
+            log.warn(sm.getString("webXml.unrecognisedPublicId", publicId));
         }
     }
 

Modified: tomcat/tc7.0.x/trunk/java/org/apache/tomcat/util/digester/Digester.java
URL: http://svn.apache.org/viewvc/tomcat/tc7.0.x/trunk/java/org/apache/tomcat/util/digester/Digester.java?rev=1547931&r1=1547930&r2=1547931&view=diff
==============================================================================
--- tomcat/tc7.0.x/trunk/java/org/apache/tomcat/util/digester/Digester.java (original)
+++ tomcat/tc7.0.x/trunk/java/org/apache/tomcat/util/digester/Digester.java Wed Dec  4 22:17:03
2013
@@ -24,6 +24,8 @@ import java.io.IOException;
 import java.io.InputStream;
 import java.io.Reader;
 import java.lang.reflect.InvocationTargetException;
+import java.net.URI;
+import java.net.URISyntaxException;
 import java.util.EmptyStackException;
 import java.util.HashMap;
 import java.util.Iterator;
@@ -48,8 +50,8 @@ import org.xml.sax.SAXNotRecognizedExcep
 import org.xml.sax.SAXNotSupportedException;
 import org.xml.sax.SAXParseException;
 import org.xml.sax.XMLReader;
+import org.xml.sax.ext.DefaultHandler2;
 import org.xml.sax.helpers.AttributesImpl;
-import org.xml.sax.helpers.DefaultHandler;
 
 
 /**
@@ -71,8 +73,7 @@ import org.xml.sax.helpers.DefaultHandle
  * the support of XML schema. You need Xerces 2.1/2.3 and up to make
  * this class working with XML schema</p>
  */
-
-public class Digester extends DefaultHandler {
+public class Digester extends DefaultHandler2 {
 
     
     // ---------------------------------------------------------- Static Fields    
@@ -904,6 +905,9 @@ public class Digester extends DefaultHan
             reader.setEntityResolver(entityResolver);           
         }
         
+        reader.setProperty(
+                "http://xml.org/sax/properties/lexical-handler", this);
+
         reader.setErrorHandler(this);
         return reader;
     }
@@ -1388,26 +1392,15 @@ public class Digester extends DefaultHan
         return entityResolver;
     }
 
-    /**
-     * Resolve the requested external entity.
-     *
-     * @param publicId The public identifier of the entity being referenced
-     * @param systemId The system identifier of the entity being referenced
-     *
-     * @exception SAXException if a parsing exception occurs
-     * 
-     */
     @Override
-    public InputSource resolveEntity(String publicId, String systemId)
-            throws SAXException {     
-                
+    public InputSource resolveEntity(String name, String publicId,
+            String baseURI, String systemId) throws SAXException, IOException {
+
         if (saxLog.isDebugEnabled()) {
-            saxLog.debug("resolveEntity('" + publicId + "', '" + systemId + "')");
+            saxLog.debug("resolveEntity('" + publicId + "', '" + systemId +
+                    "', '" + baseURI + "')");
         }
         
-        if (publicId != null)
-            this.publicId = publicId;
-                                       
         // Has this system identifier been registered?
         String entityURL = null;
         if (publicId != null) {
@@ -1425,9 +1418,24 @@ public class Digester extends DefaultHan
             } else {
                 // try to resolve using system ID
                 if (log.isDebugEnabled()) {
-                    log.debug(" Trying to resolve using system ID '" + systemId + "'");
+                    log.debug(" Trying to resolve using system ID '" +
+                            systemId + "'");
                 } 
                 entityURL = systemId;
+                // resolve systemId against baseURI if it is not absolute
+                if (baseURI != null) {
+                    try {
+                        URI uri = new URI(systemId);
+                        if (!uri.isAbsolute()) {
+                            entityURL = new URI(baseURI).resolve(uri).toString();
+                        }
+                    } catch (URISyntaxException e) {
+                        if (log.isDebugEnabled()) {
+                            log.debug("Invalid URI '" + baseURI + "' or '" +
+                                    systemId + "'");
+                        }
+                    }
+                }
             }
         }
         
@@ -1444,8 +1452,16 @@ public class Digester extends DefaultHan
     }
 
 
-    // ------------------------------------------------- ErrorHandler Methods
+    // ----------------------------------------------- LexicalHandler Methods
 
+    @Override
+    public void startDTD(String name, String publicId, String systemId)
+            throws SAXException {
+        setPublicId(publicId);
+    }
+
+
+    // ------------------------------------------------- ErrorHandler Methods
 
     /**
      * Forward notification of a parsing error to the application supplied

Modified: tomcat/tc7.0.x/trunk/test/javax/servlet/resources/TestSchemaValidation.java
URL: http://svn.apache.org/viewvc/tomcat/tc7.0.x/trunk/test/javax/servlet/resources/TestSchemaValidation.java?rev=1547931&r1=1547930&r2=1547931&view=diff
==============================================================================
    (empty)

Propchange: tomcat/tc7.0.x/trunk/test/javax/servlet/resources/TestSchemaValidation.java
------------------------------------------------------------------------------
--- svn:mergeinfo (added)
+++ svn:mergeinfo Wed Dec  4 22:17:03 2013
@@ -0,0 +1 @@
+/tomcat/trunk/test/javax/servlet/resources/TestSchemaValidation.java:1156115-1157160,1157162-1157859,1157862-1157942,1157945-1160347,1160349-1163716,1163718-1166689,1166691-1174340,1174342-1175596,1175598-1175611,1175613-1175932,1175934-1177783,1177785-1177980,1178006-1180720,1180722-1183094,1183096-1187753,1187755,1187775,1187801,1187806,1187809,1187826-1188312,1188314-1188401,1188646-1188840,1188842-1190176,1190178-1195223,1195225-1195953,1195955,1195957-1201238,1201240-1203345,1203347-1206623,1206625-1208046,1208073,1208096,1208114,1208145,1208772,1209194-1212125,1212127-1220291,1220293,1220295-1221321,1221323-1222328,1222332-1222401,1222405-1222795,1222850-1222950,1222969-1225326,1225328-1225463,1225465,1225627,1225629-1226534,1226536-1228908,1228911-1228923,1228927-1229532,1229534-1230766,1230768-1231625,1231627-1233414,1233419-1235207,1235209-1237425,1237427,1237429-1237977,1237981,1237985,1237995,1238070,1238073,1239024-1239048,1239050-1239062,1239135,1239256,1239258-1239485,
 1239785-1240046,1240101,1240106,1240109,1240112,1240114,1240116,1240118,1240121,1240329,1240474-1240850,1240857,1241087,1241160,1241408-1241822,1241908-1241909,1241912-1242110,1242371-1292130,1292134-1292458,1292464-1292670,1292672-1292776,1292780-1293392,1293397-1297017,1297019-1297963,1297965-1299820,1300108,1300111-1300460,1300520-1300948,1300997,1301006,1301280,1302332,1302348,1302608-1302610,1302649,1302837,1303138,1303163,1303338,1303521,1303587,1303698,1303803,1303852,1304011,1304035,1304037,1304135,1304249,1304253,1304260,1304271,1304275,1304468,1304895,1304930-1304932,1305194,1305943,1305965,1306556,1306579-1306580,1307084,1307310,1307511-1307512,1307579,1307591,1307597,1310636,1310639-1310640,1310642,1310701,1311212,1311995,1327617,1327670,1331766,1333161,1333173,1333827,1334787,1335026,1335257,1335547,1335692,1335711,1335731,1336515,1336813,1336864,1336868,1336884,1337419,1337426,1337546,1337572,1337591-1337595,1337643,1337707,1337719,1337734,1337741,1337745,1338151-13381
 54,1338178,1342027,1342029,1342315,1342320,1342476,1342498,1342503,1342717,1342795,1342805,1343044-1343046,1343335,1343394,1343400,1343629,1343708,1343718,1343895,1344063,1344068,1344250,1344266,1344515,1344528,1344612,1344629,1344725,1344868,1344890,1344893,1344896,1344901,1345020,1345029,1345039,1345287-1345290,1345294,1345309,1345325,1345357,1345367,1345579-1345580,1345582,1345688,1345699,1345704,1345731-1345732,1345737,1345744,1345752,1345754,1345779,1345781,1345846,1346107,1346376,1346404,1346510,1346514,1346519,1346581,1346635,1346644,1346683,1346794,1346885,1346932,1347034,1347047,1347087,1347108-1347109,1347583,1347737,1348105,1348357,1348398,1348425,1348461-1348495,1348498,1348752,1348762,1348772,1348776,1348859,1348968,1348973,1348989,1349007,1349237,1349298,1349317,1349410,1349473,1349539,1349879,1349887,1349893,1349922,1349984,1350124,1350241,1350243,1350294-1350295,1350299,1350864,1350900,1351010,1351054,1351056,1351068,1351134-1351135,1351148,1351259,1351604,1351636-13
 51640,1351991,1351993,1352011,1352056,1352059,1352661,1352663,1352788,1352799,1353087,1353125,1353240,1353261,1353414,1353468,1353501,1353581,1353708,1354137,1354170,1354197,1354255,1354362,1354375,1354469,1354664,1354685,1354817,1354847,1354856,1355726,1355810,1356006-1356007,1356014,1356045,1356125,1356422,1356505,1356898,1357042,1357401,1357407,1358586,1358590,1358612-1358613,1359102,1359340,1359981,1360059,1360455,1360460,1360838,1360847,1360892,1360942,1361263,1361430,1361754-1361755,1361762,1361769,1361772,1361962,1361982,1361985,1361991,1364141,1364149,1364411-1364412,1364448,1366708,1366720,1366729,1366734,1366910,1366945,1366953,1366959,1367214,1370346,1370364,1370373,1370386,1370473,1370537,1370549,1370553,1370879,1370916,1370958,1370960,1370973,1371017,1371283,1371336,1371620,1371812,1371823,1371896,1371976,1371978,1371995,1371999,1372131,1372152,1372156,1372390,1373003,1373080,1373142,1373488,1373578,1373618,1373622,1373666,1373985,1373987,1373990,1373993,1374000,1374019
 ,1374823,1376994,1377078,1377292,1377311,1377342,1377433,1377444,1377516,1377518-1377519,1377532,1377535,1377544,1377689,1377785,1377794,1377811,1377824,1377827,1377831,1377852-1377853,1377887,1377900,1378322,1378361,1378394,1378699,1378715,1378818,1378868,1378918,1379047,1379090,1379178,1379206,1379213,1379418,1379580,1379590,1379639,1379647,1379649,1379665,1379733,1379735,1380066,1380073,1380075,1380376,1380635,1380637,1380838,1381411,1381623,1382314,1382343,1382366,1382515,1382832,1382842,1385336,1387937,1388709,1390882,1392098,1392619,1393071,1393115,1396615,1396723,1397086,1397464,1397466,1397472,1397482,1397484,1397839,1397868,1397944,1399022,1401472,1401792,1401808,1401814,1402113,1402122,1402345,1402348,1402350,1402428,1402573,1402576,1402600-1402601,1402622,1402643,1402683,1402837,1402855,1403099,1403468,1404374,1404658,1404704,1404773,1404917-1404918,1405133,1405168,1405321,1405353,1405357,1405364,1405397,1405399-1405400,1405415,1405435,1405676,1405681,1406456,1406481,1406
 526,1407595,1407619,1408043,1408148,1408154,1408156,1408159,1408163-1408165,1408248,1408438,1408504,1408513-1408517,1408562-1408565,1408714,1408721,1408739,1408750,1408774,1408792,1408872-1408876,1408906,1408934,1409007,1409030,1410466,1410545,1410609,1410611,1410632,1410714,1410763-1410764,1410766,1411585,1411993,1412575,1413552,1413556,1413562,1414053,1414113,1414215,1414889,1415177-1415179,1415186,1416458,1416481,1416501,1416529,1416534-1416535,1416658,1417201,1417224,1417282,1417347-1417348,1417353,1417363,1417365,1417370-1417372,1417463,1417465,1417467,1417469,1417476,1424894,1425502,1425564,1425628,1426662,1427013,1427757,1427784,1427804,1427846,1428010,1428079,1428283,1428355,1428403,1428643,1428869,1428959,1428993,1429123,1429153,1429167,1429173,1429179-1429180,1429182,1429356,1429687,1429745,1429784,1429836,1429863,1429946,1429969,1430079,1430147,1430165,1430445,1430448,1430481,1430487,1430508,1430550,1430567,1430771,1430773,1430775,1430791,1430799,1430806,1430809,1430921,1
 431164,1431171,1431206,1431221,1431293,1431298,1431302,1431308,1431310,1431320,1431661,1431920,1431990,1432517,1432867,1433976,1434403,1434428,1434438,1434447,1434456,1434463,1434500,1434598,1434660,1434685,1434725,1434757,1434882,1435126,1435505,1435509,1435600,1435606,1435636,1435642,1435759-1435760,1435765,1435767,1437317,1437337,1437505,1437637,1437649,1437743,1437891,1437897,1437903,1438411,1438463,1439054,1439334,1439434,1439442,1439445,1439667,1440095,1440622,1440911,1441342,1441348,1441403,1441416,1441428,1441807,1441895,1441916,1441920,1443350,1443405,1443427,1445111,1445125,1445190,1445208,1445212,1445328,1445337,1445520,1446108,1446137,1446357,1446612,1446640,1446650,1447012,1447178,1447791,1447817-1447818,1448117,1448121,1448125,1448826,1449225,1449406,1450990,1451053,1451061,1451105,1451408,1451434,1451769,1451938-1451939,1451947,1451955-1451956,1452295,1452501,1452707,1452719,1452721,1452752,1453105,1453112,1453435,1453439,1453490,1453544,1453549,1453621,1454828,145483
 2,1454953,1455344,1455854,1455973,1456083,1456440,1456453,1456491,1456494,1456657,1456666,1456678,1456706,1456713,1456716,1456721,1456740,1456762,1456766,1456822,1456844,1456863,1456872,1456882,1456885,1456895,1456899,1456904,1456916,1456920,1456926,1456932,1456959,1456963,1456970,1457299,1457301,1457362,1457382,1457402,1457452,1457748,1457968,1458187,1458192,1458200,1458221,1458562,1458564-1458565,1458694,1458726,1458738-1458739,1459010,1459028,1459031,1459061,1459074-1459075,1459085,1459218,1459223,1459289,1459389,1459523-1459524,1459673,1459681,1459761,1459769,1459933,1460107,1460115,1460234,1460313,1460330,1460342,1460533,1460633,1460679,1460873,1461026,1461110,1461341,1461349,1461849,1464781,1465795,1465807,1466051,1466072,1466106,1467091,1468415,1470400,1470435,1470765,1471371,1471632,1475750,1475791,1475900,1475930,1475968,1476761,1476805,1476815,1476972,1477051,1479175,1479179,1479248,1479482,1479951,1481164,1481835,1482115,1482288,1482309,1482311,1482313,1482321,1482591,148
 2720,1482723,1482799,1482835,1482854,1483104,1483229,1483288,1483360-1483361,1483390,1483552,1483554,1483679,1483743-1483744,1483786-1483787,1483816-1483817,1483949,1484253,1484592,1484780,1484786,1484861-1484862,1484959,1485114,1485489,1485495,1485611,1485847,1486134,1486217,1486294,1486443,1486834,1486861,1486875,1486890,1486939,1487862,1487882,1488151,1488793,1489170,1489195-1489196,1489201,1489385,1489390,1489405,1489437,1489536,1489546,1489610,1489633,1489648,1489738,1489812,1489886,1491485,1491596,1491709,1491841,1491890,1492307,1492336,1492343,1492358,1492555,1492570,1493011,1493013-1493014,1493071,1493113,1493740,1493801,1493910,1494044,1494048,1494051,1494056,1494143,1495015,1495043,1495154,1495197,1495880,1495886,1496061,1496732,1496734,1497474,1497538,1497754,1498340,1498363,1498368,1498409,1498475,1498482,1498498,1498669,1498698,1498808,1499953,1500003,1500062,1500371,1500380,1500577,1500590,1500663,1501266,1501719,1501823,1501910,1501927,1501929,1502254,1502349,1503851,
 1505843,1505929,1506053,1507013,1507052,1507096,1507872,1508196,1508346,1509128,1509151,1509156,1509161,1509806,1510246,1510488,1511212,1511217,1511434,1513148-1513149,1513665,1514281,1514291,1514305,1514368,1514470,1514485-1514486,1515841,1515926,1516113,1516295,1516419,1516710,1516953,1517536,1517898,1517941,1517970,1517980,1518189,1518210,1519611,1520349,1520632,1520655,1521023,1521025,1521027,1521030,1521032,1521034,1521040,1521043,1521049-1521050,1521059-1521061,1521073,1521075,1521271,1521276,1521687,1521829,1521831,1521834-1521835,1521837,1521839-1521840,1522016,1523555,1523646-1523647,1523674,1523781,1523788,1523830,1523955,1523958,1523964,1523982,1524078,1524558,1524652,1524657,1524668,1524683,1524687,1524761,1525593,1525696,1526043,1526052,1527480,1527493,1527727-1527728,1527730-1527733,1528060,1528166,1528169,1528171-1528172,1528248,1528369,1528383,1528407,1528424,1528855,1529149,1529181,1529317,1529546,1529549,1529787,1530057,1530081,1530103,1530213,1530296,1530298,15303
 25,1530342,1530348,1530353,1530397,1530418,1530421,1530423,1530445,1530574,1530599,1530632,1530791,1530822,1530866,1530875,1530909,1530989,1531087,1531099,1531130,1531138,1531156,1531161,1531271,1531312,1531600,1532036,1532269,1532286,1532373,1532437,1532445,1532506,1532544,1532622,1532627,1532718-1532722,1532765-1532766,1533048-1533049,1533117,1533312,1533347,1533962,1533980,1534165,1534418,1534540,1534543-1534544,1534612,1534616,1534619,1534727,1534744,1534846,1536298,1536337,1536520,1536624,1536632,1536735,1536834,1536848,1536850,1536852,1537041,1537057,1537073,1537404,1537835,1538533,1538781,1538798,1538921,1538923-1538924,1539133,1539157,1539173,1539445,1539452,1539702,1539716,1540374,1540539,1540641,1540647,1540670,1540687,1540765,1540807,1542267,1542339,1542769,1542841,1542845,1542856,1543383,1543753,1543772,1543815-1543817,1543897,1543943,1543948,1544072,1544075,1544082,1544165,1544208,1544210,1544453,1544455,1544460,1544472,1544589,1544593,1544606,1544679,1545075,1545078,15
 45082,1545213,1545215,1545261,1545284,1545288,1545377,1545416,1545471,1545480,1545619,1545665,1545750,1545799,1545814,1545832,1545847,1545863,1546172,1546372,1546382,1546631,1546656,1547032,1547760

Modified: tomcat/tc7.0.x/trunk/test/org/apache/catalina/deploy/TestWebXml.java
URL: http://svn.apache.org/viewvc/tomcat/tc7.0.x/trunk/test/org/apache/catalina/deploy/TestWebXml.java?rev=1547931&r1=1547930&r2=1547931&view=diff
==============================================================================
--- tomcat/tc7.0.x/trunk/test/org/apache/catalina/deploy/TestWebXml.java (original)
+++ tomcat/tc7.0.x/trunk/test/org/apache/catalina/deploy/TestWebXml.java Wed Dec  4 22:17:03
2013
@@ -24,6 +24,9 @@ import java.util.Set;
 import org.junit.Assert;
 import org.junit.Test;
 
+import org.apache.tomcat.util.descriptor.XmlIdentifiers;
+
+
 /**
  * Test case for {@link WebXml}.
  */
@@ -43,38 +46,15 @@ public class TestWebXml {
         Assert.assertEquals(2, webxml.getMajorVersion());
         Assert.assertEquals(5, webxml.getMinorVersion());
 
-        // Reset
+        // unknown input should be ignored
         webxml.setVersion("0.0");
-        Assert.assertEquals(0, webxml.getMajorVersion());
-        Assert.assertEquals(0, webxml.getMinorVersion());
+        Assert.assertEquals(2, webxml.getMajorVersion());
+        Assert.assertEquals(5, webxml.getMinorVersion());
 
         // null input should be ignored
         webxml.setVersion(null);
-        Assert.assertEquals(0, webxml.getMajorVersion());
-        Assert.assertEquals(0, webxml.getMinorVersion());
-
-        // major only
-        webxml.setVersion("3");
-        Assert.assertEquals(3, webxml.getMajorVersion());
-        Assert.assertEquals(0, webxml.getMinorVersion());
-
-        // no minor digit
-        webxml.setVersion("0.0");   // reset
-        webxml.setVersion("3.");
-        Assert.assertEquals(3, webxml.getMajorVersion());
-        Assert.assertEquals(0, webxml.getMinorVersion());
-
-        // minor only
-        webxml.setVersion("0.0");   // reset
-        webxml.setVersion(".5");
-        Assert.assertEquals(0, webxml.getMajorVersion());
-        Assert.assertEquals(5, webxml.getMinorVersion());
-
-        // leading & training zeros
-        webxml.setVersion("0.0");   // reset
-        webxml.setVersion("002.500");
         Assert.assertEquals(2, webxml.getMajorVersion());
-        Assert.assertEquals(500, webxml.getMinorVersion());
+        Assert.assertEquals(5, webxml.getMinorVersion());
     }
 
     @Test
@@ -82,8 +62,7 @@ public class TestWebXml {
 
         WebXml webxml = new WebXml();
 
-        webxml.setPublicId(
-                org.apache.catalina.startup.Constants.WebDtdPublicId_22);
+        webxml.setPublicId(XmlIdentifiers.WEB_22_PUBLIC);
         Assert.assertEquals(2, webxml.getMajorVersion());
         Assert.assertEquals(2, webxml.getMinorVersion());
         Assert.assertEquals("2.2", webxml.getVersion());
@@ -94,8 +73,7 @@ public class TestWebXml {
 
         WebXml webxml = new WebXml();
 
-        webxml.setPublicId(
-                org.apache.catalina.startup.Constants.WebDtdPublicId_23);
+        webxml.setPublicId(XmlIdentifiers.WEB_23_PUBLIC);
         Assert.assertEquals(2, webxml.getMajorVersion());
         Assert.assertEquals(3, webxml.getMinorVersion());
         Assert.assertEquals("2.3", webxml.getVersion());
@@ -106,8 +84,7 @@ public class TestWebXml {
 
         WebXml webxml = new WebXml();
 
-        webxml.setPublicId(
-                org.apache.catalina.startup.Constants.WebSchemaPublicId_24);
+        webxml.setVersion("2.4");
         Assert.assertEquals(2, webxml.getMajorVersion());
         Assert.assertEquals(4, webxml.getMinorVersion());
         Assert.assertEquals("2.4", webxml.getVersion());
@@ -118,8 +95,7 @@ public class TestWebXml {
 
         WebXml webxml = new WebXml();
 
-        webxml.setPublicId(
-                org.apache.catalina.startup.Constants.WebSchemaPublicId_25);
+        webxml.setVersion("2.5");
         Assert.assertEquals(2, webxml.getMajorVersion());
         Assert.assertEquals(5, webxml.getMinorVersion());
         Assert.assertEquals("2.5", webxml.getVersion());
@@ -130,8 +106,7 @@ public class TestWebXml {
 
         WebXml webxml = new WebXml();
 
-        webxml.setPublicId(
-                org.apache.catalina.startup.Constants.WebSchemaPublicId_30);
+        webxml.setVersion("3.0");
         Assert.assertEquals(3, webxml.getMajorVersion());
         Assert.assertEquals(0, webxml.getMinorVersion());
         Assert.assertEquals("3.0", webxml.getVersion());



---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org


Mime
View raw message