下面列出了java.security.cert.X509CRLSelector#setMinCRLNumber() 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。
/**
* setMinCRLNumber(BigInteger minCRL) method testing. Tests if CRLs with any
* crl number value match the selector in the case of null crlNumber
* criteria, if specified minCRL value matches the selector, and if CRL with
* inappropriate crlNumber value does not match the selector.
*/
public void testSetMinCRLNumberLjava_math_BigInteger() {
X509CRLSelector selector = new X509CRLSelector();
BigInteger minCRL = new BigInteger("10000");
CRL crl = new TestCRL(minCRL);
selector.setMinCRLNumber(null);
assertTrue("Any CRL should match in the case of null minCRLNumber.",
selector.match(crl));
selector.setMinCRLNumber(minCRL);
assertTrue("The CRL should match the selection criteria.", selector
.match(crl));
selector.setMinCRLNumber(new BigInteger("10001"));
assertFalse("The CRL should not match the selection criteria.",
selector.match(crl));
}
public void testToString() {
X509CRLSelector selector = new X509CRLSelector();
X500Principal iss1 = new X500Principal("O=First Org.");
X500Principal iss2 = new X500Principal("O=Second Org.");
BigInteger minCRL = new BigInteger("10000");
BigInteger maxCRL = new BigInteger("10000");
Date date = new Date(200);
selector.addIssuer(iss1);
selector.addIssuer(iss2);
selector.setMinCRLNumber(minCRL);
selector.setMaxCRLNumber(maxCRL);
selector.setDateAndTime(date);
assertNotNull("The result should not be null.", selector.toString());
}
/**
* getMinCRL() method testing. Tests if the method return null in the case
* of not specified minCRL criteria, and if the returned value corresponds
* to the specified one.
*/
public void testGetMinCRL() {
X509CRLSelector selector = new X509CRLSelector();
assertNull("Initially the minCRL should be null.", selector.getMinCRL());
BigInteger minCRL = new BigInteger("10000");
selector.setMinCRLNumber(minCRL);
assertTrue("The result should be equal to specified.", minCRL
.equals(selector.getMinCRL()));
}
/**
* clone() method testing. Tests if the selector is cloned correctly: the
* crl which matche to the initial selector should match to the clone and
* the change of clone should not cause the change of initial selector.
*/
public void testClone() {
X509CRLSelector selector = new X509CRLSelector();
X500Principal iss1 = new X500Principal("O=First Org.");
X500Principal iss2 = new X500Principal("O=Second Org.");
X500Principal iss3 = new X500Principal("O=Third Org.");
BigInteger minCRL = new BigInteger("10000");
BigInteger maxCRL = new BigInteger("10000");
Date date = new Date(200);
selector.addIssuer(iss1);
selector.addIssuer(iss2);
selector.setMinCRLNumber(minCRL);
selector.setMaxCRLNumber(maxCRL);
selector.setDateAndTime(date);
X509CRLSelector clone = (X509CRLSelector) selector.clone();
TestCRL crl = new TestCRL(iss1);
crl.setCrlNumber(minCRL);
crl.setUpdateDates(new Date(200), new Date(200));
assertTrue("The specified CRL should match the clone selector.",
selector.match(crl));
clone.addIssuer(iss3);
assertFalse("The changes of the clone selector should not cause "
+ "the changes of initial object", selector.getIssuerNames()
.size() == 3);
}