geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From djen...@apache.org
Subject svn commit: rev 54978 - in geronimo/trunk/modules/j2ee-schema/src: java/org/apache/geronimo/schema test-data/j2ee_1_4schema test/org/apache/geronimo/schema
Date Sun, 17 Oct 2004 22:54:10 GMT
Author: djencks
Date: Sun Oct 17 15:54:10 2004
New Revision: 54978

Added:
   geronimo/trunk/modules/j2ee-schema/src/test-data/j2ee_1_4schema/web-1-24.xml
Modified:
   geronimo/trunk/modules/j2ee-schema/src/java/org/apache/geronimo/schema/SchemaConversionUtils.java
   geronimo/trunk/modules/j2ee-schema/src/test/org/apache/geronimo/schema/SchemaConversionUtilsTest.java
Log:
reject invalid web 2.4 dds

Modified: geronimo/trunk/modules/j2ee-schema/src/java/org/apache/geronimo/schema/SchemaConversionUtils.java
==============================================================================
--- geronimo/trunk/modules/j2ee-schema/src/java/org/apache/geronimo/schema/SchemaConversionUtils.java
(original)
+++ geronimo/trunk/modules/j2ee-schema/src/java/org/apache/geronimo/schema/SchemaConversionUtils.java
Sun Oct 17 15:54:10 2004
@@ -173,6 +173,13 @@
         }
         XmlCursor cursor = xmlObject.newCursor();
         XmlCursor moveable = xmlObject.newCursor();
+        moveable.toStartDoc();
+        moveable.toFirstChild();
+        if ("http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd".equals(moveable.getName().getNamespaceURI()))
{
+            XmlObject result = xmlObject.changeType(WebAppDocument.type);
+            validateDD(result);
+            return (WebAppDocument) result;
+        }
         String schemaLocationURL = "http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd";
         String version = "2.4";
         try {

Added: geronimo/trunk/modules/j2ee-schema/src/test-data/j2ee_1_4schema/web-1-24.xml
==============================================================================
--- (empty file)
+++ geronimo/trunk/modules/j2ee-schema/src/test-data/j2ee_1_4schema/web-1-24.xml	Sun Oct 17
15:54:10 2004
@@ -0,0 +1,37 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<web-app xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"
version="2.4" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/j2ee">
+    <servlet>
+        <display-name>Jetspeed Container</display-name>
+        <description>MVC Servlet for Jetspeed Portlet Applications</description>
+        <servlet-name>JetspeedContainer</servlet-name>
+        <servlet-class>org.apache.jetspeed.container.JetspeedContainerServlet</servlet-class>
+        <init-param>
+            <param-name>registerAtInit</param-name>
+            <param-value>1</param-value>
+        </init-param>
+        <init-param>
+            <param-name>portletApplication</param-name>
+            <param-value>RssPortlet-enhanced</param-value>
+        </init-param>
+        <load-on-startup>100</load-on-startup>
+    </servlet>
+    <servlet>
+        <display-name>Jetspeed Container</display-name>
+        <description>MVC Servlet for Jetspeed Portlet Applications</description>
+        <servlet-name>JetspeedContainer2</servlet-name>
+        <servlet-class>org.apache.jetspeed.container.JetspeedContainerServlet</servlet-class>
+        <init-param>
+            <param-name>registerAtInit</param-name>
+            <param-value>1</param-value>
+        </init-param>
+        <init-param>
+            <param-name>portletApplication</param-name>
+            <param-value>RssPortlet-enhanced</param-value>
+        </init-param>
+        <load-on-startup>100</load-on-startup>
+    </servlet>
+    <servlet-mapping>
+        <servlet-name>JetspeedContainer</servlet-name>
+        <url-pattern>/container/*</url-pattern>
+    </servlet-mapping>
+</web-app>

Modified: geronimo/trunk/modules/j2ee-schema/src/test/org/apache/geronimo/schema/SchemaConversionUtilsTest.java
==============================================================================
--- geronimo/trunk/modules/j2ee-schema/src/test/org/apache/geronimo/schema/SchemaConversionUtilsTest.java
(original)
+++ geronimo/trunk/modules/j2ee-schema/src/test/org/apache/geronimo/schema/SchemaConversionUtilsTest.java
Sun Oct 17 15:54:10 2004
@@ -24,6 +24,7 @@
 import junit.framework.TestCase;
 import org.apache.xmlbeans.XmlCursor;
 import org.apache.xmlbeans.XmlObject;
+import org.apache.xmlbeans.XmlException;
 import org.apache.geronimo.xbeans.j2ee.EjbJarType;
 
 /**
@@ -270,6 +271,17 @@
         xmlObject = SchemaConversionUtils.convertToServletSchema(xmlObject);
         boolean ok2 = compareXmlObjects(xmlObject, expected, problems);
         assertTrue("Differences: " + problems, ok2);
+    }
+
+    public void testWebRejectBad24() throws Exception {
+        File srcXml = new File(basedir, "src/test-data/j2ee_1_4schema/web-1-24.xml");
+        XmlObject xmlObject = XmlObject.Factory.parse(srcXml);
+        try {
+            xmlObject = SchemaConversionUtils.convertToServletSchema(xmlObject);
+            fail("doc src/test-data/j2ee_1_4schema/web-1-24.xml is invalid, should not have
validated");
+        } catch (XmlException e) {
+            //expected
+        }
     }
 
     public void testEJB21To21DoesNothing() throws Exception {

Mime
View raw message