Issue #817
This commit is contained in:
parent
5cb50e5f5d
commit
6f643d6982
|
@ -57,9 +57,18 @@ public abstract class NamingEntry
|
|||
}
|
||||
|
||||
|
||||
/**
|
||||
* Create a naming entry.
|
||||
*
|
||||
* @param scope an object representing the scope of the name to be bound into jndi, where null means jvm scope.
|
||||
* @param jndiName the name that will be associated with an object bound into jndi
|
||||
* @throws NamingException
|
||||
*/
|
||||
protected NamingEntry (Object scope, String jndiName)
|
||||
throws NamingException
|
||||
{
|
||||
if (jndiName == null)
|
||||
throw new NamingException("jndi name is null");
|
||||
this._scope=scope;
|
||||
this._jndiName = jndiName;
|
||||
}
|
||||
|
|
|
@ -23,6 +23,7 @@ import static org.junit.Assert.assertFalse;
|
|||
import static org.junit.Assert.assertNotNull;
|
||||
import static org.junit.Assert.assertNull;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.junit.Assert.fail;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Hashtable;
|
||||
|
@ -241,6 +242,35 @@ public class TestNamingEntries
|
|||
testLink();
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testNullJndiName () throws Exception
|
||||
{
|
||||
try
|
||||
{
|
||||
InitialContext icontext = new InitialContext();
|
||||
Resource resource = new Resource (null,"foo");
|
||||
fail ("Null jndi name should not be permitted");
|
||||
}
|
||||
catch (NamingException e)
|
||||
{
|
||||
//expected
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testNullObject () throws Exception
|
||||
{
|
||||
InitialContext icontext = new InitialContext();
|
||||
Resource resource = new Resource ("foo/bar", null);
|
||||
NamingEntry ne = NamingEntryUtil.lookupNamingEntry(null, "foo/bar");
|
||||
assertNotNull(ne);
|
||||
Object o = icontext.lookup("foo/bar");
|
||||
assertNull(o);
|
||||
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testLink () throws Exception
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue