Skip to content

Latest commit

 

History

History
49 lines (33 loc) · 1.12 KB

README.md

File metadata and controls

49 lines (33 loc) · 1.12 KB

JNDI for JUnit4

this library is JNDI mock implementation for testing with JUnit4.x

USAGE

INSTALL

$ git clone git://github.com/gensan/junit-jndi.git junit-jndi
$ cd junit-jndi
$ mvn install

and write dependency in your pom.xml

<dependency>
  <groupId>junit-jndi</groupId>
  <artifactId>junit-jndi</artifactId>
  <version>1.0-SNAPSHOT</version>
</dependency>

HOW TO WRITE TESTCASE WITH JNDI-JUNIT

It's very simple to use.

Please see JndiJunitTest.java for more details.

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"));
	}

}

LICENSE