use of org.apache.hop.core.row.value.ValueMetaBinary in project hop by apache.
the class CheckSumMeta method getFields.
@Override
public void getFields(IRowMeta inputRowMeta, String name, IRowMeta[] info, TransformMeta nextTransform, IVariables variables, IHopMetadataProvider metadataProvider) throws HopTransformException {
// Output field (String)
if (!Utils.isEmpty(resultFieldName)) {
IValueMeta v = null;
if (checkSumType == CheckSumType.CRC32 || checkSumType == CheckSumType.ADLER32) {
v = new ValueMetaInteger(variables.resolve(resultFieldName));
} else {
switch(resultType) {
case BINARY:
v = new ValueMetaBinary(variables.resolve(resultFieldName));
break;
default:
v = new ValueMetaString(variables.resolve(resultFieldName));
break;
}
}
v.setOrigin(name);
inputRowMeta.addValueMeta(v);
}
}
use of org.apache.hop.core.row.value.ValueMetaBinary in project hop by apache.
the class CheckSumTest method testHexOutput_adler32.
@Test
public void testHexOutput_adler32() throws Exception {
MockRowListener results = executeHexTest(CheckSumMeta.CheckSumType.ADLER32, "xyz", new ValueMetaString("test"));
assertEquals(1, results.getWritten().size());
assertEquals(Long.valueOf("47645036"), results.getWritten().get(0)[1]);
results = executeHexTest(CheckSumMeta.CheckSumType.ADLER32, 10.8, new ValueMetaNumber("test"));
assertEquals(1, results.getWritten().size());
assertEquals(Long.valueOf("32243912"), results.getWritten().get(0)[1]);
results = executeHexTest(CheckSumMeta.CheckSumType.ADLER32, 10.82, new ValueMetaNumber("test"));
assertEquals(1, results.getWritten().size());
assertEquals(Long.valueOf("48627962"), results.getWritten().get(0)[1]);
byte[] input = IOUtils.toByteArray(getFile("/checksum.svg").getContent().getInputStream());
results = executeHexTest(CheckSumMeta.CheckSumType.ADLER32, input, new ValueMetaBinary("test"));
assertEquals(1, results.getWritten().size());
assertEquals(Long.valueOf("3864809454"), results.getWritten().get(0)[1]);
}
use of org.apache.hop.core.row.value.ValueMetaBinary in project hop by apache.
the class CheckSumTest method testHexOutput_md5.
@Test
public void testHexOutput_md5() throws Exception {
MockRowListener results = executeHexTest(CheckSumMeta.CheckSumType.MD5, "xyz", new ValueMetaString("test"));
assertEquals(1, results.getWritten().size());
assertEquals("d16fb36f0911f878998c136191af705e", results.getWritten().get(0)[1]);
results = executeHexTest(CheckSumMeta.CheckSumType.MD5, 10.8, new ValueMetaNumber("test"));
assertEquals(1, results.getWritten().size());
assertEquals("372df98e33ac1bf6b26d225361ba7eb5", results.getWritten().get(0)[1]);
results = executeHexTest(CheckSumMeta.CheckSumType.MD5, 10.82, new ValueMetaNumber("test"));
assertEquals(1, results.getWritten().size());
assertEquals("68b142f87143c917f29d178aa1715957", results.getWritten().get(0)[1]);
byte[] input = IOUtils.toByteArray(getFile("/checksum.svg").getContent().getInputStream());
results = executeHexTest(CheckSumMeta.CheckSumType.MD5, input, new ValueMetaBinary("test"));
assertEquals(1, results.getWritten().size());
assertEquals("056c290e3639d0f15db479810973d601", results.getWritten().get(0)[1]);
}
use of org.apache.hop.core.row.value.ValueMetaBinary in project hop by apache.
the class CheckSumTest method testHexOutput_sha384.
@Test
public void testHexOutput_sha384() throws Exception {
MockRowListener results = executeHexTest(CheckSumMeta.CheckSumType.SHA384, "xyz", new ValueMetaString("test"));
assertEquals(1, results.getWritten().size());
assertEquals("edcb0f4721e6578d900e4c24ad4b19e194ab6c87f8243bfc6b11754dd8b0bbde4f30b1d18197932b6376da004dcd97c4", results.getWritten().get(0)[1]);
results = executeHexTest(CheckSumMeta.CheckSumType.SHA384, 10.8, new ValueMetaNumber("test"));
assertEquals(1, results.getWritten().size());
assertEquals("bf42c2b293b7562deca2acccc99f85b33aa150603608d610495dc45e0fb55b60c808ce466213edcf6ca184d97305b20d", results.getWritten().get(0)[1]);
results = executeHexTest(CheckSumMeta.CheckSumType.SHA384, 10.82, new ValueMetaNumber("test"));
assertEquals(1, results.getWritten().size());
assertEquals("96adb3d911a5b02f7604b9f8159d5baf21a6719162887792b7232f91fe19fefeaf9438dc1e09685a33c998897a7e76e2", results.getWritten().get(0)[1]);
byte[] input = IOUtils.toByteArray(getFile("/checksum.svg").getContent().getInputStream());
results = executeHexTest(CheckSumMeta.CheckSumType.SHA384, input, new ValueMetaBinary("test"));
assertEquals(1, results.getWritten().size());
assertEquals("ef97e467e4fc1894abcdfd589481ff9c269322f7f2f42fde41468d7ac1f2bcd10db6f797f58e531419c886a43d1d8cd0", results.getWritten().get(0)[1]);
}
use of org.apache.hop.core.row.value.ValueMetaBinary in project hop by apache.
the class CheckSumTest method testHexOutput_sha256.
@Test
public void testHexOutput_sha256() throws Exception {
MockRowListener results = executeHexTest(CheckSumMeta.CheckSumType.SHA256, "xyz", new ValueMetaString("test"));
assertEquals(1, results.getWritten().size());
assertEquals("3608bca1e44ea6c4d268eb6db02260269892c0b42b86bbf1e77a6fa16c3c9282", results.getWritten().get(0)[1]);
results = executeHexTest(CheckSumMeta.CheckSumType.SHA256, 10.8, new ValueMetaNumber("test"));
assertEquals(1, results.getWritten().size());
assertEquals("b52b603f9ec86c382a8483cad4f788f2f927535a76ad1388caedcef5e3c3c813", results.getWritten().get(0)[1]);
results = executeHexTest(CheckSumMeta.CheckSumType.SHA256, 10.82, new ValueMetaNumber("test"));
assertEquals(1, results.getWritten().size());
assertEquals("45cbb96ff9625490cd675a7a39fecad6c167c1ed9b8957f53224fcb3e4a1e4a1", results.getWritten().get(0)[1]);
byte[] input = IOUtils.toByteArray(getFile("/org/apache/hop/pipeline/transforms/loadfileinput/files/hop.jpg").getContent().getInputStream());
results = executeHexTest(CheckSumMeta.CheckSumType.SHA256, input, new ValueMetaBinary("test"));
assertEquals(1, results.getWritten().size());
assertEquals("51165cf63a5b08470272cbf75f6bfb439fad977a451866a25b5ebb3767f31872", results.getWritten().get(0)[1]);
}
Aggregations