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());
}
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);
}
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());
}
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);
}
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]);
}
Aggregations