/** * Tests the ASN.1 encoding for the response control. * * @throws Exception If an unexpected problem occurs. */ @Test() public void testASN1ValueEncoding() throws Exception { ByteStringBuilder builder = new ByteStringBuilder(); ASN1Writer writer = ASN1.getWriter(builder); VLVResponseControl vlvResponse = new VLVResponseControl(true, 0, 15, 0, ByteString.valueOf("foo")); vlvResponse.writeValue(writer); ASN1Reader reader = ASN1.getReader(builder.toByteString()); // Should start as an octet string with a nested sequence assertEquals(reader.peekType(), ASN1Constants.UNIVERSAL_OCTET_STRING_TYPE); reader.readStartSequence(); // Should be an sequence start assertEquals(reader.peekType(), ASN1Constants.UNIVERSAL_SEQUENCE_TYPE); reader.readStartSequence(); // Should be an integer with targetPosition assertEquals(reader.peekType(), ASN1Constants.UNIVERSAL_INTEGER_TYPE); assertEquals(reader.readInteger(), 0); // Should be an integer with contentCount assertEquals(reader.peekType(), ASN1Constants.UNIVERSAL_INTEGER_TYPE); assertEquals(reader.readInteger(), 15); // Should be an enumerated with virtualListViewResult assertEquals(reader.peekType(), ASN1Constants.UNIVERSAL_ENUMERATED_TYPE); assertEquals(reader.readEnumerated(), 0); // Should be an octet string with contextID assertEquals(reader.peekType(), ASN1Constants.UNIVERSAL_OCTET_STRING_TYPE); assertEquals(reader.readOctetStringAsString(), "foo"); }