1 package org.wamblee.support.jndi;
3 import static junit.framework.Assert.assertEquals;
5 import javax.naming.InitialContext;
6 import javax.naming.NamingException;
8 import org.junit.After;
9 import org.junit.Before;
10 import org.junit.Test;
11 import org.wamblee.support.jndi.StubInitialContextFactory;
13 public class StubInitiaContextFactoryTest {
18 StubInitialContextFactory.unregister();
22 @Test(expected = NamingException.class)
23 public void testLookupNotRegistered() throws Exception {
24 InitialContext ctx = new InitialContext();
25 ctx.bind("a/b", "hallo");
29 public void testLookup() throws Exception {
30 StubInitialContextFactory.register();
32 InitialContext ctx = new InitialContext();
33 ctx.bind("a/b", "hallo");
35 ctx = new InitialContext();
36 Object obj = ctx.lookup("a/b");
38 assertEquals("hallo", obj);