Search in sources :

Example 71 with LogMessage

use of org.apache.qpid.server.logging.LogMessage in project qpid-broker-j by apache.

the class SubjectCreatorTest method testUnsuccessfulAuthentication.

private void testUnsuccessfulAuthentication(AuthenticationStatus expectedStatus) {
    AuthenticationResult failedAuthenticationResult = new AuthenticationResult(expectedStatus);
    when(_testSaslNegotiator.handleResponse(_saslResponseBytes)).thenReturn(failedAuthenticationResult);
    SubjectAuthenticationResult subjectAuthenticationResult = _subjectCreator.authenticate(_testSaslNegotiator, _saslResponseBytes);
    assertSame(expectedStatus, subjectAuthenticationResult.getStatus());
    assertNull(subjectAuthenticationResult.getSubject());
    if (expectedStatus == AuthenticationStatus.ERROR) {
        ArgumentCaptor<LogMessage> argument = ArgumentCaptor.forClass(LogMessage.class);
        verify(_eventLogger).message(argument.capture());
        assertTrue("Unexpected operational log message", argument.getValue().toString().startsWith("ATH-1010"));
    }
}
Also used : LogMessage(org.apache.qpid.server.logging.LogMessage) SubjectAuthenticationResult(org.apache.qpid.server.security.auth.SubjectAuthenticationResult) SubjectAuthenticationResult(org.apache.qpid.server.security.auth.SubjectAuthenticationResult) AuthenticationResult(org.apache.qpid.server.security.auth.AuthenticationResult)

Example 72 with LogMessage

use of org.apache.qpid.server.logging.LogMessage in project qpid-broker-j by apache.

the class ServerSession method onClose.

public void onClose() {
    AMQPConnection_0_10 amqpConnection = getAMQPConnection();
    if (_transaction instanceof LocalTransaction) {
        if (((LocalTransaction) _transaction).hasOutstandingWork()) {
            amqpConnection.incrementTransactionRollbackCounter();
        }
        amqpConnection.decrementTransactionOpenCounter();
        _transaction.rollback();
        amqpConnection.unregisterTransactionTickers(_transaction);
    } else if (_transaction instanceof DistributedTransaction) {
        getAddressSpace().getDtxRegistry().endAssociations(_modelObject);
    }
    for (MessageDispositionChangeListener listener : _messageDispositionListenerMap.values()) {
        listener.onRelease(true, true);
    }
    _messageDispositionListenerMap.clear();
    for (Action<? super Session_0_10> task : _modelObject.getTaskList()) {
        task.performAction(_modelObject);
    }
    LogMessage operationalLoggingMessage = _forcedCloseLogMessage.get();
    if (operationalLoggingMessage == null && getConnection().getConnectionCloseMessage() != null) {
        operationalLoggingMessage = ChannelMessages.CLOSE_FORCED(getConnection().getConnectionCloseCode(), getConnection().getConnectionCloseMessage());
    }
    if (operationalLoggingMessage == null) {
        operationalLoggingMessage = ChannelMessages.CLOSE();
    }
    amqpConnection.getEventLogger().message(getLogSubject(), operationalLoggingMessage);
}
Also used : DistributedTransaction(org.apache.qpid.server.txn.DistributedTransaction) LocalTransaction(org.apache.qpid.server.txn.LocalTransaction) LogMessage(org.apache.qpid.server.logging.LogMessage)

Example 73 with LogMessage

use of org.apache.qpid.server.logging.LogMessage in project qpid-broker-j by apache.

the class ProducerFlowControlOverflowPolicyHandlerTest method testCheckOverflowBlocksSessionWhenOverfullMessages.

public void testCheckOverflowBlocksSessionWhenOverfullMessages() throws Exception {
    AMQPSession<?, ?> session = mock(AMQPSession.class);
    when(_queue.getMaximumQueueDepthMessages()).thenReturn(10L);
    when(_queue.getQueueDepthMessages()).thenReturn(11);
    checkOverflow(session);
    verify(session, times(1)).block(_queue);
    LogMessage logMessage = QueueMessages.OVERFULL(0, -1, 11, 10);
    verify(_eventLogger).message(same(_subject), argThat(new LogMessageMatcher(logMessage)));
    verifyNoMoreInteractions(_eventLogger);
    verifyNoMoreInteractions(session);
}
Also used : LogMessage(org.apache.qpid.server.logging.LogMessage)

Example 74 with LogMessage

use of org.apache.qpid.server.logging.LogMessage in project qpid-broker-j by apache.

the class ProducerFlowControlOverflowPolicyHandlerTest method testCheckOverflowBlocksSessionWhenOverfullBytes.

public void testCheckOverflowBlocksSessionWhenOverfullBytes() throws Exception {
    AMQPSession<?, ?> session = mock(AMQPSession.class);
    when(_queue.getQueueDepthBytes()).thenReturn(11L);
    when(_queue.getMaximumQueueDepthBytes()).thenReturn(10L);
    checkOverflow(session);
    verify(session, times(1)).block(_queue);
    LogMessage logMessage = QueueMessages.OVERFULL(11, 10, 0, -1);
    verify(_eventLogger).message(same(_subject), argThat(new LogMessageMatcher(logMessage)));
    verifyNoMoreInteractions(_eventLogger);
    verifyNoMoreInteractions(session);
}
Also used : LogMessage(org.apache.qpid.server.logging.LogMessage)

Example 75 with LogMessage

use of org.apache.qpid.server.logging.LogMessage in project qpid-broker-j by apache.

the class ProducerFlowControlOverflowPolicyHandlerTest method testCheckOverflowResumesFlowWhenUnderfullBytes.

public void testCheckOverflowResumesFlowWhenUnderfullBytes() throws Exception {
    AMQPSession<?, ?> session = mock(AMQPSession.class);
    when(_queue.getQueueDepthBytes()).thenReturn(11L);
    when(_queue.getMaximumQueueDepthBytes()).thenReturn(10L);
    checkOverflow(session);
    verify(session, times(1)).block(_queue);
    LogMessage overfullMessage = QueueMessages.OVERFULL(11, 10, 0, -1);
    verify(_eventLogger).message(same(_subject), argThat(new LogMessageMatcher(overfullMessage)));
    assertTrue("Flow should be stopped", _producerFlowControlOverflowPolicyHandler.isQueueFlowStopped());
    when(_queue.getQueueDepthBytes()).thenReturn(8L);
    _producerFlowControlOverflowPolicyHandler.checkOverflow(null);
    verify(session, times(1)).unblock(_queue);
    assertFalse("Flow should not be stopped", _producerFlowControlOverflowPolicyHandler.isQueueFlowStopped());
    LogMessage underfullMessage = QueueMessages.UNDERFULL(8, 8, 0, -1);
    verify(_eventLogger).message(same(_subject), argThat(new LogMessageMatcher(underfullMessage)));
    verifyNoMoreInteractions(_eventLogger);
    verifyNoMoreInteractions(session);
}
Also used : LogMessage(org.apache.qpid.server.logging.LogMessage)

Aggregations

LogMessage (org.apache.qpid.server.logging.LogMessage)152 MessageFormat (java.text.MessageFormat)105 LogMessageMatcher (org.apache.qpid.server.queue.ProducerFlowControlOverflowPolicyHandlerTest.LogMessageMatcher)2 LocalTransaction (org.apache.qpid.server.txn.LocalTransaction)2 Subject (javax.security.auth.Subject)1 ConnectionPrincipal (org.apache.qpid.server.connection.ConnectionPrincipal)1 EventLogger (org.apache.qpid.server.logging.EventLogger)1 LogSubject (org.apache.qpid.server.logging.LogSubject)1 UnitTestMessageLogger (org.apache.qpid.server.logging.UnitTestMessageLogger)1 AuthenticationResult (org.apache.qpid.server.security.auth.AuthenticationResult)1 SubjectAuthenticationResult (org.apache.qpid.server.security.auth.SubjectAuthenticationResult)1 DistributedTransaction (org.apache.qpid.server.txn.DistributedTransaction)1