/** * @deprecated Use {@link ValueDataUtil#loadFileContentInBinary(ValueMetaInterface, Object, boolean)} instead */ @Deprecated public static Object loadFileContentInBinary( ValueMetaInterface metaA, Object dataA ) throws KettleValueException { Object content = null; try { content = loadFileContentInBinary( metaA, dataA, true ); } catch ( KettleFileNotFoundException e ) { throw new KettleValueException(); } return content; }
@Test public void loadFileContentInBinary() throws Exception { String path = getClass().getResource( "txt-sample.txt" ).getPath(); byte[] content = ValueDataUtil.loadFileContentInBinary( new ValueMetaString(), path, true ); assertTrue( Arrays.equals( "test".getBytes(), content ) ); }
@Test( expected = KettleFileNotFoundException.class ) public void loadFileContentInBinaryFailIfNoFileTest() throws KettleFileNotFoundException, KettleValueException { String nonExistingPath = "nonExistingPath"; ValueDataUtil.loadFileContentInBinary( new ValueMetaString(), nonExistingPath, true ); }
@Test public void loadFileContentInBinaryNullPathFailTest() throws KettleFileNotFoundException, KettleValueException { assertNull( ValueDataUtil.loadFileContentInBinary( new ValueMetaString(), null, true ) ); }
@Test public void loadFileContentInBinaryNoFailIfNoFileTest() throws Exception { String nonExistingPath = "nonExistingPath"; assertNull( ValueDataUtil.loadFileContentInBinary( new ValueMetaString(), nonExistingPath, false ) ); }
@Test public void loadFileContentInBinaryNullPathNoFailTest() throws Exception { assertNull( ValueDataUtil.loadFileContentInBinary( new ValueMetaString(), null, false ) ); }
break; case CalculatorMetaFunction.CALC_LOAD_FILE_CONTENT_BINARY: // LOAD CONTENT OF A FILE A IN A BLOB calcData[index] = ValueDataUtil.loadFileContentInBinary( metaA, dataA, meta.isFailIfNoFile() ); resultType = CalculatorMetaFunction.calcDefaultResultType[calcType]; break;