Search in sources :

Example 31 with ConnectionFactory

use of com.rabbitmq.client.ConnectionFactory in project rabbitmq-java-client by rabbitmq.

the class ExchangeDeclare method exchangeDeclaredWithEnumerationEquivalentOnRecoverableConnection.

@Test
public void exchangeDeclaredWithEnumerationEquivalentOnRecoverableConnection() throws IOException, TimeoutException, InterruptedException {
    ConnectionFactory connectionFactory = TestUtils.connectionFactory();
    connectionFactory.setAutomaticRecoveryEnabled(true);
    connectionFactory.setTopologyRecoveryEnabled(false);
    Connection c = connectionFactory.newConnection();
    try {
        doTestExchangeDeclaredWithEnumerationEquivalent(c.createChannel());
    } finally {
        c.abort();
    }
}
Also used : ConnectionFactory(com.rabbitmq.client.ConnectionFactory) Connection(com.rabbitmq.client.Connection) Test(org.junit.Test)

Example 32 with ConnectionFactory

use of com.rabbitmq.client.ConnectionFactory in project rabbitmq-java-client by rabbitmq.

the class FrameMax method rejectLargeFramesDuringConnectionNegotiation.

/* server should reject frames larger than AMQP.FRAME_MIN_SIZE
     * during connection negotiation */
@Test
public void rejectLargeFramesDuringConnectionNegotiation() throws IOException, TimeoutException {
    ConnectionFactory cf = TestUtils.connectionFactory();
    cf.getClientProperties().put("too_long", LongStringHelper.asLongString(new byte[AMQP.FRAME_MIN_SIZE]));
    try {
        cf.newConnection();
        fail("Expected exception during connection negotiation");
    } catch (IOException e) {
    }
}
Also used : ConnectionFactory(com.rabbitmq.client.ConnectionFactory) IOException(java.io.IOException) Test(org.junit.Test)

Example 33 with ConnectionFactory

use of com.rabbitmq.client.ConnectionFactory in project rabbitmq-java-client by rabbitmq.

the class FrameMax method rejectExceedingFrameMax.

/* server should reject frames larger than the negotiated frame
     * size */
@Test
public void rejectExceedingFrameMax() throws IOException, TimeoutException {
    closeChannel();
    closeConnection();
    ConnectionFactory cf = new GenerousConnectionFactory();
    connection = cf.newConnection();
    openChannel();
    basicPublishVolatile(new byte[connection.getFrameMax()], "void");
    expectError(AMQP.FRAME_ERROR);
}
Also used : ConnectionFactory(com.rabbitmq.client.ConnectionFactory) Test(org.junit.Test)

Example 34 with ConnectionFactory

use of com.rabbitmq.client.ConnectionFactory in project rabbitmq-java-client by rabbitmq.

the class Metrics method createConnectionFactory.

private static ConnectionFactory createConnectionFactory() {
    ConnectionFactory connectionFactory = TestUtils.connectionFactory();
    connectionFactory.setAutomaticRecoveryEnabled(false);
    return connectionFactory;
}
Also used : ConnectionFactory(com.rabbitmq.client.ConnectionFactory)

Example 35 with ConnectionFactory

use of com.rabbitmq.client.ConnectionFactory in project rabbitmq-java-client by rabbitmq.

the class SaslMechanisms method connectionWithoutCapabilities.

// start a connection without capabilities, causing authentication failures
// to be reported by the broker by closing the connection
private Connection connectionWithoutCapabilities(String username, String password) throws IOException, TimeoutException {
    ConnectionFactory customFactory = TestUtils.connectionFactory();
    customFactory.setUsername(username);
    customFactory.setPassword(password);
    Map<String, Object> customProperties = AMQConnection.defaultClientProperties();
    customProperties.remove("capabilities");
    customFactory.setClientProperties(customProperties);
    return customFactory.newConnection();
}
Also used : ConnectionFactory(com.rabbitmq.client.ConnectionFactory) LongString(com.rabbitmq.client.LongString)

Aggregations

ConnectionFactory (com.rabbitmq.client.ConnectionFactory)64 Connection (com.rabbitmq.client.Connection)28 Test (org.junit.Test)26 IOException (java.io.IOException)17 Channel (com.rabbitmq.client.Channel)13 AMQConnection (com.rabbitmq.client.impl.AMQConnection)6 AutorecoveringConnection (com.rabbitmq.client.impl.recovery.AutorecoveringConnection)4 DefaultConsumer (com.rabbitmq.client.DefaultConsumer)3 QueueingConsumer (com.rabbitmq.client.QueueingConsumer)3 ShutdownSignalException (com.rabbitmq.client.ShutdownSignalException)3 KeyManagementException (java.security.KeyManagementException)3 NoSuchAlgorithmException (java.security.NoSuchAlgorithmException)3 TimeoutException (java.util.concurrent.TimeoutException)3 AMQP (com.rabbitmq.client.AMQP)2 Address (com.rabbitmq.client.Address)2 Consumer (com.rabbitmq.client.Consumer)2 DnsRecordIpAddressResolver (com.rabbitmq.client.DnsRecordIpAddressResolver)2 MetricsCollector (com.rabbitmq.client.MetricsCollector)2 ShutdownListener (com.rabbitmq.client.ShutdownListener)2 SslContextFactory (com.rabbitmq.client.SslContextFactory)2