geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From djen...@apache.org
Subject svn commit: r344331 - in /geronimo/trunk/modules: j2ee-schema/src/java/org/apache/geronimo/schema/ jetty-builder/src/test/org/apache/geronimo/jetty/deployment/ web-builder/src/java/org/apache/geronimo/web/deployment/ web-builder/src/test-resources/plan...
Date Tue, 15 Nov 2005 08:13:14 GMT
Author: djencks
Date: Tue Nov 15 00:13:07 2005
New Revision: 344331

URL: http://svn.apache.org/viewcvs?rev=344331&view=rev
Log:
GERONIMO-1175 fix some schema conversion problems

Added:
    geronimo/trunk/modules/web-builder/src/test-resources/plans/
    geronimo/trunk/modules/web-builder/src/test-resources/plans/tomcat-post.xml
    geronimo/trunk/modules/web-builder/src/test-resources/plans/tomcat-pre.xml
    geronimo/trunk/modules/web-builder/src/test/org/apache/geronimo/web/deployment/GenericToSpecificPlanConverterTest.java
Modified:
    geronimo/trunk/modules/j2ee-schema/src/java/org/apache/geronimo/schema/GBeanElementConverter.java
    geronimo/trunk/modules/j2ee-schema/src/java/org/apache/geronimo/schema/SchemaConversionUtils.java
    geronimo/trunk/modules/jetty-builder/src/test/org/apache/geronimo/jetty/deployment/PlanParsingTest.java
    geronimo/trunk/modules/web-builder/src/java/org/apache/geronimo/web/deployment/GenericToSpecificPlanConverter.java

Modified: geronimo/trunk/modules/j2ee-schema/src/java/org/apache/geronimo/schema/GBeanElementConverter.java
URL: http://svn.apache.org/viewcvs/geronimo/trunk/modules/j2ee-schema/src/java/org/apache/geronimo/schema/GBeanElementConverter.java?rev=344331&r1=344330&r2=344331&view=diff
==============================================================================
--- geronimo/trunk/modules/j2ee-schema/src/java/org/apache/geronimo/schema/GBeanElementConverter.java
(original)
+++ geronimo/trunk/modules/j2ee-schema/src/java/org/apache/geronimo/schema/GBeanElementConverter.java
Tue Nov 15 00:13:07 2005
@@ -38,10 +38,9 @@
                     return;
                 }
                 String localPart = cursor.getName().getLocalPart();
+                cursor.setName(new QName(GERONIMO_SERVICE_NAMESPACE, localPart));
                 if (localPart.equals("xml-attribute") || localPart.equals("xml-reference"))
{
                     cursor.toEndToken();
-                } else {
-                    cursor.setName(new QName(GERONIMO_SERVICE_NAMESPACE, localPart));
                 }
             }
             //this should not break because the xml-* elements are never top level.

Modified: geronimo/trunk/modules/j2ee-schema/src/java/org/apache/geronimo/schema/SchemaConversionUtils.java
URL: http://svn.apache.org/viewcvs/geronimo/trunk/modules/j2ee-schema/src/java/org/apache/geronimo/schema/SchemaConversionUtils.java?rev=344331&r1=344330&r2=344331&view=diff
==============================================================================
--- 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
Tue Nov 15 00:13:07 2005
@@ -327,18 +327,26 @@
         XmlCursor end = cursor.newCursor();
         try {
             while (cursor.hasNextToken()) {
-                if (cursor.isStart()) {
-                    String localName = cursor.getName().getLocalPart();
-                    ElementConverter converter = (ElementConverter) GERONIMO_SCHEMA_CONVERSIONS.get(localName);
-                    if (converter != null) {
-                        converter.convertElement(cursor, end);
-                    }
-                }
+                convertSingleElementToGeronimoSubSchemas(cursor, end);
                 cursor.toNextToken();
             }
         } finally {
             end.dispose();
         }
+    }
+
+    public static boolean convertSingleElementToGeronimoSubSchemas(XmlCursor cursor, XmlCursor
end) {
+        if (cursor.isStart()) {
+            String localName = cursor.getName().getLocalPart();
+            ElementConverter converter = (ElementConverter) GERONIMO_SCHEMA_CONVERSIONS.get(localName);
+            if (converter != null) {
+                converter.convertElement(cursor, end);
+                return true;
+            }
+            return false;
+        }
+        //you should only call this method at a start token
+        return false;
     }
 
     public static XmlObject fixGeronimoSchema(XmlObject rawPlan, String desiredElement, SchemaType
desiredType) throws XmlException {

Modified: geronimo/trunk/modules/jetty-builder/src/test/org/apache/geronimo/jetty/deployment/PlanParsingTest.java
URL: http://svn.apache.org/viewcvs/geronimo/trunk/modules/jetty-builder/src/test/org/apache/geronimo/jetty/deployment/PlanParsingTest.java?rev=344331&r1=344330&r2=344331&view=diff
==============================================================================
--- geronimo/trunk/modules/jetty-builder/src/test/org/apache/geronimo/jetty/deployment/PlanParsingTest.java
(original)
+++ geronimo/trunk/modules/jetty-builder/src/test/org/apache/geronimo/jetty/deployment/PlanParsingTest.java
Tue Nov 15 00:13:07 2005
@@ -2,6 +2,7 @@
 
 import java.io.File;
 import java.net.URI;
+import java.net.URL;
 import java.util.ArrayList;
 import java.util.HashSet;
 import java.util.List;
@@ -27,6 +28,8 @@
 /**
  */
 public class PlanParsingTest extends TestCase {
+    private ClassLoader classLoader = this.getClass().getClassLoader();
+
     ObjectName jettyContainerObjectName = JMXUtil.getObjectName("test:type=JettyContainer");
     ObjectName pojoWebServiceTemplate = null;
     WebServiceBuilder webServiceBuilder = null;
@@ -38,58 +41,58 @@
     }
 
     public void testContents() throws Exception {
-        File resourcePlan = new File(basedir, "src/test-resources/plans/plan1.xml");
-        assertTrue(resourcePlan.exists());
-        JettyWebAppType jettyWebApp = builder.getJettyWebApp(resourcePlan, null, true, null,
null);
+        URL resourcePlan = classLoader.getResource("plans/plan1.xml");
+        assertTrue(resourcePlan != null);
+        JettyWebAppType jettyWebApp = builder.getJettyWebApp(new File(resourcePlan.getFile()),
null, true, null, null);
         assertEquals(1, jettyWebApp.getResourceRefArray().length);
         assertEquals(4, jettyWebApp.getSecurity().getRoleMappings().getRoleArray().length);
     }
 
     public void testMoveSecurity1() throws Exception {
-        File resourcePlan = new File(basedir, "src/test-resources/plans/plan1A.xml");
-        assertTrue(resourcePlan.exists());
-        JettyWebAppType jettyWebApp = builder.getJettyWebApp(resourcePlan, null, true, null,
null);
+        URL resourcePlan = classLoader.getResource("plans/plan1A.xml");
+        assertTrue(resourcePlan != null);
+        JettyWebAppType jettyWebApp = builder.getJettyWebApp(new File(resourcePlan.getFile()),
null, true, null, null);
         assertEquals(1, jettyWebApp.getResourceRefArray().length);
         assertEquals(4, jettyWebApp.getSecurity().getRoleMappings().getRoleArray().length);
     }
 
     public void testMoveSecurity2() throws Exception {
-        File resourcePlan = new File(basedir, "src/test-resources/plans/plan1B.xml");
-        assertTrue(resourcePlan.exists());
-        JettyWebAppType jettyWebApp = builder.getJettyWebApp(resourcePlan, null, true, null,
null);
+        URL resourcePlan = classLoader.getResource("plans/plan1B.xml");
+        assertTrue(resourcePlan != null);
+        JettyWebAppType jettyWebApp = builder.getJettyWebApp(new File(resourcePlan.getFile()),
null, true, null, null);
         assertEquals(1, jettyWebApp.getResourceRefArray().length);
         assertEquals(4, jettyWebApp.getSecurity().getRoleMappings().getRoleArray().length);
     }
 
     public void testMoveSecurity3() throws Exception {
-        File resourcePlan = new File(basedir, "src/test-resources/plans/plan1C.xml");
-        assertTrue(resourcePlan.exists());
-        JettyWebAppType jettyWebApp = builder.getJettyWebApp(resourcePlan, null, true, null,
null);
+        URL resourcePlan = classLoader.getResource("plans/plan1C.xml");
+        assertTrue(resourcePlan != null);
+        JettyWebAppType jettyWebApp = builder.getJettyWebApp(new File(resourcePlan.getFile()),
null, true, null, null);
         assertEquals(4, jettyWebApp.getSecurity().getRoleMappings().getRoleArray().length);
 //        System.out.println(jettyWebApp.xmlText());
     }
 
     public void testOldFormat() throws Exception {
-        File resourcePlan = new File(basedir, "src/test-resources/plans/plan2.xml");
-        assertTrue(resourcePlan.exists());
-        JettyWebAppType jettyWebApp = builder.getJettyWebApp(resourcePlan, null, true, null,
null);
+        URL resourcePlan = classLoader.getResource("plans/plan2.xml");
+        assertTrue(resourcePlan!= null);
+        JettyWebAppType jettyWebApp = builder.getJettyWebApp(new File(resourcePlan.getFile()),
null, true, null, null);
         assertEquals(1, jettyWebApp.getResourceRefArray().length);
         assertEquals(4, jettyWebApp.getSecurity().getRoleMappings().getRoleArray().length);
     }
 
     public void testOldFormatExploded() throws Exception {
-        File war = new File(basedir, "src/test-resources/deployables/war5");
-        assertTrue(war.exists());
-        UnpackedJarFile moduleFile = new UnpackedJarFile(war);
+        URL war = classLoader.getResource("deployables/war5");
+        assertTrue(war != null);
+        UnpackedJarFile moduleFile = new UnpackedJarFile(new File(war.getFile()));
         JettyWebAppType jettyWebApp = builder.getJettyWebApp(null, moduleFile, true, null,
null);
         moduleFile.close();
         assertEquals(1, jettyWebApp.getResourceRefArray().length);
     }
 
     public void XtestOldFormatPackaged() throws Exception {
-        File war = new File(basedir, "src/test-resources/deployables/war6.war");
-        assertTrue(war.exists());
-        JarFile moduleFile = new JarFile(war);
+        URL war = classLoader.getResource("deployables/war6.war");
+        assertTrue(war != null);
+        JarFile moduleFile = new JarFile(new File(war.getFile()));
         JettyWebAppType jettyWebApp = builder.getJettyWebApp(null, moduleFile, true, null,
null);
         moduleFile.close();
         assertEquals(1, jettyWebApp.getResourceRefArray().length);
@@ -110,18 +113,18 @@
     }
 
     public void testContextPriorityClassloader() throws Exception {
-        File resourcePlan = new File(basedir, "src/test-resources/plans/plan3.xml");
-        assertTrue(resourcePlan.exists());
+        URL resourcePlan = classLoader.getResource("plans/plan3.xml");
+        assertTrue(resourcePlan != null);
 
-        JettyWebAppType jettyWebApp = builder.getJettyWebApp(resourcePlan, null, false, null,
null);
+        JettyWebAppType jettyWebApp = builder.getJettyWebApp(new File(resourcePlan.getFile()),
null, false, null, null);
         assertFalse(jettyWebApp.getContextPriorityClassloader());
     }
 
     public void testContextPriorityClassloaderTrue() throws Exception {
-        File resourcePlan = new File(basedir, "src/test-resources/plans/plan4.xml");
-        assertTrue(resourcePlan.exists());
+        URL resourcePlan = classLoader.getResource("plans/plan4.xml");
+        assertTrue(resourcePlan != null);
 
-        JettyWebAppType jettyWebApp = builder.getJettyWebApp(resourcePlan, null, false, null,
null);
+        JettyWebAppType jettyWebApp = builder.getJettyWebApp(new File(resourcePlan.getFile()),
null, false, null, null);
         assertTrue(jettyWebApp.getContextPriorityClassloader());
 
     }
@@ -140,7 +143,9 @@
         webApp.setContextRoot("myContextRoot");
         webApp.setContextPriorityClassloader(false);
 
-        JarFile dummyFile = new JarFile(new File(basedir, "src/test-resources/deployables/war2.war"));
+        URL war = classLoader.getResource("deployables/war2.war");
+        assertTrue(war != null);
+        JarFile dummyFile = new JarFile(new File(war.getFile()));
 
         webApp = builder.getJettyWebApp(webApp, dummyFile, true, null, null);
 
@@ -150,7 +155,9 @@
 
     public void testContextRootWithoutPlanStandAlone() throws Exception {
 
-        JarFile dummyFile = new JarFile(new File(basedir, "src/test-resources/deployables/war2.war"));
+        URL war = classLoader.getResource("deployables/war2.war");
+        assertTrue(war != null);
+        JarFile dummyFile = new JarFile(new File(war.getFile()));
         JettyWebAppType GerWebAppType = builder.getJettyWebApp(null, dummyFile, true, null,
null);
 
         assertEquals("war2", GerWebAppType.getContextRoot());
@@ -159,7 +166,9 @@
 
     public void testContextRootWithoutPlanAndTargetPath() throws Exception {
 
-        JarFile dummyFile = new JarFile(new File(basedir, "src/test-resources/deployables/war2.war"));
+        URL war = classLoader.getResource("deployables/war2.war");
+        assertTrue(war != null);
+        JarFile dummyFile = new JarFile(new File(war.getFile()));
         JettyWebAppType GerWebAppType = builder.getJettyWebApp(null, dummyFile, false, "myTargetPath",
null);
 
         assertEquals("myTargetPath", GerWebAppType.getContextRoot());
@@ -172,7 +181,9 @@
         WebAppType webAppType = webAppDocument.addNewWebApp();
         webAppType.setId("myId");
 
-        JarFile dummyFile = new JarFile(new File(basedir, "src/test-resources/deployables/war2.war"));
+        URL war = classLoader.getResource("deployables/war2.war");
+        assertTrue(war != null);
+        JarFile dummyFile = new JarFile(new File(war.getFile()));
         JettyWebAppType GerWebAppType = builder.getJettyWebApp(null, dummyFile, false, "myTargetPath",
webAppType);
 
         assertEquals("myId", GerWebAppType.getContextRoot());
@@ -184,14 +195,14 @@
     }
 
     public void testConvertToJettySchema() throws Exception {
-        File resourcePlan = new File(basedir, "src/test-resources/plans/plan4.xml");
-        assertTrue(resourcePlan.exists());
-        XmlObject rawPlan = XmlBeansUtil.parse(resourcePlan.toURL());
+        URL resourcePlan = classLoader.getResource("plans/plan4.xml");
+        assertTrue(resourcePlan != null);
+        XmlObject rawPlan = XmlBeansUtil.parse(resourcePlan);
         XmlObject webPlan = new GenericToSpecificPlanConverter(GerJettyDocument.type.getDocumentElementName().getNamespaceURI(),
                 JettyWebAppDocument.type.getDocumentElementName().getNamespaceURI(), "jetty").convertToSpecificPlan(rawPlan);
-        File ConvertedPlan = new File(basedir, "src/test-resources/plans/plan4-converted.xml");
-        assertTrue(ConvertedPlan.exists());
-        XmlObject converted = XmlBeansUtil.parse(ConvertedPlan.toURL());
+        URL ConvertedPlan = classLoader.getResource("plans/plan4-converted.xml");
+        assertTrue(ConvertedPlan != null);
+        XmlObject converted = XmlBeansUtil.parse(ConvertedPlan);
         XmlCursor c = converted.newCursor();
         SchemaConversionUtils.findNestedElement(c, "web-app");
         c.toFirstChild();

Modified: geronimo/trunk/modules/web-builder/src/java/org/apache/geronimo/web/deployment/GenericToSpecificPlanConverter.java
URL: http://svn.apache.org/viewcvs/geronimo/trunk/modules/web-builder/src/java/org/apache/geronimo/web/deployment/GenericToSpecificPlanConverter.java?rev=344331&r1=344330&r2=344331&view=diff
==============================================================================
--- geronimo/trunk/modules/web-builder/src/java/org/apache/geronimo/web/deployment/GenericToSpecificPlanConverter.java
(original)
+++ geronimo/trunk/modules/web-builder/src/java/org/apache/geronimo/web/deployment/GenericToSpecificPlanConverter.java
Tue Nov 15 00:13:07 2005
@@ -53,64 +53,66 @@
                 XmlObject webPlan = rawCursor.getObject().copy();
 
                 XmlCursor cursor = webPlan.newCursor();
-                cursor.push();
-                if (cursor.toChild(GENERIC_CONFIG_QNAME)) {
-                    XmlCursor source = cursor.newCursor();
+                XmlCursor end = cursor.newCursor();
+                try {
                     cursor.push();
-                    cursor.toEndToken();
-                    cursor.toNextToken();
-                    try {
-                        if (source.toChild(configNamespace, element)) {
-                            source.copyXmlContents(cursor);
-                        }
+                    if (cursor.toChild(GENERIC_CONFIG_QNAME)) {
+                        XmlCursor source = cursor.newCursor();
+                        cursor.push();
+                        cursor.toEndToken();
+                        cursor.toNextToken();
+                        try {
+                            if (source.toChild(configNamespace, element)) {
+                                source.copyXmlContents(cursor);
+                            }
 
-                    } finally {
-                        source.dispose();
+                        } finally {
+                            source.dispose();
+                        }
+                        cursor.pop();
+                        cursor.removeXml();
                     }
                     cursor.pop();
-                    cursor.removeXml();
-                }
-                cursor.pop();
-                cursor.push();
-                while (cursor.hasNextToken()) {
-                    if (cursor.isStart()) {
-                        if (namespace.equals(cursor.getName().getNamespaceURI())) {
-                            //already has correct schema, exit
-                            break;
+                    cursor.push();
+                    while (cursor.hasNextToken()) {
+                        if (cursor.isStart()) {
+                            if (!SchemaConversionUtils.convertSingleElementToGeronimoSubSchemas(cursor,
end)
+                            && !namespace.equals(cursor.getName().getNamespaceURI()))
{
+                                cursor.setName(new QName(namespace, cursor.getName().getLocalPart()));
+                            }
                         }
-                        cursor.setName(new QName(namespace, cursor.getName().getLocalPart()));
-                        cursor.toNextToken();
-                    } else {
                         cursor.toNextToken();
                     }
-                }
-                SchemaConversionUtils.convertToGeronimoSubSchemas(cursor);
-                //move security elements after refs
+                    //move security elements after refs
 
-                cursor.pop();
-                cursor.push();
-                if (cursor.toChild(namespace, "security-realm-name")) {
-                    XmlCursor other = cursor.newCursor();
-                    try {
-                        other.toParent();
-                        if (other.toChild(SYSTEM_NAMESPACE, "gbean")) {
-                            other.toPrevToken();
-                        } else {
-                            other.toEndToken();
-                            other.toPrevToken();
-                        }
-                        cursor.moveXml(other);
-                        cursor.pop();
-                        cursor.push();
-                        if (cursor.toChild(SECURITY_QNAME)) {
+                    cursor.pop();
+                    cursor.push();
+                    if (cursor.toChild(namespace, "security-realm-name")) {
+                        XmlCursor other = cursor.newCursor();
+                        try {
+                            other.toParent();
+                            if (other.toChild(SYSTEM_NAMESPACE, "gbean")) {
+                                other.toPrevToken();
+                            } else {
+                                other.toEndToken();
+                                other.toPrevToken();
+                            }
                             cursor.moveXml(other);
+                            cursor.pop();
+                            cursor.push();
+                            if (cursor.toChild(SECURITY_QNAME)) {
+                                cursor.moveXml(other);
+                            }
+                        } finally {
+                            other.dispose();
                         }
-                    } finally {
-                        other.dispose();
                     }
+                    cursor.pop();
+                    return webPlan;
+                } finally {
+                    cursor.dispose();
+                    end.dispose();
                 }
-                cursor.pop();
-                return webPlan;
             } else {
                 throw new DeploymentException("No web-app element");
             }

Added: geronimo/trunk/modules/web-builder/src/test-resources/plans/tomcat-post.xml
URL: http://svn.apache.org/viewcvs/geronimo/trunk/modules/web-builder/src/test-resources/plans/tomcat-post.xml?rev=344331&view=auto
==============================================================================
--- geronimo/trunk/modules/web-builder/src/test-resources/plans/tomcat-post.xml (added)
+++ geronimo/trunk/modules/web-builder/src/test-resources/plans/tomcat-post.xml Tue Nov 15
00:13:07 2005
@@ -0,0 +1,39 @@
+<?xml version="1.0"?>
+<xml-fragment configId="org/apache/jetspeed/web" xmlns:tom="http://geronimo.apache.org/xml/ns/j2ee/web/tomcat-1.0"
xmlns:nam="http://geronimo.apache.org/xml/ns/naming-1.0" xmlns:sec="http://geronimo.apache.org/xml/ns/security-1.1"
xmlns:dep="http://geronimo.apache.org/xml/ns/deployment-1.0">
+    <tom:context-priority-classloader>false</tom:context-priority-classloader>
+    <tom:cross-context/>
+    <tom:tomcat-realm>TomcatJAASRealm</tom:tomcat-realm>
+    <nam:resource-ref>
+        <nam:ref-name>jdbc/DB1</nam:ref-name>
+        <nam:target-name>DefaultDatabase</nam:target-name>
+    </nam:resource-ref>
+    <tom:security-realm-name>jetspeed-realm</tom:security-realm-name>
+    <sec:security>
+        <sec:default-principal>
+            <sec:principal class="org.apache.jetspeed.security.impl.UserPrincipalImpl"
name="guest"/>
+        </sec:default-principal>
+        <sec:role-mappings>
+            <sec:role role-name="admin">
+                <sec:principal class="org.apache.jetspeed.security.impl.RolePrincipalImpl"
name="admin" designated-run-as="true"/>
+            </sec:role>
+        </sec:role-mappings>
+    </sec:security>
+    <dep:gbean name="jetspeed-realm" class="org.apache.geronimo.security.realm.GenericSecurityRealm">
+        <dep:attribute name="realmName">jetspeed-realm</dep:attribute>
+        <dep:xml-reference name="LoginModuleConfiguration">
+            <lc:login-config xmlns:lc="http://geronimo.apache.org/xml/ns/loginconfig-1.0">
+                <lc:login-module control-flag="REQUIRED" server-side="true">
+                    <lc:login-domain-name>jetspeed-realm</lc:login-domain-name>
+                    <lc:login-module-class>org.apache.jetspeed.security.impl.DefaultLoginModule</lc:login-module-class>
+                </lc:login-module>
+            </lc:login-config>
+        </dep:xml-reference>
+        <dep:reference name="ServerInfo">
+            <dep:module>org/apache/geronimo/System</dep:module>
+            <dep:name>ServerInfo</dep:name>
+        </dep:reference>
+        <dep:reference name="LoginService">
+            <dep:name>JaasLoginService</dep:name>
+        </dep:reference>
+    </dep:gbean>
+</xml-fragment>

Added: geronimo/trunk/modules/web-builder/src/test-resources/plans/tomcat-pre.xml
URL: http://svn.apache.org/viewcvs/geronimo/trunk/modules/web-builder/src/test-resources/plans/tomcat-pre.xml?rev=344331&view=auto
==============================================================================
--- geronimo/trunk/modules/web-builder/src/test-resources/plans/tomcat-pre.xml (added)
+++ geronimo/trunk/modules/web-builder/src/test-resources/plans/tomcat-pre.xml Tue Nov 15
00:13:07 2005
@@ -0,0 +1,43 @@
+<?xml version="1.0"?>
+<web-app xmlns="http://geronimo.apache.org/xml/ns/j2ee/web-1.0" configId="org/apache/jetspeed/web">
+    <context-priority-classloader>false</context-priority-classloader>
+    <container-config>
+        <tomcat xmlns="http://geronimo.apache.org/xml/ns/j2ee/web/tomcat/config-1.0">
+            <cross-context/>
+            <tomcat-realm>TomcatJAASRealm</tomcat-realm>
+        </tomcat>
+    </container-config>
+    <resource-ref>
+      <ref-name>jdbc/DB1</ref-name>
+      <target-name>DefaultDatabase</target-name>
+    </resource-ref>
+    <security-realm-name>jetspeed-realm</security-realm-name>
+    <security>
+        <default-principal>
+            <principal class="org.apache.jetspeed.security.impl.UserPrincipalImpl" name="guest"/>
+        </default-principal>
+        <role-mappings>
+            <role role-name="admin">
+                <principal class="org.apache.jetspeed.security.impl.RolePrincipalImpl"
name="admin" designated-run-as="true"/>
+            </role>
+        </role-mappings>
+    </security>
+    <gbean name="jetspeed-realm" class="org.apache.geronimo.security.realm.GenericSecurityRealm">
+        <attribute name="realmName">jetspeed-realm</attribute>
+        <xml-reference name="LoginModuleConfiguration">
+            <lc:login-config xmlns:lc="http://geronimo.apache.org/xml/ns/loginconfig-1.0">
+                <lc:login-module control-flag="REQUIRED" server-side="true">
+                    <lc:login-domain-name>jetspeed-realm</lc:login-domain-name>
+                    <lc:login-module-class>org.apache.jetspeed.security.impl.DefaultLoginModule</lc:login-module-class>
+                </lc:login-module>
+            </lc:login-config>
+        </xml-reference>
+        <reference name="ServerInfo">
+            <module>org/apache/geronimo/System</module>
+            <name>ServerInfo</name>
+        </reference>
+        <reference name="LoginService">
+            <name>JaasLoginService</name>
+        </reference>
+    </gbean>
+</web-app>

Added: geronimo/trunk/modules/web-builder/src/test/org/apache/geronimo/web/deployment/GenericToSpecificPlanConverterTest.java
URL: http://svn.apache.org/viewcvs/geronimo/trunk/modules/web-builder/src/test/org/apache/geronimo/web/deployment/GenericToSpecificPlanConverterTest.java?rev=344331&view=auto
==============================================================================
--- geronimo/trunk/modules/web-builder/src/test/org/apache/geronimo/web/deployment/GenericToSpecificPlanConverterTest.java
(added)
+++ geronimo/trunk/modules/web-builder/src/test/org/apache/geronimo/web/deployment/GenericToSpecificPlanConverterTest.java
Tue Nov 15 00:13:07 2005
@@ -0,0 +1,85 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation
+ *
+ *  Licensed 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.geronimo.web.deployment;
+
+import java.net.URL;
+import java.util.List;
+import java.util.ArrayList;
+
+import junit.framework.TestCase;
+import org.apache.xmlbeans.XmlObject;
+import org.apache.xmlbeans.XmlCursor;
+
+/**
+ * @version $Rev:  $ $Date:  $
+ */
+public class GenericToSpecificPlanConverterTest extends TestCase {
+    private ClassLoader classLoader = this.getClass().getClassLoader();
+
+    public void testConvertPlan() throws Exception {
+        URL srcXml = classLoader.getResource("plans/tomcat-pre.xml");
+        URL expectedOutputXml = classLoader.getResource("plans/tomcat-post.xml");
+        XmlObject rawPlan = XmlObject.Factory.parse(srcXml);
+        XmlObject expected = XmlObject.Factory.parse(expectedOutputXml);
+        XmlObject webPlan = new GenericToSpecificPlanConverter("http://geronimo.apache.org/xml/ns/j2ee/web/tomcat/config-1.0",
+                "http://geronimo.apache.org/xml/ns/j2ee/web/tomcat-1.0", "tomcat").convertToSpecificPlan(rawPlan);
+
+//        System.out.println(webPlan.toString());
+//        System.out.println(expected.toString());
+        List problems = new ArrayList();
+        boolean ok = compareXmlObjects(webPlan, expected, problems);
+        assertTrue("Differences: " + problems, ok);
+    }
+
+
+    private boolean compareXmlObjects(XmlObject xmlObject, XmlObject expectedObject, List
problems) {
+        XmlCursor test = xmlObject.newCursor();
+        XmlCursor expected = expectedObject.newCursor();
+        boolean similar = true;
+        int elementCount = 0;
+        while (toNextStartToken(test)) {
+            elementCount++;
+            if (!toNextStartToken(expected)) {
+                problems.add("test longer than expected at element: " + elementCount);
+                return false;
+            }
+            String actualChars = test.getName().getLocalPart();
+            String expectedChars = expected.getName().getLocalPart();
+            if (!actualChars.equals(expectedChars)) {
+                problems.add("Different elements at elementCount: " + elementCount + ", test:
" + actualChars + ", expected: " + expectedChars);
+                similar = false;
+            }
+            test.toNextToken();
+            expected.toNextToken();
+        }
+        if (toNextStartToken(expected)) {
+            problems.add("test shorter that expected at element: " + elementCount);
+            similar = false;
+        }
+        return similar;
+    }
+
+    private boolean toNextStartToken(XmlCursor cursor) {
+        while (!cursor.isStart()) {
+            if (!cursor.hasNextToken()) {
+                return false;
+            }
+            cursor.toNextToken();
+        }
+        return true;
+    }
+}



Mime
View raw message