use of com.unboundid.ldap.sdk.unboundidds.logs.LogException in project ldapsdk by pingidentity.
the class TextFormattedAccessLogReaderTestCase method testReadMessageWithoutAnyUnnamedFields.
/**
* Tests the behavior when trying to read a file that contains a log message
* that doesn't have any unnamed fields.
*
* @throws Exception If an unexpected problem occurs.
*/
@Test()
public void testReadMessageWithoutAnyUnnamedFields() throws Exception {
final StringBuilder messageBuffer = createLogMessage(true, null, null, false);
appendField(messageBuffer, DIAGNOSTIC_MESSAGE, "value1");
appendField(messageBuffer, ADDITIONAL_INFO, "value2");
final File logFile = createTempFile(messageBuffer.toString());
try (TextFormattedAccessLogReader reader = new TextFormattedAccessLogReader(logFile)) {
reader.readMessage();
fail("Expected an exception for a file that contains a message without " + "any unnamed fields");
} catch (final LogException e) {
// This was expected.
}
}
use of com.unboundid.ldap.sdk.unboundidds.logs.LogException in project ldapsdk by pingidentity.
the class TextFormattedAccessLogReaderTestCase method testReadUnbindForwardMessage.
/**
* Tests the behavior when trying to read a file that contains a log message
* that attempts to create an unbind forward message, which is not valid.
*
* @throws Exception If an unexpected problem occurs.
*/
@Test()
public void testReadUnbindForwardMessage() throws Exception {
final StringBuilder messageBuffer = createLogMessage(true, FORWARD, UNBIND, false);
final File logFile = createTempFile(messageBuffer.toString());
try (TextFormattedAccessLogReader reader = new TextFormattedAccessLogReader(logFile)) {
reader.readMessage();
fail("Expected an exception for a file that contains an unbind forward " + "message");
} catch (final LogException e) {
// This was expected.
}
}
use of com.unboundid.ldap.sdk.unboundidds.logs.LogException in project ldapsdk by pingidentity.
the class TextFormattedAccessLogReaderTestCase method testReadMessageWithUnsupportedSecondUnnamedField.
/**
* Tests the behavior when trying to read a file that contains a log message
* that has two unnamed fields in which the second is not a valid message
* type.
*
* @throws Exception If an unexpected problem occurs.
*/
@Test()
public void testReadMessageWithUnsupportedSecondUnnamedField() throws Exception {
final StringBuilder messageBuffer = createLogMessage(true, null, null, false);
messageBuffer.append("ADD UNSUPPORTED");
appendField(messageBuffer, DIAGNOSTIC_MESSAGE, "value1");
appendField(messageBuffer, ADDITIONAL_INFO, "value2");
final File logFile = createTempFile(messageBuffer.toString());
try (TextFormattedAccessLogReader reader = new TextFormattedAccessLogReader(logFile)) {
reader.readMessage();
fail("Expected an exception for a file that contains a message with " + "an unsupported second unnamed field");
} catch (final LogException e) {
// This was expected.
}
}
use of com.unboundid.ldap.sdk.unboundidds.logs.LogException in project ldapsdk by pingidentity.
the class TextFormattedAccessLogReaderTestCase method testFileMalformedLogMessage.
/**
* Tests the behavior when trying to read a file that doesn't contain valid
* log messages.
*
* @throws Exception If an unexpected problem occurs.
*/
@Test()
public void testFileMalformedLogMessage() throws Exception {
final File logFile = createTempFile("# This is a comment", "# The next line will be blank", "", "# The next line will be parsed as a log message, but it's " + "malformed.", "This is a malformed log message");
try (FileInputStream inputStream = new FileInputStream(logFile);
TextFormattedAccessLogReader reader = new TextFormattedAccessLogReader(inputStream)) {
reader.readMessage();
fail("Expected an exception for a file that contains a malformed " + "message.");
} catch (final LogException e) {
// This was expected.
}
}
use of com.unboundid.ldap.sdk.unboundidds.logs.LogException in project ldapsdk by pingidentity.
the class JSONAccessLogReaderTestCase method testReadUnbindForwardFailedMessage.
/**
* Tests the behavior when trying to read a file containing a JSON object for
* a forward failed log message for an unbind operation (which can't be
* forwarded).
*
* @throws Exception If an unexpected problem occurs.
*/
@Test()
public void testReadUnbindForwardFailedMessage() throws Exception {
final JSONObject messageObject = createMinimalMessageObject(FORWARD_FAILED, UNBIND);
final File logFile = createTempFile(messageObject.toSingleLineString());
try (JSONAccessLogReader reader = new JSONAccessLogReader(logFile)) {
reader.readMessage();
fail("Expected an exception for a forward failed message with an " + "operation type of unbind.");
} catch (final LogException e) {
// This was expected.
}
}
Aggregations