本文整理汇总了Java中it.unimi.dsi.fastutil.io.InspectableFileCachedInputStream类的典型用法代码示例。如果您正苦于以下问题:Java InspectableFileCachedInputStream类的具体用法?Java InspectableFileCachedInputStream怎么用?Java InspectableFileCachedInputStream使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
InspectableFileCachedInputStream类属于it.unimi.dsi.fastutil.io包,在下文中一共展示了InspectableFileCachedInputStream类的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: FetchData
import it.unimi.dsi.fastutil.io.InspectableFileCachedInputStream; //导入依赖的package包/类
/** Creates a fetched response according to the given properties.
*
* @param rc the runtime configuration.
*/
public FetchData(final RuntimeConfiguration rc) throws NoSuchAlgorithmException, IllegalArgumentException, IOException {
inspectableFileCachedInputStream = new InspectableFileCachedInputStream(rc.fetchDataBufferByteSize, it.unimi.di.law.bubing.util.Util.createHierarchicalTempFile(rc.responseCacheDir, OVERFLOW_FILES_RANDOM_PATH_ELEMENTS, getClass().getSimpleName() + "-", ".overflow"));
this.rc = rc;
wrappedEntity = new InspectableCachedHttpEntity(inspectableFileCachedInputStream);
httpGet = new HttpGet();
// TODO: This should be done more properly
binaryParser = new BinaryParser(rc.digestAlgorithm);
//context = new BasicHttpContext();
//cachingAsyncByteConsumer = new CachingAsyncByteConsumer(this);
//enqueueFetchedHttpResponseFutureCallback = new EnqueueFetchedHttpResponseFutureCallback(this);
}
示例2: testCopyContent
import it.unimi.dsi.fastutil.io.InspectableFileCachedInputStream; //导入依赖的package包/类
@Test
public void testCopyContent() throws IOException {
final RandomTestMocks.HttpResponse mockResponse = new RandomTestMocks.HttpResponse(MAX_NUMBER_OF_HEADERS, MAX_LENGTH_OF_HEADER, MAX_LENGTH_OF_BODY, 0);
final InspectableFileCachedInputStream inputStream = new InspectableFileCachedInputStream();
final InspectableCachedHttpEntity wrappedEntity = new InspectableCachedHttpEntity(inputStream);
wrappedEntity.setEntity(mockResponse.getEntity());
wrappedEntity.copyContent(Long.MAX_VALUE, System.currentTimeMillis(), Long.MAX_VALUE, 0);
assertEquals(mockResponse.getMockContent(), IOUtils.toString(wrappedEntity.getContent(), StandardCharsets.ISO_8859_1));
inputStream.close();
}
示例3: testWithSpecifiedFile
import it.unimi.dsi.fastutil.io.InspectableFileCachedInputStream; //导入依赖的package包/类
@Test
public void testWithSpecifiedFile() throws IOException {
final InspectableFileCachedInputStream icis = new InspectableFileCachedInputStream( 4, File.createTempFile( getClass().getSimpleName(), "overflow" ) );
final byte[] data = new byte[] { 1, 2 };
icis.write( ByteBuffer.wrap( data ) );
assertEquals( 2, icis.length() );
assertEquals( 1, icis.read() );
assertEquals( 2, icis.read() );
assertEquals( -1, icis.read() );
icis.close();
icis.dispose();
}
示例4: testClosed
import it.unimi.dsi.fastutil.io.InspectableFileCachedInputStream; //导入依赖的package包/类
@Test(expected=IOException.class)
public void testClosed() throws IOException {
final InspectableFileCachedInputStream icis = new InspectableFileCachedInputStream( 4 );
final byte[] data = new byte[] { 1, 2 };
icis.write( ByteBuffer.wrap( data ) );
icis.close();
assertFalse( icis.isOpen() );
icis.read();
}
示例5: testDisposed
import it.unimi.dsi.fastutil.io.InspectableFileCachedInputStream; //导入依赖的package包/类
@Test(expected=IOException.class)
public void testDisposed() throws IOException {
@SuppressWarnings("resource")
final InspectableFileCachedInputStream icis = new InspectableFileCachedInputStream( 4 );
final byte[] data = new byte[] { 1, 2 };
icis.write( ByteBuffer.wrap( data ) );
icis.dispose();
assertFalse( icis.isOpen() );
icis.read();
}
示例6: testClearDisposed
import it.unimi.dsi.fastutil.io.InspectableFileCachedInputStream; //导入依赖的package包/类
@Test(expected=IOException.class)
public void testClearDisposed() throws IOException {
@SuppressWarnings("resource")
final InspectableFileCachedInputStream icis = new InspectableFileCachedInputStream();
final byte[] data = new byte[] { 1, 2 };
icis.write( ByteBuffer.wrap( data ) );
icis.dispose();
icis.clear();
}
示例7: testResetDisposed
import it.unimi.dsi.fastutil.io.InspectableFileCachedInputStream; //导入依赖的package包/类
@Test(expected=IOException.class)
public void testResetDisposed() throws IOException {
@SuppressWarnings("resource")
final InspectableFileCachedInputStream icis = new InspectableFileCachedInputStream();
final byte[] data = new byte[] { 1, 2 };
icis.write( ByteBuffer.wrap( data ) );
icis.dispose();
icis.reset();
}
示例8: InspectableCachedHttpEntity
import it.unimi.dsi.fastutil.io.InspectableFileCachedInputStream; //导入依赖的package包/类
public InspectableCachedHttpEntity(final InspectableFileCachedInputStream cachedContent) {
super(THROW_AWAY_ENTITY);
this.cachedContent = cachedContent;
buffer = new byte[BUFFER_SIZE];
byteBuffer = ByteBuffer.wrap(buffer);
}
示例9: RandomFetchedHttpResponse
import it.unimi.dsi.fastutil.io.InspectableFileCachedInputStream; //导入依赖的package包/类
public RandomFetchedHttpResponse(RuntimeConfiguration conf) throws IOException, NoSuchAlgorithmException, IllegalArgumentException {
super(conf);
inspectableBufferedInputStream = new InspectableFileCachedInputStream();
}
示例10: contentAsStream
import it.unimi.dsi.fastutil.io.InspectableFileCachedInputStream; //导入依赖的package包/类
public InspectableFileCachedInputStream contentAsStream() throws IOException {
inspectableBufferedInputStream.position(0);
return inspectableBufferedInputStream;
}
示例11: testSmall
import it.unimi.dsi.fastutil.io.InspectableFileCachedInputStream; //导入依赖的package包/类
@Test
public void testSmall() throws IOException {
InspectableFileCachedInputStream icis = new InspectableFileCachedInputStream( 4 );
assertTrue( icis.isOpen() );
byte[] data = new byte[] { 1, 2 };
icis.write( ByteBuffer.wrap( data ) );
assertEquals( 2, icis.length() );
assertEquals( 1, icis.read() );
assertEquals( 2, icis.read() );
assertEquals( -1, icis.read() );
icis.position( 0 );
byte b[] = new byte[ 2 ];
assertEquals( 2, icis.read( b ) );
assertArrayEquals( data, b );
assertEquals( -1, icis.read() );
assertEquals( -1, icis.read( b, 0, b.length ) );
assertEquals( 0, icis.read( b, 0, 0 ) );
icis.clear();
assertTrue( icis.isOpen() );
data = new byte[] { 1, 2, 3, 4, 5 };
icis.write( ByteBuffer.wrap( data ) );
assertEquals( 5, icis.length() );
assertEquals( 1, icis.read() );
assertEquals( 2, icis.read() );
assertEquals( 3, icis.read() );
assertEquals( 4, icis.read() );
assertEquals( 5, icis.read() );
assertEquals( -1, icis.read() );
icis.position( 0 );
assertEquals( 0, icis.position() );
b = new byte[ 5 ];
assertEquals( 5, icis.read( b ) );
assertArrayEquals( data, b );
icis.position( 2 );
b = new byte[ 4 ];
assertEquals( 3, icis.read( b ) );
assertArrayEquals( Arrays.copyOfRange( data, 2, 5 ), Arrays.copyOfRange( b, 0, 3 ) );
icis.position( 0 );
assertEquals( 1, icis.read() );
icis.position( 4 );
assertEquals( 1, icis.available() );
assertEquals( 5, icis.read() );
assertEquals( 5, icis.position() );
icis.position( 0 );
assertEquals( 2, icis.skip( 2 ) );
assertEquals( 2, icis.skip( 2 ) );
assertEquals( 5, icis.read() );
assertEquals( 5, icis.position() );
icis.position( 5 );
assertEquals( -1, icis.read() );
assertEquals( -1, icis.read( b, 0, b.length ) );
icis.close();
icis.dispose();
}
示例12: testNegativeBuffer
import it.unimi.dsi.fastutil.io.InspectableFileCachedInputStream; //导入依赖的package包/类
@SuppressWarnings("resource")
@Test(expected=IllegalArgumentException.class)
public void testNegativeBuffer() throws IOException {
new InspectableFileCachedInputStream( -1 );
}