Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
  package org.bouncycastle.asn1.test;
  
  
 
     extends SimpleTest
 {
     public String getName()
     {
         return "CommitmentTypeQualifier";
     }
 
     public void performTest() 
         throws Exception
     {
         
         
         ASN1Encodable info = new ASN1ObjectIdentifier("1.2");
         
         ctq = new CommitmentTypeQualifier(.info);
 
         
         ctq = CommitmentTypeQualifier.getInstance(null);
         
         if (ctq != null)
         {
             fail("null getInstance() failed.");
         }
         
         try
         {
             CommitmentTypeQualifier.getInstance(new Object());
             
             fail("getInstance() failed to detect bad object.");
         }
         catch (IllegalArgumentException e)
         {
             // expected
         }
     }
 
     private void checkConstruction(
          CommitmentTypeQualifier mv,
          ASN1ObjectIdentifier commitmenttTypeId,
          ASN1Encodable qualifier
          throws IOException
     {
         checkStatement(mvcommitmenttTypeIdqualifier);
         
         mv = CommitmentTypeQualifier.getInstance(mv);
         
         checkStatement(mvcommitmenttTypeIdqualifier);
         
         ASN1InputStream aIn = new ASN1InputStream(mv.toASN1Object().getEncoded());
 
         ASN1Sequence seq = (ASN1Sequence)aIn.readObject();
         
         mv = CommitmentTypeQualifier.getInstance(seq);
         
         checkStatement(mvcommitmenttTypeIdqualifier);
     }
 
     private void checkStatement(
         CommitmentTypeQualifier ctq,
         ASN1ObjectIdentifier     commitmentTypeId,
         ASN1Encodable           qualifier)
     {
         if (!ctq.getCommitmentTypeIdentifier().equals(commitmentTypeId))
         {
             fail("commitmentTypeIds don't match.");
         }
         
         if (qualifier != null)
         {
             if (!ctq.getQualifier().equals(qualifier))
             {
                 fail("qualifiers don't match.");
             }
         }
         else if (ctq.getQualifier() != null)
         {
             fail("qualifier found when none expected.");
         }
     }
     
     public static void main(
         String[]    args)
     {
    }
New to GrepCode? Check out our FAQ X