org.bouncycastle.asn1.test.OtherMsgTest Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of bcprov-jdk14 Show documentation
Show all versions of bcprov-jdk14 Show documentation
The Bouncy Castle Crypto package is a Java implementation of cryptographic algorithms. This jar contains JCE provider and lightweight API for the Bouncy Castle Cryptography APIs for JDK 1.4.
package org.bouncycastle.asn1.test;
import org.bouncycastle.asn1.DERSequence;
import org.bouncycastle.asn1.DERUTF8String;
import org.bouncycastle.asn1.cmc.BodyPartID;
import org.bouncycastle.asn1.cmc.OtherMsg;
import org.bouncycastle.asn1.pkcs.PKCSObjectIdentifiers;
import org.bouncycastle.util.test.SimpleTest;
public class OtherMsgTest
extends SimpleTest
{
public static void main(String[] args)
{
runTest(new OtherMsgTest());
}
public String getName()
{
return "OtherMsgTest";
}
public void performTest()
throws Exception
{
OtherMsg otherMsg = new OtherMsg(new BodyPartID(10L), PKCSObjectIdentifiers.id_aa, new DERUTF8String("Cats"));
byte[] b = otherMsg.getEncoded();
OtherMsg otherMsgResult = OtherMsg.getInstance(b);
isEquals("bodyPartID", otherMsg.getBodyPartID(), otherMsgResult.getBodyPartID());
isEquals("otherMsgType", otherMsg.getOtherMsgType(), otherMsgResult.getOtherMsgType());
isEquals("otherMsgValue", otherMsg.getOtherMsgValue(), otherMsgResult.getOtherMsgValue());
try {
OtherMsg.getInstance(new DERSequence());
fail("Sequence should be 3 elements long.");
} catch (Throwable t) {
isEquals("Sequence size",t.getClass(), IllegalArgumentException.class);
}
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy