public void testFlush() 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){
  }
;
  cos.write(data);
  cos.flush();
  byte[] result=tos.toByteArray();
  if (!Arrays.equals(result,data)) {
    fail("CipherOutputStream did not flush the data.");
  }
}

public void testFlush ( ) 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 ) { } ; cos . write ( data ) ; cos . flush ( ) ; byte [ ] result = tos . toByteArray ( ) ; if ( ! Arrays . equals ( result , data ) ) { fail ( "CipherOutputStream did not flush the data." ) ; } }
flush ( ) method testing . tests that method flushes the data to the underlying output stream .
