package junitjndi;

import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.CoreMatchers.notNullValue;
import static org.junit.Assert.assertThat;

import javax.naming.Context;
import javax.naming.InitialContext;
import javax.naming.NamingException;

import org.junit.ClassRule;
import org.junit.Test;

public class JUnitJndiTest {
	
	@ClassRule
	public static JndiRule jndi = new JndiRule() {
		@Override
		protected void bind(Context context) throws NamingException {
			context.bind("someobj", new Object());
			context.bind("somestring", "abc");
		}
	};
	
	
	@Test
	public void lookup() throws NamingException {
		assertThat(new InitialContext().lookup("someobj"), is(notNullValue(Object.class)));
		assertThat((String)new InitialContext().lookup("somestring"), is("abc"));
	}
	
	@Test(expected=NamingException.class)
	public void lookupNothing() throws NamingException {
		new InitialContext().lookup("ohter");
	}

}
@@ -790,16 +790,231 @@
 );%0A%09%7D%0A%09%0A
+%09@Test%0A%09public void doLookup() throws NamingException %7B%0A%09%09assertThat(InitialContext.doLookup(%22someobj%22), is(notNullValue(Object.class)));%0A%09%09assertThat((String)InitialContext.doLookup(%22somestring%22), is(%22abc%22));%0A%09%7D%0A%09%0A
 %09@Test(e
@@ -1140,11 +1140,51 @@
 er%22);%0A%09%7D
+%0A%09%0A%09@Test%0A%09public void lookup2() %7B%0A%09%09%0A%09%7D
 %0A%0A%7D

add test