Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@YannRobert
Created September 21, 2015 12:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save YannRobert/f1d6a90803888df7fc3a to your computer and use it in GitHub Desktop.
Save YannRobert/f1d6a90803888df7fc3a to your computer and use it in GitHub Desktop.
import com.rabbitmq.client.ConnectionFactory;
import org.junit.Test;
public class ConnectionFactorySettersTest {
// considering the default value for handshakeTimeout is 10000 and the default value for connectionTimeout is 0
// this test is failing
// if we set the connectionTimeout to a higher value than the default value of handshakeTimeout, the test will fail
@Test
public void shouldBeAbleToSetConnectionTimeoutBeforeHandshakeTimeout_high_values() {
ConnectionFactory connectionFactory = new ConnectionFactory();
connectionFactory.setConnectionTimeout(20 * 1000);
connectionFactory.setHandshakeTimeout(40 * 1000);
}
// this test is successful
// we can set the connectionTimeout before the handshakeTimeout if the connectionTimeout is lower than the previous value of the handshakeTimeout
@Test
public void shouldBeAbleToSetConnectionTimeoutBeforeHandshakeTimeout_low_values() {
ConnectionFactory connectionFactory = new ConnectionFactory();
connectionFactory.setConnectionTimeout(2 * 1000);
connectionFactory.setHandshakeTimeout(4 * 1000);
}
// this test is successful
// we have to first set the handshakeTimeout, then set the connectionTimeout
@Test
public void shouldBeAbleToSetConnectionTimeoutAfterHandshakeTimeout() {
ConnectionFactory connectionFactory = new ConnectionFactory();
connectionFactory.setHandshakeTimeout(40 * 1000);
connectionFactory.setConnectionTimeout(20 * 1000);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment