Package org.apache.hadoop.hdfs.util

Examples of org.apache.hadoop.hdfs.util.ExactSizeInputStream.available()


public class TestExactSizeInputStream {
  @Test
  public void testBasicsReadSingle() throws IOException {
    ExactSizeInputStream s = new ExactSizeInputStream(byteStream("hello"), 3);
    assertEquals(3, s.available());
   
    assertEquals((int)'h', s.read());
    assertEquals((int)'e', s.read());
    assertEquals((int)'l', s.read());
    assertEquals(-1, s.read());
View Full Code Here


   
    assertEquals((int)'h', s.read());
    assertEquals((int)'e', s.read());
    assertEquals((int)'l', s.read());
    assertEquals(-1, s.read());
    assertEquals(0, s.available());
  }
 
  @Test
  public void testBasicsReadArray() throws IOException {
    ExactSizeInputStream s = new ExactSizeInputStream(byteStream("hello"), 3);
View Full Code Here

  }
 
  @Test
  public void testBasicsReadArray() throws IOException {
    ExactSizeInputStream s = new ExactSizeInputStream(byteStream("hello"), 3);
    assertEquals(3, s.available());
   
    byte[] buf = new byte[10];
   
    assertEquals(2, s.read(buf, 0, 2));
    assertEquals('h', buf[0]);
View Full Code Here

  }
 
  @Test
  public void testBasicsSkip() throws IOException {
    ExactSizeInputStream s = new ExactSizeInputStream(byteStream("hello"), 3);
    assertEquals(3, s.available());
   
    assertEquals(2, s.skip(2));
    assertEquals(1, s.skip(2));
    assertEquals(0, s.skip(2));
  }
View Full Code Here

 
  @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();
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. 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.