From: Scott M S. <st...@us...> - 2002-08-13 00:56:29
|
User: starksm Date: 02/08/12 17:56:28 Modified: src/main/org/jboss/test/naming/test Tag: Branch_3_2 SimpleUnitTestCase.java Log: Add a test of using the http invoker based initial context factory to access the JBoss JNDI tree Revision Changes Path No revision No revision 1.2.4.1 +26 -2 jbosstest/src/main/org/jboss/test/naming/test/SimpleUnitTestCase.java Index: SimpleUnitTestCase.java =================================================================== RCS file: /cvsroot/jboss/jbosstest/src/main/org/jboss/test/naming/test/SimpleUnitTestCase.java,v retrieving revision 1.2 retrieving revision 1.2.4.1 diff -u -r1.2 -r1.2.4.1 --- SimpleUnitTestCase.java 15 Sep 2001 19:50:39 -0000 1.2 +++ SimpleUnitTestCase.java 13 Aug 2002 00:56:28 -0000 1.2.4.1 @@ -6,15 +6,19 @@ */ package org.jboss.test.naming.test; +import java.util.Properties; +import javax.naming.Context; import javax.naming.InitialContext; import javax.naming.NameAlreadyBoundException; +import javax.naming.NamingEnumeration; import javax.naming.NamingException; import junit.framework.Test; import org.jboss.test.JBossTestCase; -/** - * simple unit tests for the jndi implementation. +/** Simple unit tests for the jndi implementation. + @author Sco...@jb... + @version $Revision: 1.2.4.1 $ */ public class SimpleUnitTestCase extends JBossTestCase { @@ -49,5 +53,25 @@ ctx.createSubcontext("foo/bar"); ctx.unbind("foo/bar"); ctx.unbind("foo"); + } + + public void testHttpInvoker() throws Exception + { + Properties env = new Properties(); + env.setProperty(Context.INITIAL_CONTEXT_FACTORY, "org.jboss.naming.HttpNamingContextFactory"); + env.setProperty(Context.PROVIDER_URL, "http://localhost:8080/http-invoker/invokers/NamingFactoryServlet"); + getLog().debug("Creating InitialContext with env="+env); + InitialContext ctx = new InitialContext(env); + getLog().debug("Created InitialContext"); + Object obj = ctx.lookup("invokers"); + getLog().debug("lookup(invokers) : "+obj); + Context invokersCtx = (Context) obj; + NamingEnumeration list = invokersCtx.list(""); + while( list.hasMore() ) + { + Object entry = list.next(); + getLog().debug(" + "+entry); + } + ctx.close(); } } |