You are viewing a plain text version of this content. The canonical link for it is here.
Posted to pluto-scm@portals.apache.org by es...@apache.org on 2007/12/29 18:52:43 UTC

svn commit: r607452 - in /portals/pluto/branches/pluto-1.1.x: pluto-descriptor-api/src/main/java/org/apache/pluto/descriptors/services/ pluto-descriptor-api/src/main/java/org/apache/pluto/descriptors/servlet/ pluto-descriptor-impl/ pluto-descriptor-imp...

Author: esm
Date: Sat Dec 29 09:52:38 2007
New Revision: 607452

URL: http://svn.apache.org/viewvc?rev=607452&view=rev
Log:
[PLUTO-455]: Patch for descriptor-impl to produce a valid 2.3 web.xml and a 2.4 web.xml that declares its schema and namespace.  Thanks Eric Dalquist!

Added:
    portals/pluto/branches/pluto-1.1.x/pluto-descriptor-impl/src/main/java/org/apache/pluto/descriptors/services/castor/ServletNamespaceCastorFieldHandler.java   (with props)
    portals/pluto/branches/pluto-1.1.x/pluto-descriptor-impl/src/test/java/org/apache/pluto/descriptors/services/castor/AbstractVersionedWebAppDescriptorTest.java   (with props)
    portals/pluto/branches/pluto-1.1.x/pluto-descriptor-impl/src/test/resources/servlet-2.3-expected-webapp-descriptor.xml   (with props)
    portals/pluto/branches/pluto-1.1.x/pluto-descriptor-impl/src/test/resources/servlet-2.4-expected-webapp-descriptor.xml   (with props)
Modified:
    portals/pluto/branches/pluto-1.1.x/pluto-descriptor-api/src/main/java/org/apache/pluto/descriptors/services/Constants.java
    portals/pluto/branches/pluto-1.1.x/pluto-descriptor-api/src/main/java/org/apache/pluto/descriptors/servlet/WebAppDD.java
    portals/pluto/branches/pluto-1.1.x/pluto-descriptor-impl/pom.xml
    portals/pluto/branches/pluto-1.1.x/pluto-descriptor-impl/src/main/java/org/apache/pluto/descriptors/services/castor/WebAppDescriptorServiceImpl.java
    portals/pluto/branches/pluto-1.1.x/pluto-descriptor-impl/src/main/resources/org/apache/pluto/descriptors/services/castor/castor-web-xml-mapping.xml
    portals/pluto/branches/pluto-1.1.x/pluto-descriptor-impl/src/test/java/org/apache/pluto/descriptors/services/castor/Servlet23WebAppDescriptorTest.java
    portals/pluto/branches/pluto-1.1.x/pluto-descriptor-impl/src/test/java/org/apache/pluto/descriptors/services/castor/Servlet24WebAppDescriptorTest.java
    portals/pluto/branches/pluto-1.1.x/pluto-descriptor-impl/src/test/resources/servlet-2.4-webapp-descriptor.xml

Modified: portals/pluto/branches/pluto-1.1.x/pluto-descriptor-api/src/main/java/org/apache/pluto/descriptors/services/Constants.java
URL: http://svn.apache.org/viewvc/portals/pluto/branches/pluto-1.1.x/pluto-descriptor-api/src/main/java/org/apache/pluto/descriptors/services/Constants.java?rev=607452&r1=607451&r2=607452&view=diff
==============================================================================
--- portals/pluto/branches/pluto-1.1.x/pluto-descriptor-api/src/main/java/org/apache/pluto/descriptors/services/Constants.java (original)
+++ portals/pluto/branches/pluto-1.1.x/pluto-descriptor-api/src/main/java/org/apache/pluto/descriptors/services/Constants.java Sat Dec 29 09:52:38 2007
@@ -26,6 +26,9 @@
     public static final String WEB_XML_PUBLIC_ID = "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN";
     public static final String WEB_XML_DTD = "http://java.sun.com/dtd/web-app_2_3.dtd";
 
+    public static final String WEB_XML_24_SCHEMA_NAMESPACE = "http://java.sun.com/xml/ns/j2ee";
+    public static final String WEB_XML_24_SCHEMA_LOCATION = WEB_XML_24_SCHEMA_NAMESPACE + " http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd";
+
     public static final String PORLTET_XML_PUBLIC_ID = "-//Sun Microsystems, Inc.//DTD PortletApplication 1.0//EN";
     public static final String PORTLET_XML_DTD = "http://java.sun.com/dtd/portlet-app_1_0.dtd";
 

Modified: portals/pluto/branches/pluto-1.1.x/pluto-descriptor-api/src/main/java/org/apache/pluto/descriptors/servlet/WebAppDD.java
URL: http://svn.apache.org/viewvc/portals/pluto/branches/pluto-1.1.x/pluto-descriptor-api/src/main/java/org/apache/pluto/descriptors/servlet/WebAppDD.java?rev=607452&r1=607451&r2=607452&view=diff
==============================================================================
--- portals/pluto/branches/pluto-1.1.x/pluto-descriptor-api/src/main/java/org/apache/pluto/descriptors/servlet/WebAppDD.java (original)
+++ portals/pluto/branches/pluto-1.1.x/pluto-descriptor-api/src/main/java/org/apache/pluto/descriptors/servlet/WebAppDD.java Sat Dec 29 09:52:38 2007
@@ -59,6 +59,9 @@
     // contains a <distributable/> element, then
     // Castor will update this field to true.
     private DistributableDD distributableDD = new DistributableDD();
+    // Needed to generate the correct default
+    // namespace URI in Castor
+    private String xmlNs = null;
 
     public WebAppDD() {
 
@@ -252,7 +255,16 @@
     public void setServletVersion(String servletVersion) {
         this.servletVersion = servletVersion;
     }
+    
+    public String getXmlNs() {
+        return this.xmlNs;
+    }
+
+    public void setXmlNs(String xmlNs) {
+        this.xmlNs = xmlNs;
+    }
 
+    
 // Helpers
 
     public ServletDD getServlet(String name) {

Modified: portals/pluto/branches/pluto-1.1.x/pluto-descriptor-impl/pom.xml
URL: http://svn.apache.org/viewvc/portals/pluto/branches/pluto-1.1.x/pluto-descriptor-impl/pom.xml?rev=607452&r1=607451&r2=607452&view=diff
==============================================================================
--- portals/pluto/branches/pluto-1.1.x/pluto-descriptor-impl/pom.xml (original)
+++ portals/pluto/branches/pluto-1.1.x/pluto-descriptor-impl/pom.xml Sat Dec 29 09:52:38 2007
@@ -82,6 +82,12 @@
       <version>${junit.version}</version>
       <scope>test</scope>
     </dependency>
+    <dependency>
+      <groupId>xmlunit</groupId>
+      <artifactId>xmlunit</artifactId>
+      <version>${xmlunit.version}</version>
+      <scope>test</scope>
+    </dependency>
   </dependencies>
   
 </project>

Added: portals/pluto/branches/pluto-1.1.x/pluto-descriptor-impl/src/main/java/org/apache/pluto/descriptors/services/castor/ServletNamespaceCastorFieldHandler.java
URL: http://svn.apache.org/viewvc/portals/pluto/branches/pluto-1.1.x/pluto-descriptor-impl/src/main/java/org/apache/pluto/descriptors/services/castor/ServletNamespaceCastorFieldHandler.java?rev=607452&view=auto
==============================================================================
--- portals/pluto/branches/pluto-1.1.x/pluto-descriptor-impl/src/main/java/org/apache/pluto/descriptors/services/castor/ServletNamespaceCastorFieldHandler.java (added)
+++ portals/pluto/branches/pluto-1.1.x/pluto-descriptor-impl/src/main/java/org/apache/pluto/descriptors/services/castor/ServletNamespaceCastorFieldHandler.java Sat Dec 29 09:52:38 2007
@@ -0,0 +1,93 @@
+/*
+ * 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.
+ */
+package org.apache.pluto.descriptors.services.castor;
+
+import org.apache.pluto.descriptors.services.Constants;
+import org.apache.pluto.descriptors.servlet.WebAppDD;
+import org.exolab.castor.mapping.AbstractFieldHandler;
+
+/**
+ * This class manages the <code>xmlns</code> attribute on the &lt;web-app&gt; for
+ * Servlet 2.4 and greater deployment descriptors.
+ *
+ * Servlet 2.3 does not have a <code>xmlns</code> attribute, for the &lt;web-app&gt;
+ * while Servlet 2.4 and higher do.
+ *
+ * @since Mar 3, 2007
+ * @version $Id$
+ */
+public class ServletNamespaceCastorFieldHandler extends AbstractFieldHandler
+{
+
+    public Object getValue(Object webAppDD) throws IllegalStateException
+    {
+        if (! ( webAppDD instanceof WebAppDD ) )
+        {
+            throw new ClassCastException( "Error: was expecting a " +
+                    WebAppDD.class.getName() + " but received a " + webAppDD.getClass().getName() );
+        }
+
+        String servletVersion = ((WebAppDD)webAppDD).getServletVersion();
+
+        if ( "2.3".equals(servletVersion) )
+        {
+            return null;
+        }
+        else if ( "2.4".equals(servletVersion) )
+        {
+            return Constants.WEB_XML_24_SCHEMA_NAMESPACE;
+        }
+
+        return servletVersion;
+    }
+
+    public Object newInstance(Object arg0) throws IllegalStateException
+    {
+        // Do nothing
+        return null;
+    }
+
+    public Object newInstance(Object arg0, Object[] arg1)
+            throws IllegalStateException
+    {
+        // Do nothing
+        return null;
+    }
+
+    public void resetValue(Object arg0) throws IllegalStateException,
+            IllegalArgumentException
+    {
+        // Do nothing
+    }
+
+    public void setValue(Object webAppDD, Object namespaceValue) throws IllegalStateException, IllegalArgumentException
+    {
+        if (! ( webAppDD instanceof WebAppDD ) )
+        {
+            throw new ClassCastException( "Error: was expecting a " +
+                    WebAppDD.class.getName() + " but received a " + webAppDD.getClass().getName() );
+        }
+        if (! ( namespaceValue instanceof String) )
+        {
+            throw new ClassCastException( "Error: was expecting a " +
+                    String.class.getName() + " but received a " + namespaceValue.getClass().getName() );
+        }
+
+        ((WebAppDD)webAppDD).setXmlNs((String)namespaceValue);
+    }
+
+}

Propchange: portals/pluto/branches/pluto-1.1.x/pluto-descriptor-impl/src/main/java/org/apache/pluto/descriptors/services/castor/ServletNamespaceCastorFieldHandler.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: portals/pluto/branches/pluto-1.1.x/pluto-descriptor-impl/src/main/java/org/apache/pluto/descriptors/services/castor/ServletNamespaceCastorFieldHandler.java
------------------------------------------------------------------------------
    svn:keywords = Id

Propchange: portals/pluto/branches/pluto-1.1.x/pluto-descriptor-impl/src/main/java/org/apache/pluto/descriptors/services/castor/ServletNamespaceCastorFieldHandler.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Modified: portals/pluto/branches/pluto-1.1.x/pluto-descriptor-impl/src/main/java/org/apache/pluto/descriptors/services/castor/WebAppDescriptorServiceImpl.java
URL: http://svn.apache.org/viewvc/portals/pluto/branches/pluto-1.1.x/pluto-descriptor-impl/src/main/java/org/apache/pluto/descriptors/services/castor/WebAppDescriptorServiceImpl.java?rev=607452&r1=607451&r2=607452&view=diff
==============================================================================
--- portals/pluto/branches/pluto-1.1.x/pluto-descriptor-impl/src/main/java/org/apache/pluto/descriptors/services/castor/WebAppDescriptorServiceImpl.java (original)
+++ portals/pluto/branches/pluto-1.1.x/pluto-descriptor-impl/src/main/java/org/apache/pluto/descriptors/services/castor/WebAppDescriptorServiceImpl.java Sat Dec 29 09:52:38 2007
@@ -80,6 +80,14 @@
     protected String getDTDUri() {
         return Constants.WEB_XML_DTD;
     }
+    
+    /**
+     * Retrieve the Web Application Schema location for a Servlet version 2.4 web.xml
+     * @return
+     */
+    protected String get24SchemaLocation() {
+        return Constants.WEB_XML_24_SCHEMA_LOCATION;
+    }
 
     /**
      * Read and Retrieve the Web Application's Castor Mapping
@@ -106,6 +114,11 @@
         if ( "2.3".equals(servletVersion) )
         {
             marshaller.setDoctype(getPublicId(), getDTDUri());
+            marshaller.setSuppressNamespaces(true);
+        }
+        else if ( "2.4".equals(servletVersion) )
+        {
+            marshaller.setSchemaLocation(get24SchemaLocation());
         }
     }
 

Modified: portals/pluto/branches/pluto-1.1.x/pluto-descriptor-impl/src/main/resources/org/apache/pluto/descriptors/services/castor/castor-web-xml-mapping.xml
URL: http://svn.apache.org/viewvc/portals/pluto/branches/pluto-1.1.x/pluto-descriptor-impl/src/main/resources/org/apache/pluto/descriptors/services/castor/castor-web-xml-mapping.xml?rev=607452&r1=607451&r2=607452&view=diff
==============================================================================
--- portals/pluto/branches/pluto-1.1.x/pluto-descriptor-impl/src/main/resources/org/apache/pluto/descriptors/services/castor/castor-web-xml-mapping.xml (original)
+++ portals/pluto/branches/pluto-1.1.x/pluto-descriptor-impl/src/main/resources/org/apache/pluto/descriptors/services/castor/castor-web-xml-mapping.xml Sat Dec 29 09:52:38 2007
@@ -56,6 +56,12 @@
            type="java.lang.String">
         <bind-xml name="version" node="attribute"/>
     </field>
+    
+    <field name="XmlNs"
+           handler="org.apache.pluto.descriptors.services.castor.ServletNamespaceCastorFieldHandler"
+           type="java.lang.String">
+        <bind-xml name="xmlns" node="attribute"/>
+    </field>
         
     <field name="Icon"
            type="org.apache.pluto.descriptors.common.IconDD"/>
@@ -86,6 +92,12 @@
       <bind-xml name="filter" node="element"/>
     </field>
 
+    <field name="FilterMappings"
+           type="org.apache.pluto.descriptors.servlet.FilterMappingDD"
+           collection="arraylist">
+      <bind-xml name="filter-mapping" node="element"/>
+    </field>
+
     <field name="Listeners"
         type="org.apache.pluto.descriptors.servlet.ListenerDD"
         collection="arraylist">
@@ -98,12 +110,6 @@
       <bind-xml name="servlet" node="element"/>
     </field>
 
-    <field name="FilterMappings"
-           type="org.apache.pluto.descriptors.servlet.FilterMappingDD"
-           collection="arraylist">
-      <bind-xml name="filter-mapping" node="element"/>
-    </field>
-
     <field name="ServletMappings"
         type="org.apache.pluto.descriptors.servlet.ServletMappingDD"
         collection="arraylist">
@@ -302,23 +308,36 @@
                type="org.apache.pluto.descriptors.common.UserDataConstraintDD"/>
     </class>
     <class name="org.apache.pluto.descriptors.servlet.WebResourceCollectionDD">
-        <field name="description" type="java.lang.String"/>
         <field name="webResourceName" type="java.lang.String"/>
+        <field name="description" type="java.lang.String"/>
+        <field name="urlPatterns" type="java.lang.String" collection="arraylist">
+            <bind-xml name="url-pattern" node="element"/>
+        </field>
         <field name="httpMethods" type="java.lang.String" collection="arraylist">
           <bind-xml name="http-method" node="element"/>
         </field>
-        <field name="urlPatterns" type="java.lang.String" collection="arraylist">
-            <bind-xml name="url-pattern" node="element"/>
+    </class>
+    <class name="org.apache.pluto.descriptors.servlet.AuthConstraintDD">
+        <field name="Description">
+            <bind-xml name="description" node="element"/>
+        </field>
+        
+        <field name="RoleName">
+            <bind-xml name="role-name" node="element"/>
         </field>
     </class>
 
     <class name="org.apache.pluto.descriptors.servlet.LoginConfigDD">
         <field name="AuthMethod" type="java.lang.String"/>
+        <field name="RealmName" type="java.lang.String"/>
         <field name="FormLoginConfig"
                type="org.apache.pluto.descriptors.servlet.FormLoginConfigDD">
           <bind-xml name="form-login-config" node="element"/>
         </field>
-        <field name="RealmName" type="java.lang.String"/>
+    </class>
+    <class name="org.apache.pluto.descriptors.servlet.FormLoginConfigDD">
+        <field name="FormLoginPage" type="java.lang.String"/>
+        <field name="FormErrorPage" type="java.lang.String"/>
     </class>
 
     <class name="org.apache.pluto.descriptors.servlet.LoadOnStartupDD">
@@ -328,10 +347,6 @@
     </class>
     
     <class name="org.apache.pluto.descriptors.common.DescriptionDD">
-        <field name="Lang">
-            <bind-xml name="lang" node="attribute"/>
-        </field>
-
         <field name="Description">
             <bind-xml name="description" node="text"/>
         </field>
@@ -383,5 +398,44 @@
          </field>
     </class>        
 
+    <class name="org.apache.pluto.descriptors.servlet.MimeMappingDD">
+        <field name="Extension" type="java.lang.String"/>
+        <field name="MimeType" type="java.lang.String"/>
+    </class>
+    
+    <class name="org.apache.pluto.descriptors.servlet.ErrorPageDD">
+        <field name="ErrorCode" type="java.lang.String"/>
+        <field name="ExceptionType" type="java.lang.String"/>
+        <field name="Location" type="java.lang.String"/>
+    </class>
+    
+    <class name="org.apache.pluto.descriptors.servlet.ResourceRefDD">
+        <field name="Description" type="java.lang.String"/>
+        <field name="ResRefName" type="java.lang.String"/>
+        <field name="ResType" type="java.lang.String"/>
+        <field name="ResAuth" type="java.lang.String"/>
+        <field name="ResSharingScope" type="java.lang.String"/>
+    </class>
+    
+    <class name="org.apache.pluto.descriptors.servlet.SecurityRoleDD">
+        <field name="Description" type="java.lang.String"/>
+        <field name="RoleName" type="java.lang.String"/>
+    </class>
+    
+    <class name="org.apache.pluto.descriptors.servlet.EnvEntryDD">
+        <field name="Description" type="java.lang.String"/>
+        <field name="EnvEntryName" type="java.lang.String"/>
+        <field name="EnvEntryValue" type="java.lang.String"/>
+        <field name="EnvEntryType" type="java.lang.String"/>
+    </class>
+    
+    <class name="org.apache.pluto.descriptors.servlet.EjbRefDD">
+        <field name="Description" type="java.lang.String"/>
+        <field name="EjbRefName" type="java.lang.String"/>
+        <field name="EjbRefType" type="java.lang.String"/>
+        <field name="Home" type="java.lang.String"/>
+        <field name="Remote" type="java.lang.String"/>
+        <field name="EjbLink" type="java.lang.String"/>
+    </class>
 </mapping>
 

Added: portals/pluto/branches/pluto-1.1.x/pluto-descriptor-impl/src/test/java/org/apache/pluto/descriptors/services/castor/AbstractVersionedWebAppDescriptorTest.java
URL: http://svn.apache.org/viewvc/portals/pluto/branches/pluto-1.1.x/pluto-descriptor-impl/src/test/java/org/apache/pluto/descriptors/services/castor/AbstractVersionedWebAppDescriptorTest.java?rev=607452&view=auto
==============================================================================
--- portals/pluto/branches/pluto-1.1.x/pluto-descriptor-impl/src/test/java/org/apache/pluto/descriptors/services/castor/AbstractVersionedWebAppDescriptorTest.java (added)
+++ portals/pluto/branches/pluto-1.1.x/pluto-descriptor-impl/src/test/java/org/apache/pluto/descriptors/services/castor/AbstractVersionedWebAppDescriptorTest.java Sat Dec 29 09:52:38 2007
@@ -0,0 +1,100 @@
+/*
+ * 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.
+ */
+package org.apache.pluto.descriptors.services.castor;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileOutputStream;
+import java.io.FileReader;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.io.OutputStream;
+
+import org.apache.pluto.descriptors.services.WebAppDescriptorService;
+import org.apache.pluto.descriptors.servlet.WebAppDD;
+import org.custommonkey.xmlunit.XMLTestCase;
+
+/**
+ * Base test for doing a read and read/write/read test on specific versions
+ * of the descriptor xml.
+ *
+ * @since Mar 3, 2007
+ * @version $Id$
+ * @todo JavaDoc
+ */
+public abstract class AbstractVersionedWebAppDescriptorTest extends XMLTestCase
+{
+    private WebAppDescriptorService underTest = null;
+
+    protected void setUp() throws Exception
+    {
+        underTest = new WebAppDescriptorServiceImpl();
+    }
+
+    protected final InputStream getDescriptorStream() {
+        final String descriptorPath = this.getDescriptorPath();
+        return this.getRequiredResource(descriptorPath);
+    }
+    
+    protected final InputStream getExpectedDescriptorStream() {
+        final String expectedDescriptorPath = this.getExpectedDescriptorPath();
+        return this.getRequiredResource(expectedDescriptorPath);
+    }
+    
+    protected final InputStream getRequiredResource(String path) {
+        final InputStream resource = this.getClass().getResourceAsStream(path);
+        assertNotNull(resource);
+        return resource;
+    }
+
+    protected void tearDown() throws Exception
+    {
+        underTest = null;
+    }
+    
+    protected abstract String getDescriptorPath();
+    
+    protected abstract String getExpectedDescriptorPath();
+    
+    protected abstract String getDescriptorVersion();
+
+    public final void testRead() throws Exception
+    {
+        final InputStream descriptorStream = this.getDescriptorStream();
+        WebAppDD webappdd = underTest.read(descriptorStream);
+        assertNotNull(webappdd);
+        assertEquals(this.getDescriptorVersion(), webappdd.getServletVersion());
+    }
+
+    public final void testWrite() throws Exception
+    {
+        File outputFile = File.createTempFile("web-app-descriptor-test", ".xml");
+        OutputStream out = new FileOutputStream(outputFile);
+        final InputStream descriptorStream = this.getDescriptorStream();
+        WebAppDD webappdd = underTest.read(descriptorStream);
+        underTest.write(webappdd, out);
+        
+        final InputStream expectedDescriptorStream = getExpectedDescriptorStream();
+        assertXMLEqual(new InputStreamReader(expectedDescriptorStream), new FileReader(outputFile));
+        
+        // now round-trip it
+        WebAppDD webappdd2 = underTest.read(new FileInputStream(outputFile));
+        assertNotNull(webappdd2);
+        assertEquals(this.getDescriptorVersion(), webappdd2.getServletVersion());
+        outputFile.delete();
+    }
+}

Propchange: portals/pluto/branches/pluto-1.1.x/pluto-descriptor-impl/src/test/java/org/apache/pluto/descriptors/services/castor/AbstractVersionedWebAppDescriptorTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: portals/pluto/branches/pluto-1.1.x/pluto-descriptor-impl/src/test/java/org/apache/pluto/descriptors/services/castor/AbstractVersionedWebAppDescriptorTest.java
------------------------------------------------------------------------------
    svn:keywords = Id

Propchange: portals/pluto/branches/pluto-1.1.x/pluto-descriptor-impl/src/test/java/org/apache/pluto/descriptors/services/castor/AbstractVersionedWebAppDescriptorTest.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Modified: portals/pluto/branches/pluto-1.1.x/pluto-descriptor-impl/src/test/java/org/apache/pluto/descriptors/services/castor/Servlet23WebAppDescriptorTest.java
URL: http://svn.apache.org/viewvc/portals/pluto/branches/pluto-1.1.x/pluto-descriptor-impl/src/test/java/org/apache/pluto/descriptors/services/castor/Servlet23WebAppDescriptorTest.java?rev=607452&r1=607451&r2=607452&view=diff
==============================================================================
--- portals/pluto/branches/pluto-1.1.x/pluto-descriptor-impl/src/test/java/org/apache/pluto/descriptors/services/castor/Servlet23WebAppDescriptorTest.java (original)
+++ portals/pluto/branches/pluto-1.1.x/pluto-descriptor-impl/src/test/java/org/apache/pluto/descriptors/services/castor/Servlet23WebAppDescriptorTest.java Sat Dec 29 09:52:38 2007
@@ -16,16 +16,6 @@
  */
 package org.apache.pluto.descriptors.services.castor;
 
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileOutputStream;
-import java.io.InputStream;
-import java.io.OutputStream;
-
-import junit.framework.TestCase;
-
-import org.apache.pluto.descriptors.services.WebAppDescriptorService;
-import org.apache.pluto.descriptors.servlet.WebAppDD;
 
 /**
  * This test ensures that the version attribute of a servlet 2.3 descriptor
@@ -35,43 +25,31 @@
  * @version $Id$
  * @todo JavaDoc
  */
-public class Servlet23WebAppDescriptorTest extends TestCase
+public class Servlet23WebAppDescriptorTest extends AbstractVersionedWebAppDescriptorTest
 {
 
     private static final String DESCRIPTOR = "/servlet-2.3-webapp-descriptor.xml";
-    private InputStream in = null;
-    private WebAppDescriptorService underTest = null;
-
-    protected void setUp() throws Exception
-    {
-        underTest = new WebAppDescriptorServiceImpl();
-        in = this.getClass().getResourceAsStream(DESCRIPTOR);
-        assertNotNull(in);
+    private static final String EXPECTED_DESCRIPTOR = "/servlet-2.3-expected-webapp-descriptor.xml";
+    
+    
+    /* (non-Javadoc)
+     * @see org.apache.pluto.descriptors.services.castor.AbstractVersionedWebAppDescriptorTest#getDescriptorPath()
+     */
+    protected String getDescriptorPath() {
+        return DESCRIPTOR;
     }
-
-    protected void tearDown() throws Exception
-    {
-        underTest = null;
-        in = null;
+    
+    /* (non-Javadoc)
+     * @see org.apache.pluto.descriptors.services.castor.AbstractVersionedWebAppDescriptorTest#getExpectedDescriptorPath()
+     */
+    protected String getExpectedDescriptorPath() {
+        return EXPECTED_DESCRIPTOR;
     }
-
-    public void testRead() throws Exception
-    {
-        WebAppDD webappdd = underTest.read(in);
-        assertNotNull(webappdd);
-        assertEquals("2.3", webappdd.getServletVersion());
-    }
-
-    public void testWrite() throws Exception
-    {
-        File outputFile = File.createTempFile( "webapp-2.3-descriptor-test", ".xml" );
-        OutputStream out = new FileOutputStream( outputFile );
-        WebAppDD webappdd = underTest.read(in);
-        underTest.write(webappdd, out);
-        // now round-trip it
-        WebAppDD webappdd2 = underTest.read(new FileInputStream(outputFile));
-        assertNotNull(webappdd2);
-        assertEquals("2.3", webappdd2.getServletVersion());
-        outputFile.delete();
+    
+    /* (non-Javadoc)
+     * @see org.apache.pluto.descriptors.services.castor.AbstractVersionedWebAppDescriptorTest#getDescriptorVersion()
+     */
+    protected String getDescriptorVersion() {
+        return "2.3";
     }
 }

Modified: portals/pluto/branches/pluto-1.1.x/pluto-descriptor-impl/src/test/java/org/apache/pluto/descriptors/services/castor/Servlet24WebAppDescriptorTest.java
URL: http://svn.apache.org/viewvc/portals/pluto/branches/pluto-1.1.x/pluto-descriptor-impl/src/test/java/org/apache/pluto/descriptors/services/castor/Servlet24WebAppDescriptorTest.java?rev=607452&r1=607451&r2=607452&view=diff
==============================================================================
--- portals/pluto/branches/pluto-1.1.x/pluto-descriptor-impl/src/test/java/org/apache/pluto/descriptors/services/castor/Servlet24WebAppDescriptorTest.java (original)
+++ portals/pluto/branches/pluto-1.1.x/pluto-descriptor-impl/src/test/java/org/apache/pluto/descriptors/services/castor/Servlet24WebAppDescriptorTest.java Sat Dec 29 09:52:38 2007
@@ -16,15 +16,6 @@
  */
 package org.apache.pluto.descriptors.services.castor;
 
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileOutputStream;
-import java.io.InputStream;
-
-import junit.framework.TestCase;
-
-import org.apache.pluto.descriptors.services.WebAppDescriptorService;
-import org.apache.pluto.descriptors.servlet.WebAppDD;
 
 /**
  * This test ensures that the version attribute of a Servlet 2.4
@@ -33,44 +24,30 @@
  * @since Mar 3, 2007
  * @version $Id$
  */
-public class Servlet24WebAppDescriptorTest extends TestCase
+public class Servlet24WebAppDescriptorTest extends AbstractVersionedWebAppDescriptorTest
 {
 
     private static final String DESCRIPTOR = "/servlet-2.4-webapp-descriptor.xml";
-    InputStream in = null;
-    private WebAppDescriptorService underTest = null;
-
-    protected void setUp() throws Exception
-    {
-        underTest = new WebAppDescriptorServiceImpl();
-        in = this.getClass().getResourceAsStream(DESCRIPTOR);
-        assertNotNull(in);
-    }
-
-    protected void tearDown() throws Exception
-    {
-        in = null;
-        underTest = null;
+    private static final String EXPECTED_DESCRIPTOR = "/servlet-2.4-expected-webapp-descriptor.xml";
+    
+    /* (non-Javadoc)
+     * @see org.apache.pluto.descriptors.services.castor.AbstractVersionedWebAppDescriptorTest#getDescriptorPath()
+     */
+    protected String getDescriptorPath() {
+        return DESCRIPTOR;
     }
-
-    public void testRead() throws Exception
-    {
-        WebAppDD webapp = underTest.read(in);
-        assertNotNull(webapp);
-        assertEquals("2.4", webapp.getServletVersion());
+    
+    /* (non-Javadoc)
+     * @see org.apache.pluto.descriptors.services.castor.AbstractVersionedWebAppDescriptorTest#getExpectedDescriptorPath()
+     */
+    protected String getExpectedDescriptorPath() {
+        return EXPECTED_DESCRIPTOR;
     }
-
-    public void testWrite() throws Exception
-    {
-        WebAppDD webapp = underTest.read(in);
-        File outputFile = File.createTempFile("webapp-2.4-descriptor-test", ".xml");
-        FileOutputStream out = new FileOutputStream(outputFile);
-        underTest.write(webapp, out);
-        // roundtrip it.
-        WebAppDD webapp2 = underTest.read(new FileInputStream(outputFile));
-        assertNotNull(webapp2);
-        assertEquals("2.4", webapp2.getServletVersion());
-        outputFile.delete();
+    
+    /* (non-Javadoc)
+     * @see org.apache.pluto.descriptors.services.castor.AbstractVersionedWebAppDescriptorTest#getDescriptorVersion()
+     */
+    protected String getDescriptorVersion() {
+        return "2.4";
     }
-
 }

Added: portals/pluto/branches/pluto-1.1.x/pluto-descriptor-impl/src/test/resources/servlet-2.3-expected-webapp-descriptor.xml
URL: http://svn.apache.org/viewvc/portals/pluto/branches/pluto-1.1.x/pluto-descriptor-impl/src/test/resources/servlet-2.3-expected-webapp-descriptor.xml?rev=607452&view=auto
==============================================================================
--- portals/pluto/branches/pluto-1.1.x/pluto-descriptor-impl/src/test/resources/servlet-2.3-expected-webapp-descriptor.xml (added)
+++ portals/pluto/branches/pluto-1.1.x/pluto-descriptor-impl/src/test/resources/servlet-2.3-expected-webapp-descriptor.xml Sat Dec 29 09:52:38 2007
@@ -0,0 +1,185 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
+                         "http://java.sun.com/dtd/web-app_2_3.dtd">
+<web-app>
+    <icon>
+        <large-icon>/icon/large.gif</large-icon>
+    </icon>
+    <display-name>Test Web XML</display-name>
+    <description>This is a test web.xml file.</description>
+    <context-param>
+        <param-name>TestParam1</param-name>
+        <param-value>TestParam1Value</param-value>
+        <description>Test Parameter 1</description>
+    </context-param>
+    <context-param>
+        <param-name>TestParam2</param-name>
+        <param-value>TestParam2Value</param-value>
+        <description>Test Parameter 1</description>
+    </context-param>
+    <filter>
+        <icon>
+            <large-icon>/icon/large.gif</large-icon>
+        </icon>
+        <filter-name>test</filter-name>
+        <display-name>TestName</display-name>
+        <description>Test Description</description>
+        <filter-class>org.apache.pluto.test.TestMe</filter-class>
+        <init-param>
+            <param-name>Test</param-name>
+            <param-value>true</param-value>
+        </init-param>
+        <init-param>
+            <param-name>Test2</param-name>
+            <param-value>true</param-value>
+        </init-param>
+    </filter>
+    <filter-mapping>
+        <filter-name>test</filter-name>
+        <url-pattern>/test/*</url-pattern>
+    </filter-mapping>
+    <filter-mapping>
+        <filter-name>test</filter-name>
+        <servlet-name>jsp</servlet-name>
+    </filter-mapping>
+    <listener>
+        <listener-class>org.apache.pluto.test.TestListener</listener-class>
+    </listener>
+    <listener>
+        <listener-class>org.apache.pluto.test.AnotherListener</listener-class>
+    </listener>
+    <servlet>
+        <servlet-name>default</servlet-name>
+        <servlet-class>org.apache.catalina.servlets.DefaultServlet</servlet-class>
+        <init-param>
+            <param-name>debug</param-name>
+            <param-value>0</param-value>
+        </init-param>
+        <init-param>
+            <param-name>listings</param-name>
+            <param-value>true</param-value>
+        </init-param>
+        <load-on-startup>1</load-on-startup>
+    </servlet>
+    <servlet>
+        <servlet-name>jsp</servlet-name>
+        <servlet-class>org.apache.jasper.servlet.JspServlet</servlet-class>
+        <init-param>
+            <param-name>fork</param-name>
+            <param-value>false</param-value>
+        </init-param>
+        <init-param>
+            <param-name>xpoweredBy</param-name>
+            <param-value>false</param-value>
+        </init-param>
+        <load-on-startup>3</load-on-startup>
+    </servlet>
+    <servlet-mapping>
+        <servlet-name>default</servlet-name>
+        <url-pattern>/</url-pattern>
+    </servlet-mapping>
+    <servlet-mapping>
+        <servlet-name>jsp</servlet-name>
+        <url-pattern>*.jsp</url-pattern>
+    </servlet-mapping>
+    <servlet-mapping>
+        <servlet-name>jsp</servlet-name>
+        <url-pattern>*.jspx</url-pattern>
+    </servlet-mapping>
+    <session-config>
+        <session-timeout>30</session-timeout>
+    </session-config>
+    <mime-mapping>
+        <extension>abs</extension>
+        <mime-type>audio/x-mpeg</mime-type>
+    </mime-mapping>
+    <mime-mapping>
+        <extension>ai</extension>
+        <mime-type>application/postscript</mime-type>
+    </mime-mapping>
+    <welcome-file-list>
+        <welcome-file>index.html</welcome-file>
+        <welcome-file>index.htm</welcome-file>
+        <welcome-file>index.jsp</welcome-file>
+    </welcome-file-list>
+    <error-page>
+        <error-code>400</error-code>
+        <location>/400.html</location>
+    </error-page>
+    <error-page>
+        <exception-type>java.io.IOException</exception-type>
+        <location>/error/io.html</location>
+    </error-page>
+    <taglib>
+        <taglib-uri>test</taglib-uri>
+        <taglib-location>/WEB-INF/test.tld</taglib-location>
+    </taglib>
+    <resource-ref>
+        <description>Test Resource</description>
+        <res-ref-name>RefName</res-ref-name>
+        <res-type>java.lang.String</res-type>
+        <res-auth>CONTIANER</res-auth>
+        <res-sharing-scope>Scope</res-sharing-scope>
+    </resource-ref>
+    <resource-ref>
+        <description>Test Resource</description>
+        <res-ref-name>RefName2</res-ref-name>
+        <res-type>java.lang.String</res-type>
+        <res-auth>CONTIANER</res-auth>
+        <res-sharing-scope>Scope</res-sharing-scope>
+    </resource-ref>
+    <security-constraint>
+        <display-name>Test Constraint</display-name>
+        <web-resource-collection>
+            <web-resource-name>secured</web-resource-name>
+            <description>TestCollection</description>
+            <url-pattern>/test/*</url-pattern>
+            <url-pattern>/secure/*</url-pattern>
+            <http-method>GET</http-method>
+            <http-method>POST</http-method>
+        </web-resource-collection>
+        <auth-constraint>
+            <description>Test Role</description>
+            <role-name>TestRole</role-name>
+        </auth-constraint>
+        <user-data-constraint>
+            <description>CONFIDENTIAL</description>
+            <transport-guarantee>CONFIDENTIAL</transport-guarantee>
+        </user-data-constraint>
+    </security-constraint>
+    <login-config>
+        <auth-method>FORM</auth-method>
+        <realm-name>BASIC</realm-name>
+        <form-login-config>
+            <form-login-page>/login.jsp</form-login-page>
+            <form-error-page>/login.jsp?error=true</form-error-page>
+        </form-login-config>
+    </login-config>
+    <security-role>
+        <description>A Test Role</description>
+        <role-name>TestRole</role-name>
+    </security-role>
+    <security-role>
+        <description>Another Role</description>
+        <role-name>AnotherRole</role-name>
+    </security-role>
+    <env-entry>
+        <description>Test Environment Entry</description>
+        <env-entry-name>Test</env-entry-name>
+        <env-entry-value>TestValue</env-entry-value>
+        <env-entry-type>java.lang.String</env-entry-type>
+    </env-entry>
+    <env-entry>
+        <description>Another Environment Entry</description>
+        <env-entry-name>Another</env-entry-name>
+        <env-entry-value>AnotherValue</env-entry-value>
+        <env-entry-type>java.lang.String</env-entry-type>
+    </env-entry>
+    <ejb-ref>
+        <description>Test EJB</description>
+        <ejb-ref-name>test</ejb-ref-name>
+        <ejb-ref-type>org.apache.pluto.test.ejb.TestEJB</ejb-ref-type>
+        <home>testHomeInterface</home>
+        <remote>testRemoteInterface</remote>
+    </ejb-ref>
+</web-app>

Propchange: portals/pluto/branches/pluto-1.1.x/pluto-descriptor-impl/src/test/resources/servlet-2.3-expected-webapp-descriptor.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: portals/pluto/branches/pluto-1.1.x/pluto-descriptor-impl/src/test/resources/servlet-2.3-expected-webapp-descriptor.xml
------------------------------------------------------------------------------
    svn:mime-type = text/xml

Added: portals/pluto/branches/pluto-1.1.x/pluto-descriptor-impl/src/test/resources/servlet-2.4-expected-webapp-descriptor.xml
URL: http://svn.apache.org/viewvc/portals/pluto/branches/pluto-1.1.x/pluto-descriptor-impl/src/test/resources/servlet-2.4-expected-webapp-descriptor.xml?rev=607452&view=auto
==============================================================================
--- portals/pluto/branches/pluto-1.1.x/pluto-descriptor-impl/src/test/resources/servlet-2.4-expected-webapp-descriptor.xml (added)
+++ portals/pluto/branches/pluto-1.1.x/pluto-descriptor-impl/src/test/resources/servlet-2.4-expected-webapp-descriptor.xml Sat Dec 29 09:52:38 2007
@@ -0,0 +1,2 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<web-app 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" version="2.4" xmlns="http://java.sun.com/xml/ns/j2ee"><icon><large-icon>/icon/large.gif</large-icon></icon><display-name>Test Web XML</display-name><description>This is a test web.xml file.</description><context-param><param-name>TestParam1</param-name><param-value>TestParam1Value</param-value><description>Test Parameter 1</description></context-param><context-param><param-name>TestParam2</param-name><param-value>TestParam2Value</param-value><description>Test Parameter 1</description></context-param><filter><icon><large-icon>/icon/large.gif</large-icon></icon><filter-name>test</filter-name><filter-class>org.apache.pluto.test.TestMe</filter-class><init-param><param-name>Test</param-name><param-value>true</param-value></init-param><init-param><param-name>Test2</param-name><param-value>true</param-value></init-param>
 </filter><filter-mapping><filter-name>test</filter-name><url-pattern>/test/*</url-pattern></filter-mapping><filter-mapping><filter-name>test</filter-name><servlet-name>jsp</servlet-name></filter-mapping><listener><listener-class>org.apache.pluto.test.TestListener</listener-class></listener><listener><listener-class>org.apache.pluto.test.AnotherListener</listener-class></listener><servlet><servlet-name>default</servlet-name><servlet-class>org.apache.catalina.servlets.DefaultServlet</servlet-class><init-param><param-name>debug</param-name><param-value>0</param-value></init-param><init-param><param-name>listings</param-name><param-value>true</param-value></init-param><load-on-startup>1</load-on-startup></servlet><servlet><servlet-name>jsp</servlet-name><servlet-class>org.apache.jasper.servlet.JspServlet</servlet-class><init-param><param-name>fork</param-name><param-value>false</param-value></init-param><init-param><param-name>xpoweredBy</param-name><param-value>false</param-val
 ue></init-param><load-on-startup>3</load-on-startup></servlet><servlet-mapping><servlet-name>default</servlet-name><url-pattern>/</url-pattern></servlet-mapping><servlet-mapping><servlet-name>jsp</servlet-name><url-pattern>*.jsp</url-pattern></servlet-mapping><servlet-mapping><servlet-name>jsp</servlet-name><url-pattern>*.jspx</url-pattern></servlet-mapping><session-config><session-timeout>30</session-timeout></session-config><mime-mapping><extension>abs</extension><mime-type>audio/x-mpeg</mime-type></mime-mapping><mime-mapping><extension>ai</extension><mime-type>application/postscript</mime-type></mime-mapping><welcome-file-list><welcome-file>index.html</welcome-file><welcome-file>index.htm</welcome-file><welcome-file>index.jsp</welcome-file></welcome-file-list><error-page><error-code>400</error-code><location>/400.html</location></error-page><error-page><exception-type>java.io.IOException</exception-type><location>/error/io.html</location></error-page><security-constraint>
 <display-name>Test Constraint</display-name><web-resource-collection><web-resource-name>secured</web-resource-name><description>TestCollection</description><url-pattern>/test/*</url-pattern><url-pattern>/secure/*</url-pattern><http-method>GET</http-method><http-method>POST</http-method></web-resource-collection><auth-constraint><description>Test Role</description><role-name>TestRole</role-name></auth-constraint><user-data-constraint><description>CONFIDENTIAL</description><transport-guarantee>CONFIDENTIAL</transport-guarantee></user-data-constraint></security-constraint><login-config><auth-method>FORM</auth-method><realm-name>BASIC</realm-name><form-login-config><form-login-page>/login.jsp</form-login-page><form-error-page>/login.jsp?error=true</form-error-page></form-login-config></login-config><security-role><description>A Test Role</description><role-name>TestRole</role-name></security-role><security-role><description>Another Role</description><role-name>AnotherRole</role-
 name></security-role><env-entry><description>Test Environment Entry</description><env-entry-name>Test</env-entry-name><env-entry-value>TestValue</env-entry-value><env-entry-type>java.lang.String</env-entry-type></env-entry><env-entry><description>Another Environment Entry</description><env-entry-name>Another</env-entry-name><env-entry-value>AnotherValue</env-entry-value><env-entry-type>java.lang.String</env-entry-type></env-entry><ejb-ref><description>Test EJB</description><ejb-ref-name>test</ejb-ref-name><ejb-ref-type>Entity</ejb-ref-type><home>testHomeInterface</home><remote>testRemoteInterface</remote></ejb-ref></web-app>
\ No newline at end of file

Propchange: portals/pluto/branches/pluto-1.1.x/pluto-descriptor-impl/src/test/resources/servlet-2.4-expected-webapp-descriptor.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: portals/pluto/branches/pluto-1.1.x/pluto-descriptor-impl/src/test/resources/servlet-2.4-expected-webapp-descriptor.xml
------------------------------------------------------------------------------
    svn:mime-type = text/xml

Modified: portals/pluto/branches/pluto-1.1.x/pluto-descriptor-impl/src/test/resources/servlet-2.4-webapp-descriptor.xml
URL: http://svn.apache.org/viewvc/portals/pluto/branches/pluto-1.1.x/pluto-descriptor-impl/src/test/resources/servlet-2.4-webapp-descriptor.xml?rev=607452&r1=607451&r2=607452&view=diff
==============================================================================
--- portals/pluto/branches/pluto-1.1.x/pluto-descriptor-impl/src/test/resources/servlet-2.4-webapp-descriptor.xml (original)
+++ portals/pluto/branches/pluto-1.1.x/pluto-descriptor-impl/src/test/resources/servlet-2.4-webapp-descriptor.xml Sat Dec 29 09:52:38 2007
@@ -169,19 +169,19 @@
     <env-entry>
         <description>Test Environment Entry</description>
         <env-entry-name>Test</env-entry-name>
+        <env-entry-type>java.lang.String</env-entry-type>
         <env-entry-value>TestValue</env-entry-value>
-        <env-entry-type>java.lang.String</env-entry-type>        
     </env-entry>
     <env-entry>
         <description>Another Environment Entry</description>
         <env-entry-name>Another</env-entry-name>
-        <env-entry-value>AnotherValue</env-entry-value>
-        <env-entry-type>java.lang.String</env-entry-type>        
+        <env-entry-type>java.lang.String</env-entry-type>
+        <env-entry-value>AnotherValue</env-entry-value>        
     </env-entry>
     <ejb-ref>
         <description>Test EJB</description>                
         <ejb-ref-name>test</ejb-ref-name>
-        <ejb-ref-type>org.apache.pluto.test.ejb.TestEJB</ejb-ref-type>
+        <ejb-ref-type>Entity</ejb-ref-type>
         <home>testHomeInterface</home>
         <remote>testRemoteInterface</remote>        
     </ejb-ref>