Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
 package org.bouncycastle.asn1.test;
 
 
    extends ASN1UnitTest
    public String getName()
    {
        return "AdmissionSyntax";
    }
    public void performTest()
        throws Exception
    {
        GeneralName     name = new GeneralName(new X509Name("CN=hello world"));
        ASN1Sequence    admissions = new DERSequence(
                                        new Admissions(name,
                                          new NamingAuthority(new ASN1ObjectIdentifier("1.2.3"), "url"new DirectoryString("fred")),
                                          new ProfessionInfo[0]));
        AdmissionSyntax syntax = new AdmissionSyntax(nameadmissions);
        checkConstruction(syntaxnameadmissions);
        syntax = AdmissionSyntax.getInstance(null);
        if (syntax != null)
        {
            fail("null getInstance() failed.");
        }
        try
        {
            AdmissionSyntax.getInstance(new Object());
            fail("getInstance() failed to detect bad object.");
        }
        catch (IllegalArgumentException e)
        {
            // expected
        }
    }
    private void checkConstruction(
        AdmissionSyntax syntax,
        GeneralName     authority,
        ASN1Sequence    admissions)
        throws IOException
    {
        checkValues(syntaxauthorityadmissions);
        syntax = AdmissionSyntax.getInstance(syntax);
        checkValues(syntaxauthorityadmissions);
        ASN1InputStream aIn = new ASN1InputStream(syntax.toASN1Object().getEncoded());
        ASN1Sequence info = (ASN1Sequence)aIn.readObject();
        syntax = AdmissionSyntax.getInstance(info);
        checkValues(syntaxauthorityadmissions);
    }
    private void checkValues(
        AdmissionSyntax syntax,
        GeneralName     authority,
        ASN1Sequence    admissions)
    {
        checkMandatoryField("admissionAuthority"authoritysyntax.getAdmissionAuthority());
        Admissions[] adm = syntax.getContentsOfAdmissions();
        if (adm.length != 1 || !adm[0].equals(admissions.getObjectAt(0)))
        {
            fail("admissions check failed");
        }
    }
    public static void main(
        String[]    args)
    {
        runTest(new AdmissionSyntaxUnitTest());
    }
New to GrepCode? Check out our FAQ X