Merge remote-tracking branch 'origin/jetty-9.3.x' into jetty-9.4.x

This commit is contained in:
Jan Bartel 2016-08-05 18:26:39 +10:00
commit 9984ff533b
2 changed files with 39 additions and 0 deletions

View File

@ -55,9 +55,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;
}

View File

@ -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;
@ -238,6 +239,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
{