本文整理汇总了Java中org.apache.commons.io.input.NullInputStream类的典型用法代码示例。如果您正苦于以下问题:Java NullInputStream类的具体用法?Java NullInputStream怎么用?Java NullInputStream使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
NullInputStream类属于org.apache.commons.io.input包,在下文中一共展示了NullInputStream类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: fileNested
import org.apache.commons.io.input.NullInputStream; //导入依赖的package包/类
@Test
public void fileNested() throws Exception {
waitForWorkspaceChanges(() -> {
project.getFolder("/folder").create(true, true, null);
project.getFolder("/folder/deep/").create(true, true, null);
IFile file = project.getFile("/folder/deep/myFile.ext");
file.create(new NullInputStream(0), true, null);
});
URI uri = URI.createPlatformResourceURI("/myProject/folder/deep/myFile.ext", true);
IResource iResource = UriUtils.toIResource(uri);
assertTrue(iResource instanceof IFile);
assertTrue(iResource.exists());
assertEquals("/myProject/folder/deep/myFile.ext", iResource.getFullPath().toString());
}
示例2: fileSlashesExcess
import org.apache.commons.io.input.NullInputStream; //导入依赖的package包/类
@Test
public void fileSlashesExcess() throws Exception {
waitForWorkspaceChanges(() -> {
project.getFolder("/folder").create(true, true, null);
project.getFolder("/folder/deep/").create(true, true, null);
IFile file = project.getFile("/folder/deep/myFile.ext");
file.create(new NullInputStream(0), true, null);
});
URI uri = URI.createPlatformResourceURI("////myProject///folder///deep/myFile.ext//", true);
IResource iResource = UriUtils.toIResource(uri);
assertTrue(iResource instanceof IFile);
assertTrue(iResource.exists());
assertEquals("/myProject/folder/deep/myFile.ext", iResource.getFullPath().toString());
}
示例3: testWriteZeroLength
import org.apache.commons.io.input.NullInputStream; //导入依赖的package包/类
@Test
public void testWriteZeroLength() throws Exception {
final Host host = new Host(new SDSProtocol(), "duck.ssp-europe.eu", new Credentials(
System.getProperties().getProperty("sds.user"), System.getProperties().getProperty("sds.key")
));
final SDSSession session = new SDSSession(host, new DisabledX509TrustManager(), new DefaultX509KeyManager());
session.open(new DisabledHostKeyCallback(), new DisabledLoginCallback());
session.login(new DisabledPasswordStore(), new DisabledLoginCallback(), new DisabledCancelCallback());
final Path room = new SDSDirectoryFeature(session).mkdir(
new Path(new AlphanumericRandomStringService().random(), EnumSet.of(Path.Type.directory, Path.Type.volume)), null, new TransferStatus());
final TransferStatus status = new TransferStatus();
final Path test = new Path(room, UUID.randomUUID().toString(), EnumSet.of(Path.Type.file));
final SDSMultipartWriteFeature writer = new SDSMultipartWriteFeature(session);
final HttpResponseOutputStream<VersionId> out = writer.write(test, status, new DisabledConnectionCallback());
assertNotNull(out);
new StreamCopier(status, status).transfer(new NullInputStream(0L), out);
final VersionId version = out.getStatus();
assertNotNull(version);
assertTrue(new DefaultFindFeature(session).find(test));
new SDSDeleteFeature(session).delete(Collections.singletonList(room), new DisabledLoginCallback(), new Delete.DisabledCallback());
session.close();
}
示例4: read
import org.apache.commons.io.input.NullInputStream; //导入依赖的package包/类
@Override
public synchronized int read(final byte[] chunk, final Long offset) throws IOException {
final RandomAccessFile file = random();
if(offset < file.length()) {
file.seek(offset);
if(chunk.length + offset > file.length()) {
return file.read(chunk, 0, (int) (file.length() - offset));
}
else {
return file.read(chunk, 0, chunk.length);
}
}
else {
final NullInputStream nullStream = new NullInputStream(length);
if(nullStream.available() > 0) {
nullStream.skip(offset);
return nullStream.read(chunk, 0, chunk.length);
}
else {
return IOUtils.EOF;
}
}
}
示例5: setUp
import org.apache.commons.io.input.NullInputStream; //导入依赖的package包/类
@Before
public void setUp() throws Exception {
releasableInputStream = new ReleasableInputStream(new NullInputStream(2048), () -> wasCalled.set(true));
failedReleasableInputStream = new ReleasableInputStream(new InputStream() {
@Override
public int read() throws IOException {
throw new IOException("Oops");
}
@Override
public int available() throws IOException {
throw new IOException("Oops");
}
@Override
public synchronized void mark(int readlimit) {
throw new RuntimeException("Oops");
}
}, () -> wasCalled.set(true));
}
示例6: useFileCollector
import org.apache.commons.io.input.NullInputStream; //导入依赖的package包/类
String useFileCollector(FileCollectorAbstract fileCollector) throws Exception {
CachingClassLoaderConfiguration classLoaderConfiguration = new CachingClassLoaderConfiguration();
classLoaderConfiguration.setFileCollector(fileCollector);
classLoaderConfiguration.setLocalFirst(false);
classLoaderConfiguration.setCacheType(CacheType.NoCache, true);
classLoaderConfiguration.getCacheConfiguration().setCacheFolder("target"+File.separator +"classLoaderCache");
startup(classLoaderConfiguration);
try(at.ac.tuwien.infosys.jcloudscale.classLoader.caching.RemoteClassLoader classLoader = (at.ac.tuwien.infosys.jcloudscale.classLoader.caching.RemoteClassLoader)classLoaderConfiguration.createClassLoader())
{
assertSame(at.ac.tuwien.infosys.jcloudscale.classLoader.caching.RemoteClassLoader.class, classLoader.getClass());
InputStream stream = getInputStream(classLoader);
return IOUtils.toString(firstNonNull(stream, new NullInputStream(0)));
}
}
示例7: testWriteGiantRecord
import org.apache.commons.io.input.NullInputStream; //导入依赖的package包/类
public void testWriteGiantRecord() throws IOException {
PrintStream dummyStream = new PrintStream(new NullOutputStream());
ARCWriter arcWriter =
new ARCWriter(
SERIAL_NO,
dummyStream,
new File("dummy"),
new WriterPoolSettingsData(
"",
"",
-1,
false,
null,
null));
assertNotNull(arcWriter);
// Start the record with an arbitrary 14-digit date per RFC2540
long now = System.currentTimeMillis();
long recordLength = org.apache.commons.io.FileUtils.ONE_GB * 3;
arcWriter.write("dummy:uri", "application/octet-stream",
"0.1.2.3", now, recordLength, new NullInputStream(recordLength));
arcWriter.close();
}
示例8: testSaveEmailAndNotify_correct_config_invalid_input
import org.apache.commons.io.input.NullInputStream; //导入依赖的package包/类
@SuppressWarnings("deprecation")
// TEST WITH CORRECT CONFIG AND INVALID INPUT
@Test
public void testSaveEmailAndNotify_correct_config_invalid_input() throws Exception {
// GIVEN I have a server accurately configured (relay domains)
ServerConfiguration serverConfiguration = new ServerConfiguration();
MailSaver mailSaver = new MailSaver(serverConfiguration);
serverConfiguration.relayDomains("data.org");
MailServerModel mailServerModel = new MailServerModel();
// AND I don't forget to register the mailServerModel
mailSaver.addObserver(mailServerModel);
// WHEN I sent a mail
mailSaver.saveEmailAndNotify(FROM, TO, new NullInputStream(10));
// THEN
Assert.assertEquals(1, mailServerModel.getEmailModels().size());
EmailModel emailModel = mailServerModel.getEmailModels().get(0);
assertNotNull(emailModel);
assertEquals("", emailModel.getSubject());
//
}
示例9: testCloseQuietlyImageInputStreamOpen
import org.apache.commons.io.input.NullInputStream; //导入依赖的package包/类
@Test
public void testCloseQuietlyImageInputStreamOpen() {
final ImageInputStream in =
new MemoryCacheImageInputStream(new NullInputStream(1000));
IOUtils.closeQuietly(in);
try {
in.close();
fail();
}
catch (IOException e) {
// This, oddly, the expected behavior of close().
}
}
示例10: fileSlash
import org.apache.commons.io.input.NullInputStream; //导入依赖的package包/类
@Test
public void fileSlash() throws Exception {
waitForWorkspaceChanges(() -> {
IFile file = project.getFile("myFile.ext");
file.create(new NullInputStream(0), true, null);
});
URI uri = URI.createPlatformResourceURI("/myProject/myFile.ext/", true);
IResource iResource = UriUtils.toIResource(uri);
assertTrue(iResource instanceof IFile);
assertTrue(iResource.exists());
assertEquals("/myProject/myFile.ext", iResource.getFullPath().toString());
}
示例11: fileDifferentCase
import org.apache.commons.io.input.NullInputStream; //导入依赖的package包/类
@Test
public void fileDifferentCase() throws Exception {
waitForWorkspaceChanges(() -> {
IFile file = project.getFile("myFile.ext");
file.create(new NullInputStream(0), true, null);
});
URI uri = URI.createPlatformResourceURI("/myProject/MYfILE.ext", true);
IResource iResource = UriUtils.toIResource(uri);
assertTrue(iResource instanceof IFile);
assertFalse(iResource.exists());
assertEquals("/myProject/MYfILE.ext", iResource.getFullPath().toString());
}
示例12: fragment
import org.apache.commons.io.input.NullInputStream; //导入依赖的package包/类
@Test
public void fragment() throws Exception {
waitForWorkspaceChanges(() -> {
IFile file = project.getFile("myFile.ext");
file.create(new NullInputStream(0), true, null);
});
URI uri = URI.createPlatformResourceURI("/myProject/myFile.ext", true).appendFragment("fragment");
IResource iResource = UriUtils.toIResource(uri);
assertTrue(iResource instanceof IFile);
assertTrue(iResource.exists());
assertEquals("/myProject/myFile.ext", iResource.getFullPath().toString());
}
示例13: query
import org.apache.commons.io.input.NullInputStream; //导入依赖的package包/类
@Test
public void query() throws Exception {
waitForWorkspaceChanges(() -> {
IFile file = project.getFile("myFile.ext");
file.create(new NullInputStream(0), true, null);
});
URI uri = URI.createPlatformResourceURI("/myProject/myFile.ext", true).appendQuery("query");
IResource iResource = UriUtils.toIResource(uri);
assertTrue(iResource instanceof IFile);
assertTrue(iResource.exists());
assertEquals("/myProject/myFile.ext", iResource.getFullPath().toString());
}
示例14: mkdir
import org.apache.commons.io.input.NullInputStream; //导入依赖的package包/类
@Override
public Path mkdir(final Path folder, final String region, final TransferStatus status) throws BackgroundException {
if(containerService.isContainer(folder)) {
return super.mkdir(folder, region, status);
}
else {
if(Checksum.NONE == status.getChecksum()) {
status.setChecksum(writer.checksum(folder).compute(new NullInputStream(0L), status));
}
return super.mkdir(folder, region, status);
}
}
示例15: touch
import org.apache.commons.io.input.NullInputStream; //导入依赖的package包/类
@Override
public Path touch(final Path file, final TransferStatus status) throws BackgroundException {
if(Checksum.NONE == status.getChecksum()) {
status.setChecksum(writer.checksum(file).compute(new NullInputStream(0L), status));
}
status.setTimestamp(System.currentTimeMillis());
final StatusOutputStream<BaseB2Response> out = writer.write(file, status, new DisabledConnectionCallback());
new DefaultStreamCloser().close(out);
return new Path(file.getParent(), file.getName(), file.getType(),
new PathAttributes(file.attributes()).withVersionId(((B2FileResponse) out.getStatus()).getFileId()));
}