use of org.pentaho.di.core.database.MySQLDatabaseMeta in project pentaho-kettle by pentaho.
the class MySQLBulkLoaderTest method setUp.
@Before
public void setUp() {
TransMeta transMeta = new TransMeta();
transMeta.setName("MysqlBulkLoader");
Map<String, String> vars = new HashMap<String, String>();
vars.put("delim", ",");
vars.put("enclos", "'");
vars.put("charset", "UTF8");
vars.put("tbl", "sometable");
vars.put("schema", "someschema");
transMeta.injectVariables(vars);
MySQLDatabaseMeta mysql = new MySQLDatabaseMeta();
mysql.setName("MySQL");
DatabaseMeta dbMeta = new DatabaseMeta();
dbMeta.setDatabaseInterface(mysql);
dbMeta.setQuoteAllFields(true);
lmeta = new MySQLBulkLoaderMeta();
lmeta.setDelimiter("${delim}");
lmeta.setEnclosure("${enclos}");
lmeta.setEncoding("${charset}");
lmeta.setTableName("${tbl}");
lmeta.setSchemaName("${schema}");
lmeta.setDatabaseMeta(dbMeta);
ldata = new MySQLBulkLoaderData();
PluginRegistry plugReg = PluginRegistry.getInstance();
String mblPid = plugReg.getPluginId(StepPluginType.class, lmeta);
smeta = new StepMeta(mblPid, "MySqlBulkLoader", lmeta);
Trans trans = new Trans(transMeta);
transMeta.addStep(smeta);
lder = new MySQLBulkLoader(smeta, ldata, 1, transMeta, trans);
lder.copyVariablesFrom(transMeta);
}
use of org.pentaho.di.core.database.MySQLDatabaseMeta in project pentaho-kettle by pentaho.
the class DatabaseLookupUTest method testEqualsAndIsNullAreCached.
@Test
public void testEqualsAndIsNullAreCached() throws Exception {
when(mockHelper.logChannelInterfaceFactory.create(any(), any(LoggingObjectInterface.class))).thenReturn(mockHelper.logChannelInterface);
DatabaseLookup look = new MockDatabaseLookup(mockHelper.stepMeta, mockHelper.stepDataInterface, 0, mockHelper.transMeta, mockHelper.trans);
DatabaseLookupData lookData = new DatabaseLookupData();
lookData.cache = DefaultCache.newCache(lookData, 0);
lookData.lookupMeta = new RowMeta();
MySQLDatabaseMeta mysql = new MySQLDatabaseMeta();
mysql.setName("MySQL");
DatabaseMeta dbMeta = new DatabaseMeta();
dbMeta.setDatabaseInterface(mysql);
DatabaseLookupMeta meta = new DatabaseLookupMeta();
meta.setDatabaseMeta(dbMeta);
meta.setTablename("VirtualTable");
meta.setTableKeyField(new String[] { "ID1", "ID2" });
meta.setKeyCondition(new String[] { "=", "IS NULL" });
meta.setReturnValueNewName(new String[] { "val1", "val2" });
meta.setReturnValueField(new String[] { BINARY_FIELD, BINARY_FIELD });
meta.setReturnValueDefaultType(new int[] { ValueMetaInterface.TYPE_BINARY, ValueMetaInterface.TYPE_BINARY });
meta.setStreamKeyField1(new String[0]);
meta.setStreamKeyField2(new String[0]);
meta.setReturnValueDefault(new String[] { "", "" });
meta = spy(meta);
doAnswer(new Answer() {
@Override
public Object answer(InvocationOnMock invocation) throws Throwable {
RowMetaInterface row = (RowMetaInterface) invocation.getArguments()[0];
ValueMetaInterface v = new ValueMetaBinary(BINARY_FIELD);
row.addValueMeta(v);
return null;
}
}).when(meta).getFields(any(RowMetaInterface.class), anyString(), any(RowMetaInterface[].class), any(StepMeta.class), any(VariableSpace.class), any(Repository.class), any(IMetaStore.class));
look.init(meta, lookData);
// Test for fix on PDI-15202
assertTrue(lookData.allEquals);
}
Aggregations