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/core/src/test/org/apache/geronimo/naming/ger GerContextTest.java GerRootContextTest.java
Date Wed, 14 Jan 2004 08:28:33 GMT
djencks     2004/01/14 00:28:33

  Modified:    modules/core/src/java/org/apache/geronimo/naming/java
                        ReadOnlyContext.java
  Added:       modules/core/src/java/org/apache/geronimo/naming/ger
                        GerContext.java GerContextManager.java
                        GerRootContext.java gerURLContextFactory.java
               modules/core/src/test/org/apache/geronimo/naming/ger
                        GerContextTest.java GerRootContextTest.java
  Log:
  Global in-vm non-read only jndi context with nonstandard bind/unbind methods (They create/delete
subcontexts as needed)
  
  Revision  Changes    Path
  1.1                  incubator-geronimo/modules/core/src/java/org/apache/geronimo/naming/ger/GerContext.java
  
  Index: GerContext.java
  ===================================================================
  /* ====================================================================
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 2003 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution,
   *    if any, must include the following acknowledgment:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowledgment may appear in the software itself,
   *    if and wherever such third-party acknowledgments normally appear.
   *
   * 4. The names "Apache" and "Apache Software Foundation" and
   *    "Apache Geronimo" must not be used to endorse or promote products
   *    derived from this software without prior written permission. For
   *    written permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache",
   *    "Apache Geronimo", nor may "Apache" appear in their name, without
   *    prior written permission of the Apache Software Foundation.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   *
   * ====================================================================
   */
  
  package org.apache.geronimo.naming.ger;
  
  import java.util.HashSet;
  import java.util.Hashtable;
  import java.util.Iterator;
  import java.util.Map;
  import java.util.Set;
  
  import javax.naming.Name;
  import javax.naming.NamingEnumeration;
  import javax.naming.NamingException;
  
  import org.apache.geronimo.naming.java.ReadOnlyContext;
  
  /**
   *
   *
   * @version $Revision: 1.1 $ $Date: 2004/01/14 08:28:33 $
   *
   * */
  public class GerContext extends ReadOnlyContext {
  
      GerContext() {
          super();
      }
  
      GerContext(GerContext context, Hashtable environment) {
          super(context, environment);
      }
  
      protected synchronized Map internalBind(String name, Object value) throws NamingException
{
          return super.internalBind(name, value);
      }
  
      protected ReadOnlyContext newContext() {
          return new GerContext();
      }
  
      protected synchronized Set internalUnbind(String name) throws NamingException {
          assert name != null;
          assert !name.equals("");
          Set removeBindings = new HashSet();
          int pos = name.indexOf('/');
          if (pos == -1) {
              if (treeBindings.remove(name) == null) {
                  throw new NamingException("Nothing was bound at " + name);
              }
              bindings.remove(name);
              removeBindings.add(name);
          } else {
              String segment = name.substring(0, pos);
              assert segment != null;
              assert !segment.equals("");
              Object o = treeBindings.get(segment);
              if (o == null) {
                  throw new NamingException("No context was bound at " + name);
              } else if (!(o instanceof GerContext)) {
                  throw new NamingException("Something else bound where a subcontext should
be " + o);
              }
              GerContext gerContext = (GerContext)o;
  
              String remainder = name.substring(pos + 1);
              Set subBindings = gerContext.internalUnbind(remainder);
              for (Iterator iterator = subBindings.iterator(); iterator.hasNext();) {
                  String subName = segment + "/" + (String) iterator.next();
                  treeBindings.remove(subName);
                  removeBindings.add(subName);
              }
              if (gerContext.bindings.isEmpty()) {
                  bindings.remove(segment);
                  treeBindings.remove(segment);
                  removeBindings.add(segment);
              }
          }
          return removeBindings;
      }
  
  
      public synchronized Object lookup(String name) throws NamingException {
          return super.lookup(name);
      }
  
      public Object lookup(Name name) throws NamingException {
          return super.lookup(name);
      }
  
      public synchronized Object lookupLink(String name) throws NamingException {
          return super.lookupLink(name);
      }
  
      public synchronized Name composeName(Name name, Name prefix) throws NamingException
{
          return super.composeName(name, prefix);
      }
  
      public synchronized String composeName(String name, String prefix) throws NamingException
{
          return super.composeName(name, prefix);
      }
  
      public synchronized NamingEnumeration list(String name) throws NamingException {
          return super.list(name);
      }
  
      public synchronized NamingEnumeration listBindings(String name) throws NamingException
{
          return super.listBindings(name);
      }
  
      public synchronized Object lookupLink(Name name) throws NamingException {
          return super.lookupLink(name);
      }
  
      public synchronized NamingEnumeration list(Name name) throws NamingException {
          return super.list(name);
      }
  
      public synchronized NamingEnumeration listBindings(Name name) throws NamingException
{
          return super.listBindings(name);
      }
  
  }
  
  
  
  1.1                  incubator-geronimo/modules/core/src/java/org/apache/geronimo/naming/ger/GerContextManager.java
  
  Index: GerContextManager.java
  ===================================================================
  /* ====================================================================
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 2003 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution,
   *    if any, must include the following acknowledgment:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowledgment may appear in the software itself,
   *    if and wherever such third-party acknowledgments normally appear.
   *
   * 4. The names "Apache" and "Apache Software Foundation" and
   *    "Apache Geronimo" must not be used to endorse or promote products
   *    derived from this software without prior written permission. For
   *    written permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache",
   *    "Apache Geronimo", nor may "Apache" appear in their name, without
   *    prior written permission of the Apache Software Foundation.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   *
   * ====================================================================
   */
  
  package org.apache.geronimo.naming.ger;
  
  import javax.naming.NamingException;
  
  /**
   *
   *
   * @version $Revision: 1.1 $ $Date: 2004/01/14 08:28:33 $
   *
   * */
  public class GerContextManager {
  
      private GerContextManager() {}
  
      public static void bind(String name, Object value) throws NamingException {
          GerRootContext.rootContext.internalBind(name, value);
      }
  
      public static void unbind(String name) throws NamingException {
          GerRootContext.rootContext.internalUnbind(name);
      }
  }
  
  
  
  1.1                  incubator-geronimo/modules/core/src/java/org/apache/geronimo/naming/ger/GerRootContext.java
  
  Index: GerRootContext.java
  ===================================================================
  /* ====================================================================
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 2003 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution,
   *    if any, must include the following acknowledgment:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowledgment may appear in the software itself,
   *    if and wherever such third-party acknowledgments normally appear.
   *
   * 4. The names "Apache" and "Apache Software Foundation" and
   *    "Apache Geronimo" must not be used to endorse or promote products
   *    derived from this software without prior written permission. For
   *    written permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache",
   *    "Apache Geronimo", nor may "Apache" appear in their name, without
   *    prior written permission of the Apache Software Foundation.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   *
   * ====================================================================
   */
  
  package org.apache.geronimo.naming.ger;
  
  import java.util.Hashtable;
  
  import javax.naming.NamingException;
  
  /**
   *
   *
   * @version $Revision: 1.1 $ $Date: 2004/01/14 08:28:33 $
   *
   * */
  public class GerRootContext extends GerContext {
      static GerRootContext rootContext = new GerRootContext();
  
      private GerRootContext() {
          super();
      }
  
      GerRootContext(Hashtable environment) {
          super(rootContext, environment);
      }
  
      public Object lookup(String name) throws NamingException {
          if (name.startsWith("ger:")) {
              name = name.substring(4);
              if (name.length() == 0) {
                  return this;
              }
          }
          return super.lookup(name);
      }
  }
  
  
  
  1.1                  incubator-geronimo/modules/core/src/java/org/apache/geronimo/naming/ger/gerURLContextFactory.java
  
  Index: gerURLContextFactory.java
  ===================================================================
  /* ====================================================================
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 2003 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution,
   *    if any, must include the following acknowledgment:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowledgment may appear in the software itself,
   *    if and wherever such third-party acknowledgments normally appear.
   *
   * 4. The names "Apache" and "Apache Software Foundation" and
   *    "Apache Geronimo" must not be used to endorse or promote products
   *    derived from this software without prior written permission. For
   *    written permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache",
   *    "Apache Geronimo", nor may "Apache" appear in their name, without
   *    prior written permission of the Apache Software Foundation.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   *
   * ====================================================================
   */
  
  package org.apache.geronimo.naming.ger;
  
  import java.util.Hashtable;
  
  import javax.naming.spi.ObjectFactory;
  import javax.naming.Name;
  import javax.naming.Context;
  import javax.naming.OperationNotSupportedException;
  
  import org.apache.geronimo.naming.jmx.JMXContext;
  
  /**
   *
   *
   * @version $Revision: 1.1 $ $Date: 2004/01/14 08:28:33 $
   *
   * */
  public class gerURLContextFactory implements ObjectFactory {
  
  
      public Object getObjectInstance(Object obj, Name name, Context nameCtx,
                                      Hashtable environment) throws Exception {
          if (obj == null) {
              return new GerRootContext(environment);
          } else {
              throw new OperationNotSupportedException();
          }
      }
  
  }
  
  
  
  1.9       +12 -9     incubator-geronimo/modules/core/src/java/org/apache/geronimo/naming/java/ReadOnlyContext.java
  
  Index: ReadOnlyContext.java
  ===================================================================
  RCS file: /home/cvs/incubator-geronimo/modules/core/src/java/org/apache/geronimo/naming/java/ReadOnlyContext.java,v
  retrieving revision 1.8
  retrieving revision 1.9
  diff -u -r1.8 -r1.9
  --- ReadOnlyContext.java	12 Jan 2004 06:19:52 -0000	1.8
  +++ ReadOnlyContext.java	14 Jan 2004 08:28:33 -0000	1.9
  @@ -96,12 +96,11 @@
    * @version $Revision$ $Date$
    */
   public class ReadOnlyContext implements Context {
  -    private final Hashtable env;        // environment for this context
  -    private final Map bindings;         // bindings at my level
  -    private final Map treeBindings;     // all bindings under me
  +    protected final Hashtable env;        // environment for this context
  +    protected final Map bindings;         // bindings at my level
  +    protected final Map treeBindings;     // all bindings under me
   
  -
  -    ReadOnlyContext() {
  +    protected ReadOnlyContext() {
           env = new Hashtable();
           bindings = new HashMap();
           treeBindings = new HashMap();
  @@ -117,7 +116,7 @@
           this.treeBindings = Collections.EMPTY_MAP;
       }
   
  -    ReadOnlyContext(ReadOnlyContext clone, Hashtable env) {
  +    protected ReadOnlyContext(ReadOnlyContext clone, Hashtable env) {
           this.bindings = clone.bindings;
           this.treeBindings = clone.treeBindings;
           this.env = new Hashtable(env);
  @@ -135,7 +134,7 @@
        * @return
        * @throws NamingException
        */
  -    Map internalBind(String name, Object value) throws NamingException {
  +    protected Map internalBind(String name, Object value) throws NamingException {
           assert name != null;
           assert !name.equals("");
           Map newBindings = new HashMap();
  @@ -152,7 +151,7 @@
               assert !segment.equals("");
               Object o = treeBindings.get(segment);
               if (o == null) {
  -                o = new ReadOnlyContext();
  +                o = newContext();
                   treeBindings.put(segment, o);
                   bindings.put(segment, o);
                   newBindings.put(segment, o);
  @@ -171,6 +170,10 @@
               }
           }
           return newBindings;
  +    }
  +
  +    protected ReadOnlyContext newContext() {
  +        return new ReadOnlyContext();
       }
   
       public Object addToEnvironment(String propName, Object propVal) throws NamingException
{
  
  
  
  1.1                  incubator-geronimo/modules/core/src/test/org/apache/geronimo/naming/ger/GerContextTest.java
  
  Index: GerContextTest.java
  ===================================================================
  /* ====================================================================
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 2003 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution,
   *    if any, must include the following acknowledgment:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowledgment may appear in the software itself,
   *    if and wherever such third-party acknowledgments normally appear.
   *
   * 4. The names "Apache" and "Apache Software Foundation" and
   *    "Apache Geronimo" must not be used to endorse or promote products
   *    derived from this software without prior written permission. For
   *    written permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache",
   *    "Apache Geronimo", nor may "Apache" appear in their name, without
   *    prior written permission of the Apache Software Foundation.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   *
   * ====================================================================
   */
  
  package org.apache.geronimo.naming.ger;
  
  import javax.naming.NamingException;
  
  import junit.framework.TestCase;
  
  /**
   *
   *
   * @version $Revision: 1.1 $ $Date: 2004/01/14 08:28:33 $
   *
   * */
  public class GerContextTest extends TestCase {
      private GerContext context;
  
      protected void setUp() throws Exception {
          context = new GerContext();
          context.internalBind("one", "one");
          context.internalBind("this/is/a/compound/name", "two");
          context.internalBind("this/is/another/compound/name", "three");
      }
  
      public void testLookup() throws Exception {
          assertEquals(context.lookup("one"), "one");
          assertEquals(context.lookup("this/is/a/compound/name"), "two");
          assertEquals(context.lookup("this/is/another/compound/name"), "three");
      }
  
      public void testUnbind() throws Exception {
          assertEquals(1, context.internalUnbind("one").size());
          try {
              context.lookup("one");
              fail();
          } catch (NamingException e) {
          }
          assertEquals(3, context.internalUnbind("this/is/a/compound/name").size());
          try {
              context.lookup("this/is/a/compound/name");
              fail();
          } catch (NamingException e) {
          }
          context.lookup("this/is");
          assertEquals(5, context.internalUnbind("this/is/another/compound/name").size());
          try {
              context.lookup("this/is");
              fail();
          } catch (NamingException e) {
          }
      }
  }
  
  
  
  1.1                  incubator-geronimo/modules/core/src/test/org/apache/geronimo/naming/ger/GerRootContextTest.java
  
  Index: GerRootContextTest.java
  ===================================================================
  /* ====================================================================
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 2003 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution,
   *    if any, must include the following acknowledgment:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowledgment may appear in the software itself,
   *    if and wherever such third-party acknowledgments normally appear.
   *
   * 4. The names "Apache" and "Apache Software Foundation" and
   *    "Apache Geronimo" must not be used to endorse or promote products
   *    derived from this software without prior written permission. For
   *    written permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache",
   *    "Apache Geronimo", nor may "Apache" appear in their name, without
   *    prior written permission of the Apache Software Foundation.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   *
   * ====================================================================
   */
  
  package org.apache.geronimo.naming.ger;
  
  import javax.naming.InitialContext;
  
  import junit.framework.TestCase;
  
  /**
   *
   *
   * @version $Revision: 1.1 $ $Date: 2004/01/14 08:28:33 $
   *
   * */
  public class GerRootContextTest extends TestCase {
  
      protected void setUp() throws Exception {
          GerContextManager.bind("one", "one");
          GerContextManager.bind("this/is/a/compound/name", "two");
          GerContextManager.bind("this/is/another/compound/name", "three");
      }
  
      public void testLookup() throws Exception {
          InitialContext context = new InitialContext();
          assertEquals(context.lookup("ger:one"), "one");
          assertEquals(context.lookup("ger:this/is/a/compound/name"), "two");
          assertEquals(context.lookup("ger:this/is/another/compound/name"), "three");
  
      }
  }
  
  
  

Mime
View raw message