0x06, 0x02, 0x01, 0x03, // oid bytes
0x01, 0x00 // just random bytes
};
// pass boolean encoding
BerInputStream in = new BerInputStream(encoded, 0, 3);
assertEquals("boolean", 1, in.getLength());
// pass oid encoding
in = new BerInputStream(encoded, 3, 4);
assertEquals("boolean", 2, in.getLength());
// pass random encoding (equals to ANY)
in = new BerInputStream(encoded, 7, 2);
assertEquals("any", 0, in.getLength());
// extra bytes for oid
try {
new BerInputStream(encoded, 3, 5);
fail("No expected ASN1Exception");
} catch (ASN1Exception e) {
assertEquals("Wrong content length", e.getMessage());
}
// less bytes for oid
try {
new BerInputStream(encoded, 3, 3);
fail("No expected ASN1Exception");
} catch (ASN1Exception e) {
assertEquals("Wrong content length", e.getMessage());
}
}