當前位置: 首頁>>代碼示例>>Java>>正文


Java DigestInputStream.setMessageDigest方法代碼示例

本文整理匯總了Java中java.security.DigestInputStream.setMessageDigest方法的典型用法代碼示例。如果您正苦於以下問題:Java DigestInputStream.setMessageDigest方法的具體用法?Java DigestInputStream.setMessageDigest怎麽用?Java DigestInputStream.setMessageDigest使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在java.security.DigestInputStream的用法示例。


在下文中一共展示了DigestInputStream.setMessageDigest方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: testSetMessageDigest

import java.security.DigestInputStream; //導入方法依賴的package包/類
/**
 * Test for <code>setMessageDigest()</code> method<br>
 *
 * Assertion: set associated message digest<br>
 */
@TestTargetNew(
    level = TestLevel.PARTIAL,
    notes = "Method setMessageDigest is not tested with null parameter",
    method = "setMessageDigest",
    args = {java.security.MessageDigest.class}
)
public final void testSetMessageDigest() {
    for (int ii=0; ii<algorithmName.length; ii++) {
        try {
            DigestInputStream dis = new DigestInputStream(null, null);
            MessageDigest md = MessageDigest.getInstance(algorithmName[ii]);
            dis.setMessageDigest(md);

            assertTrue(dis.getMessageDigest() == md);
            return;
        } catch (NoSuchAlgorithmException e) {
            // allowed failure
        }
    }
    fail(getName() + ": no MessageDigest algorithms available - test not performed");
}
 
開發者ID:keplersj,項目名稱:In-the-Box-Fork,代碼行數:27,代碼來源:DigestInputStreamTest.java

示例2: testSetMessageDigest

import java.security.DigestInputStream; //導入方法依賴的package包/類
/**
 * Test for <code>setMessageDigest()</code> method<br>
 * 
 * Assertion: set associated message digest<br>
 */
public final void testSetMessageDigest() {
    for (int ii=0; ii<algorithmName.length; ii++) {
        try {
            DigestInputStream dis = new DigestInputStream(null, null);
            MessageDigest md = MessageDigest.getInstance(algorithmName[ii]);
            dis.setMessageDigest(md);
            
            assertTrue(dis.getMessageDigest() == md);
            return;
        } catch (NoSuchAlgorithmException e) {
            // allowed failure
        }
    }
    fail(getName() + ": no MessageDigest algorithms available - test not performed");
}
 
開發者ID:shannah,項目名稱:cn1,代碼行數:21,代碼來源:DigestInputStreamTest.java

示例3: test_setMessageDigestLjava_security_MessageDigest

import java.security.DigestInputStream; //導入方法依賴的package包/類
/**
 * java.security.DigestInputStream#setMessageDigest(java.security.MessageDigest)
 */
public void test_setMessageDigestLjava_security_MessageDigest() {
    // Test for method void
    // java.security.DigestInputStream.setMessageDigest(java.security.MessageDigest)
    DigestInputStream dis = new DigestInputStream(inStream, null);

    // make sure the digest is null when it's not been set
    assertNull(
            "Uninitialised MessageDigest should have been returned as null",
            dis.getMessageDigest());
    dis.setMessageDigest(digest);
    assertEquals("Wrong MessageDigest was returned.", digest, dis
            .getMessageDigest());
}
 
開發者ID:keplersj,項目名稱:In-the-Box-Fork,代碼行數:17,代碼來源:DigestInputStream2Test.java

示例4: test_setMessageDigestLjava_security_MessageDigest

import java.security.DigestInputStream; //導入方法依賴的package包/類
/**
 * @tests java.security.DigestInputStream#setMessageDigest(java.security.MessageDigest)
 */
public void test_setMessageDigestLjava_security_MessageDigest() {
	// Test for method void
	// java.security.DigestInputStream.setMessageDigest(java.security.MessageDigest)
	DigestInputStream dis = new DigestInputStream(inStream, null);
	
	// make sure the digest is null when it's not been set
	assertNull(
			"Uninitialised MessageDigest should have been returned as null",
			dis.getMessageDigest());
	dis.setMessageDigest(digest);
	assertEquals("Wrong MessageDigest was returned.", digest, dis
			.getMessageDigest());
}
 
開發者ID:shannah,項目名稱:cn1,代碼行數:17,代碼來源:DigestInputStream2Test.java


注:本文中的java.security.DigestInputStream.setMessageDigest方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。