In a nutshell. If you want to mock the JNDI tree using mock InitialContext in unit tests, you can use SimpleNamingContextBuilder. I created an instance of SimpleNamingContextBuildeit in the launch method for testing and successfully created the source code in memory. for example in the spring testing class ..
@BeforeClass public static void setupJndi() throws Exception { SimpleNamingContextBuilder.emptyActivatedContextBuilder(); Context context = new InitialContext(); context.bind("java:comp/env/jms/ConnectionFactory",myJmsConnectionFactory); }
supernova
source share