Java Code Examples for org.pentaho.di.core.KettleClientEnvironment#init()

The following examples show how to use org.pentaho.di.core.KettleClientEnvironment#init() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: RestorePDIEnvironment.java    From pentaho-kettle with Apache License 2.0 6 votes vote down vote up
void defaultInit() throws Throwable {
  // make sure static class initializers are correctly initialized
  // re-init
  cleanUp();
  KettleClientEnvironment.init();

  // initialize some classes, this will fail if some tests init this classes before any PDI init()
  // the best thing to do is to invoke this ClassRule in every test
  Class.forName( Database.class.getName() );
  Class.forName( Timestamp.class.getName() );
  Class.forName( ValueMetaBase.class.getName() );
  Class.forName( SimpleTimestampFormat.class.getName() );
  Class.forName( SimpleDateFormat.class.getName() );
  Class.forName( XMLHandler.class.getName() );
  Class.forName( LogChannel.class.getName() );
  DatabaseMeta.init();
  ExtensionPointMap.getInstance().reInitialize();
  KettleVFS.getInstance().reset(); // reinit
}
 
Example 2
Source File: RepositoryCleanupUtil.java    From pentaho-kettle with Apache License 2.0 6 votes vote down vote up
/**
 * Use REST API to authenticate provided credentials
 * 
 * @throws Exception
 */
@VisibleForTesting
void authenticateLoginCredentials() throws Exception {
  KettleClientEnvironment.init();

  if ( client == null ) {
    ClientConfig clientConfig = new DefaultClientConfig();
    clientConfig.getFeatures().put( JSONConfiguration.FEATURE_POJO_MAPPING, Boolean.TRUE );
    client = Client.create( clientConfig );
    client.addFilter( new HTTPBasicAuthFilter( username, Encr.decryptPasswordOptionallyEncrypted( password ) ) );
  }

  WebResource resource = client.resource( url + AUTHENTICATION + AdministerSecurityAction.NAME );
  String response = resource.get( String.class );

  if ( !response.equals( "true" ) ) {
    throw new Exception( Messages.getInstance().getString( "REPOSITORY_CLEANUP_UTIL.ERROR_0012.ACCESS_DENIED" ) );
  }
}
 
Example 3
Source File: OracleDatabaseMetaTest.java    From pentaho-kettle with Apache License 2.0 5 votes vote down vote up
@Before
public void setupOnce() throws Exception {
  nativeMeta = new OracleDatabaseMeta();
  odbcMeta = new OracleDatabaseMeta();
  ociMeta = new OracleDatabaseMeta();
  nativeMeta.setAccessType( DatabaseMeta.TYPE_ACCESS_NATIVE );
  odbcMeta.setAccessType( DatabaseMeta.TYPE_ACCESS_ODBC );
  ociMeta.setAccessType( DatabaseMeta.TYPE_ACCESS_OCI );
  //nativeMeta.setSupportsTimestampDataType( true );
  KettleClientEnvironment.init();
}
 
Example 4
Source File: OracleRDBDatabaseMetaTest.java    From pentaho-kettle with Apache License 2.0 5 votes vote down vote up
@Before
public void setupOnce() throws Exception {
  nativeMeta = new OracleRDBDatabaseMeta();
  odbcMeta = new OracleRDBDatabaseMeta();
  jndiMeta = new OracleRDBDatabaseMeta();
  nativeMeta.setAccessType( DatabaseMeta.TYPE_ACCESS_NATIVE );
  odbcMeta.setAccessType( DatabaseMeta.TYPE_ACCESS_ODBC );
  jndiMeta.setAccessType( DatabaseMeta.TYPE_ACCESS_JNDI );
  KettleClientEnvironment.init();
}
 
Example 5
Source File: JobEntryJobIT.java    From pentaho-kettle with Apache License 2.0 5 votes vote down vote up
@BeforeClass
public static void init() throws Exception {
  KettleClientEnvironment.init();
  PluginRegistry.addPluginType( StepPluginType.getInstance() );
  PluginRegistry.init();
  if ( !Props.isInitialized() ) {
    Props.init( 0 );
  }
}
 
Example 6
Source File: SlaveDelegateTest.java    From pentaho-kettle with Apache License 2.0 5 votes vote down vote up
@Before
public void setup() throws KettleException {
  KettleClientEnvironment.init();
  mockPurRepository = mock( PurRepository.class );
  slaveDelegate = new SlaveDelegate( mockPurRepository );

  mockSlaveServer = mock( SlaveServer.class );
  when( mockSlaveServer.getHostname() ).thenReturn( PROP_HOST_NAME_VALUE );
  when( mockSlaveServer.getUsername() ).thenReturn( PROP_USERNAME_VALUE );
  when( mockSlaveServer.getPassword() ).thenReturn( PROP_PASSWORD_VALUE );
  when( mockSlaveServer.getPort() ).thenReturn( PROP_PORT_VALUE );
  when( mockSlaveServer.getProxyHostname() ).thenReturn( PROP_PROXY_HOST_NAME_VALUE );
  when( mockSlaveServer.getProxyPort() ).thenReturn( PROP_PROXY_PORT_VALUE );
  when( mockSlaveServer.getWebAppName() ).thenReturn( PROP_WEBAPP_NAME_VALUE );
  when( mockSlaveServer.getNonProxyHosts() ).thenReturn( PROP_NON_PROXY_HOSTS_VALUE );
  when( mockSlaveServer.isMaster() ).thenReturn( PROP_MASTER_VALUE );
  when( mockSlaveServer.isSslMode() ).thenReturn( PROP_USE_HTTPS_PROTOCOL_VALUE );

  mockDataNode = mock( DataNode.class, RETURNS_DEEP_STUBS );
  when( mockDataNode.hasProperty( SlaveDelegate.PROP_HOST_NAME ) ).thenReturn( true );
  when( mockDataNode.getProperty( SlaveDelegate.PROP_HOST_NAME ).getString() ).thenReturn( PROP_HOST_NAME_VALUE );
  when( mockDataNode.hasProperty( SlaveDelegate.PROP_USERNAME ) ).thenReturn( true );
  when( mockDataNode.getProperty( SlaveDelegate.PROP_USERNAME ).getString() ).thenReturn( PROP_USERNAME_VALUE );
  when( mockDataNode.hasProperty( SlaveDelegate.PROP_PASSWORD ) ).thenReturn( true );
  when( mockDataNode.getProperty( SlaveDelegate.PROP_PASSWORD ).getString() ).thenReturn( PROP_PASSWORD_VALUE );
  when( mockDataNode.hasProperty( SlaveDelegate.PROP_PORT ) ).thenReturn( true );
  when( mockDataNode.getProperty( SlaveDelegate.PROP_PORT ).getString() ).thenReturn( PROP_PORT_VALUE );
  when( mockDataNode.hasProperty( SlaveDelegate.PROP_PROXY_HOST_NAME ) ).thenReturn( true );
  when( mockDataNode.getProperty( SlaveDelegate.PROP_PROXY_HOST_NAME ).getString() ).thenReturn( PROP_PROXY_HOST_NAME_VALUE );
  when( mockDataNode.hasProperty( SlaveDelegate.PROP_PROXY_PORT ) ).thenReturn( true );
  when( mockDataNode.getProperty( SlaveDelegate.PROP_PROXY_PORT ).getString() ).thenReturn( PROP_PROXY_PORT_VALUE );
  when( mockDataNode.hasProperty( SlaveDelegate.PROP_WEBAPP_NAME ) ).thenReturn( true );
  when( mockDataNode.getProperty( SlaveDelegate.PROP_WEBAPP_NAME ).getString() ).thenReturn( PROP_WEBAPP_NAME_VALUE );
  when( mockDataNode.hasProperty( SlaveDelegate.PROP_NON_PROXY_HOSTS ) ).thenReturn( true );
  when( mockDataNode.getProperty( SlaveDelegate.PROP_NON_PROXY_HOSTS ).getString() ).thenReturn( PROP_NON_PROXY_HOSTS_VALUE );
  when( mockDataNode.hasProperty( SlaveDelegate.PROP_MASTER ) ).thenReturn( true );
  when( mockDataNode.getProperty( SlaveDelegate.PROP_MASTER ).getBoolean() ).thenReturn( PROP_MASTER_VALUE );
  when( mockDataNode.hasProperty( SlaveDelegate.PROP_USE_HTTPS_PROTOCOL ) ).thenReturn( true );
  when( mockDataNode.getProperty( SlaveDelegate.PROP_USE_HTTPS_PROTOCOL ).getBoolean() ).thenReturn( PROP_USE_HTTPS_PROTOCOL_VALUE );
}
 
Example 7
Source File: LdapSslProtocolIT.java    From pentaho-kettle with Apache License 2.0 5 votes vote down vote up
@Test
public void testResolvingPasswordAndDecryptVariables() throws KettleException {
  String hostConcrete = "host_concrete";
  String portConcrete = "12345";
  String trustStorePath = "/home/test_path";
  String trustStorePassword = "${PASSWORD_VARIABLE}";
  String trustStorePasswordResolved = "Encrypted 2be98afc86aa7f2e4cb79ff228dc6fa8c"; //original value 123456


  when( mockLdapMeta.getHost() ).thenReturn( hostConcrete );
  when( mockLdapMeta.getPort() ).thenReturn( portConcrete );
  when( mockLdapMeta.getDerefAliases() ).thenReturn( "always" );
  when( mockLdapMeta.getReferrals() ).thenReturn( "follow" );
  when( mockLdapMeta.isUseCertificate() ).thenReturn( true );
  when( mockLdapMeta.isTrustAllCertificates() ).thenReturn( true );
  when( mockLdapMeta.getTrustStorePath() ).thenReturn( trustStorePath );
  when( mockLdapMeta.getTrustStorePassword() ).thenReturn( trustStorePassword );

  when( mockVariableSpace.environmentSubstitute( eq( hostConcrete ) ) ).thenReturn( hostConcrete );
  when( mockVariableSpace.environmentSubstitute( eq( portConcrete ) ) ).thenReturn( portConcrete );
  when( mockVariableSpace.environmentSubstitute( eq( trustStorePath ) ) ).thenReturn( trustStorePath );
  when( mockVariableSpace.environmentSubstitute( eq( trustStorePassword ) ) ).thenReturn( trustStorePasswordResolved );

  KettleClientEnvironment.init();
  TestableLdapProtocol testableLdapProtocol =
          new TestableLdapProtocol( mockLogChannelInterface, mockVariableSpace, mockLdapMeta, null );
  testableLdapProtocol.connect( null, null );
  assertEquals( "123456", testableLdapProtocol.trustStorePassword );
}
 
Example 8
Source File: MQTTConsumerTest.java    From pentaho-kettle with Apache License 2.0 5 votes vote down vote up
@BeforeClass
public static void setupClass() throws Exception {
  KettleClientEnvironment.init();
  PluginRegistry.addPluginType( StepPluginType.getInstance() );
  PluginRegistry.init();
  if ( !Props.isInitialized() ) {
    Props.init( 0 );
  }
  StepPluginType.getInstance().handlePluginAnnotation(
    MQTTConsumerMeta.class,
    MQTTConsumerMeta.class.getAnnotation( org.pentaho.di.core.annotations.Step.class ),
    Collections.emptyList(), false, null );
}
 
Example 9
Source File: DataSetTest.java    From pentaho-pdi-dataset with Apache License 2.0 5 votes vote down vote up
@Override
protected void setUp() throws Exception {
  KettleClientEnvironment.init();
  metaStore = new MemoryMetaStore();
  databaseMeta = new DatabaseMeta( "dataset", "H2", "JDBC", null, "/tmp/datasets", null, null, null );
  dataSetGroup = new DataSetGroup( GROUP_TYPE, GROUP_NAME, GROUP_DESC, databaseMeta, GROUP_SCHEMA );

  List<DataSetField> fields = new ArrayList<>();
  for ( int i = 0; i < NR_FIELDS; i++ ) {
    fields.add( new DataSetField( "field" + i, "column" + i, ValueMetaInterface.TYPE_STRING, 50, 0, "comment" + i, null ) );
  }
  dataSet = new DataSet( NAME, DESC, dataSetGroup, TABLE, fields );
}
 
Example 10
Source File: JmsConsumerMetaTest.java    From pentaho-kettle with Apache License 2.0 5 votes vote down vote up
@BeforeClass
public static void init() throws Exception {
  KettleClientEnvironment.init();
  PluginRegistry.addPluginType( StepPluginType.getInstance() );
  PluginRegistry.init();
  if ( !Props.isInitialized() ) {
    Props.init( 0 );
  }
  StepPluginType.getInstance().handlePluginAnnotation(
    JmsConsumerMeta.class,
    JmsConsumerMeta.class.getAnnotation( org.pentaho.di.core.annotations.Step.class ),
    Collections.emptyList(), false, null );
}
 
Example 11
Source File: MailTest.java    From pentaho-kettle with Apache License 2.0 4 votes vote down vote up
@BeforeClass
public static void setupBeforeClass() throws KettleException {
  wasMailMimeCharset = System.getProperty( MAIL_CHARSET_KEY );
  wasFileEncoding = System.getProperty( FILE_ENCODING_KEY );
  KettleClientEnvironment.init();
}
 
Example 12
Source File: MemoryGroupByAggregationTest.java    From pentaho-kettle with Apache License 2.0 4 votes vote down vote up
@BeforeClass
public static void setUpBeforeClass() throws KettleException {
  KettleClientEnvironment.init();
}
 
Example 13
Source File: ConnectionPoolUtilTest.java    From pentaho-kettle with Apache License 2.0 4 votes vote down vote up
@BeforeClass
public static void setupBeforeClass() throws KettleException {
  KettleClientEnvironment.init();
}
 
Example 14
Source File: JobEntryHTTP_PDI_18044_Test.java    From pentaho-kettle with Apache License 2.0 4 votes vote down vote up
@BeforeClass
public static void setupBeforeClass() throws KettleException, IOException {
  KettleClientEnvironment.init();
  JobEntryHTTP_PDI_18044_Test.startHTTPServer();
}
 
Example 15
Source File: DatabaseTest.java    From pentaho-kettle with Apache License 2.0 4 votes vote down vote up
@BeforeClass
public static void setUpClass() throws Exception {
  KettleClientEnvironment.init();
}
 
Example 16
Source File: PGBulkLoaderTest.java    From pentaho-kettle with Apache License 2.0 4 votes vote down vote up
@BeforeClass
public static void setupBeforeClass() throws KettleException {
  KettleClientEnvironment.init();
}
 
Example 17
Source File: RestIT.java    From pentaho-kettle with Apache License 2.0 4 votes vote down vote up
@BeforeClass
public static void setupBeforeClass() throws KettleException {
  KettleClientEnvironment.init();
}
 
Example 18
Source File: RedshiftDatabaseMetaTest.java    From pentaho-kettle with Apache License 2.0 4 votes vote down vote up
@BeforeClass
public static void beforeClass() throws KettleException {
  KettleClientEnvironment.init();
}
 
Example 19
Source File: PluginRegistryConcurrencyTest.java    From pentaho-kettle with Apache License 2.0 4 votes vote down vote up
@BeforeClass
public static void initKettle() throws Exception {
  KettleClientEnvironment.init();
}
 
Example 20
Source File: JsonInputAnalyzerTest.java    From pentaho-kettle with Apache License 2.0 4 votes vote down vote up
@BeforeClass
public static void init() throws KettleException {
  KettleClientEnvironment.init();
}