[jboss-cvs] JBossAS SVN: r63338 - in trunk: 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:04:27 EDT 2007
Author: scott.stark at jboss.org
Date: 2007-06-04 22:04:27 -0400 (Mon, 04 Jun 2007)
New Revision: 63338
Modified:
trunk/naming/src/main/org/jnp/interfaces/NamingContext.java
trunk/testsuite/src/main/org/jboss/test/naming/test/ImplUnitTestCase.java
Log:
JBAS-4461, handle bind/rebind of a null value.
Modified: trunk/naming/src/main/org/jnp/interfaces/NamingContext.java
===================================================================
--- trunk/naming/src/main/org/jnp/interfaces/NamingContext.java 2007-06-04 20:33:40 UTC (rev 63337)
+++ trunk/naming/src/main/org/jnp/interfaces/NamingContext.java 2007-06-05 02:04:27 UTC (rev 63338)
@@ -494,7 +494,7 @@
try
{
- String className;
+ String className = null;
// Referenceable
if (obj instanceof Referenceable)
@@ -502,7 +502,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);
}
@@ -548,7 +549,7 @@
try
{
- String className;
+ String className = null;
// Referenceable
if (obj instanceof Referenceable)
@@ -556,8 +557,9 @@
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: trunk/testsuite/src/main/org/jboss/test/naming/test/ImplUnitTestCase.java
===================================================================
--- trunk/testsuite/src/main/org/jboss/test/naming/test/ImplUnitTestCase.java 2007-06-04 20:33:40 UTC (rev 63337)
+++ trunk/testsuite/src/main/org/jboss/test/naming/test/ImplUnitTestCase.java 2007-06-05 02:04:27 UTC (rev 63338)
@@ -1,24 +1,24 @@
/*
- * JBoss, Home of Professional Open Source
- * Copyright 2005, JBoss Inc., and individual contributors as indicated
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
+ * JBoss, Home of Professional Open Source
+ * Copyright 2006, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
package org.jboss.test.naming.test;
@@ -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