FileDocCategorySizeDatePackage
TestIA5.javaAPI DocphoneME MR2 API (J2ME)5397Wed May 02 18:00:38 BST 2007com.sun.satsa.utils

TestIA5

public 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
Constructors Summary
Methods Summary
private booleanequal(byte[] one, byte[] two)
Compare two byte arrays.

param
one the first array
param
two the second array
return
true if arrays are equal, false otherwise

        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 voidrunTests()
Run tests.

        try {
            declare("testOne");
            testOne();
            
            declare("testTwo");
            testTwo();
            
            declare("testThree");
            testThree();
        }
        catch (Throwable t) {
            fail("" + t);
        }
    
private voidtestOne()
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 voidtestThree()

        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 voidtestTwo()

        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));