use of com.unboundid.asn1.ASN1Buffer in project ldapsdk by pingidentity.
the class SearchRequestProtocolOpTestCase method testDecodeMalformedFilter.
/**
* Tests the behavior when trying to decode a search request with a malformed
* filter.
*
* @throws Exception If an unexpected problem occurs.
*/
@Test(expectedExceptions = { LDAPException.class })
public void testDecodeMalformedFilter() throws Exception {
ASN1Buffer b = new ASN1Buffer();
ASN1BufferSequence s = b.beginSequence((byte) 0x63);
b.addOctetString("dc=example,dc=com");
b.addEnumerated(2);
b.addEnumerated(0);
b.addInteger(0);
b.addInteger(0);
b.addBoolean(false);
b.addOctetString((byte) 0x00);
b.beginSequence().end();
s.end();
ByteArrayInputStream inputStream = new ByteArrayInputStream(b.toByteArray());
ASN1StreamReader reader = new ASN1StreamReader(inputStream);
new SearchRequestProtocolOp(reader);
}
use of com.unboundid.asn1.ASN1Buffer in project ldapsdk by pingidentity.
the class UnbindRequestProtocolOpTestCase method testUnbindRequestProtocolOp.
/**
* Provides test coverage for the unbind request protocol op.
*
* @throws Exception If an unexpected problem occurs.
*/
@Test()
public void testUnbindRequestProtocolOp() throws Exception {
UnbindRequestProtocolOp op = new UnbindRequestProtocolOp();
ASN1Buffer buffer = new ASN1Buffer();
op.writeTo(buffer);
byte[] opBytes = buffer.toByteArray();
ByteArrayInputStream inputStream = new ByteArrayInputStream(opBytes);
ASN1StreamReader reader = new ASN1StreamReader(inputStream);
op = new UnbindRequestProtocolOp(reader);
op = UnbindRequestProtocolOp.decodeProtocolOp(op.encodeProtocolOp());
assertEquals(op.getProtocolOpType(), (byte) 0x42);
assertNotNull(op.toString());
}
use of com.unboundid.asn1.ASN1Buffer in project ldapsdk by pingidentity.
the class CompareRequestTestCase method testEncoding.
/**
* Tests to ensure that the encoding for the provided compare request is
* identical when using the stream-based and non-stream-based ASN.1 encoding
* mechanisms.
*
* @param compareRequest The compare request to be tested.
*
* @throws Exception If an unexpected problem occurs.
*/
private static void testEncoding(final CompareRequest compareRequest) throws Exception {
ASN1Element protocolOpElement = compareRequest.encodeProtocolOp();
ASN1Buffer b = new ASN1Buffer();
compareRequest.writeTo(b);
assertTrue(Arrays.equals(b.toByteArray(), protocolOpElement.encode()));
}
use of com.unboundid.asn1.ASN1Buffer in project ldapsdk by pingidentity.
the class DeleteRequestTestCase method testEncoding.
/**
* Tests to ensure that the encoding for the provided delete request is
* identical when using the stream-based and non-stream-based ASN.1 encoding
* mechanisms.
*
* @param deleteRequest The delete request to be tested.
*
* @throws Exception If an unexpected problem occurs.
*/
private static void testEncoding(final DeleteRequest deleteRequest) throws Exception {
ASN1Element protocolOpElement = deleteRequest.encodeProtocolOp();
ASN1Buffer b = new ASN1Buffer();
deleteRequest.writeTo(b);
assertTrue(Arrays.equals(b.toByteArray(), protocolOpElement.encode()));
}
use of com.unboundid.asn1.ASN1Buffer in project ldapsdk by pingidentity.
the class ModifyDNRequestTestCase method testEncoding.
/**
* Tests to ensure that the encoding for the provided modify DN request is
* identical when using the stream-based and non-stream-based ASN.1 encoding
* mechanisms.
*
* @param modifyDNRequest The modify DN request to be tested.
*
* @throws Exception If an unexpected problem occurs.
*/
private static void testEncoding(final ModifyDNRequest modifyDNRequest) throws Exception {
ASN1Element protocolOpElement = modifyDNRequest.encodeProtocolOp();
ASN1Buffer b = new ASN1Buffer();
modifyDNRequest.writeTo(b);
assertTrue(Arrays.equals(b.toByteArray(), protocolOpElement.encode()));
}
Aggregations