public void testRead1() throws Exception {
  byte[] data=new byte[]{-127,-100,-50,-10,-1,0,1,10,50,127};
  TestInputStream tis=new TestInputStream(data);
  CipherInputStream cis=new CipherInputStream(tis,new NullCipher());
  byte res;
  for (int i=0; i < data.length; i++) {
    if ((res=(byte)cis.read()) != data[i]) {
      fail("read() returned the incorrect value. " + "Expected: " + data[i] + ", Got: "+ res+ ".");
    }
  }
  if (cis.read() != -1) {
    fail("read() should return -1 at the end of the stream.");
  }
}

public void testRead1 ( ) throws Exception { byte [ ] data = new byte [ ] { - 127 , - 100 , - 50 , - 10 , - 1 , 0 , 1 , 10 , 50 , 127 } ; TestInputStream tis = new TestInputStream ( data ) ; CipherInputStream cis = new CipherInputStream ( tis , new NullCipher ( ) ) ; byte res ; for ( int i = 0 ; i < data . length ; i ++ ) { if ( ( res = ( byte ) cis . read ( ) ) != data [ i ] ) { fail ( "read() returned the incorrect value. " + "Expected: " + data [ i ] + ", Got: " + res + "." ) ; } } if ( cis . read ( ) != - 1 ) { fail ( "read() should return -1 at the end of the stream." ) ; } }
read ( ) method testing . tests that method returns the correct value ( related to the inputstream ) and that it returns - 1 at the end of stream .
