Search in sources :

Example 1 with NoopConnectionEstablishmentPolicy

use of org.apache.qpid.server.virtualhost.NoopConnectionEstablishmentPolicy in project qpid-broker-j by apache.

the class VirtualHostTest method testRegisterConnectionOnStoppedVirtualhost.

public void testRegisterConnectionOnStoppedVirtualhost() {
    QueueManagingVirtualHost<?> vhost = createVirtualHost("sdf");
    AMQPConnection<?> connection = getMockConnection();
    ((AbstractConfiguredObject<?>) vhost).stop();
    try {
        vhost.registerConnection(connection, new NoopConnectionEstablishmentPolicy());
        fail("exception not thrown");
    } catch (VirtualHostUnavailableException e) {
    // pass
    }
    assertEquals("unexpected number of connections", 0, vhost.getConnectionCount());
    ((AbstractConfiguredObject<?>) vhost).start();
    vhost.registerConnection(connection, new NoopConnectionEstablishmentPolicy());
    assertEquals("unexpected number of connections", 1, vhost.getConnectionCount());
}
Also used : VirtualHostUnavailableException(org.apache.qpid.server.virtualhost.VirtualHostUnavailableException) NoopConnectionEstablishmentPolicy(org.apache.qpid.server.virtualhost.NoopConnectionEstablishmentPolicy)

Example 2 with NoopConnectionEstablishmentPolicy

use of org.apache.qpid.server.virtualhost.NoopConnectionEstablishmentPolicy in project qpid-broker-j by apache.

the class VirtualHostTest method testRegisterConnection.

public void testRegisterConnection() {
    QueueManagingVirtualHost<?> vhost = createVirtualHost("sdf");
    AMQPConnection<?> connection = getMockConnection();
    assertEquals("unexpected number of connections before test", 0, vhost.getConnectionCount());
    vhost.registerConnection(connection, new NoopConnectionEstablishmentPolicy());
    assertEquals("unexpected number of connections after registerConnection", 1, vhost.getConnectionCount());
    assertEquals("unexpected connection object", Collections.singleton(connection), vhost.getConnections());
}
Also used : NoopConnectionEstablishmentPolicy(org.apache.qpid.server.virtualhost.NoopConnectionEstablishmentPolicy)

Example 3 with NoopConnectionEstablishmentPolicy

use of org.apache.qpid.server.virtualhost.NoopConnectionEstablishmentPolicy in project qpid-broker-j by apache.

the class VirtualHostTest method testStopVirtualHost_ClosesConnections.

public void testStopVirtualHost_ClosesConnections() {
    String virtualHostName = getName();
    QueueManagingVirtualHost<?> virtualHost = createVirtualHost(virtualHostName);
    assertEquals("Unexpected state", State.ACTIVE, virtualHost.getState());
    AbstractAMQPConnection connection = createMockProtocolConnection(virtualHost);
    assertEquals("Unexpected number of connections before connection registered", 0, virtualHost.getConnectionCount());
    AMQPConnection modelConnection = mock(AMQPConnection.class);
    when(modelConnection.closeAsync()).thenReturn(Futures.immediateFuture(null));
    virtualHost.registerConnection(modelConnection, new NoopConnectionEstablishmentPolicy());
    assertEquals("Unexpected number of connections after connection registered", 1, virtualHost.getConnectionCount());
    ((AbstractConfiguredObject<?>) virtualHost).stop();
    assertEquals("Unexpected state", State.STOPPED, virtualHost.getState());
    assertEquals("Unexpected number of connections after virtualhost stopped", 0, virtualHost.getConnectionCount());
    verify(modelConnection).closeAsync();
}
Also used : AbstractAMQPConnection(org.apache.qpid.server.transport.AbstractAMQPConnection) AMQPConnection(org.apache.qpid.server.transport.AMQPConnection) AbstractAMQPConnection(org.apache.qpid.server.transport.AbstractAMQPConnection) NoopConnectionEstablishmentPolicy(org.apache.qpid.server.virtualhost.NoopConnectionEstablishmentPolicy) Matchers.anyString(org.mockito.Matchers.anyString)

Example 4 with NoopConnectionEstablishmentPolicy

use of org.apache.qpid.server.virtualhost.NoopConnectionEstablishmentPolicy in project qpid-broker-j by apache.

the class VirtualHostTest method testExistingConnectionBlocking.

public void testExistingConnectionBlocking() {
    VirtualHost<?> host = createVirtualHost(getTestName());
    AbstractAMQPConnection connection = mock(AbstractAMQPConnection.class);
    host.registerConnection(connection, new NoopConnectionEstablishmentPolicy());
    ((EventListener) host).event(Event.PERSISTENT_MESSAGE_SIZE_OVERFULL);
    verify(connection).block();
}
Also used : AbstractAMQPConnection(org.apache.qpid.server.transport.AbstractAMQPConnection) NoopConnectionEstablishmentPolicy(org.apache.qpid.server.virtualhost.NoopConnectionEstablishmentPolicy) EventListener(org.apache.qpid.server.store.EventListener)

Example 5 with NoopConnectionEstablishmentPolicy

use of org.apache.qpid.server.virtualhost.NoopConnectionEstablishmentPolicy in project qpid-broker-j by apache.

the class VirtualHostTest method testStopVirtualhostClosesConnections.

public void testStopVirtualhostClosesConnections() {
    QueueManagingVirtualHost<?> vhost = createVirtualHost("sdf");
    AMQPConnection<?> connection = getMockConnection();
    vhost.registerConnection(connection, new NoopConnectionEstablishmentPolicy());
    assertEquals("unexpected number of connections after registerConnection", 1, vhost.getConnectionCount());
    assertEquals("unexpected connection object", Collections.singleton(connection), vhost.getConnections());
    ((AbstractConfiguredObject<?>) vhost).stop();
    verify(connection).stopConnection();
    verify(connection).closeAsync();
}
Also used : NoopConnectionEstablishmentPolicy(org.apache.qpid.server.virtualhost.NoopConnectionEstablishmentPolicy)

Aggregations

NoopConnectionEstablishmentPolicy (org.apache.qpid.server.virtualhost.NoopConnectionEstablishmentPolicy)8 AbstractAMQPConnection (org.apache.qpid.server.transport.AbstractAMQPConnection)3 AMQPConnection (org.apache.qpid.server.transport.AMQPConnection)2 VirtualHostUnavailableException (org.apache.qpid.server.virtualhost.VirtualHostUnavailableException)2 Matchers.anyString (org.mockito.Matchers.anyString)2 AccessControlException (java.security.AccessControlException)1 NamedAddressSpace (org.apache.qpid.server.model.NamedAddressSpace)1 AmqpPort (org.apache.qpid.server.model.port.AmqpPort)1 EventListener (org.apache.qpid.server.store.EventListener)1