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/org/apache/geronimo/jetty/deployment WARConfigurationFactoryTest.java
Date Wed, 11 Feb 2004 08:02:21 GMT
djencks     2004/02/11 00:02:21

  Modified:    modules/connector/src/java/org/apache/geronimo/connector/deployment/dconfigbean
                        AdminObjectInstanceDConfigBean.java
                        ConnectionDefinitionInstanceDConfigBean.java
                        ResourceAdapterDConfigBean.java
                        ResourceAdapterDConfigRoot.java
               modules/deployment/src/java/org/apache/geronimo/deployment/tools
                        DDBeanImpl.java DDBeanRootImpl.java
               modules/deployment/src/test/org/apache/geronimo/deployment/tools
                        DDBeanRootTest.java
               modules/jetty/src/java/org/apache/geronimo/jetty/deployment
                        WebAppDConfigRoot.java
               modules/jetty/src/test/org/apache/geronimo/jetty/deployment
                        WARConfigurationFactoryTest.java
  Log:
  fix DDBeans so they return the xpath that was used to find them, from the DConfigBean
  
  Revision  Changes    Path
  1.3       +2 -2      incubator-geronimo/modules/connector/src/java/org/apache/geronimo/connector/deployment/dconfigbean/AdminObjectInstanceDConfigBean.java
  
  Index: AdminObjectInstanceDConfigBean.java
  ===================================================================
  RCS file: /home/cvs/incubator-geronimo/modules/connector/src/java/org/apache/geronimo/connector/deployment/dconfigbean/AdminObjectInstanceDConfigBean.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- AdminObjectInstanceDConfigBean.java	10 Feb 2004 08:04:21 -0000	1.2
  +++ AdminObjectInstanceDConfigBean.java	11 Feb 2004 08:02:20 -0000	1.3
  @@ -123,7 +123,7 @@
   
       public DConfigBean getDConfigBean(DDBean bean) throws ConfigurationException {
           String xpath = bean.getXpath();
  -        if (xpath.endsWith("/config-property")) {
  +        if (xpath.equals(ADMIN_OBJECT_INSTANCE_XPATHS[0])) {
               String configPropertyName = bean.getText("config-property-name")[0];
               ConfigPropertySettingDConfigBean configPropertySetting = (ConfigPropertySettingDConfigBean)
configPropertiesMap.get(configPropertyName);
               assert configPropertySetting != null;
  
  
  
  1.3       +2 -2      incubator-geronimo/modules/connector/src/java/org/apache/geronimo/connector/deployment/dconfigbean/ConnectionDefinitionInstanceDConfigBean.java
  
  Index: ConnectionDefinitionInstanceDConfigBean.java
  ===================================================================
  RCS file: /home/cvs/incubator-geronimo/modules/connector/src/java/org/apache/geronimo/connector/deployment/dconfigbean/ConnectionDefinitionInstanceDConfigBean.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- ConnectionDefinitionInstanceDConfigBean.java	10 Feb 2004 19:59:14 -0000	1.2
  +++ ConnectionDefinitionInstanceDConfigBean.java	11 Feb 2004 08:02:20 -0000	1.3
  @@ -205,7 +205,7 @@
   
       public DConfigBean getDConfigBean(DDBean bean) throws ConfigurationException {
           String xpath = bean.getXpath();
  -        if (xpath.endsWith("/config-property")) {
  +        if (xpath.equals(CONNECTION_DEFINITION_INSTANCE_XPATHS[0])) {
               String configPropertyName = bean.getText("config-property-name")[0];
               ConfigPropertySettingDConfigBean configPropertySetting = (ConfigPropertySettingDConfigBean)
configPropertiesMap.get(configPropertyName);
               assert configPropertySetting != null;
  
  
  
  1.3       +4 -4      incubator-geronimo/modules/connector/src/java/org/apache/geronimo/connector/deployment/dconfigbean/ResourceAdapterDConfigBean.java
  
  Index: ResourceAdapterDConfigBean.java
  ===================================================================
  RCS file: /home/cvs/incubator-geronimo/modules/connector/src/java/org/apache/geronimo/connector/deployment/dconfigbean/ResourceAdapterDConfigBean.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- ResourceAdapterDConfigBean.java	10 Feb 2004 08:04:21 -0000	1.2
  +++ ResourceAdapterDConfigBean.java	11 Feb 2004 08:02:20 -0000	1.3
  @@ -177,21 +177,21 @@
   
       public DConfigBean getDConfigBean(DDBean bean) throws ConfigurationException {
           String xpath = bean.getXpath();
  -        if (xpath.endsWith("/" + RESOURCE_ADAPTER_XPATHS[0])) {
  +        if (xpath.equals(RESOURCE_ADAPTER_XPATHS[0])) {
               //resource adapter config property
               String configPropertyName = bean.getText("config-property-name")[0];
               ConfigPropertySettingDConfigBean configPropertySetting = (ConfigPropertySettingDConfigBean)
configPropertiesMap.get(configPropertyName);
               assert configPropertySetting != null;
               return configPropertySetting;
           }
  -        if (xpath.endsWith("/" + RESOURCE_ADAPTER_XPATHS[1])) {
  +        if (xpath.equals(RESOURCE_ADAPTER_XPATHS[1])) {
               //connection definition
               String connectionFactoryInterface = bean.getText("connectionfactory-interface")[0];
               ConnectionDefinitionDConfigBean connectionDefinition = (ConnectionDefinitionDConfigBean)
connectionDefinitionsMap.get(connectionFactoryInterface);
               assert connectionDefinition != null;
               return connectionDefinition;
           }
  -        if (xpath.endsWith("/" + RESOURCE_ADAPTER_XPATHS[2])) {
  +        if (xpath.equals(RESOURCE_ADAPTER_XPATHS[2])) {
               //admin objects
               String adminObjectInterface = bean.getText("adminobject-interface")[0];
               String adminObjectClass = bean.getText("adminobject-class")[0];
  
  
  
  1.3       +2 -3      incubator-geronimo/modules/connector/src/java/org/apache/geronimo/connector/deployment/dconfigbean/ResourceAdapterDConfigRoot.java
  
  Index: ResourceAdapterDConfigRoot.java
  ===================================================================
  RCS file: /home/cvs/incubator-geronimo/modules/connector/src/java/org/apache/geronimo/connector/deployment/dconfigbean/ResourceAdapterDConfigRoot.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- ResourceAdapterDConfigRoot.java	10 Feb 2004 08:04:21 -0000	1.2
  +++ ResourceAdapterDConfigRoot.java	11 Feb 2004 08:02:20 -0000	1.3
  @@ -105,9 +105,8 @@
           return XPATHS;
       }
   
  -    //TODO should the xpath start with /??
       public DConfigBean getDConfigBean(DDBean bean) throws ConfigurationException {
  -        if (("/" + XPATHS[0]).equals(bean.getXpath())) {
  +        if (XPATHS[0].equals(bean.getXpath())) {
               return resourceAdapterDConfigBean;
           }
           return null;
  
  
  
  1.3       +29 -3     incubator-geronimo/modules/deployment/src/java/org/apache/geronimo/deployment/tools/DDBeanImpl.java
  
  Index: DDBeanImpl.java
  ===================================================================
  RCS file: /home/cvs/incubator-geronimo/modules/deployment/src/java/org/apache/geronimo/deployment/tools/DDBeanImpl.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- DDBeanImpl.java	23 Jan 2004 19:58:17 -0000	1.2
  +++ DDBeanImpl.java	11 Feb 2004 08:02:21 -0000	1.3
  @@ -60,6 +60,7 @@
   import java.util.Iterator;
   import java.util.List;
   import java.util.Map;
  +
   import javax.enterprise.deploy.model.DDBean;
   import javax.enterprise.deploy.model.DDBeanRoot;
   import javax.enterprise.deploy.model.XpathListener;
  @@ -99,6 +100,13 @@
           }
       }
   
  +    DDBeanImpl(DDBeanImpl source, String xpath) {
  +        this.xpath = xpath;
  +        this.root = source.root;
  +        this.children = source.children;
  +        this.element = source.element;
  +    }
  +
       public DDBeanRoot getRoot() {
           return root;
       }
  @@ -146,7 +154,11 @@
               if (beans == null) {
                   return null;
               }
  -            return (DDBean[]) beans.toArray(new DDBean[beans.size()]);
  +            DDBean[] newDDBeans = (DDBean[]) beans.toArray(new DDBean[beans.size()]);
  +            for (int i = 0; i < newDDBeans.length; i++) {
  +                newDDBeans[i] = new DDBeanImpl((DDBeanImpl) newDDBeans[i], xpath);
  +            }
  +            return newDDBeans;
           } else {
               List childBeans = (List) children.get(xpath.substring(0, index));
               if (childBeans == null) {
  @@ -159,7 +171,7 @@
                   DDBean[] childs = bean.getChildBean(path);
                   if (childs != null) {
                       for (int j = 0; j < childs.length; j++) {
  -                        beans.add(childs[j]);
  +                        beans.add(new DDBeanImpl((DDBeanImpl) childs[j], xpath));
                       }
                   }
               }
  @@ -181,5 +193,19 @@
       }
   
       public void removeXpathListener(String xpath, XpathListener xpl) {
  +    }
  +
  +    public boolean equals(Object other) {
  +        if (other.getClass() != DDBeanImpl.class) {
  +            return false;
  +        }
  +        DDBeanImpl otherdd = (DDBeanImpl)other;
  +        return xpath.equals(otherdd.xpath)
  +        && element.equals(otherdd.element)
  +        && root.equals(otherdd.root);
  +    }
  +
  +    public int hashCode() {
  +        return xpath.hashCode() ^ element.hashCode() ^ root.hashCode();
       }
   }
  
  
  
  1.2       +9 -5      incubator-geronimo/modules/deployment/src/java/org/apache/geronimo/deployment/tools/DDBeanRootImpl.java
  
  Index: DDBeanRootImpl.java
  ===================================================================
  RCS file: /home/cvs/incubator-geronimo/modules/deployment/src/java/org/apache/geronimo/deployment/tools/DDBeanRootImpl.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- DDBeanRootImpl.java	21 Jan 2004 20:37:29 -0000	1.1
  +++ DDBeanRootImpl.java	11 Feb 2004 08:02:21 -0000	1.2
  @@ -71,8 +71,8 @@
   import org.w3c.dom.Document;
   
   /**
  - * 
  - * 
  + *
  + *
    * @version $Revision$ $Date$
    */
   public class DDBeanRootImpl implements DDBeanRoot {
  @@ -158,9 +158,13 @@
           String childName = (index == -1) ? xpath : xpath.substring(0, index);
           if (childName.equals(doc.getDocumentElement().getNodeName())) {
               if (index == -1) {
  -                return new DDBean[] {docBean };
  +                return new DDBean[] {new DDBeanImpl((DDBeanImpl)docBean, xpath)};
               } else {
  -                return docBean.getChildBean(xpath.substring(index+1));
  +                DDBean[] newDDBeans = docBean.getChildBean(xpath.substring(index+1));
  +                for (int i = 0; i < newDDBeans.length; i++) {
  +                    newDDBeans[i] = new DDBeanImpl((DDBeanImpl)newDDBeans[i], xpath);
  +                }
  +                return newDDBeans;
               }
           } else {
               return null;
  
  
  
  1.2       +4 -4      incubator-geronimo/modules/deployment/src/test/org/apache/geronimo/deployment/tools/DDBeanRootTest.java
  
  Index: DDBeanRootTest.java
  ===================================================================
  RCS file: /home/cvs/incubator-geronimo/modules/deployment/src/test/org/apache/geronimo/deployment/tools/DDBeanRootTest.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- DDBeanRootTest.java	21 Jan 2004 20:37:28 -0000	1.1
  +++ DDBeanRootTest.java	11 Feb 2004 08:02:21 -0000	1.2
  @@ -69,8 +69,8 @@
   import junit.framework.TestCase;
   
   /**
  - * 
  - * 
  + *
  + *
    * @version $Revision$ $Date$
    */
   public class DDBeanRootTest extends TestCase {
  @@ -93,7 +93,7 @@
   
           DDBean description = root.getChildBean("application-client/description")[0];
           assertEquals("Test DD for app-client1", description.getText());
  -        assertEquals("/application-client/description", description.getXpath());
  +        assertEquals("application-client/description", description.getXpath());
           assertEquals(description, description.getChildBean("/application-client/description")[0]);
       }
   
  
  
  
  1.5       +3 -3      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.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- WebAppDConfigRoot.java	9 Feb 2004 23:11:04 -0000	1.4
  +++ WebAppDConfigRoot.java	11 Feb 2004 08:02:21 -0000	1.5
  @@ -91,7 +91,7 @@
   
       private void replaceWebAppDConfigBean(JettyWebAppType webApp) {
           DDBean ddBean = getDDBean();
  -        webAppBean = new WebAppDConfigBean(ddBean.getChildBean("/web-app")[0], webApp);
  +        webAppBean = new WebAppDConfigBean(ddBean.getChildBean(XPATHS[0])[0], webApp);
       }
   
       JettyWebAppDocument getWebAppDocument() {
  @@ -103,7 +103,7 @@
       }
   
       public DConfigBean getDConfigBean(DDBean bean) throws ConfigurationException {
  -        if ("/web-app".equals(bean.getXpath())) {
  +        if (XPATHS[0].equals(bean.getXpath())) {
               return webAppBean;
           }
           return null;
  
  
  
  1.9       +5 -6      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.8
  retrieving revision 1.9
  diff -u -r1.8 -r1.9
  --- WARConfigurationFactoryTest.java	9 Feb 2004 00:01:20 -0000	1.8
  +++ WARConfigurationFactoryTest.java	11 Feb 2004 08:02:21 -0000	1.9
  @@ -59,7 +59,6 @@
   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.xbeans.geronimo.deployment.jetty.JettyContextRootType;
  @@ -94,7 +93,7 @@
           WebDeployable deployable = new WebDeployable(classLoader.getResource("deployables/war1/"));
           WARConfiguration config = new WARConfiguration(deployable);
           DConfigBeanRoot configRoot = config.getDConfigBeanRoot(deployable.getDDBeanRoot());
  -        WebAppDConfigBean contextBean = (WebAppDConfigBean) configRoot.getDConfigBean(deployable.getChildBean("/web-app")[0]);
  +        WebAppDConfigBean contextBean = (WebAppDConfigBean) configRoot.getDConfigBean(deployable.getChildBean(configRoot.getXpaths()[0])[0]);
           contextBean.setContextRoot("/test");
           contextBean.setContextPriorityClassLoader(false);
   
  @@ -114,7 +113,7 @@
           WebDeployable deployable = new WebDeployable(classLoader.getResource("deployables/war1/"));
           WARConfiguration config = new WARConfiguration(deployable);
           DConfigBeanRoot configRoot = config.getDConfigBeanRoot(deployable.getDDBeanRoot());
  -        WebAppDConfigBean contextBean = (WebAppDConfigBean) configRoot.getDConfigBean(deployable.getChildBean("/web-app")[0]);
  +        WebAppDConfigBean contextBean = (WebAppDConfigBean) configRoot.getDConfigBean(deployable.getChildBean(configRoot.getXpaths()[0])[0]);
           contextBean.setContextRoot("/test");
           contextBean.setContextPriorityClassLoader(true);
           checkContents(((WebAppDConfigRoot)configRoot).getWebAppDocument());
  @@ -127,7 +126,7 @@
   
           config = new WARConfiguration(deployable);
           configRoot = config.getDConfigBeanRoot(deployable.getDDBeanRoot());
  -        contextBean = (WebAppDConfigBean) configRoot.getDConfigBean(deployable.getChildBean("/web-app")[0]);
  +        contextBean = (WebAppDConfigBean) configRoot.getDConfigBean(deployable.getChildBean(configRoot.getXpaths()[0])[0]);
   
           assertEquals("", contextBean.getContextRoot());
   
  @@ -136,7 +135,7 @@
           checkContents(((WebAppDConfigRoot)configRoot).getWebAppDocument());
   
   
  -        contextBean = (WebAppDConfigBean) configRoot.getDConfigBean(deployable.getChildBean("/web-app")[0]);
  +        contextBean = (WebAppDConfigBean) configRoot.getDConfigBean(deployable.getChildBean(configRoot.getXpaths()[0])[0]);
           assertEquals("/test", contextBean.getContextRoot());
           assertEquals(true, contextBean.getContextPriorityClassLoader());
       }
  
  
  

Mime
View raw message