01: package org.bouncycastle.asn1.test;
02:
03: import org.bouncycastle.asn1.DERApplicationSpecific;
04: import org.bouncycastle.asn1.DERInteger;
05: import org.bouncycastle.asn1.DERTags;
06: import org.bouncycastle.util.encoders.Hex;
07: import org.bouncycastle.util.test.SimpleTest;
08:
09: public class DERApplicationSpecificTest extends SimpleTest {
10: byte[] impData = Hex.decode("430109");
11:
12: public String getName() {
13: return "DERApplicationSpecific";
14: }
15:
16: public void performTest() throws Exception {
17: DERInteger value = new DERInteger(9);
18:
19: DERApplicationSpecific tagged = new DERApplicationSpecific(
20: false, 3, value);
21:
22: if (!areEqual(impData, tagged.getEncoded())) {
23: fail("implicit encoding failed");
24: }
25:
26: DERInteger recVal = (DERInteger) tagged
27: .getObject(DERTags.INTEGER);
28:
29: if (!value.equals(recVal)) {
30: fail("implicit read back failed");
31: }
32: }
33:
34: public static void main(String[] args) {
35: runTest(new DERApplicationSpecificTest());
36: }
37: }
|