TeraDataBulkLoader extends BaseStep implements StepInterface { public String[] createEnvironmentVariables() { List<String> varlist = new ArrayList<String>(); StringBuffer libpath = new StringBuffer(); varlist.add( "TWB_ROOT=" + environmentSubstitute( this.meta.getTwbRoot() ) ); varlist.add( "COPLIB=" + environmentSubstitute( this.meta.getCopLibPath() ) ); varlist.add( "COPERR=" + environmentSubstitute( this.meta.getCopLibPath() ) ); libpath.append( environmentSubstitute( this.meta.getLibPath() ) + ":" ); libpath.append( environmentSubstitute( this.meta.getTbuildLibPath() ) + ":" ); libpath.append( environmentSubstitute( this.meta.getTdicuLibPath() ) + ":" ); libpath.append( environmentSubstitute( this.meta.getLibPath() ) + "64:" ); libpath.append( environmentSubstitute( this.meta.getTbuildLibPath() ) + "64:" ); libpath.append( environmentSubstitute( this.meta.getTdicuLibPath() ) + "64:" ); varlist.add( "LD_LIBRARY_PATH=" + libpath.toString() ); return varlist.toArray( new String[varlist.size()] ); } TeraDataBulkLoader( StepMeta stepMeta, StepDataInterface stepDataInterface, int copyNr, TransMeta transMeta,
      Trans trans ); boolean execute( TeraDataBulkLoaderMeta meta ); String createCommandLine(); String[] createEnvironmentVariables(); @Override boolean processRow( StepMetaInterface smi, StepDataInterface sdi ); @Override boolean init( StepMetaInterface smi, StepDataInterface sdi ); @Override void dispose( StepMetaInterface smi, StepDataInterface sdi ); static String[] ActionTypes; static String[] ScriptTypes; static final long DEFAULT_ERROR_CODE; }
@Test public void createEnvironmentVariablesTest() { when( teraDataBulkLoaderMetaMock.getTwbRoot() ).thenReturn( "twbrootvalue" ); when( teraDataBulkLoaderMetaMock.getCopLibPath() ).thenReturn( "coplibpathvalue" ); when( teraDataBulkLoaderMetaMock.getLibPath() ).thenReturn( "libpathvalue" ); when( teraDataBulkLoaderMetaMock.getTbuildLibPath() ).thenReturn( "tbuildlibpathvalue" ); when( teraDataBulkLoaderMetaMock.getTdicuLibPath() ).thenReturn( "tdiculibpathvalue" ); String[] envVariables = teraDataBulkLoader.createEnvironmentVariables(); String expectedVariables = "[TWB_ROOT=twbrootvalue, COPLIB=coplibpathvalue, COPERR=coplibpathvalue, " + "LD_LIBRARY_PATH=libpathvalue:tbuildlibpathvalue:tdiculibpathvalue:libpathvalue64:tbuildlibpathvalue64:tdiculibpathvalue64:]"; assertEquals( expectedVariables, Arrays.toString( envVariables ) ); }
@Test public void createEnvironmentVariablesWithEnvVarTest() { teraDataBulkLoader.setVariable( "TwbRoot", "twbrootvalue" ); teraDataBulkLoader.setVariable( "CopLibPath", "coplibpathvalue" ); teraDataBulkLoader.setVariable( "LibPath", "libpathvalue" ); teraDataBulkLoader.setVariable( "TbuildLibPath", "tbuildlibpathvalue" ); teraDataBulkLoader.setVariable( "TdicuLibPath", "tdiculibpathvalue" ); when( teraDataBulkLoaderMetaMock.getTwbRoot() ).thenReturn( "${TwbRoot}" ); when( teraDataBulkLoaderMetaMock.getCopLibPath() ).thenReturn( "${CopLibPath}" ); when( teraDataBulkLoaderMetaMock.getLibPath() ).thenReturn( "${LibPath}" ); when( teraDataBulkLoaderMetaMock.getTbuildLibPath() ).thenReturn( "${TbuildLibPath}" ); when( teraDataBulkLoaderMetaMock.getTdicuLibPath() ).thenReturn( "${TdicuLibPath}" ); String[] envVariables = teraDataBulkLoader.createEnvironmentVariables(); String expectedVariables = "[TWB_ROOT=twbrootvalue, COPLIB=coplibpathvalue, COPERR=coplibpathvalue, " + "LD_LIBRARY_PATH=libpathvalue:tbuildlibpathvalue:tdiculibpathvalue:libpathvalue64:tbuildlibpathvalue64:tdiculibpathvalue64:]"; assertEquals( expectedVariables, Arrays.toString( envVariables ) ); }