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());
}
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());
}
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();
}
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();
}
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();
}
Aggregations