当前位置: 首页>>代码示例>>Java>>正文


Java InspectableFileCachedInputStream类代码示例

本文整理汇总了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);
}
 
开发者ID:LAW-Unimi,项目名称:BUbiNG,代码行数:16,代码来源:FetchData.java

示例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();
}
 
开发者ID:LAW-Unimi,项目名称:BUbiNG,代码行数:11,代码来源:InspectableCachedHttpEntityTest.java

示例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();
}
 
开发者ID:phishman3579,项目名称:fastutil,代码行数:15,代码来源:InspectableFileCachedInputStreamTest.java

示例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();
}
 
开发者ID:phishman3579,项目名称:fastutil,代码行数:10,代码来源:InspectableFileCachedInputStreamTest.java

示例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();
}
 
开发者ID:phishman3579,项目名称:fastutil,代码行数:11,代码来源:InspectableFileCachedInputStreamTest.java

示例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();
}
 
开发者ID:phishman3579,项目名称:fastutil,代码行数:10,代码来源:InspectableFileCachedInputStreamTest.java

示例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();
}
 
开发者ID:phishman3579,项目名称:fastutil,代码行数:10,代码来源:InspectableFileCachedInputStreamTest.java

示例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);
}
 
开发者ID:LAW-Unimi,项目名称:BUbiNG,代码行数:7,代码来源:InspectableCachedHttpEntity.java

示例9: RandomFetchedHttpResponse

import it.unimi.dsi.fastutil.io.InspectableFileCachedInputStream; //导入依赖的package包/类
public RandomFetchedHttpResponse(RuntimeConfiguration conf) throws IOException, NoSuchAlgorithmException, IllegalArgumentException {
	super(conf);
	inspectableBufferedInputStream = new InspectableFileCachedInputStream();
}
 
开发者ID:LAW-Unimi,项目名称:BUbiNG,代码行数:5,代码来源:MockFetchedResponses.java

示例10: contentAsStream

import it.unimi.dsi.fastutil.io.InspectableFileCachedInputStream; //导入依赖的package包/类
public InspectableFileCachedInputStream contentAsStream() throws IOException {
	inspectableBufferedInputStream.position(0);
	return inspectableBufferedInputStream;
}
 
开发者ID:LAW-Unimi,项目名称:BUbiNG,代码行数:5,代码来源:MockFetchedResponses.java

示例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();
}
 
开发者ID:phishman3579,项目名称:fastutil,代码行数:67,代码来源:InspectableFileCachedInputStreamTest.java

示例12: testNegativeBuffer

import it.unimi.dsi.fastutil.io.InspectableFileCachedInputStream; //导入依赖的package包/类
@SuppressWarnings("resource")
@Test(expected=IllegalArgumentException.class)
public void testNegativeBuffer() throws IOException {
	new InspectableFileCachedInputStream( -1 );
}
 
开发者ID:phishman3579,项目名称:fastutil,代码行数:6,代码来源:InspectableFileCachedInputStreamTest.java


注:本文中的it.unimi.dsi.fastutil.io.InspectableFileCachedInputStream类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。