Example usage for org.apache.commons.io.input NullInputStream NullInputStream

List of usage examples for org.apache.commons.io.input NullInputStream NullInputStream

Introduction

In this page you can find the example usage for org.apache.commons.io.input NullInputStream NullInputStream.

Prototype

public NullInputStream(long size) 

Source Link

Document

Create an InputStream that emulates a specified size which supports marking and does not throw EOFException.

Usage

From source file:ch.cyberduck.core.io.CRC32ChecksumComputeTest.java

@Test
public void testCompute() throws Exception {
    assertEquals("0", new CRC32ChecksumCompute().compute(new NullInputStream(0), new TransferStatus()).hash);
    assertEquals("d202ef8d",
            new CRC32ChecksumCompute().compute(new NullInputStream(1L), new TransferStatus()).hash);
}

From source file:ch.cyberduck.core.io.DisabledChecksumComputeTest.java

@Test(expected = IOException.class)
public void compute() throws Exception {
    final NullInputStream in = new NullInputStream(0L);
    new DisabledChecksumCompute().compute(in, new TransferStatus());
    assertEquals(-1, in.read());/*from www. j av  a 2 s  .  c  o  m*/
    in.read();
}

From source file:ch.cyberduck.core.NullReadFeature.java

@Override
public InputStream read(final Path file, final TransferStatus status, final ConnectionCallback callback)
        throws BackgroundException {
    return new NullInputStream(0L);
}

From source file:ch.cyberduck.core.io.SHA1ChecksumComputeTest.java

@Test
public void testCompute() throws Exception {
    assertEquals("da39a3ee5e6b4b0d3255bfef95601890afd80709",
            new SHA1ChecksumCompute().compute(new NullInputStream(0), new TransferStatus()).hash);

}

From source file:ch.cyberduck.core.io.SHA512ChecksumComputeTest.java

@Test
public void testCompute() throws Exception {
    assertEquals(//from   w  ww.j a v a  2  s  . co m
            "cf83e1357eefb8bdf1542850d66d8007d620e4050b5715dc83f4a921d36ce9ce47d0d13c5d85f2b0ff8318d2877eec2f63b931bd47417a81a538327af927da3e",
            new SHA512ChecksumCompute().compute(new NullInputStream(0), new TransferStatus()).hash);
}

From source file:ch.cyberduck.core.io.SHA256ChecksumComputeTest.java

@Test
public void testCompute() throws Exception {
    assertEquals("e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855",
            new SHA256ChecksumCompute().compute(new NullInputStream(0), new TransferStatus()).hash);
}

From source file:com.talis.storage.StoredItemTest.java

@Test
public void getEntityFromEnclosedItem() {
    InputStream entity = new NullInputStream(100);
    SubmittedItem enclosed = new SubmittedItem(MediaType.TEXT_PLAIN_TYPE, entity);

    StoredItem stored = new StoredItem(enclosed, now(), etag);
    InputStream storedEntity = stored.getEntity();
    assertSame(entity, storedEntity);/*  w w w.  j a va2 s. c  o  m*/
}

From source file:ch.cyberduck.core.openstack.SwiftSmallObjectUploadFeatureTest.java

@Test
public void testDecorate() throws Exception {
    final NullInputStream n = new NullInputStream(1L);
    final SwiftSession session = new SwiftSession(new Host(new SwiftProtocol()));
    assertSame(NullInputStream.class,
            new SwiftSmallObjectUploadFeature(new SwiftWriteFeature(session, new SwiftRegionService(session)))
                    .decorate(n, null).getClass());
}

From source file:com.norconex.importer.handler.tagger.impl.CharacterCaseTaggerTest.java

@Test
public void testUpperLower() throws IOException, ImporterHandlerException {
    ImporterMetadata meta = new ImporterMetadata();
    meta.addString("field1", "Doit tre upper");
    meta.addString("field1", "Must be upper");
    meta.setString("field2", "DOIT TRE LOWER");

    CharacterCaseTagger tagger = new CharacterCaseTagger();
    tagger.addFieldCase("field1", "upper");
    tagger.addFieldCase("field2", "lower");

    tagger.tagDocument("blah", new NullInputStream(0), meta, false);

    Assert.assertEquals("DOIT TRE UPPER", meta.getStrings("field1").get(0));
    Assert.assertEquals("MUST BE UPPER", meta.getStrings("field1").get(1));
    Assert.assertEquals("doit tre lower", meta.getString("field2"));
}

From source file:ch.cyberduck.core.b2.B2TouchFeature.java

@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));
    }/*from   w w w .  java 2 s. c  o  m*/
    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()));
}