if (!values.equals(val1))
if (!compareVectors(values, val1))
    public void performTest()        throws Exception    {        testEncodingPrintableString(X509Name.C, "AU");        testEncodingPrintableString(X509Name.SERIALNUMBER, "123456");        testEncodingPrintableString(X509Name.DN_QUALIFIER, "123456");        testEncodingIA5String(X509Name.EmailAddress, "test@test.com");        testEncodingIA5String(X509Name.DC, "test");        // correct encoding        testEncodingGeneralizedTime(X509Name.DATE_OF_BIRTH, "#180F32303032303132323132323232305A");        // compatability encoding        testEncodingGeneralizedTime(X509Name.DATE_OF_BIRTH, "20020122122220Z");        //        // composite        //        Hashtable                   attrs = new Hashtable();        attrs.put(X509Name.C, "AU");        attrs.put(X509Name.O, "The Legion of the Bouncy Castle");        attrs.put(X509Name.L, "Melbourne");        attrs.put(X509Name.ST, "Victoria");        attrs.put(X509Name.E, "feedback-crypto@bouncycastle.org");        X509Name    name1 = new X509Name(attrs);        if (!name1.equals(name1))        {            fail("Failed same object test");        }        if (!name1.equals(name1, true))        {            fail("Failed same object test - in Order");        }        X509Name    name2 = new X509Name(attrs);        if (!name1.equals(name2))        {            fail("Failed same name test");        }        if (!name1.equals(name2, true))        {            fail("Failed same name test - in Order");        }        if (name1.hashCode() != name2.hashCode())        {            fail("Failed same name test - in Order");        }        Vector  ord1 = new Vector();        ord1.addElement(X509Name.C);        ord1.addElement(X509Name.O);        ord1.addElement(X509Name.L);        ord1.addElement(X509Name.ST);        ord1.addElement(X509Name.E);        Vector  ord2 = new Vector();        ord2.addElement(X509Name.E);        ord2.addElement(X509Name.ST);        ord2.addElement(X509Name.L);        ord2.addElement(X509Name.O);        ord2.addElement(X509Name.C);        name1 = new X509Name(ord1, attrs);        name2 = new X509Name(ord2, attrs);        if (!name1.equals(name2))        {            fail("Failed reverse name test");        }        if (name1.equals(name2, true))        {            fail("Failed reverse name test - in Order");        }        if (!name1.equals(name2, false))        {            fail("Failed reverse name test - in Order false");        }        Vector oids = name1.getOIDs();        if (!oids.equals(ord1))        {            fail("oid comparison test");        }        Vector val1 = new Vector();        val1.addElement("AU");        val1.addElement("The Legion of the Bouncy Castle");        val1.addElement("Melbourne");        val1.addElement("Victoria");        val1.addElement("feedback-crypto@bouncycastle.org");        name1 = new X509Name(ord1, val1);                Vector values = name1.getValues();        if (!values.equals(val1))        {            fail("value comparison test");        }        ord2 = new Vector();        ord2.addElement(X509Name.ST);        ord2.addElement(X509Name.ST);        ord2.addElement(X509Name.L);        ord2.addElement(X509Name.O);        ord2.addElement(X509Name.C);        name1 = new X509Name(ord1, attrs);        name2 = new X509Name(ord2, attrs);        if (name1.equals(name2))        {            fail("Failed different name test");        }        ord2 = new Vector();        ord2.addElement(X509Name.ST);        ord2.addElement(X509Name.L);        ord2.addElement(X509Name.O);        ord2.addElement(X509Name.C);        name1 = new X509Name(ord1, attrs);        name2 = new X509Name(ord2, attrs);        if (name1.equals(name2))        {            fail("Failed subset name test");        }        compositeTest();        ByteArrayOutputStream bOut;        ASN1OutputStream aOut;        ASN1InputStream aIn;        //        // getValues test        //        Vector v1 = name1.getValues(X509Name.O);        if (v1.size() != 1 || !v1.elementAt(0).equals("The Legion of the Bouncy Castle"))        {            fail("O test failed");        }        Vector v2 = name1.getValues(X509Name.L);        if (v2.size() != 1 || !v2.elementAt(0).equals("Melbourne"))        {            fail("L test failed");        }        //        // general subjects test        //        for (int i = 0; i != subjects.length; i++)        {            X509Name    name = new X509Name(subjects[i]);            bOut = new ByteArrayOutputStream();            aOut = new ASN1OutputStream(bOut);            aOut.writeObject(name);            aIn = new ASN1InputStream(new ByteArrayInputStream(bOut.toByteArray()));            name = X509Name.getInstance(aIn.readObject());            if (!name.toString().equals(subjects[i]))            {                fail("failed regeneration test " + i);            }        }        //        // sort test        //        X509Name unsorted = new X509Name("SN=BBB + CN=AA");        if (!fromBytes(unsorted.getEncoded()).toString().equals("CN=AA+SN=BBB"))        {            fail("failed sort test 1");        }        unsorted = new X509Name("CN=AA + SN=BBB");        if (!fromBytes(unsorted.getEncoded()).toString().equals("CN=AA+SN=BBB"))        {            fail("failed sort test 2");        }        unsorted = new X509Name("SN=B + CN=AA");        if (!fromBytes(unsorted.getEncoded()).toString().equals("SN=B+CN=AA"))        {            fail("failed sort test 3");        }        unsorted = new X509Name("CN=AA + SN=B");        if (!fromBytes(unsorted.getEncoded()).toString().equals("SN=B+CN=AA"))        {            fail("failed sort test 4");        }        //        // equality tests        //        equalityTest(new X509Name("CN=The     Legion"), new X509Name("CN=The Legion"));        equalityTest(new X509Name("CN=   The Legion"), new X509Name("CN=The Legion"));        equalityTest(new X509Name("CN=The Legion   "), new X509Name("CN=The Legion"));        equalityTest(new X509Name("CN=  The     Legion "), new X509Name("CN=The Legion"));        equalityTest(new X509Name("CN=  the     legion "), new X509Name("CN=The Legion"));        //        // inequality to sequences        //        name1 = new X509Name("CN=The Legion");        if (name1.equals(new DERSequence()))        {            fail("inequality test with sequence");        }        if (name1.equals(new DERSequence(new DERSet())))        {            fail("inequality test with sequence and set");        }        ASN1EncodableVector v = new ASN1EncodableVector();        v.add(new DERObjectIdentifier("1.1"));        v.add(new DERObjectIdentifier("1.1"));        if (name1.equals(new DERSequence(new DERSet(new DERSet(v)))))        {            fail("inequality test with sequence and bad set");        }        if (name1.equals(new DERSequence(new DERSet(new DERSet(v))), true))        {            fail("inequality test with sequence and bad set");        }        if (name1.equals(new DERSequence(new DERSet(new DERSequence()))))        {            fail("inequality test with sequence and short sequence");        }        if (name1.equals(new DERSequence(new DERSet(new DERSequence())), true))        {            fail("inequality test with sequence and short sequence");        }        v = new ASN1EncodableVector();        v.add(new DERObjectIdentifier("1.1"));        v.add(new DERSequence());        if (name1.equals(new DERSequence(new DERSet(new DERSequence(v)))))        {            fail("inequality test with sequence and bad sequence");        }        if (name1.equals(null))        {            fail("inequality test with null");        }        if (name1.equals(null, true))        {            fail("inequality test with null");        }        //        // this is contrived but it checks sorting of sets with equal elements        //        unsorted = new X509Name("CN=AA + CN=AA + CN=AA");        //        // tagging test - only works if CHOICE implemented        //        /*        ASN1TaggedObject tag = new DERTaggedObject(false, 1, new X509Name("CN=AA"));        if (!tag.isExplicit())        {            fail("failed to explicitly tag CHOICE object");        }        X509Name name = X509Name.getInstance(tag, false);        if (!name.equals(new X509Name("CN=AA")))        {            fail("failed to recover tagged name");        }        */        DERUTF8String testString = new DERUTF8String("The Legion of the Bouncy Castle");        byte[] encodedBytes = testString.getEncoded();        byte[] hexEncodedBytes = Hex.encode(encodedBytes);        String hexEncodedString = "#" + new String(hexEncodedBytes);        DERUTF8String converted = (DERUTF8String)            new X509DefaultEntryConverter().getConvertedValue(                X509Name.L , hexEncodedString);        if (!converted.equals(testString))        {            fail("failed X509DefaultEntryConverter test");        }        //        // try a weird value        //    }