Skip to content

Commit 67bfbb2

Browse files
committed
Add optional NIO tweak point in tests
1 parent c1f069b commit 67bfbb2

File tree

2 files changed

+17
-0
lines changed

2 files changed

+17
-0
lines changed

src/test/java/com/rabbitmq/client/test/BrokerTestCase.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
package com.rabbitmq.client.test;
1818

1919
import com.rabbitmq.client.*;
20+
import com.rabbitmq.client.impl.nio.NioParams;
2021
import com.rabbitmq.tools.Host;
2122
import org.junit.After;
2223
import org.junit.Before;
@@ -60,10 +61,17 @@ protected void finished(Description description) {
6061

6162
protected ConnectionFactory newConnectionFactory() {
6263
ConnectionFactory connectionFactory = TestUtils.connectionFactory();
64+
if(TestUtils.USE_NIO) {
65+
connectionFactory.setNioParams(nioParams());
66+
}
6367
connectionFactory.setAutomaticRecoveryEnabled(isAutomaticRecoveryEnabled());
6468
return connectionFactory;
6569
}
6670

71+
protected NioParams nioParams() {
72+
return new NioParams();
73+
}
74+
6775
protected boolean isAutomaticRecoveryEnabled() {
6876
return true;
6977
}

src/test/java/com/rabbitmq/client/test/server/PersistenceGuarantees.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919

2020
import java.io.IOException;
2121

22+
import com.rabbitmq.client.impl.nio.NioParams;
2223
import org.junit.Test;
2324

2425
import com.rabbitmq.client.MessageProperties;
@@ -28,6 +29,14 @@ public class PersistenceGuarantees extends BrokerTestCase {
2829
private static final int COUNT = 10000;
2930
private String queue;
3031

32+
@Override
33+
protected NioParams nioParams() {
34+
NioParams nioParams = super.nioParams();
35+
// may need a higher enqueuing timeout on slow environments
36+
return nioParams
37+
.setWriteEnqueuingTimeoutInMs(nioParams.getWriteEnqueuingTimeoutInMs() * 2);
38+
}
39+
3140
protected void declareQueue() throws IOException {
3241
queue = channel.queueDeclare("", true, false, false, null).getQueue();
3342
}

0 commit comments

Comments
 (0)