geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From djen...@apache.org
Subject svn commit: r707233 - in /geronimo/server/trunk: ./ framework/modules/geronimo-naming/src/test/java/org/apache/geronimo/gjndi/
Date Thu, 23 Oct 2008 00:11:58 GMT
Author: djencks
Date: Wed Oct 22 17:11:58 2008
New Revision: 707233

URL: http://svn.apache.org/viewvc?rev=707233&view=rev
Log:
GERONIMO-4375 fix rebind of entry originating from deepBind.  See XBEAN-115

Added:
    geronimo/server/trunk/framework/modules/geronimo-naming/src/test/java/org/apache/geronimo/gjndi/MockResourceSource.java
  (with props)
Modified:
    geronimo/server/trunk/framework/modules/geronimo-naming/src/test/java/org/apache/geronimo/gjndi/JavaCompContextTest.java
    geronimo/server/trunk/framework/modules/geronimo-naming/src/test/java/org/apache/geronimo/gjndi/KernelContextGBeanTest.java
    geronimo/server/trunk/pom.xml

Modified: geronimo/server/trunk/framework/modules/geronimo-naming/src/test/java/org/apache/geronimo/gjndi/JavaCompContextTest.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/framework/modules/geronimo-naming/src/test/java/org/apache/geronimo/gjndi/JavaCompContextTest.java?rev=707233&r1=707232&r2=707233&view=diff
==============================================================================
--- geronimo/server/trunk/framework/modules/geronimo-naming/src/test/java/org/apache/geronimo/gjndi/JavaCompContextTest.java
(original)
+++ geronimo/server/trunk/framework/modules/geronimo-naming/src/test/java/org/apache/geronimo/gjndi/JavaCompContextTest.java
Wed Oct 22 17:11:58 2008
@@ -195,7 +195,7 @@
         RootContext.setComponentContext(readOnlyContext);
 
         Context javaCompContext = new JavaCompContextGBean();
-        Context globalContext = new ImmutableContext(Collections.singletonMap(javaCompContext.getNameInNamespace(),
javaCompContext));
+        Context globalContext = new ImmutableContext(Collections.<String, Object>singletonMap(javaCompContext.getNameInNamespace(),
javaCompContext));
         GlobalContextManager.setGlobalContext(globalContext);
 
         initialContext = new InitialContext();

Modified: geronimo/server/trunk/framework/modules/geronimo-naming/src/test/java/org/apache/geronimo/gjndi/KernelContextGBeanTest.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/framework/modules/geronimo-naming/src/test/java/org/apache/geronimo/gjndi/KernelContextGBeanTest.java?rev=707233&r1=707232&r2=707233&view=diff
==============================================================================
--- geronimo/server/trunk/framework/modules/geronimo-naming/src/test/java/org/apache/geronimo/gjndi/KernelContextGBeanTest.java
(original)
+++ geronimo/server/trunk/framework/modules/geronimo-naming/src/test/java/org/apache/geronimo/gjndi/KernelContextGBeanTest.java
Wed Oct 22 17:11:58 2008
@@ -16,10 +16,22 @@
  */
 package org.apache.geronimo.gjndi;
 
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Hashtable;
+import java.util.Iterator;
+import java.util.Map;
+
+import javax.naming.Context;
+import javax.naming.InitialContext;
+import javax.sql.DataSource;
+
+import org.apache.geronimo.gbean.AbstractName;
 import org.apache.geronimo.gbean.GBeanData;
 import org.apache.geronimo.gbean.GBeanInfo;
 import org.apache.geronimo.gbean.GBeanInfoBuilder;
-import org.apache.geronimo.gbean.AbstractName;
+import org.apache.geronimo.gbean.AbstractNameQuery;
+import org.apache.geronimo.gbean.annotation.AnnotationGBeanInfoBuilder;
 import org.apache.geronimo.kernel.Kernel;
 import org.apache.geronimo.kernel.KernelFactory;
 import org.apache.geronimo.kernel.config.ConfigurationData;
@@ -30,17 +42,11 @@
 import org.apache.geronimo.kernel.repository.DefaultArtifactManager;
 import org.apache.geronimo.kernel.repository.DefaultArtifactResolver;
 import org.apache.geronimo.naming.java.RootContext;
+import org.apache.geronimo.gjndi.binding.GBeanFormatBinding;
+import org.apache.geronimo.gjndi.binding.ResourceBinding;
 import org.apache.xbean.naming.context.ImmutableContext;
 import org.apache.xbean.naming.global.GlobalContextManager;
 
-import javax.naming.Context;
-import javax.naming.InitialContext;
-import java.util.HashMap;
-import java.util.Hashtable;
-import java.util.Map;
-import java.util.Iterator;
-import java.util.Collections;
-
 /**
  * @version $Rev$ $Date$
  */
@@ -52,13 +58,15 @@
     private Hashtable contextEnv;
 
     public void test() throws Exception {
-        Map globalBindings = new HashMap();
-        globalBindings.put("java:comp/string", "foo");
-        globalBindings.put("java:comp/nested/context/string", "bar");
-        globalBindings.put("java:comp/a/b/c/d/e/string", "beer");
-        globalBindings.put("java:comp/a/b/c/d/e/one", new Integer(1));
-        globalBindings.put("java:comp/a/b/c/d/e/two", new Integer(2));
-        globalBindings.put("java:comp/a/b/c/d/e/three", new Integer(3));
+        HashMap javaCompOnlyBindings = new HashMap();
+        javaCompOnlyBindings.put("java:comp/string", "foo");
+        javaCompOnlyBindings.put("java:comp/nested/context/string", "bar");
+        javaCompOnlyBindings.put("java:comp/a/b/c/d/e/string", "beer");
+        javaCompOnlyBindings.put("java:comp/a/b/c/d/e/one", new Integer(1));
+        javaCompOnlyBindings.put("java:comp/a/b/c/d/e/two", new Integer(2));
+        javaCompOnlyBindings.put("java:comp/a/b/c/d/e/three", new Integer(3));
+
+        Map globalBindings = new HashMap(javaCompOnlyBindings);
         globalBindings.put("test/env/foo", new Integer(42));
         globalBindings.put("test/baz", "caz");
 
@@ -86,9 +94,7 @@
         //
         kernel.stopGBean(testName);
 
-        HashMap javaCompOnlyBindings = new HashMap(globalBindings);
-        javaCompOnlyBindings.remove("test/env/foo");
-        javaCompOnlyBindings.remove("test/baz");
+
         assertEq(javaCompOnlyBindings, ctx);
 
         //
@@ -98,7 +104,6 @@
 
         assertEq(Collections.EMPTY_MAP, ctx);
 
-
         //
         // restart java context
         //
@@ -114,6 +119,45 @@
         assertEq(globalBindings, ctx);
     }
 
+    public void testGBeanFormatBinding() throws Exception {
+        setUpJcaContext();
+        configurationManager.loadConfiguration(configurationData);
+        configurationManager.startConfiguration(configurationData.getId());
+
+        InitialContext ctx = new InitialContext(contextEnv);
+        Context fooCtx = ctx.createSubcontext("jca:foo");
+        fooCtx.createSubcontext("bar");
+        ctx.bind("jca:foo/bar/baz", 1);
+        assertEquals(ctx.lookup("jca:foo/bar/baz"), 1);
+        ctx.rebind("jca:foo/bar/baz", 2);
+        assertEquals(ctx.lookup("jca:foo/bar/baz"), 2);
+
+    }
+
+    public void testGBeanFormatReBinding() throws Exception {
+        setUpJcaContext();
+        configurationData.addGBean("resourceSource", new AnnotationGBeanInfoBuilder(MockResourceSource.class).buildGBeanInfo());
+
+        configurationManager.loadConfiguration(configurationData);
+        configurationManager.startConfiguration(configurationData.getId());
+
+        InitialContext ctx = new InitialContext(contextEnv);
+        assertTrue(ctx.lookup("jca:/test/test/GBean/resourceSource") instanceof DataSource);
+        Context context = (Context)ctx.lookup("jca:/test/test");
+        assertTrue(context.lookup("GBean/resourceSource") instanceof DataSource);
+
+        ctx.rebind("jca:/test/test/GBean/resourceSource", 2);
+        assertEquals(2, ctx.lookup("jca:/test/test/GBean/resourceSource"));
+
+    }
+
+    private void setUpJcaContext() {
+        GBeanData jca = configurationData.addGBean("jca", ResourceBinding.GBEAN_INFO);
+        jca.setAttribute("format","{groupId}/{artifactId}/{j2eeType}/{name}");
+        jca.setAttribute("nameInNamespace", "jca:");
+        jca.setAttribute("abstractNameQuery", new AbstractNameQuery("org.apache.geronimo.naming.ResourceSource"));
+    }
+
     protected Map getNestedBindings(Map globalBindings, String nestedPath) {
         HashMap nestedBindings = new HashMap();
         for (Iterator iterator = globalBindings.entrySet().iterator(); iterator.hasNext();)
{
@@ -154,7 +198,7 @@
         configurationData.addGBean("GlobalContext", GlobalContextGBean.GBEAN_INFO);
 
         GBeanInfoBuilder builder = new GBeanInfoBuilder(ImmutableContext.class);
-        builder.setConstructor(new String[] {"nameInNamespace", "bindings", "cacheReferences"});
+        builder.setConstructor(new String[]{"nameInNamespace", "bindings", "cacheReferences"});
         builder.addAttribute("nameInNamespace", String.class, true);
         builder.addAttribute("bindings", Map.class, true);
         builder.addAttribute("cacheReferences", boolean.class, true);

Added: geronimo/server/trunk/framework/modules/geronimo-naming/src/test/java/org/apache/geronimo/gjndi/MockResourceSource.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/framework/modules/geronimo-naming/src/test/java/org/apache/geronimo/gjndi/MockResourceSource.java?rev=707233&view=auto
==============================================================================
--- geronimo/server/trunk/framework/modules/geronimo-naming/src/test/java/org/apache/geronimo/gjndi/MockResourceSource.java
(added)
+++ geronimo/server/trunk/framework/modules/geronimo-naming/src/test/java/org/apache/geronimo/gjndi/MockResourceSource.java
Wed Oct 22 17:11:58 2008
@@ -0,0 +1,35 @@
+/*
+ * 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.geronimo.gjndi;
+
+import org.apache.geronimo.naming.ResourceSource;
+import org.apache.geronimo.gjndi.binding.MockDataSource;
+import org.apache.geronimo.gbean.annotation.GBean;
+
+/**
+ * @version $Rev:$ $Date:$
+ */
+@GBean
+public class MockResourceSource implements ResourceSource {
+    public Object $getResource() throws Throwable {
+        return new MockDataSource();
+    }
+}

Propchange: geronimo/server/trunk/framework/modules/geronimo-naming/src/test/java/org/apache/geronimo/gjndi/MockResourceSource.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/server/trunk/framework/modules/geronimo-naming/src/test/java/org/apache/geronimo/gjndi/MockResourceSource.java
------------------------------------------------------------------------------
    svn:keywords = Date Revision

Propchange: geronimo/server/trunk/framework/modules/geronimo-naming/src/test/java/org/apache/geronimo/gjndi/MockResourceSource.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Modified: geronimo/server/trunk/pom.xml
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/pom.xml?rev=707233&r1=707232&r2=707233&view=diff
==============================================================================
--- geronimo/server/trunk/pom.xml (original)
+++ geronimo/server/trunk/pom.xml Wed Oct 22 17:11:58 2008
@@ -81,7 +81,7 @@
         <springVersion>2.0.5</springVersion>
         <plutoVersion>1.1.6-G643117</plutoVersion>
         <openjpaVersion>1.2.0</openjpaVersion>
-        <xbeanVersion>3.4.1</xbeanVersion>
+        <xbeanVersion>3.5-SNAPSHOT</xbeanVersion>
         <wadiVersion>2.1-SNAPSHOT</wadiVersion>
         <jetty>jetty6</jetty>
         <!--<jetty>jetty7</jetty>-->



Mime
View raw message