@Test public void testInitJNDI() throws Exception { final String factoryInitialKey = "java.naming.factory.initial"; final String factoryInitialBak = System.getProperty( factoryInitialKey ); final String sjRootKey = "org.osjava.sj.root"; final String sjRootBak = System.getProperty( sjRootKey ); final String sjDelimiterKey = "org.osjava.sj.root"; final String sjDelimiterBak = System.getProperty( sjDelimiterKey ); System.clearProperty( factoryInitialKey ); System.clearProperty( sjRootKey ); System.clearProperty( sjDelimiterKey ); JndiUtil.initJNDI(); try { assertFalse( System.getProperty( factoryInitialKey ).isEmpty() ); assertFalse( System.getProperty( sjRootKey ).isEmpty() ); assertFalse( System.getProperty( sjDelimiterKey ).isEmpty() ); assertEquals( System.getProperty( sjRootKey ), Const.JNDI_DIRECTORY ); } finally { if ( factoryInitialBak != null ) { System.setProperty( factoryInitialKey, factoryInitialBak ); } if ( sjRootBak != null ) { System.setProperty( sjRootKey, sjRootBak ); } if ( sjDelimiterBak != null ) { System.setProperty( sjDelimiterKey, sjDelimiterBak ); } } }
public static void initJNDI() throws KettleException { String path = Const.JNDI_DIRECTORY; if ( path == null || path.equals( "" ) ) { try { File file = new File( "simple-jndi" ); path = file.getCanonicalPath(); } catch ( Exception e ) { throw new KettleException( "Error initializing JNDI", e ); } Const.JNDI_DIRECTORY = path; } System.setProperty( "java.naming.factory.initial", "org.osjava.sj.SimpleContextFactory" ); System.setProperty( "org.osjava.sj.root", path ); System.setProperty( "org.osjava.sj.delimiter", "/" ); }
JndiUtil { public static void initJNDI() throws KettleException { String path = Const.JNDI_DIRECTORY; if ( path == null || path.equals( "" ) ) { try { File file = new File( "simple-jndi" ); path = file.getCanonicalPath(); } catch ( Exception e ) { throw new KettleException( "Error initializing JNDI", e ); } Const.JNDI_DIRECTORY = path; } System.setProperty( "java.naming.factory.initial", "org.osjava.sj.SimpleContextFactory" ); System.setProperty( "org.osjava.sj.root", path ); System.setProperty( "org.osjava.sj.delimiter", "/" ); } }
JndiUtil { public static void initJNDI() throws KettleException { String path = Const.JNDI_DIRECTORY; if ( path == null || path.equals( "" ) ) { try { File file = new File( "simple-jndi" ); path = file.getCanonicalPath(); } catch ( Exception e ) { throw new KettleException( "Error initializing JNDI", e ); } Const.JNDI_DIRECTORY = path; } System.setProperty( "java.naming.factory.initial", "org.osjava.sj.SimpleContextFactory" ); System.setProperty( "org.osjava.sj.root", path ); System.setProperty( "org.osjava.sj.delimiter", "/" ); }  }
JndiUtil { public static void initJNDI() throws KettleException { String path = Const.JNDI_DIRECTORY; if ( path == null || path.equals( "" ) ) { try { File file = new File( "simple-jndi" ); path = file.getCanonicalPath(); } catch ( Exception e ) { throw new KettleException( "Error initializing JNDI", e ); } Const.JNDI_DIRECTORY = path; } System.setProperty( "java.naming.factory.initial", "org.osjava.sj.SimpleContextFactory" ); System.setProperty( "org.osjava.sj.root", path ); System.setProperty( "org.osjava.sj.delimiter", "/" ); }  static void initJNDI(); }
JndiUtil { public static void initJNDI() throws KettleException { String path = Const.JNDI_DIRECTORY; if ( path == null || path.equals( "" ) ) { try { File file = new File( "simple-jndi" ); path = file.getCanonicalPath(); } catch ( Exception e ) { throw new KettleException( "Error initializing JNDI", e ); } Const.JNDI_DIRECTORY = path; } System.setProperty( "java.naming.factory.initial", "org.osjava.sj.SimpleContextFactory" ); System.setProperty( "org.osjava.sj.root", path ); System.setProperty( "org.osjava.sj.delimiter", "/" ); }  static void initJNDI();  }