1 Reply Latest reply on Jan 4, 2005 2:56 PM by Scott Stark

    local JBossNS without opening socket or discovery

    mazz Master

      I have a JUnit test that needs to bind and lookup things in JNDI.

      I do not want to have the full JNDI featureset enabled - that is, I don't want the JNDI SPI to try to discovery any remote naming servers and I don't even want the JNDI SPI to open a socket and enable itself to be accessible to remote clients. I want the JUnit to run as fast as possible and not use networking resources if at all possible.

      I have jnp.disableDiscovery set to true in my initial context:

      String ip = InetAddress.getLocalHost( ).getHostAddress( );
      Hashtable env = new Hashtable( );
      env.put( Context.INITIAL_CONTEXT_FACTORY, "org.jnp.interfaces.NamingContextFactory" );
      env.put( Context.PROVIDER_URL, "jnp://" + ip );
      env.put( Context.URL_PKG_PREFIXES, "org.jboss.naming:org.jnp.interfaces" );
      env.put( NamingContext.JNP_DISABLE_DISCOVERY, "true" );
      m_initialContext = new InitialContext( env );

      Is there a way to say, "just use an internal JNDI provider without opening server sockets or going out on the network looking for JNDI servers?

        • 1. Re: local JBossNS without opening socket or discovery
          Scott Stark Master

          You need to create a testcase naming server. See the org.jboss.test.naming.test.NamingServerSetup in the testsuite. Its setup method should just be something like:

           protected void setUp() throws Exception
           namingServer = new Main();
           namingServer.setLookupPool(new BasicThreadPool());