[jboss-cvs] JBossAS SVN: r63339 - in branches/Branch_4_2: testsuite/src/main/org/jboss/test/naming/test and 1 other directory.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Mon Jun 4 22:05:22 EDT 2007
Author: scott.stark at jboss.org
Date: 2007-06-04 22:05:22 -0400 (Mon, 04 Jun 2007)
New Revision: 63339
Modified:
branches/Branch_4_2/naming/src/main/org/jnp/interfaces/NamingContext.java
branches/Branch_4_2/testsuite/src/main/org/jboss/test/naming/test/ImplUnitTestCase.java
Log:
JBAS-4461, handle bind/rebind of a null value
Modified: branches/Branch_4_2/naming/src/main/org/jnp/interfaces/NamingContext.java
===================================================================
--- branches/Branch_4_2/naming/src/main/org/jnp/interfaces/NamingContext.java 2007-06-05 02:04:27 UTC (rev 63338)
+++ branches/Branch_4_2/naming/src/main/org/jnp/interfaces/NamingContext.java 2007-06-05 02:05:22 UTC (rev 63339)
@@ -491,7 +491,7 @@
try
{
- String className;
+ String className = null;
// Referenceable
if (obj instanceof Referenceable)
@@ -499,7 +499,8 @@
if (!(obj instanceof Reference))
{
- className = obj.getClass().getName();
+ if( obj != null )
+ className = obj.getClass().getName();
// Normal object - serialize using a MarshalledValuePair
obj = new MarshalledValuePair(obj);
}
@@ -545,7 +546,7 @@
try
{
- String className;
+ String className = null;
// Referenceable
if (obj instanceof Referenceable)
@@ -553,7 +554,8 @@
if (!(obj instanceof Reference))
{
- className = obj.getClass().getName();
+ if( obj != null )
+ className = obj.getClass().getName();
// Normal object - serialize using a MarshalledValuePair
obj = new MarshalledValuePair(obj);
Modified: branches/Branch_4_2/testsuite/src/main/org/jboss/test/naming/test/ImplUnitTestCase.java
===================================================================
--- branches/Branch_4_2/testsuite/src/main/org/jboss/test/naming/test/ImplUnitTestCase.java 2007-06-05 02:04:27 UTC (rev 63338)
+++ branches/Branch_4_2/testsuite/src/main/org/jboss/test/naming/test/ImplUnitTestCase.java 2007-06-05 02:05:22 UTC (rev 63339)
@@ -33,6 +33,8 @@
import javax.naming.Context;
import javax.naming.InitialContext;
import javax.naming.NameAlreadyBoundException;
+import javax.naming.NameClassPair;
+import javax.naming.NamingEnumeration;
import javax.naming.NamingException;
import javax.naming.Name;
import javax.naming.spi.StateFactory;
@@ -101,6 +103,58 @@
log.debug("lookup('') = "+obj);
}
+ /**
+ * Validate that bind("x", null) works
+ *
+ */
+ public void testBindNull()
+ throws Exception
+ {
+ log.debug("+++ testBindNull");
+ InitialContext ctx = getInitialContext();
+ ctx.bind("testBindNull", null);
+ Object x = ctx.lookup("testBindNull");
+ assertNull("testBindNull", x);
+ NamingEnumeration<NameClassPair> ncps = ctx.list("");
+ NameClassPair testBindNullNCP = null;
+ while( ncps.hasMore() )
+ {
+ NameClassPair ncp = ncps.next();
+ if( ncp.getName().equals("testBindNull") )
+ {
+ testBindNullNCP = ncp;
+ break;
+ }
+ }
+ assertTrue("testBindNull NameClassPair != null", testBindNullNCP != null);
+ }
+
+ /**
+ * Validate that rebind("x", null) works
+ *
+ */
+ public void testRebindNull()
+ throws Exception
+ {
+ log.debug("+++ testRebindNull");
+ InitialContext ctx = getInitialContext();
+ ctx.bind("testRebindNull", null);
+ Object x = ctx.lookup("testRebindNull");
+ assertNull("testRebindNull", x);
+ NamingEnumeration<NameClassPair> ncps = ctx.list("");
+ NameClassPair testBindNullNCP = null;
+ while( ncps.hasMore() )
+ {
+ NameClassPair ncp = ncps.next();
+ if( ncp.getName().equals("testRebindNull") )
+ {
+ testBindNullNCP = ncp;
+ break;
+ }
+ }
+ assertTrue("testRebindNull NameClassPair != null", testBindNullNCP != null);
+ }
+
public void testEncPerf() throws Exception
{
int count = Integer.getInteger("jbosstest.threadcount", 10).intValue();
More information about the jboss-cvs-commits
mailing list