Package org.apache.hadoop.hdfs.util

Examples of org.apache.hadoop.hdfs.util.ExactSizeInputStream


  }
 
  @Test
  public void testReadNotEnough() throws IOException {
    // Ask for 5 bytes, only has 2
    ExactSizeInputStream s = new ExactSizeInputStream(byteStream("he"), 5);
    assertEquals(2, s.available());
   
    assertEquals((int)'h', s.read());
    assertEquals((int)'e', s.read());
    try {
      s.read();
      fail("Read when should be out of data");
    } catch (EOFException e) {
      // expected
    }
  }
View Full Code Here


  }
 
  @Test
  public void testSkipNotEnough() throws IOException {
    // Ask for 5 bytes, only has 2
    ExactSizeInputStream s = new ExactSizeInputStream(byteStream("he"), 5);
    assertEquals(2, s.skip(3));
    try {
      s.skip(1);
      fail("Skip when should be out of data");
    } catch (EOFException e) {
      // expected
    }
  }
View Full Code Here

  }
 
  @Test
  public void testReadArrayNotEnough() throws IOException {
    // Ask for 5 bytes, only has 2
    ExactSizeInputStream s = new ExactSizeInputStream(byteStream("he"), 5);
    byte[] buf = new byte[10];
    assertEquals(2, s.read(buf, 0, 5));
    try {
      s.read(buf, 2, 3);
      fail("Read buf when should be out of data");
    } catch (EOFException e) {
      // expected
    }
  }
View Full Code Here

    }
  }

  @Test
  public void testMark() throws IOException {
    ExactSizeInputStream s = new ExactSizeInputStream(byteStream("he"), 5);
    assertFalse(s.markSupported());
    try {
      s.mark(1);
      fail("Mark should not succeed");
    } catch (UnsupportedOperationException uoe) {
      // expected
    }
  }
View Full Code Here

      throw new EOFException("Premature EOF: no length prefix available");
    }

    int size = CodedInputStream.readRawVarint32(firstByte, input);
    assert size >= 0;
    return new ExactSizeInputStream(input, size);
  }
View Full Code Here

      throw new EOFException("Premature EOF: no length prefix available");
    }

    int size = CodedInputStream.readRawVarint32(firstByte, input);
    assert size >= 0;
    return new ExactSizeInputStream(input, size);
  }
View Full Code Here

      throw new EOFException("Premature EOF: no length prefix available");
    }

    int size = CodedInputStream.readRawVarint32(firstByte, input);
    assert size >= 0;
    return new ExactSizeInputStream(input, size);
  }
View Full Code Here

    }
   
    int size = CodedInputStream.readRawVarint32(firstByte, input);
    assert size >= 0;
 
    return new ExactSizeInputStream(input, size);
  }
View Full Code Here

    }
   
    int size = CodedInputStream.readRawVarint32(firstByte, input);
    assert size >= 0;
 
    return new ExactSizeInputStream(input, size);
  }
View Full Code Here

    }
   
    int size = CodedInputStream.readRawVarint32(firstByte, input);
    assert size >= 0;
 
    return new ExactSizeInputStream(input, size);
  }
View Full Code Here

TOP

Related Classes of org.apache.hadoop.hdfs.util.ExactSizeInputStream

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.