Code example for DigestOutputStream

Methods: getMessageDigest, setMessageDigest

0
    public void test_setMessageDigestLjava_security_MessageDigest() { 
 
        MessageDigest digest = new MyMessageDigest1();
        OutputStream out = new MyOutputStream();
 
        DigestOutputStream dos = new DigestOutputStream(out, null);
 
        // non-null parameter 
        dos.setMessageDigest(digest);
        assertSame(digest, dos.getMessageDigest());
 
        // null parameter 
        dos.setMessageDigest(null);
        assertNull("getMessageDigest should have returned null", dos.getMessageDigest());
    } 
 
 
    /** 
     * Test #1 for <code>write(int)</code> method<br> 
     * 
     * Assertion: writes the byte to the output stream<br>