geronimo-xbean-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From djen...@apache.org
Subject svn commit: r707227 - in /geronimo/xbean/trunk/xbean-naming/src: main/java/org/apache/xbean/naming/context/ test/java/org/apache/xbean/naming/context/
Date Wed, 22 Oct 2008 23:57:16 GMT
Author: djencks
Date: Wed Oct 22 16:57:16 2008
New Revision: 707227

URL: http://svn.apache.org/viewvc?rev=707227&view=rev
Log:
XBEAN-115 Fix rebind of entry added using deepBind

Modified:
    geronimo/xbean/trunk/xbean-naming/src/main/java/org/apache/xbean/naming/context/AbstractContext.java
    geronimo/xbean/trunk/xbean-naming/src/main/java/org/apache/xbean/naming/context/WritableContext.java
    geronimo/xbean/trunk/xbean-naming/src/test/java/org/apache/xbean/naming/context/WritableContextTest.java

Modified: geronimo/xbean/trunk/xbean-naming/src/main/java/org/apache/xbean/naming/context/AbstractContext.java
URL: http://svn.apache.org/viewvc/geronimo/xbean/trunk/xbean-naming/src/main/java/org/apache/xbean/naming/context/AbstractContext.java?rev=707227&r1=707226&r2=707227&view=diff
==============================================================================
--- geronimo/xbean/trunk/xbean-naming/src/main/java/org/apache/xbean/naming/context/AbstractContext.java
(original)
+++ geronimo/xbean/trunk/xbean-naming/src/main/java/org/apache/xbean/naming/context/AbstractContext.java
Wed Oct 22 16:57:16 2008
@@ -351,11 +351,11 @@
         if (name == null) throw new NullPointerException("name is null");
         if (name.size() < 2) throw new InvalidNameException("name must have at least 2
parts " + name);
 
-        if (!path.endsWith("/")) path += "/";
+        if (path.length() > 0 && !path.endsWith("/")) path += "/";
 
-        for (int i = name.size() - 2; i >= 0; i--) {
-            String fullPath = path + name.getSuffix(i);
-            String key = name.get(i + 1);
+        for (int i = name.size() - 1; i > 0; i--) {
+            String fullPath = path + name.getPrefix(i);
+            String key = name.get(i);
             value = createNestedSubcontext(fullPath, Collections.singletonMap(key, value));
         }
         return (Context) value;

Modified: geronimo/xbean/trunk/xbean-naming/src/main/java/org/apache/xbean/naming/context/WritableContext.java
URL: http://svn.apache.org/viewvc/geronimo/xbean/trunk/xbean-naming/src/main/java/org/apache/xbean/naming/context/WritableContext.java?rev=707227&r1=707226&r2=707227&view=diff
==============================================================================
--- geronimo/xbean/trunk/xbean-naming/src/main/java/org/apache/xbean/naming/context/WritableContext.java
(original)
+++ geronimo/xbean/trunk/xbean-naming/src/main/java/org/apache/xbean/naming/context/WritableContext.java
Wed Oct 22 16:57:16 2008
@@ -203,7 +203,8 @@
 
         public NestedWritableContext(String path, Map<String, Object> bindings) throws
NamingException {
             super(WritableContext.this, path);
-
+            
+            path = getNameInNamespace();
             if (!path.endsWith("/")) path += "/";
             this.pathWithSlash = path;
 

Modified: geronimo/xbean/trunk/xbean-naming/src/test/java/org/apache/xbean/naming/context/WritableContextTest.java
URL: http://svn.apache.org/viewvc/geronimo/xbean/trunk/xbean-naming/src/test/java/org/apache/xbean/naming/context/WritableContextTest.java?rev=707227&r1=707226&r2=707227&view=diff
==============================================================================
--- geronimo/xbean/trunk/xbean-naming/src/test/java/org/apache/xbean/naming/context/WritableContextTest.java
(original)
+++ geronimo/xbean/trunk/xbean-naming/src/test/java/org/apache/xbean/naming/context/WritableContextTest.java
Wed Oct 22 16:57:16 2008
@@ -894,4 +894,19 @@
         }
         assertEq(bindings, context);
     }
+
+    public void testLookupSubContext() throws Exception {
+        Context ctx = (Context) context.lookup("a/b/c");
+        String s = (String) ctx.lookup("d/e/string");
+        assertEquals(s, WritableContextTest.STRING_VAL);
+    }
+
+    public void testDeepBinding() throws Exception {
+        WritableContext w = new WritableContext("jca:");
+        w.addDeepBinding(w.getNameParser("").parse("test/test/GBean/resourceSource"), WritableContextTest.STRING_VAL,
false, true);
+        assertEquals(WritableContextTest.STRING_VAL, w.lookup("test/test/GBean/resourceSource"));
+        w.rebind("test/test/GBean/resourceSource", 1);
+        assertEquals(new Integer(1), w.lookup("test/test/GBean/resourceSource"));
+    }
+
 }



Mime
View raw message