Package javax.management.remote

Examples of javax.management.remote.JMXConnectionNotification


    }

    public void testOpenedNotification()
    {
        when(_usernameAccessor.getUsernameForConnectionId(TEST_JMX_UNIQUE_CONNECTION_ID)).thenReturn(TEST_USER);
        JMXConnectionNotification openNotification = createMockNotification(TEST_JMX_UNIQUE_CONNECTION_ID, OPENED);

        _reporter.handleNotification(openNotification, null);

        verify(_rootMessageLogger).rawMessage("[main] MNG-1007 : Open : User jmxuser", "qpid.message.managementconsole.open");
    }
View Full Code Here


    }

    public void testClosedNotification()
    {
        when(_usernameAccessor.getUsernameForConnectionId(TEST_JMX_UNIQUE_CONNECTION_ID)).thenReturn(TEST_USER);
        JMXConnectionNotification closeNotification = createMockNotification(TEST_JMX_UNIQUE_CONNECTION_ID, CLOSED);

        _reporter.handleNotification(closeNotification, null);

        verify(_rootMessageLogger).rawMessage("[main] MNG-1008 : Close : User jmxuser", "qpid.message.managementconsole.close");
    }
View Full Code Here

        verify(_rootMessageLogger).rawMessage("[main] MNG-1008 : Close : User jmxuser", "qpid.message.managementconsole.close");
    }

    public void tesNotifiedForLogOnTypeEvents()
    {
        JMXConnectionNotification openNotification = createMockNotification(TEST_JMX_UNIQUE_CONNECTION_ID, OPENED);
        JMXConnectionNotification closeNotification = createMockNotification(TEST_JMX_UNIQUE_CONNECTION_ID, CLOSED);
        JMXConnectionNotification failedNotification = createMockNotification(TEST_JMX_UNIQUE_CONNECTION_ID, FAILED);

        assertTrue(_reporter.isNotificationEnabled(openNotification));
        assertTrue(_reporter.isNotificationEnabled(closeNotification));
        assertTrue(_reporter.isNotificationEnabled(failedNotification));

        JMXConnectionNotification otherNotification = createMockNotification(TEST_JMX_UNIQUE_CONNECTION_ID, "other");
        assertFalse(_reporter.isNotificationEnabled(otherNotification));
    }
View Full Code Here

        assertFalse(_reporter.isNotificationEnabled(otherNotification));
    }

    private JMXConnectionNotification createMockNotification(String connectionId, String notificationType)
    {
        JMXConnectionNotification notification = mock(JMXConnectionNotification.class);
        when(notification.getConnectionId()).thenReturn(connectionId);
        when(notification.getType()).thenReturn(notificationType);
        return notification;
    }
View Full Code Here

        Notification n = new Notification("touched", this, mSequence++, mTimestamp, "I was touched");
        sendNotification(n);
    }

    public void triggerConnectionNotification() {
        JMXConnectionNotification n = new JMXConnectionNotification("connection", this,
                "conn-123", mSequence++, "connection notification", null);
        n.setTimeStamp(mTimestamp);
        sendNotification(n);
    }
View Full Code Here

     */
    private class ConnectionNotificationListener implements NotificationListener {

        @Override
        public void handleNotification(Notification notification, Object handback) {
            JMXConnectionNotification connectionNotification = (JMXConnectionNotification)notification;
            // only reset the connection if the notification is for the connection from this endpoint
            if (!connectionNotification.getConnectionId().equals(mConnectionId)) {
                return;
            }
            if (connectionNotification.getType().equals(JMXConnectionNotification.NOTIFS_LOST)
                        || connectionNotification.getType().equals(JMXConnectionNotification.CLOSED)
                        || connectionNotification.getType().equals(JMXConnectionNotification.FAILED)) {
                LOG.warn("Lost JMX connection for : {}", URISupport.sanitizeUri(mJmxEndpoint.getEndpointUri()));
                if (mJmxEndpoint.getReconnectOnConnectionFailure()) {
                    scheduleReconnect();
                } else {
                    LOG.warn("The JMX consumer will not be reconnected.  Use 'reconnectOnConnectionFailure' to "
View Full Code Here

    }

    public void testOpenedNotification()
    {
        when(_usernameAccessor.getSubjectConnectionId(TEST_JMX_UNIQUE_CONNECTION_ID)).thenReturn(TEST_USER);
        JMXConnectionNotification openNotification = createMockNotification(TEST_JMX_UNIQUE_CONNECTION_ID, OPENED);

        _reporter.handleNotification(openNotification, null);

        verify(_messageLogger).message(messageMatch("MNG-1007 : Open : User jmxuser",
                                                        "qpid.message.managementconsole.open"));
View Full Code Here

    }

    public void testClosedNotification()
    {
        when(_usernameAccessor.getSubjectConnectionId(TEST_JMX_UNIQUE_CONNECTION_ID)).thenReturn(TEST_USER);
        JMXConnectionNotification closeNotification = createMockNotification(TEST_JMX_UNIQUE_CONNECTION_ID, CLOSED);

        _reporter.handleNotification(closeNotification, null);

        verify(_messageLogger).message(messageMatch("MNG-1008 : Close : User jmxuser", "qpid.message.managementconsole.close"));
    }
View Full Code Here

        verify(_messageLogger).message(messageMatch("MNG-1008 : Close : User jmxuser", "qpid.message.managementconsole.close"));
    }

    public void tesNotifiedForLogOnTypeEvents()
    {
        JMXConnectionNotification openNotification = createMockNotification(TEST_JMX_UNIQUE_CONNECTION_ID, OPENED);
        JMXConnectionNotification closeNotification = createMockNotification(TEST_JMX_UNIQUE_CONNECTION_ID, CLOSED);
        JMXConnectionNotification failedNotification = createMockNotification(TEST_JMX_UNIQUE_CONNECTION_ID, FAILED);

        assertTrue(_reporter.isNotificationEnabled(openNotification));
        assertTrue(_reporter.isNotificationEnabled(closeNotification));
        assertTrue(_reporter.isNotificationEnabled(failedNotification));

        JMXConnectionNotification otherNotification = createMockNotification(TEST_JMX_UNIQUE_CONNECTION_ID, "other");
        assertFalse(_reporter.isNotificationEnabled(otherNotification));
    }
View Full Code Here

        assertFalse(_reporter.isNotificationEnabled(otherNotification));
    }

    private JMXConnectionNotification createMockNotification(String connectionId, String notificationType)
    {
        JMXConnectionNotification notification = mock(JMXConnectionNotification.class);
        when(notification.getConnectionId()).thenReturn(connectionId);
        when(notification.getType()).thenReturn(notificationType);
        return notification;
    }
View Full Code Here

TOP

Related Classes of javax.management.remote.JMXConnectionNotification

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.