geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From djen...@apache.org
Subject svn commit: r467280 - in /geronimo/server/trunk/modules: geronimo-kernel/src/main/java/org/apache/geronimo/gbean/ geronimo-system/src/main/java/org/apache/geronimo/system/configuration/ geronimo-system/src/test/java/org/apache/geronimo/system/configura...
Date Tue, 24 Oct 2006 08:53:00 GMT
Author: djencks
Date: Tue Oct 24 01:52:59 2006
New Revision: 467280

URL: http://svn.apache.org/viewvc?view=rev&rev=467280
Log:
GERONIMO-2514 fix some reference pattern bugs for config.xml

Modified:
    geronimo/server/trunk/modules/geronimo-kernel/src/main/java/org/apache/geronimo/gbean/ReferencePatterns.java
    geronimo/server/trunk/modules/geronimo-system/src/main/java/org/apache/geronimo/system/configuration/GBeanOverride.java
    geronimo/server/trunk/modules/geronimo-system/src/test/java/org/apache/geronimo/system/configuration/ServerOverrideTest.java

Modified: geronimo/server/trunk/modules/geronimo-kernel/src/main/java/org/apache/geronimo/gbean/ReferencePatterns.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/modules/geronimo-kernel/src/main/java/org/apache/geronimo/gbean/ReferencePatterns.java?view=diff&rev=467280&r1=467279&r2=467280
==============================================================================
--- geronimo/server/trunk/modules/geronimo-kernel/src/main/java/org/apache/geronimo/gbean/ReferencePatterns.java
(original)
+++ geronimo/server/trunk/modules/geronimo-kernel/src/main/java/org/apache/geronimo/gbean/ReferencePatterns.java
Tue Oct 24 01:52:59 2006
@@ -87,4 +87,22 @@
             return patterns.toString();
         }
     }
+
+    public boolean equals(Object other) {
+        if (other instanceof ReferencePatterns) {
+            ReferencePatterns otherRefPat = (ReferencePatterns) other;
+            if (abstractName != null) {
+                return abstractName.equals(otherRefPat.abstractName);
+            }
+            return patterns.equals(otherRefPat.patterns);
+        }
+        return false;
+    }
+
+    public int hashCode() {
+        if (abstractName != null) {
+            return abstractName.hashCode();
+        }
+        return patterns.hashCode();
+    }
 }

Modified: geronimo/server/trunk/modules/geronimo-system/src/main/java/org/apache/geronimo/system/configuration/GBeanOverride.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/modules/geronimo-system/src/main/java/org/apache/geronimo/system/configuration/GBeanOverride.java?view=diff&rev=467280&r1=467279&r2=467280
==============================================================================
--- geronimo/server/trunk/modules/geronimo-system/src/main/java/org/apache/geronimo/system/configuration/GBeanOverride.java
(original)
+++ geronimo/server/trunk/modules/geronimo-system/src/main/java/org/apache/geronimo/system/configuration/GBeanOverride.java
Tue Oct 24 01:52:59 2006
@@ -134,7 +134,7 @@
             // Check to see if there is a null attribute
             if (attribute.hasAttribute("null")) {
                 String nullString = attribute.getAttribute("null");
-                if (nullString.equals("true")){
+                if (nullString.equals("true")) {
                     setNullAttribute(attributeName);
                     continue;
                 }
@@ -221,7 +221,7 @@
             } else {
                 StringWriter sw = new StringWriter();
                 PrintWriter pw = new PrintWriter(sw);
-                OutputFormat of = new OutputFormat( Method.XML, null, false );
+                OutputFormat of = new OutputFormat(Method.XML, null, false);
                 of.setOmitXMLDeclaration(true);
                 XMLSerializer serializer = new XMLSerializer(pw, of);
                 try {
@@ -348,14 +348,13 @@
             Map.Entry entry = (Map.Entry) iterator.next();
             String name = (String) entry.getKey();
             String value = (String) entry.getValue();
-            if (value==null) {
-            	setNullAttribute(name);
-            }
-            else {
+            if (value == null) {
+                setNullAttribute(name);
+            } else {
                 if (getNullAttribute(name)) {
                     nullAttributes.remove(name);
                 }
-                if(name.toLowerCase().indexOf("password") > -1) {
+                if (name.toLowerCase().indexOf("password") > -1) {
                     value = EncryptionManager.encrypt(value);
                 }
                 Element attribute = doc.createElement("attribute");
@@ -395,7 +394,7 @@
             reference.setAttribute("name", name);
             gbean.appendChild(reference);
             Set patternSet;
-            if(patterns.isResolved()) {
+            if (patterns.isResolved()) {
                 patternSet = Collections.singleton(new AbstractNameQuery(patterns.getAbstractName()));
             } else {
                 patternSet = patterns.getPatterns();
@@ -411,7 +410,7 @@
                         group.appendChild(doc.createTextNode(artifact.getGroupId()));
                         pat.appendChild(group);
                     }
-                    if(artifact.getArtifactId() != null) {
+                    if (artifact.getArtifactId() != null) {
                         Element art = doc.createElement("artifactId");
                         art.appendChild(doc.createTextNode(artifact.getArtifactId()));
                         pat.appendChild(art);
@@ -426,17 +425,17 @@
                         type.appendChild(doc.createTextNode(artifact.getType()));
                         pat.appendChild(type);
                     }
-                    Map nameMap = pattern.getName();
-                    if (nameMap.get("module") != null) {
-                        Element module = doc.createElement("module");
-                        module.appendChild(doc.createTextNode(nameMap.get("module").toString()));
-                        pat.appendChild(module);
-                    }
-                    if (nameMap.get("name") != null) {
-                        Element patName = doc.createElement("name");
-                        patName.appendChild(doc.createTextNode(nameMap.get("name").toString()));
-                        pat.appendChild(patName);
-                    }
+                }
+                Map nameMap = pattern.getName();
+                if (nameMap.get("module") != null) {
+                    Element module = doc.createElement("module");
+                    module.appendChild(doc.createTextNode(nameMap.get("module").toString()));
+                    pat.appendChild(module);
+                }
+                if (nameMap.get("name") != null) {
+                    Element patName = doc.createElement("name");
+                    patName.appendChild(doc.createTextNode(nameMap.get("name").toString()));
+                    pat.appendChild(patName);
                 }
 //                out.print(pattern.toString());
             }

Modified: geronimo/server/trunk/modules/geronimo-system/src/test/java/org/apache/geronimo/system/configuration/ServerOverrideTest.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/modules/geronimo-system/src/test/java/org/apache/geronimo/system/configuration/ServerOverrideTest.java?view=diff&rev=467280&r1=467279&r2=467280
==============================================================================
--- geronimo/server/trunk/modules/geronimo-system/src/test/java/org/apache/geronimo/system/configuration/ServerOverrideTest.java
(original)
+++ geronimo/server/trunk/modules/geronimo-system/src/test/java/org/apache/geronimo/system/configuration/ServerOverrideTest.java
Tue Oct 24 01:52:59 2006
@@ -63,12 +63,12 @@
         pizza.setAttribute("cheese", "mozzarella");
         assertEquals("mozzarella", pizza.getAttribute("cheese"));
 
-        AbstractNameQuery pizzaOvenQuery = getAbstractNameQuery(":name=PizzaOven,j2eeType=oven");
+        AbstractNameQuery pizzaOvenQuery = getAbstractNameQuery(":name=PizzaOven");
         ReferencePatterns pizzaOvenPatterns = new ReferencePatterns(Collections.singleton(pizzaOvenQuery));
         pizza.setReferencePatterns("oven", pizzaOvenPatterns);
         assertEquals(pizzaOvenPatterns, pizza.getReferencePatterns("oven"));
 
-        AbstractNameQuery toasterOvenQuery = getAbstractNameQuery(":name=ToasterOven,j2eeType=oven,*");
+        AbstractNameQuery toasterOvenQuery = getAbstractNameQuery(":name=ToasterOven,*");
         AbstractNameQuery[] queries = new AbstractNameQuery[]{pizzaOvenQuery, toasterOvenQuery};
         ReferencePatterns ovenPatterns = getReferencePatterns(queries);
         pizza.setReferencePatterns("oven", ovenPatterns);
@@ -111,12 +111,12 @@
         pizza.setAttribute("size", "x-large");
         assertCopyIdentical(pizza);
 
-        AbstractNameQuery pizzaOvenQuery = getAbstractNameQuery(":name=PizzaOven,j2eeType=oven");
+        AbstractNameQuery pizzaOvenQuery = getAbstractNameQuery(":name=PizzaOven");
         ReferencePatterns pizzaOvenPatterns = new ReferencePatterns(Collections.singleton(pizzaOvenQuery));
         pizza.setReferencePatterns("oven", pizzaOvenPatterns);
         assertCopyIdentical(pizza);
 
-        AbstractNameQuery toasterOvenQuery = getAbstractNameQuery(":name=ToasterOven,j2eeType=oven,*");
+        AbstractNameQuery toasterOvenQuery = getAbstractNameQuery(":name=ToasterOven,*");
         AbstractNameQuery[] queries = new AbstractNameQuery[]{pizzaOvenQuery, toasterOvenQuery};
         ReferencePatterns ovenPatterns = getReferencePatterns(queries);
         pizza.setReferencePatterns("oven", ovenPatterns);
@@ -137,8 +137,8 @@
         pizza.setClearAttribute("greenPeppers");
         pizza.setNullAttribute("pineapple");
 
-        AbstractNameQuery pizzaOvenQuery = getAbstractNameQuery(":name=PizzaOven,j2eeType=oven");
-        AbstractNameQuery toasterOvenQuery = getAbstractNameQuery(":name=ToasterOven,j2eeType=oven,*");
+        AbstractNameQuery pizzaOvenQuery = getAbstractNameQuery(":name=PizzaOven");
+        AbstractNameQuery toasterOvenQuery = getAbstractNameQuery(":name=ToasterOven,*");
         AbstractNameQuery[] queries = new AbstractNameQuery[]{pizzaOvenQuery, toasterOvenQuery};
         ReferencePatterns ovenPatterns = getReferencePatterns(queries);
         pizza.setReferencePatterns("oven", ovenPatterns);
@@ -168,8 +168,8 @@
         pizza.setAttribute("emptyString", "");
         pizza.setClearAttribute("greenPeppers");
         pizza.setNullAttribute("pineapple");
-        AbstractNameQuery pizzaOvenQuery = getAbstractNameQuery(":name=PizzaOven,j2eeType=oven");
-        AbstractNameQuery toasterOvenQuery = getAbstractNameQuery(":name=ToasterOven,j2eeType=oven,*");
+        AbstractNameQuery pizzaOvenQuery = getAbstractNameQuery(":name=PizzaOven");
+        AbstractNameQuery toasterOvenQuery = getAbstractNameQuery(":name=ToasterOven,*");
         AbstractNameQuery[] queries = new AbstractNameQuery[]{pizzaOvenQuery, toasterOvenQuery};
         ReferencePatterns ovenPatterns = getReferencePatterns(queries);
         pizza.setReferencePatterns("oven", ovenPatterns);
@@ -201,6 +201,31 @@
         assertCopyIdentical(restaurant);
     }
 
+    private static final String REFERENCE_XML =
+            "        <gbean name=\"EJBBuilder\">\n" +
+                    "            <attribute name=\"listener\">?name=JettyWebContainer</attribute>\n"
+
+                    "            <reference name=\"ServiceBuilders\">\n" +
+                    "                <pattern>\n" +
+                    "                    <name>GBeanBuilder</name>\n" +
+                    "                </pattern>\n" +
+                    "                <pattern>\n" +
+                    "                    <name>PersistenceUnitBuilder</name>\n"
+
+                    "                </pattern>\n" +
+                    "            </reference>\n" +
+                    "            <reference name=\"WebServiceBuilder\">\n" +
+                    "                <pattern>\n" +
+                    "                    <name>CXFBuilder</name>\n" +
+                    "                </pattern>\n" +
+                    "            </reference>\n" +
+                    "        </gbean>";
+
+    public void testReferenceXml() throws Exception {
+        InputStream in = new ByteArrayInputStream(REFERENCE_XML.getBytes());
+        Element gbeanElement = parseXml(in, "gbean");
+        GBeanOverride gbean = new GBeanOverride(gbeanElement);
+        assertCopyIdentical(gbean);
+    }
+
     private void assertCopyIdentical(ServerOverride server) throws Exception {
         ServerOverride copy = copy(server);
         assertIdentical(server, copy);
@@ -263,6 +288,7 @@
         assertEquals(expected.getAttributes(), actual.getAttributes());
         assertEquals(expected.getClearAttributes(), actual.getClearAttributes());
         assertEquals(expected.getNullAttributes(), actual.getNullAttributes());
+        assertEquals(expected.getReferences(), actual.getReferences());
         assertEquals(expected.getClearReferences(), actual.getClearReferences());
     }
 



Mime
View raw message