添加单元测试
This commit is contained in:
@@ -0,0 +1,48 @@
|
||||
import com.sunyard.SydApi;
|
||||
import org.junit.After;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import racal.sunyard.main.SydApi4j;
|
||||
|
||||
public class HashTest {
|
||||
|
||||
// private static final String ip = "192.168.1.197";
|
||||
// private static final String dn = "/C=cn/O=CFCA TEST CA/OU=CIPSTEST/OU=Units/CN=041@3CIPSCNSHCLR@CN000000129@00000017";
|
||||
// private static final String ip = "192.168.1.129";
|
||||
private static final String ip = "172.16.17.161";
|
||||
// private static final String dn = "C=cn,O=CFCA TEST CA,OU=CIPSTEST,OU=Units,CN=041@3PBOCCNSFCFX@CN000000129@00000003";//"C=CN,O=CFCA OCA1,OU=YCCA,OU=Individual-2,CN=YCCA@黄金交易所@Zhuangj@1";
|
||||
// private static final String dn = "C=cn,O=CFCA TEST CA,OU=CIPSTEST,OU=Units,CN=041@3CIPSCNSHCLR@CN000000129@00000022";
|
||||
private static final String dn = "C=CN,O=CFCA OCA1,OU=YCCA,OU=Individual-2,CN=YCCA@黄金交易所@Zhuangj@1";
|
||||
private static final String rsa = "C=CN,O=sunyard,OU=rsa,CN=javaRsa";
|
||||
private SydApi api;
|
||||
|
||||
@Before
|
||||
public void before() {
|
||||
System.setProperty("com.sunyard.sydapi4j.debug", "true");
|
||||
api = new SydApi4j().connect(ip, 8889, null, 5000);
|
||||
}
|
||||
|
||||
@After
|
||||
public void after() {
|
||||
if (null != api) {
|
||||
api.disconnect();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void md5(){
|
||||
api.itHash( 2, new byte[ 5 * 1024 * 1024 ]);
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void sha1(){
|
||||
api.itHash( 0, new byte[ 5 * 1024 * 1024 ]);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void sha256(){
|
||||
api.itHash( 1, new byte[ 5 * 1024 * 1024 ]);
|
||||
}
|
||||
}
|
||||
@@ -1,24 +0,0 @@
|
||||
import com.sunyard.SydApi;
|
||||
import com.sunyard.proto.Util;
|
||||
import racal.sunyard.main.SydApi4j;
|
||||
|
||||
import java.nio.charset.StandardCharsets;
|
||||
|
||||
public class SM3Test {
|
||||
|
||||
public static void main(String[] args) {
|
||||
|
||||
SydApi api = new SydApi4j().connect("192.168.0.100", 8889, null, 1000);
|
||||
try {
|
||||
byte[] data = api.SM3Hash("test".getBytes(StandardCharsets.UTF_8));
|
||||
System.out.println("hex=" + Util.bytes2HexString(data));
|
||||
}catch ( Exception e ) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user