本文整理汇总了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());
}