Skip to content

gentarooka/junit-jndi

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

16 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

About

simple jndi mock for testing with JUnit

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages