use of org.pentaho.di.core.row.value.ValueMetaBinary in project pentaho-kettle by pentaho.
the class CheckSumTest method testHexOutput_md5_compatibilityMode.
@Test
public void testHexOutput_md5_compatibilityMode() throws Exception {
MockRowListener results = executeHexTest(2, true, "xyz", new ValueMetaString("test"), false);
assertEquals(1, results.getWritten().size());
assertEquals("FD6FFD6F0911FD78FDFD1361FDFD705E", results.getWritten().get(0)[1]);
results = executeHexTest(2, true, 10.8, new ValueMetaNumber("test"), false);
assertEquals(1, results.getWritten().size());
assertEquals("372DFDFD33FD1BFDFD6D225361FD7EFD", results.getWritten().get(0)[1]);
results = executeHexTest(2, true, 10.82, new ValueMetaNumber("test"), false);
assertEquals(1, results.getWritten().size());
assertEquals("68FD42FD7143FD17FD17FDFD715957", results.getWritten().get(0)[1]);
byte[] input = IOUtils.toByteArray(getFile("/org/pentaho/di/trans/steps/loadfileinput/files/pentaho_splash.png").getContent().getInputStream());
results = executeHexTest(2, true, input, new ValueMetaBinary("test"), false);
assertEquals(1, results.getWritten().size());
assertEquals("FDFDFDFD051FFDFDFD50FD62FDFDFD13", results.getWritten().get(0)[1]);
}
use of org.pentaho.di.core.row.value.ValueMetaBinary in project pentaho-kettle by pentaho.
the class RowMetaAndDataTest method testEmptyValues.
@Test
public void testEmptyValues() throws Exception {
RowMeta rowsMetaEmpty = new RowMeta();
rowsMetaEmpty.addValueMeta(new ValueMetaString("str"));
rowsMetaEmpty.addValueMeta(new ValueMetaBoolean("bool"));
rowsMetaEmpty.addValueMeta(new ValueMetaInteger("int"));
rowsMetaEmpty.addValueMeta(new ValueMetaNumber("num"));
rowsMetaEmpty.addValueMeta(new ValueMetaBigNumber("bignum"));
rowsMetaEmpty.addValueMeta(new ValueMetaBinary("bin"));
rowsMetaEmpty.addValueMeta(new ValueMetaDate("date"));
rowsMetaEmpty.addValueMeta(new ValueMetaTimestamp("timestamp"));
rowsMetaEmpty.addValueMeta(new ValueMetaInternetAddress("inet"));
row = new RowMetaAndData(rowsMetaEmpty, null, null, null, null, null, null, null, null, null);
assertTrue(row.isEmptyValue("str"));
assertTrue(row.isEmptyValue("bool"));
assertTrue(row.isEmptyValue("int"));
assertTrue(row.isEmptyValue("num"));
assertTrue(row.isEmptyValue("bignum"));
assertTrue(row.isEmptyValue("bin"));
assertTrue(row.isEmptyValue("date"));
assertTrue(row.isEmptyValue("timestamp"));
assertTrue(row.isEmptyValue("inet"));
}
use of org.pentaho.di.core.row.value.ValueMetaBinary in project pentaho-kettle by pentaho.
the class AzureSqlDataBaseMetaTest method testGetValueFromResultSet.
@Test
public void testGetValueFromResultSet() throws SQLException, KettleDatabaseException {
ResultSet rs = mock(ResultSet.class);
// Binary Data
Mockito.when(rs.getString(1)).thenReturn("HODBACXXXXAAA");
ValueMetaBinary tb = new ValueMetaBinary("HODBACXXXXAAA");
assertEquals("HODBACXXXXAAA", dbMeta.getValueFromResultSet(rs, tb, 0));
// Super class function calling
Mockito.when(rs.getString(2)).thenReturn("AzureDB");
ValueMetaString ts = new ValueMetaString("AzureDB");
assertEquals("AzureDB", dbMeta.getValueFromResultSet(rs, ts, 1));
// ResultSet was null
Mockito.when(rs.wasNull()).thenReturn(true);
assertNull(dbMeta.getValueFromResultSet(rs, tb, 2));
}
use of org.pentaho.di.core.row.value.ValueMetaBinary in project pentaho-kettle by pentaho.
the class LoadFileInputTest method testByteArray.
@Test
public void testByteArray() throws Exception {
RowMetaInterface mockedRowMetaInterface = mock(RowMetaInterface.class);
stepLoadFileInput.data.outputRowMeta = mockedRowMetaInterface;
stepLoadFileInput.data.convertRowMeta = mockedRowMetaInterface;
Mockito.doReturn(new ValueMetaString()).when(mockedRowMetaInterface).getValueMeta(anyInt());
// byte array
Mockito.doReturn(new ValueMetaBinary()).when(mockedRowMetaInterface).getValueMeta(anyInt());
((LoadFileInputMeta) runtimeSMI).setEncoding("UTF-8");
stepInputFiles.addFile(getFile("pentaho_splash.png"));
inputField = new LoadFileInputField();
inputField.setType(ValueMetaInterface.TYPE_BINARY);
((LoadFileInputMeta) runtimeSMI).setInputFields(new LoadFileInputField[] { inputField });
assertNotNull(stepLoadFileInput.getOneRow());
assertArrayEquals(IOUtils.toByteArray(getFile("pentaho_splash.png").getContent().getInputStream()), stepLoadFileInput.data.filecontent);
}
use of org.pentaho.di.core.row.value.ValueMetaBinary in project pentaho-kettle by pentaho.
the class FieldHelperTest method getGetSignature_Binary.
@Test
public void getGetSignature_Binary() {
ValueMetaBinary v = new ValueMetaBinary("Data");
String accessor = FieldHelper.getAccessor(true, "Data");
assertEquals("byte[] Data = get(Fields.In, \"Data\").getBinary(r);", FieldHelper.getGetSignature(accessor, v));
assertNotNull(getMethod(FieldHelper.class, "getBinary", Object[].class));
}
Aggregations