本文整理匯總了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");
}
示例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");
}
示例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());
}
示例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());
}