当前位置: 首页>>代码示例>>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;未经允许,请勿转载。