geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From djen...@apache.org
Subject cvs commit: incubator-geronimo/modules/jetty/src/test-resources/deployables/war1/WEB-INF geronimo-web.xml
Date Fri, 06 Feb 2004 08:55:49 GMT
djencks     2004/02/06 00:55:49

  Modified:    modules/jetty project.xml
               modules/jetty/src/java/org/apache/geronimo/jetty/deployment
                        JettyModule.java WARConfiguration.java
                        WARConfigurationFactory.java WebAppDConfigBean.java
                        WebAppDConfigRoot.java
               modules/jetty/src/test/org/apache/geronimo/jetty/deployment
                        DeploymentTest.java
                        WARConfigurationFactoryTest.java
               modules/jetty/src/test-resources/deployables/war1/WEB-INF
                        geronimo-web.xml
  Added:       modules/jetty maven.xml
               modules/jetty/src/schema geronimo-jetty.xsd xmlconfig.xml
               modules/jetty/src/test-resources/deployables/war1
                        geronimo-web2.xml
  Log:
  xmlbeans support in jetty module
  
  Revision  Changes    Path
  1.12      +11 -1     incubator-geronimo/modules/jetty/project.xml
  
  Index: project.xml
  ===================================================================
  RCS file: /home/cvs/incubator-geronimo/modules/jetty/project.xml,v
  retrieving revision 1.11
  retrieving revision 1.12
  diff -u -r1.11 -r1.12
  --- project.xml	3 Feb 2004 03:46:44 -0000	1.11
  +++ project.xml	6 Feb 2004 08:55:49 -0000	1.12
  @@ -25,6 +25,16 @@
       <!-- ============ -->
   
       <dependencies>
  +
  +        <!-- needed for xmlbeans runtime-->
  +        <dependency>
  +            <groupId>xmlbeans</groupId>
  +            <artifactId>xbean-apache</artifactId>
  +            <version>1.0-DEV</version>
  +            <properties>
  +            </properties>
  +        </dependency>
  +
           <dependency>
               <groupId>geronimo</groupId>
               <artifactId>geronimo-kernel</artifactId>
  
  
  
  1.1                  incubator-geronimo/modules/jetty/maven.xml
  
  Index: maven.xml
  ===================================================================
  <?xml version="1.0" encoding="ISO-8859-1"?>
  
  <!-- $Revision: 1.1 $ $Date: 2004/02/06 08:55:49 $ -->
  
  <project default="default"
      xmlns:j="jelly:core"
      xmlns:ant="jelly:ant"
      xmlns:maven="jelly:maven"
      xmlns:xmlbeans="geronimo:xmlbeans">
  
      <preGoal name="java:compile">
          <xmlbeans:schema2java
              sourceschema="${basedir}/src/schema/geronimo-jetty.xsd"
              xmlconfigs="${basedir}/src/schema/xmlconfig.xml"
              targetdir="${basedir}/target/xmlbeans"/>
      </preGoal>
  
  </project>
  
  
  
  1.8       +14 -2     incubator-geronimo/modules/jetty/src/java/org/apache/geronimo/jetty/deployment/JettyModule.java
  
  Index: JettyModule.java
  ===================================================================
  RCS file: /home/cvs/incubator-geronimo/modules/jetty/src/java/org/apache/geronimo/jetty/deployment/JettyModule.java,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- JettyModule.java	5 Feb 2004 01:37:56 -0000	1.7
  +++ JettyModule.java	6 Feb 2004 08:55:49 -0000	1.8
  @@ -68,6 +68,7 @@
   import org.apache.geronimo.deployment.ConfigurationCallback;
   import org.apache.geronimo.deployment.DeploymentException;
   import org.apache.geronimo.deployment.util.XMLUtil;
  +import org.apache.geronimo.xbeans.geronimo.deployment.jetty.JettyWebAppType;
   import org.w3c.dom.Document;
   
   /**
  @@ -121,10 +122,21 @@
           if (!contextPath.startsWith("/")) {
               contextPath = "/" + contextPath;
           }
  -        
  +
           // TODO - why does this not use the WebAppDConfigBean ??
           String t=XMLUtil.getChildContent(deploymentPlan.getDocumentElement(), "context-priority-classloader",
null, null);
           contextPriorityClassLoader= t != null && t.length() > 0 && t.toLowerCase().charAt(0)
== 't';
  +    }
  +
  +    public JettyModule(URI configID, InputStream moduleArchive, JettyWebAppType webApp)
throws DeploymentException {
  +        super(configID);
  +        moduleDirectory = null;
  +        this.zipArchive = new ZipInputStream(moduleArchive);
  +        closeStream = false;
  +        contextPath = webApp.getContextRoot().getStringValue();
  +        if (contextPath == null) {
  +            throw new DeploymentException("No context root specified");
  +        }
       }
   
       public void init() throws DeploymentException {
  
  
  
  1.4       +3 -34     incubator-geronimo/modules/jetty/src/java/org/apache/geronimo/jetty/deployment/WARConfiguration.java
  
  Index: WARConfiguration.java
  ===================================================================
  RCS file: /home/cvs/incubator-geronimo/modules/jetty/src/java/org/apache/geronimo/jetty/deployment/WARConfiguration.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- WARConfiguration.java	23 Jan 2004 19:58:17 -0000	1.3
  +++ WARConfiguration.java	6 Feb 2004 08:55:49 -0000	1.4
  @@ -68,6 +68,7 @@
   import javax.xml.parsers.ParserConfigurationException;
   
   import org.apache.geronimo.deployment.plugin.DeploymentConfigurationSupport;
  +import org.apache.xmlbeans.XmlException;
   import org.xml.sax.SAXException;
   import org.w3c.dom.Document;
   
  @@ -77,41 +78,9 @@
    * @version $Revision$ $Date$
    */
   public class WARConfiguration extends DeploymentConfigurationSupport {
  -    private final WebAppDConfigRoot root;
   
       public WARConfiguration(DeployableObject deployable) {
  -        super(deployable);
  -        root = new WebAppDConfigRoot(deployable.getDDBeanRoot());
  +        super(deployable, new WebAppDConfigRoot(deployable.getDDBeanRoot()));
       }
   
  -    public DConfigBeanRoot getDConfigBeanRoot(DDBeanRoot bean) throws ConfigurationException
{
  -        if (getDeployableObject().getDDBeanRoot().equals(bean)) {
  -            return root;
  -        }
  -        return null;
  -    }
  -
  -    public void save(OutputStream outputArchive) throws ConfigurationException {
  -        PrintWriter writer = new PrintWriter(outputArchive);
  -        try {
  -            root.toXML(writer);
  -            writer.flush();
  -        } catch (IOException e) {
  -            throw (ConfigurationException) new ConfigurationException("Unable to save configuration").initCause(e);
  -        }
  -    }
  -
  -    public void restore(InputStream inputArchive) throws ConfigurationException {
  -        try {
  -            DocumentBuilder parser = DocumentBuilderFactory.newInstance().newDocumentBuilder();
  -            Document doc = parser.parse(inputArchive);
  -            root.fromXML(doc.getDocumentElement());
  -        } catch (SAXException e) {
  -            throw (ConfigurationException) new ConfigurationException("Error parsing configuration
input").initCause(e);
  -        } catch (IOException e) {
  -            throw (ConfigurationException) new ConfigurationException("Error reading configuration
input").initCause(e);
  -        } catch (ParserConfigurationException e) {
  -            throw (ConfigurationException) new ConfigurationException("Unable to get XML
parser").initCause(e);
  -        }
  -    }
   }
  
  
  
  1.5       +20 -7     incubator-geronimo/modules/jetty/src/java/org/apache/geronimo/jetty/deployment/WARConfigurationFactory.java
  
  Index: WARConfigurationFactory.java
  ===================================================================
  RCS file: /home/cvs/incubator-geronimo/modules/jetty/src/java/org/apache/geronimo/jetty/deployment/WARConfigurationFactory.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- WARConfigurationFactory.java	26 Jan 2004 05:55:27 -0000	1.4
  +++ WARConfigurationFactory.java	6 Feb 2004 08:55:49 -0000	1.5
  @@ -58,6 +58,7 @@
   import java.io.File;
   import java.io.InputStream;
   import java.net.URI;
  +
   import javax.enterprise.deploy.model.DeployableObject;
   import javax.enterprise.deploy.shared.ModuleType;
   import javax.enterprise.deploy.spi.DeploymentConfiguration;
  @@ -68,6 +69,11 @@
   import org.apache.geronimo.deployment.plugin.factories.DeploymentConfigurationFactory;
   import org.apache.geronimo.gbean.GBeanInfo;
   import org.apache.geronimo.gbean.GBeanInfoFactory;
  +import org.apache.geronimo.xbeans.geronimo.deployment.jetty.JettyWebAppDocument;
  +import org.apache.xmlbeans.SchemaType;
  +import org.apache.xmlbeans.SchemaTypeLoader;
  +import org.apache.xmlbeans.XmlBeans;
  +import org.apache.xmlbeans.XmlObject;
   import org.w3c.dom.Document;
   import org.w3c.dom.Element;
   
  @@ -77,6 +83,8 @@
    * @version $Revision$ $Date$
    */
   public class WARConfigurationFactory implements DeploymentConfigurationFactory {
  +    private static final SchemaTypeLoader SCHEMA_TYPE_LOADER = XmlBeans.getContextTypeLoader();
  +
       public DeploymentConfiguration createConfiguration(DeployableObject deployable) throws
InvalidModuleException {
           if (!ModuleType.WAR.equals(deployable.getType())) {
               throw new InvalidModuleException("DeployableObject must be a WAR");
  @@ -84,13 +92,18 @@
           return new WARConfiguration(deployable);
       }
   
  -    public DeploymentModule createModule(InputStream moduleArchive, Document deploymentPlan,
URI configID) throws DeploymentException {
  -        Element root = deploymentPlan.getDocumentElement();
  -        if (!"web-app".equals(root.getNodeName())) {
  -            return null;
  -        }
  +    public DeploymentModule createModule(InputStream moduleArchive, XmlObject deploymentPlan,
URI configID, boolean isLocal) throws DeploymentException {
  +        JettyWebAppDocument webAppDoc = (JettyWebAppDocument)deploymentPlan;
  +        return new JettyModule(configID, moduleArchive, webAppDoc.getWebApp());
  +    }
  +
  +    //these might be temporary
  +    public SchemaType getSchemaType() {
  +        return JettyWebAppDocument.type;
  +    }
   
  -        return new JettyModule(configID, moduleArchive, deploymentPlan);
  +    public SchemaTypeLoader getSchemaTypeLoader() {
  +        return SCHEMA_TYPE_LOADER;
       }
   
       public DeploymentModule createModule(File moduleArchive, Document deploymentPlan, URI
configID, boolean isLocal) throws DeploymentException {
  
  
  
  1.5       +36 -48    incubator-geronimo/modules/jetty/src/java/org/apache/geronimo/jetty/deployment/WebAppDConfigBean.java
  
  Index: WebAppDConfigBean.java
  ===================================================================
  RCS file: /home/cvs/incubator-geronimo/modules/jetty/src/java/org/apache/geronimo/jetty/deployment/WebAppDConfigBean.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- WebAppDConfigBean.java	5 Feb 2004 01:37:56 -0000	1.4
  +++ WebAppDConfigBean.java	6 Feb 2004 08:55:49 -0000	1.5
  @@ -55,8 +55,6 @@
    */
   package org.apache.geronimo.jetty.deployment;
   
  -import java.io.IOException;
  -import java.io.PrintWriter;
   import javax.enterprise.deploy.model.DDBean;
   import javax.enterprise.deploy.spi.DConfigBean;
   import javax.enterprise.deploy.spi.exceptions.BeanNotFoundException;
  @@ -64,8 +62,9 @@
   
   import org.apache.geronimo.deployment.plugin.DConfigBeanSupport;
   import org.apache.geronimo.deployment.plugin.j2ee.ENCHelper;
  -import org.apache.geronimo.deployment.util.XMLUtil;
  -import org.w3c.dom.Element;
  +import org.apache.geronimo.xbeans.geronimo.deployment.jetty.JettyWebAppType;
  +import org.apache.xmlbeans.SchemaTypeLoader;
  +import org.apache.xmlbeans.XmlBeans;
   
   /**
    *
  @@ -73,46 +72,51 @@
    * @version $Revision$ $Date$
    */
   public class WebAppDConfigBean extends DConfigBeanSupport {
  -    private String contextRoot;
  -    private boolean contextPriorityClassLoader;
  +    private final static SchemaTypeLoader SCHEMA_TYPE_LOADER = XmlBeans.getContextTypeLoader();
   
       private final ENCHelper encHelper;
   
  -    WebAppDConfigBean(DDBean ddBean) {
  -        super(ddBean);
  +    WebAppDConfigBean(DDBean ddBean, JettyWebAppType webApp) {
  +        super(ddBean, webApp, SCHEMA_TYPE_LOADER);
  +        if (webApp.getContextRoot() == null) {
  +            webApp.addNewContextRoot();
  +        }
           encHelper = new ENCHelper(ddBean);
       }
   
  +    JettyWebAppType getWebApp() {
  +        return (JettyWebAppType)xmlObject;
  +    }
  +
       public String getContextRoot() {
  -        return contextRoot;
  +        return getWebApp().getContextRoot().getStringValue();
       }
   
       public void setContextRoot(String contextRoot) {
  -        pcs.firePropertyChange("contextRoot", this.contextRoot, contextRoot);
  -        this.contextRoot = contextRoot;
  +        pcs.firePropertyChange("contextRoot", getContextRoot(), contextRoot);
  +        getWebApp().getContextRoot().setStringValue(contextRoot);
       }
  -    
  -         
  -         /* -------------------------------------------------------------------------------
*/
  -         /** getContextPriorityClassLoader.
  -          * @return True if this context should give web application class in preference
over the containers 
  -          * classes, as per the servlet specification recommendations.
  -          */
  -         public boolean getContextPriorityClassLoader(){
  -             return contextPriorityClassLoader;
  -         }
  -     
  -         /* -------------------------------------------------------------------------------
*/
  -         /** setContextPriorityClassLoader.
  -          * @param contextPriority True if this context should give web application class
in preference over the containers 
  -          * classes, as per the servlet specification recommendations.
  -          */
  -         public void setContextPriorityClassLoader(boolean p){
  -             pcs.firePropertyChange("contextPriorityClassLoader", this.contextPriorityClassLoader,
p);
  -               this.contextPriorityClassLoader = p;
  -         }
   
   
  +    /* -------------------------------------------------------------------------------
*/
  +    /** getContextPriorityClassLoader.
  +     * @return True if this context should give web application class in preference over
the containers
  +     * classes, as per the servlet specification recommendations.
  +     */
  +    public boolean getContextPriorityClassLoader() {
  +        return getWebApp().getContextPriorityClassloader();
  +    }
  +
  +    /* -------------------------------------------------------------------------------
*/
  +    /** setContextPriorityClassLoader.
  +     * @param contextPriority True if this context should give web application class in
preference over the containers
  +     * classes, as per the servlet specification recommendations.
  +     */
  +    public void setContextPriorityClassLoader(boolean contextPriority) {
  +        pcs.firePropertyChange("contextPriorityClassLoader", getContextPriorityClassLoader(),
contextPriority);
  +        getWebApp().setContextPriorityClassloader(contextPriority);
  +    }
  +
   
       public DConfigBean getDConfigBean(DDBean ddBean) throws ConfigurationException {
           return encHelper.getDConfigBean(ddBean);
  @@ -126,20 +130,4 @@
           return ENCHelper.ENC_XPATHS;
       }
   
  -    public void toXML(PrintWriter writer) throws IOException {
  -        if (contextRoot != null) {
  -            writer.print("<context-root>");
  -            writer.print(contextRoot);
  -            writer.println("</context-root>");
  -            writer.print("<context-priority-classloader>");
  -            writer.print(contextPriorityClassLoader);
  -            writer.println("</context-priority-classloader>");
  -        }
  -        encHelper.toXML(writer);
  -    }
  -
  -    public void fromXML(Element element) {
  -        contextRoot = XMLUtil.getChildContent(element, "context-root", null, null);
  -        encHelper.fromXML(element);
  -    }
   }
  
  
  
  1.3       +26 -13    incubator-geronimo/modules/jetty/src/java/org/apache/geronimo/jetty/deployment/WebAppDConfigRoot.java
  
  Index: WebAppDConfigRoot.java
  ===================================================================
  RCS file: /home/cvs/incubator-geronimo/modules/jetty/src/java/org/apache/geronimo/jetty/deployment/WebAppDConfigRoot.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- WebAppDConfigRoot.java	23 Jan 2004 19:58:17 -0000	1.2
  +++ WebAppDConfigRoot.java	6 Feb 2004 08:55:49 -0000	1.3
  @@ -55,15 +55,20 @@
    */
   package org.apache.geronimo.jetty.deployment;
   
  +import java.io.InputStream;
   import java.io.IOException;
  -import java.io.PrintWriter;
  +
   import javax.enterprise.deploy.model.DDBean;
   import javax.enterprise.deploy.model.DDBeanRoot;
   import javax.enterprise.deploy.spi.DConfigBean;
   import javax.enterprise.deploy.spi.exceptions.ConfigurationException;
   
   import org.apache.geronimo.deployment.plugin.DConfigBeanRootSupport;
  -import org.w3c.dom.Element;
  +import org.apache.geronimo.xbeans.geronimo.deployment.jetty.JettyWebAppDocument;
  +import org.apache.geronimo.xbeans.geronimo.deployment.jetty.JettyWebAppType;
  +import org.apache.xmlbeans.SchemaTypeLoader;
  +import org.apache.xmlbeans.XmlBeans;
  +import org.apache.xmlbeans.XmlException;
   
   /**
    *
  @@ -71,15 +76,26 @@
    * @version $Revision$ $Date$
    */
   public class WebAppDConfigRoot extends DConfigBeanRootSupport {
  +    private final static SchemaTypeLoader SCHEMA_TYPE_LOADER = XmlBeans.getContextTypeLoader();
       private static String[] XPATHS = {
           "web-app"
       };
   
  -    private final WebAppDConfigBean webAppBean;
  +    private WebAppDConfigBean webAppBean;
   
       public WebAppDConfigRoot(DDBeanRoot ddBean) {
  -        super(ddBean);
  -        webAppBean = new WebAppDConfigBean(ddBean.getChildBean("web-app")[0]);
  +        super(ddBean, JettyWebAppDocument.Factory.newInstance(), SCHEMA_TYPE_LOADER);
  +        JettyWebAppType webApp = getWebAppDocument().addNewWebApp();
  +        replaceWebAppDConfigBean(webApp);
  +    }
  +
  +    private void replaceWebAppDConfigBean(JettyWebAppType webApp) {
  +        DDBean ddBean = getDDBean();
  +        webAppBean = new WebAppDConfigBean(ddBean.getChildBean("/web-app")[0], webApp);
  +    }
  +
  +    JettyWebAppDocument getWebAppDocument() {
  +        return (JettyWebAppDocument)xmlObject;
       }
   
       public String[] getXpaths() {
  @@ -93,13 +109,10 @@
           return null;
       }
   
  -    public void toXML(PrintWriter writer) throws IOException {
  -        writer.println("<web-app>");
  -        webAppBean.toXML(writer);
  -        writer.println("</web-app>");
  +    public void fromXML(InputStream inputStream) throws XmlException, IOException {
  +        super.fromXML(inputStream);
  +        replaceWebAppDConfigBean(getWebAppDocument().getWebApp());
       }
   
  -    public void fromXML(Element element) {
  -        webAppBean.fromXML(element);
  -    }
  +
   }
  
  
  
  1.1                  incubator-geronimo/modules/jetty/src/schema/geronimo-jetty.xsd
  
  Index: geronimo-jetty.xsd
  ===================================================================
  <?xml version="1.0" encoding="UTF-8"?>
  <xsd:schema xmlns="http://www.w3.org/2001/XMLSchema"
      xmlns:ger="http://org.apache.geronimo/xml/ns/web/jetty"
      targetNamespace="http://org.apache.geronimo/xml/ns/web/jetty"
      xmlns:xsd="http://www.w3.org/2001/XMLSchema"
      elementFormDefault="qualified"
      attributeFormDefault="unqualified"
      version="1.0">
  
      <xsd:element name="web-app" type="ger:web-appType"/>
  
      <xsd:complexType name="web-appType">
          <xsd:sequence>
              <xsd:element name="context-root" type="ger:context-rootType"/>
              <xsd:element name="context-priority-classloader" type="xsd:boolean"/>
          </xsd:sequence>
      </xsd:complexType>
  
      <xsd:complexType name="context-rootType">
          <xsd:simpleContent>
              <xsd:extension base="xsd:string"/>
          </xsd:simpleContent>
      </xsd:complexType>
  
  </xsd:schema>
  
  
  1.1                  incubator-geronimo/modules/jetty/src/schema/xmlconfig.xml
  
  Index: xmlconfig.xml
  ===================================================================
  <xb:config xmlns:xb="http://www.bea.com/2002/09/xbean/config"
      >
  
      <xb:namespace uri="http://org.apache.geronimo/xml/ns/web/jetty">
          <xb:package>org.apache.geronimo.xbeans.geronimo.deployment.jetty</xb:package>
          <xb:prefix>Jetty</xb:prefix>
      </xb:namespace>
  
  </xb:config>
  
  
  1.6       +14 -2     incubator-geronimo/modules/jetty/src/test/org/apache/geronimo/jetty/deployment/DeploymentTest.java
  
  Index: DeploymentTest.java
  ===================================================================
  RCS file: /home/cvs/incubator-geronimo/modules/jetty/src/test/org/apache/geronimo/jetty/deployment/DeploymentTest.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- DeploymentTest.java	4 Feb 2004 05:54:08 -0000	1.5
  +++ DeploymentTest.java	6 Feb 2004 08:55:49 -0000	1.6
  @@ -61,6 +61,8 @@
   import java.io.BufferedReader;
   import java.io.InputStreamReader;
   import java.io.IOException;
  +import java.io.InputStream;
  +import java.io.FileInputStream;
   import java.net.URI;
   import java.net.URL;
   import java.net.HttpURLConnection;
  @@ -78,6 +80,7 @@
   import org.apache.geronimo.deployment.service.ServiceDeployer;
   import org.apache.geronimo.deployment.util.URLInfo;
   import org.apache.geronimo.gbean.jmx.GBeanMBean;
  +import org.apache.geronimo.xbeans.geronimo.deployment.jetty.JettyWebAppDocument;
   
   /**
    *
  @@ -89,7 +92,16 @@
       private File configFile;
       private Target[] targets;
   
  -    public void testUnpacked() throws Exception {
  +    public void testReadGeronimoDD() throws Exception {
  +        File war = new File(URI.create(classLoader.getResource("deployables/war1/").toString()));
  +        File dd = new File(war, "geronimo-web2.xml");
  +        InputStream is = new FileInputStream(dd);
  +        JettyWebAppDocument doc = JettyWebAppDocument.Factory.parse(is);
  +        assertEquals("/test", doc.getWebApp().getContextRoot().getStringValue());
  +    }
  +
  +    //unpacked needs a little more work.
  +    public void XtestUnpacked() throws Exception {
           File war = new File(URI.create(classLoader.getResource("deployables/war1/").toString()));
   
           ProgressObject result = manager.distribute(targets, war, new File(war, "WEB-INF/geronimo-web.xml"));
  
  
  
  1.7       +50 -14    incubator-geronimo/modules/jetty/src/test/org/apache/geronimo/jetty/deployment/WARConfigurationFactoryTest.java
  
  Index: WARConfigurationFactoryTest.java
  ===================================================================
  RCS file: /home/cvs/incubator-geronimo/modules/jetty/src/test/org/apache/geronimo/jetty/deployment/WARConfigurationFactoryTest.java,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- WARConfigurationFactoryTest.java	5 Feb 2004 01:37:56 -0000	1.6
  +++ WARConfigurationFactoryTest.java	6 Feb 2004 08:55:49 -0000	1.7
  @@ -57,11 +57,14 @@
   
   import java.io.ByteArrayInputStream;
   import java.io.ByteArrayOutputStream;
  +
   import javax.enterprise.deploy.spi.DConfigBeanRoot;
   import javax.enterprise.deploy.spi.DeploymentConfiguration;
   
   import org.apache.geronimo.deployment.tools.loader.WebDeployable;
  -import org.apache.geronimo.deployment.util.XMLUtil;
  +import org.apache.geronimo.xbeans.geronimo.deployment.jetty.JettyContextRootType;
  +import org.apache.geronimo.xbeans.geronimo.deployment.jetty.JettyWebAppDocument;
  +import org.apache.geronimo.xbeans.geronimo.deployment.jetty.JettyWebAppType;
   import org.w3c.dom.Document;
   import org.w3c.dom.Element;
   
  @@ -84,10 +87,13 @@
           assertNotNull(config);
           ByteArrayOutputStream baos = new ByteArrayOutputStream();
           config.save(baos);
  +        byte[] bytes = baos.toByteArray();
  +        String output = new String(bytes);
  +        System.out.println(output);
           Document doc = parser.parse(new ByteArrayInputStream(baos.toByteArray()));
           Element root = doc.getDocumentElement();
  -        assertEquals("web-app", root.getNodeName());
  -        assertNull(XMLUtil.getChild(root, "context-root"));
  +        assertEquals("jet:web-app", root.getNodeName());
  +        //assertNull(XMLUtil.getChild(root, "jet:context-root"));
       }
   
       public void testConfigSet() throws Exception {
  @@ -100,14 +106,14 @@
   
           ByteArrayOutputStream baos = new ByteArrayOutputStream();
           config.save(baos);
  -        Document doc = parser.parse(new ByteArrayInputStream(baos.toByteArray()));
  -        Element root = doc.getDocumentElement();
  -        assertEquals("web-app", root.getNodeName());
  -        Element contextRoot = XMLUtil.getChild(root, "context-root");
  -        assertEquals("/test", XMLUtil.getContent(contextRoot));
  -        
  -        Element contextPriority = XMLUtil.getChild(root, "context-priority-classloader");
  -        assertEquals("false", XMLUtil.getContent(contextPriority));
  +        byte[] bytes = baos.toByteArray();
  +        String output = new String(bytes);
  +        System.out.println(output);
  +
  +        JettyWebAppDocument webAppDoc = JettyWebAppDocument.Factory.parse(new ByteArrayInputStream(baos.toByteArray()));
  +        JettyWebAppType webApp = webAppDoc.getWebApp();
  +        assertEquals("/test", webApp.getContextRoot().getStringValue());
  +        assertEquals(false, webApp.getContextPriorityClassloader());
       }
   
       public void testConfigSaveRestore() throws Exception {
  @@ -117,18 +123,48 @@
           WebAppDConfigBean contextBean = (WebAppDConfigBean) configRoot.getDConfigBean(deployable.getChildBean("/web-app")[0]);
           contextBean.setContextRoot("/test");
           contextBean.setContextPriorityClassLoader(true);
  +        checkContents(((WebAppDConfigRoot)configRoot).getWebAppDocument());
   
           ByteArrayOutputStream baos = new ByteArrayOutputStream();
           config.save(baos);
  +        byte[] bytes = baos.toByteArray();
  +        String output = new String(bytes);
  +        System.out.println(output);
   
           config = (WARConfiguration) warFactory.createConfiguration(deployable);
           configRoot = config.getDConfigBeanRoot(deployable.getDDBeanRoot());
           contextBean = (WebAppDConfigBean) configRoot.getDConfigBean(deployable.getChildBean("/web-app")[0]);
   
  -        assertNull(contextBean.getContextRoot());
  +        assertEquals("", contextBean.getContextRoot());
  +
           config.restore(new ByteArrayInputStream(baos.toByteArray()));
  +        configRoot = config.getDConfigBeanRoot(deployable.getDDBeanRoot());
  +        checkContents(((WebAppDConfigRoot)configRoot).getWebAppDocument());
  +
  +
  +        contextBean = (WebAppDConfigBean) configRoot.getDConfigBean(deployable.getChildBean("/web-app")[0]);
           assertEquals("/test", contextBean.getContextRoot());
  -        contextBean.setContextPriorityClassLoader(true);
  +        assertEquals(true, contextBean.getContextPriorityClassLoader());
  +    }
  +
  +    private void checkContents(JettyWebAppDocument webAppDoc) {
  +        JettyWebAppType webApp = webAppDoc.getWebApp();
  +        assertEquals("/test", webApp.getContextRoot().getStringValue());
  +        assertEquals(true, webApp.getContextPriorityClassloader());
  +    }
  +
  +    public void testSanity() throws Exception {
  +        JettyWebAppDocument webAppDoc = JettyWebAppDocument.Factory.newInstance();
  +        JettyWebAppType webApp = webAppDoc.addNewWebApp();
  +        webAppDoc.setWebApp(webApp);
  +        JettyContextRootType contextRoot = webApp.addNewContextRoot();
  +        webApp.setContextRoot(contextRoot);
  +        contextRoot.setStringValue("/test");
  +        webApp.setContextPriorityClassloader(true);
  +        checkContents(webAppDoc);
  +        assertEquals("/test", webApp.getContextRoot().getStringValue());
  +        assertEquals("/test", contextRoot.getStringValue());
  +        assertEquals(true, webApp.getContextPriorityClassloader());
       }
   
       protected void setUp() throws Exception {
  
  
  
  1.1                  incubator-geronimo/modules/jetty/src/test-resources/deployables/war1/geronimo-web2.xml
  
  Index: geronimo-web2.xml
  ===================================================================
  <?xml version="1.0" encoding="UTF-8"?>
  <jetty:web-app xmlns:jetty="http://org.apache.geronimo/xml/ns/web/jetty">
      <jetty:context-root>/test</jetty:context-root>
  </jetty:web-app>
  
  
  1.3       +5 -4      incubator-geronimo/modules/jetty/src/test-resources/deployables/war1/WEB-INF/geronimo-web.xml
  
  Index: geronimo-web.xml
  ===================================================================
  RCS file: /home/cvs/incubator-geronimo/modules/jetty/src/test-resources/deployables/war1/WEB-INF/geronimo-web.xml,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- geronimo-web.xml	5 Feb 2004 01:37:56 -0000	1.2
  +++ geronimo-web.xml	6 Feb 2004 08:55:49 -0000	1.3
  @@ -1,4 +1,5 @@
  -<web-app>
  -    <context-root>/test</context-root>
  -    <context-priority-classloader>false</context-priority-classloader>
  -</web-app>
  \ No newline at end of file
  +<?xml version="1.0" encoding="UTF-8"?>
  +<jetty:web-app xmlns:jetty="http://org.apache.geronimo/xml/ns/web/jetty">
  +    <jetty:context-root>/test</jetty:context-root>
  +    <jetty:context-priority-classloader>false</jetty:context-priority-classloader>
  +</jetty:web-app>
  
  
  

Mime
View raw message