Search in sources :

Example 16 with Variables

use of org.pentaho.di.core.variables.Variables in project pentaho-kettle by pentaho.

the class OracleDatabaseMetaTest method testOverriddenSettings.

@Test
public void testOverriddenSettings() throws Exception {
    // Tests the settings of the Oracle Database Meta
    // according to the features of the DB as we know them
    assertEquals(1521, nativeMeta.getDefaultDatabasePort());
    assertEquals(-1, odbcMeta.getDefaultDatabasePort());
    assertFalse(nativeMeta.supportsAutoInc());
    assertFalse(nativeMeta.needsToLockAllTables());
    assertEquals("oracle.jdbc.driver.OracleDriver", nativeMeta.getDriverClass());
    assertEquals("sun.jdbc.odbc.JdbcOdbcDriver", odbcMeta.getDriverClass());
    assertEquals("jdbc:odbc:FOO", odbcMeta.getURL(null, null, "FOO"));
    assertEquals("jdbc:oracle:thin:@FOO:1024:BAR", nativeMeta.getURL("FOO", "1024", "BAR"));
    assertEquals("jdbc:oracle:thin:@FOO:11:BAR", nativeMeta.getURL("FOO", "11", ":BAR"));
    assertEquals("jdbc:oracle:thin:@BAR:65534/FOO", nativeMeta.getURL("BAR", "65534", "/FOO"));
    assertEquals("jdbc:oracle:thin:@FOO", nativeMeta.getURL("", "", "FOO"));
    assertEquals("jdbc:oracle:thin:@FOO", nativeMeta.getURL(null, "-1", "FOO"));
    assertEquals("jdbc:oracle:thin:@FOO", nativeMeta.getURL(null, null, "FOO"));
    assertEquals("jdbc:oracle:thin:@FOO:1234:BAR", nativeMeta.getURL("FOO", "1234", "BAR"));
    // Pretty sure this is a bug...
    assertEquals("jdbc:oracle:thin:@", nativeMeta.getURL("", "", ""));
    assertEquals("jdbc:oracle:oci:@BAR", ociMeta.getURL(null, null, "BAR"));
    assertEquals("jdbc:oracle:oci:@(description=(address=(host=FOO)(protocol=tcp)(port=9876))(connect_data=(sid=BAR)))", ociMeta.getURL("FOO", "9876", "BAR"));
    try {
        ociMeta.getURL(null, null, null);
        fail("Expected KettleDatabaseException here");
    } catch (KettleDatabaseException expected) {
    // Keep going ...
    }
    try {
        ociMeta.getURL("", "", "");
        fail("Expected KettleDatabaseException here");
    } catch (KettleDatabaseException expected) {
    // Keep going ...
    }
    assertFalse(nativeMeta.supportsOptionsInURL());
    assertTrue(nativeMeta.supportsSequences());
    assertTrue(nativeMeta.supportsSequenceNoMaxValueOption());
    assertTrue(nativeMeta.useSchemaNameForTableList());
    assertTrue(nativeMeta.supportsSynonyms());
    String[] reservedWords = new String[] { "ACCESS", "ADD", "ALL", "ALTER", "AND", "ANY", "ARRAYLEN", "AS", "ASC", "AUDIT", "BETWEEN", "BY", "CHAR", "CHECK", "CLUSTER", "COLUMN", "COMMENT", "COMPRESS", "CONNECT", "CREATE", "CURRENT", "DATE", "DECIMAL", "DEFAULT", "DELETE", "DESC", "DISTINCT", "DROP", "ELSE", "EXCLUSIVE", "EXISTS", "FILE", "FLOAT", "FOR", "FROM", "GRANT", "GROUP", "HAVING", "IDENTIFIED", "IMMEDIATE", "IN", "INCREMENT", "INDEX", "INITIAL", "INSERT", "INTEGER", "INTERSECT", "INTO", "IS", "LEVEL", "LIKE", "LOCK", "LONG", "MAXEXTENTS", "MINUS", "MODE", "MODIFY", "NOAUDIT", "NOCOMPRESS", "NOT", "NOTFOUND", "NOWAIT", "NULL", "NUMBER", "OF", "OFFLINE", "ON", "ONLINE", "OPTION", "OR", "ORDER", "PCTFREE", "PRIOR", "PRIVILEGES", "PUBLIC", "RAW", "RENAME", "RESOURCE", "REVOKE", "ROW", "ROWID", "ROWLABEL", "ROWNUM", "ROWS", "SELECT", "SESSION", "SET", "SHARE", "SIZE", "SMALLINT", "SQLBUF", "START", "SUCCESSFUL", "SYNONYM", "SYSDATE", "TABLE", "THEN", "TO", "TRIGGER", "UID", "UNION", "UNIQUE", "UPDATE", "USER", "VALIDATE", "VALUES", "VARCHAR", "VARCHAR2", "VIEW", "WHENEVER", "WHERE", "WITH" };
    assertArrayEquals(reservedWords, nativeMeta.getReservedWords());
    assertEquals("http://download.oracle.com/docs/cd/B19306_01/java.102/b14355/urls.htm#i1006362", nativeMeta.getExtraOptionsHelpText());
    assertArrayEquals(new String[] { "ojdbc14.jar", "orai18n.jar" }, nativeMeta.getUsedLibraries());
    assertTrue(nativeMeta.requiresCreateTablePrimaryKeyAppend());
    assertFalse(nativeMeta.supportsPreparedStatementMetadataRetrieval());
    String quoteTest1 = "FOO 'BAR' \r TEST \n";
    String quoteTest2 = "FOO 'BAR' \\r TEST \\n";
    assertEquals("'FOO ''BAR'' '||chr(10)||' TEST '||chr(13)||''", nativeMeta.quoteSQLString(quoteTest1));
    assertEquals("'FOO ''BAR'' \\r TEST \\n'", nativeMeta.quoteSQLString(quoteTest2));
    assertFalse(nativeMeta.releaseSavepoint());
    Variables v = new Variables();
    v.setVariable("FOOVARIABLE", "FOOVALUE");
    DatabaseMeta dm = new DatabaseMeta();
    dm.setDatabaseInterface(nativeMeta);
    assertEquals("TABLESPACE FOOVALUE", nativeMeta.getTablespaceDDL(v, dm, "${FOOVARIABLE}"));
    assertEquals("", nativeMeta.getTablespaceDDL(v, dm, ""));
    assertFalse(nativeMeta.supportsErrorHandlingOnBatchUpdates());
    assertTrue(nativeMeta.supportsRepository());
    assertEquals(2000, nativeMeta.getMaxVARCHARLength());
    assertFalse(nativeMeta.supportsTimestampDataType());
    assertEquals(32, nativeMeta.getMaxColumnsInIndex());
}
Also used : Variables(org.pentaho.di.core.variables.Variables) KettleDatabaseException(org.pentaho.di.core.exception.KettleDatabaseException) ValueMetaString(org.pentaho.di.core.row.value.ValueMetaString) Test(org.junit.Test)

Example 17 with Variables

use of org.pentaho.di.core.variables.Variables in project pentaho-kettle by pentaho.

the class EntryCurrentDirectoryChangedListener method reapplyCurrentDir.

private String reapplyCurrentDir(String oldCurrentDir, String newCurrentDir, String path) {
    Variables vars = new Variables();
    vars.setVariable(Const.INTERNAL_VARIABLE_ENTRY_CURRENT_DIRECTORY, oldCurrentDir);
    String newPath = vars.environmentSubstitute(path);
    return getPath(newCurrentDir, newPath);
}
Also used : Variables(org.pentaho.di.core.variables.Variables)

Example 18 with Variables

use of org.pentaho.di.core.variables.Variables in project pentaho-kettle by pentaho.

the class SalesforceDeleteMetaTest method testGetFields.

@Test
public void testGetFields() throws KettleStepException {
    SalesforceDeleteMeta meta = new SalesforceDeleteMeta();
    meta.setDefault();
    RowMetaInterface r = new RowMeta();
    meta.getFields(r, "thisStep", null, null, new Variables(), null, null);
    assertEquals(0, r.size());
    r.clear();
    r.addValueMeta(new ValueMetaString("testString"));
    meta.getFields(r, "thisStep", null, null, new Variables(), null, null);
    assertEquals(1, r.size());
    assertEquals(ValueMetaInterface.TYPE_STRING, r.getValueMeta(0).getType());
    assertEquals("testString", r.getValueMeta(0).getName());
}
Also used : Variables(org.pentaho.di.core.variables.Variables) ValueMetaString(org.pentaho.di.core.row.value.ValueMetaString) RowMeta(org.pentaho.di.core.row.RowMeta) RowMetaInterface(org.pentaho.di.core.row.RowMetaInterface) SalesforceMetaTest(org.pentaho.di.trans.steps.salesforce.SalesforceMetaTest) Test(org.junit.Test)

Example 19 with Variables

use of org.pentaho.di.core.variables.Variables in project pentaho-kettle by pentaho.

the class SalesforceInputMetaTest method testGetFields.

@Test
public void testGetFields() throws KettleStepException {
    SalesforceInputMeta meta = new SalesforceInputMeta();
    meta.setDefault();
    RowMetaInterface r = new RowMeta();
    meta.getFields(r, "thisStep", null, null, new Variables(), null, null);
    assertEquals(0, r.size());
    meta.setInputFields(new SalesforceInputField[] { new SalesforceInputField("field1") });
    r.clear();
    meta.getFields(r, "thisStep", null, null, new Variables(), null, null);
    assertEquals(1, r.size());
    meta.setIncludeDeletionDate(true);
    meta.setDeletionDateField("DeletionDate");
    meta.setIncludeModule(true);
    meta.setModuleField("ModuleName");
    meta.setIncludeRowNumber(true);
    meta.setRowNumberField("RN");
    meta.setIncludeSQL(true);
    meta.setSQLField("sqlField");
    meta.setIncludeTargetURL(true);
    meta.setTargetURLField("Target");
    meta.setIncludeTimestamp(true);
    meta.setTimestampField("TS");
    r.clear();
    meta.getFields(r, "thisStep", null, null, new Variables(), null, null);
    assertEquals(7, r.size());
    assertTrue(r.indexOfValue("field1") >= 0);
    assertTrue(r.indexOfValue("DeletionDate") >= 0);
    assertTrue(r.indexOfValue("ModuleName") >= 0);
    assertTrue(r.indexOfValue("RN") >= 0);
    assertTrue(r.indexOfValue("sqlField") >= 0);
    assertTrue(r.indexOfValue("Target") >= 0);
    assertTrue(r.indexOfValue("TS") >= 0);
}
Also used : Variables(org.pentaho.di.core.variables.Variables) RowMeta(org.pentaho.di.core.row.RowMeta) RowMetaInterface(org.pentaho.di.core.row.RowMetaInterface) SalesforceMetaTest(org.pentaho.di.trans.steps.salesforce.SalesforceMetaTest) Test(org.junit.Test)

Example 20 with Variables

use of org.pentaho.di.core.variables.Variables in project pentaho-kettle by pentaho.

the class SalesforceInsertMetaTest method testGetFields.

@Test
public void testGetFields() throws KettleStepException {
    SalesforceInsertMeta meta = new SalesforceInsertMeta();
    meta.setDefault();
    RowMetaInterface r = new RowMeta();
    meta.getFields(r, "thisStep", null, null, new Variables(), null, null);
    assertEquals(1, r.size());
    assertEquals("Id", r.getFieldNames()[0]);
    meta.setSalesforceIDFieldName("id_field");
    r.clear();
    meta.getFields(r, "thisStep", null, null, new Variables(), null, null);
    assertEquals(1, r.size());
    assertEquals("id_field", r.getFieldNames()[0]);
}
Also used : Variables(org.pentaho.di.core.variables.Variables) RowMeta(org.pentaho.di.core.row.RowMeta) RowMetaInterface(org.pentaho.di.core.row.RowMetaInterface) SalesforceMetaTest(org.pentaho.di.trans.steps.salesforce.SalesforceMetaTest) Test(org.junit.Test)

Aggregations

Variables (org.pentaho.di.core.variables.Variables)119 Test (org.junit.Test)67 TransMeta (org.pentaho.di.trans.TransMeta)31 ArrayList (java.util.ArrayList)25 CheckResultInterface (org.pentaho.di.core.CheckResultInterface)20 RowMetaInterface (org.pentaho.di.core.row.RowMetaInterface)20 ValueMetaString (org.pentaho.di.core.row.value.ValueMetaString)20 StepMeta (org.pentaho.di.trans.step.StepMeta)18 RowMeta (org.pentaho.di.core.row.RowMeta)17 RowMetaAndData (org.pentaho.di.core.RowMetaAndData)16 VariableSpace (org.pentaho.di.core.variables.VariableSpace)14 Repository (org.pentaho.di.repository.Repository)12 TableView (org.pentaho.di.ui.core.widget.TableView)10 FormAttachment (org.eclipse.swt.layout.FormAttachment)9 FormData (org.eclipse.swt.layout.FormData)9 ColumnInfo (org.pentaho.di.ui.core.widget.ColumnInfo)9 Label (org.eclipse.swt.widgets.Label)8 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)7 SelectionEvent (org.eclipse.swt.events.SelectionEvent)7 DummyTransMeta (org.pentaho.di.trans.steps.dummytrans.DummyTransMeta)7