TestIA5public class TestIA5 extends com.sun.midp.i3test.TestCase This test case tests DomainComponent encoding
made by RFC2253 class. |
Fields Summary |
---|
static byte[] | testOneResult | static byte[] | testTwoResult |
Methods Summary |
---|
private boolean | equal(byte[] one, byte[] two)Compare two byte arrays.
if (one.length != two.length) {
return false;
}
for (int i = 0; i < one.length; i++) {
if (one[i] != two[i]) {
return false;
}
}
return true;
| public void | runTests()Run tests.
try {
declare("testOne");
testOne();
declare("testTwo");
testTwo();
declare("testThree");
testThree();
}
catch (Throwable t) {
fail("" + t);
}
| private void | testOne()Tests DER encoding of DomainComponent.
String nameInfo =
"cn=Certificate, dc=www, Dc=sun, dC=com";
TLV name;
boolean ok = true;
try {
name = new TLV(RFC2253Name.toDER(nameInfo), 0);
} catch (TLVException e) {
name = null;
ok = false;
}
assertTrue("Invalid name", ok);
assertTrue("Bad DER result", name != null &&
equal(name.getDERData(), testOneResult));
| private void | testThree()
String nameInfo =
"cn=Certificate, OID.0.9.2342.19200300.100.1.25=www, dc=sun, dc=com";
TLV name;
boolean ok = true;
try {
name = new TLV(RFC2253Name.toDER(nameInfo), 0);
} catch (TLVException e) {
name = null;
ok = false;
}
assertTrue("Invalid name", ok);
assertTrue("Bad DER result", name != null &&
equal(name.getDERData(), testOneResult));
| private void | testTwo()
String nameInfo =
"cn=Certificate1, dc=";
TLV name;
boolean ok = true;
try {
name = new TLV(RFC2253Name.toDER(nameInfo), 0);
} catch (TLVException e) {
name = null;
ok = false;
}
assertTrue("Invalid name", ok);
assertTrue("Bad DER result", name != null &&
equal(name.getDERData(), testTwoResult));
|
|