### Question:
CloudStreamSource extends RandomAccessStream { @Override public int read() throws IOException { int read = inputStream.read(); if (read != -1) fp++; return read; } CloudStreamSource(String fileName, long length, InputStream inputStream); void open(); @Override int read(); @Override int read(byte[] bytes, int start, int offs); @Override void close(); String getName(); @Override void moveTo(long position);  }### Answer:
@Test public void read() throws IOException { byte[] buff = new byte[10]; int n = cs.read(buff); byte[] temp = Arrays.copyOfRange(text, 0, buff.length); assertArrayEquals(temp, buff); assertEquals(buff.length, n); }
@Test public void readExceed() throws IOException { byte[] buff = new byte[100]; int n = cs.read(buff); byte[] buffer = Arrays.copyOfRange(buff, 0, n); assertArrayEquals(text, buffer); assertEquals(len, n); }
@Test public void readStartEnd() throws IOException { byte[] buff = new byte[100]; int start = 5; int end = 10; int n = cs.read(buff, start, end); byte[] file = Arrays.copyOfRange(text, 0, end - start); byte[] buffer = Arrays.copyOfRange(buff, start, end); assertArrayEquals(file, buffer); assertEquals(end, n); }
@Test(expected = IndexOutOfBoundsException.class) public void readStartEndExceedException() throws IOException { byte[] buff = new byte[100]; int start = 95; int end = 110; cs.read(buff, start, end); }