@Test public void testClose() throws IOException { CompressionProvider provider = inStream.getCompressionProvider(); ByteArrayInputStream in = createTestInputStream(); inStream = new DummyCompressionIS( in, provider ); inStream.close(); }
@Test public void testNextEntry() throws IOException { assertNull( inStream.nextEntry() ); }
@Test public void testRead() throws IOException { CompressionProvider provider = inStream.getCompressionProvider(); ByteArrayInputStream in = createTestInputStream(); inStream = new DummyCompressionIS( in, provider ); assertEquals( inStream.available(), inStream.read( new byte[ 100 ], 0, inStream.available() ) ); }
@Test public void delegatesReadBufferWithParams() throws Exception { ByteArrayInputStream in = createTestInputStream(); in = spy( in ); inStream = new DummyCompressionIS( in, inStream.getCompressionProvider() ); inStream.read( new byte[ 16 ], 0, 16 ); verify( in ).read( any( byte[].class ), anyInt(), anyInt() ); }
data.in.close(); data.isr.close();
@Test public void getCompressionProvider() { CompressionProvider provider = inStream.getCompressionProvider(); assertEquals( provider.getName(), PROVIDER_NAME ); }
try { if ( f != null ) { f.close();
@Test public void delegatesReadBuffer() throws Exception { ByteArrayInputStream in = createTestInputStream(); in = spy( in ); inStream = new DummyCompressionIS( in, inStream.getCompressionProvider() ); inStream.read( new byte[ 16 ] ); verify( in ).read( any( byte[].class ) ); }
try { if ( f != null ) { f.close();
public TextFileInputReader( IBaseFileInputStepControl step, TextFileInputMeta meta, TextFileInputData data, FileObject file, LogChannelInterface log ) throws Exception { this.step = step; this.meta = meta; this.data = data; this.log = log; CompressionProvider provider = CompressionProviderFactory.getInstance().getCompressionProviderByName( meta.content.fileCompression ); if ( log.isDetailed() ) { log.logDetailed( "This is a compressed file being handled by the " + provider.getName() + " provider" ); } in = provider.createInputStream( KettleVFS.getInputStream( file ) ); in.nextEntry(); BufferedInputStream inStream = new BufferedInputStream( in, BUFFER_SIZE_INPUT_STREAM ); BOMDetector bom = new BOMDetector( inStream ); if ( bom.bomExist() ) { // if BOM exist, use it instead defined charset isr = new InputStreamReader( inStream, bom.getCharset() ); } else if ( meta.getEncoding() != null && meta.getEncoding().length() > 0 ) { isr = new InputStreamReader( inStream, meta.getEncoding() ); } else { isr = new InputStreamReader( inStream ); } String encoding = isr.getEncoding(); data.encodingType = EncodingType.guessEncodingType( encoding ); readInitial(); }
try { if ( inputStream != null ) { inputStream.close();
data.in.nextEntry();