public void testWrite1() throws Exception {
  byte[] data=new byte[]{-127,-100,-50,-10,-1,0,1,10,50,127};
  TestOutputStream tos=new TestOutputStream();
  CipherOutputStream cos=new CipherOutputStream(tos,new NullCipher());
  for (int i=0; i < data.length; i++) {
    cos.write(data[i]);
  }
  cos.flush();
  byte[] result=tos.toByteArray();
  if (!Arrays.equals(result,data)) {
    fail("CipherOutputStream wrote incorrect data.");
  }
}

public void testWrite1 ( ) throws Exception { byte [ ] data = new byte [ ] { - 127 , - 100 , - 50 , - 10 , - 1 , 0 , 1 , 10 , 50 , 127 } ; TestOutputStream tos = new TestOutputStream ( ) ; CipherOutputStream cos = new CipherOutputStream ( tos , new NullCipher ( ) ) ; for ( int i = 0 ; i < data . length ; i ++ ) { cos . write ( data [ i ] ) ; } cos . flush ( ) ; byte [ ] result = tos . toByteArray ( ) ; if ( ! Arrays . equals ( result , data ) ) { fail ( "CipherOutputStream wrote incorrect data." ) ; } }
write ( int b ) method testing . tests that method writes correct values to the underlying output stream .
