removed static modifier on local timeout

pull/616/head
jackygurui 9 years ago
parent 8f32bd6d7d
commit 92db4fe8df

@ -25,7 +25,7 @@ public abstract class BaseReactiveTest {
@ClassRule
public static Timeout classTimeout = new Timeout(1, TimeUnit.HOURS);
@Rule
public static Timeout testTimeout = new Timeout(15, TimeUnit.MINUTES);
public Timeout testTimeout = new Timeout(15, TimeUnit.MINUTES);
protected RedissonReactiveClient redisson;
protected static RedissonReactiveClient defaultRedisson;

@ -18,7 +18,7 @@ public abstract class BaseTest {
@ClassRule
public static Timeout classTimeout = new Timeout(1, TimeUnit.HOURS);
@Rule
public static Timeout testTimeout = new Timeout(15, TimeUnit.MINUTES);
public Timeout testTimeout = new Timeout(15, TimeUnit.MINUTES);
protected RedissonClient redisson;
protected static RedissonClient defaultRedisson;

@ -43,7 +43,7 @@ public class RedisClientTest {
@ClassRule
public static Timeout classTimeout = new Timeout(1, TimeUnit.HOURS);
@Rule
public static Timeout testTimeout = new Timeout(15, TimeUnit.MINUTES);
public Timeout testTimeout = new Timeout(15, TimeUnit.MINUTES);
@BeforeClass
public static void beforeClass() throws IOException, InterruptedException {

@ -5,6 +5,7 @@ import java.io.File;
import java.io.IOException;
import java.io.InputStreamReader;
import java.net.Inet4Address;
import java.net.ServerSocket;
import java.net.URL;
import java.nio.file.Paths;
import java.util.ArrayList;
@ -31,6 +32,7 @@ public class RedisRunner {
DAEMONIZE,
PIDFILE,
PORT,
RANDOM_PORT,
TCP_BACKLOG,
BIND(true),
UNIXSOCKET,
@ -179,6 +181,7 @@ public class RedisRunner {
private boolean randomDir = false;
private ArrayList<String> bindAddr = new ArrayList<>();
private int port = 6379;
private boolean randomPort = true;
{
this.options.put(REDIS_OPTIONS.BINARY_PATH, RedissonRuntimeEnvironment.redisBinaryPath);
@ -266,9 +269,16 @@ public class RedisRunner {
public RedisRunner port(int port) {
this.port = port;
this.randomPort = false;
addConfigOption(REDIS_OPTIONS.PORT, port);
return this;
}
public RedisRunner randomPort() {
this.randomPort = true;
options.remove(REDIS_OPTIONS.PORT);
return this;
}
public int getPort() {
return this.port;
@ -785,4 +795,28 @@ public class RedisRunner {
public static RedisRunner.RedisProcess getDefaultRedisServerInstance() {
return defaultRedisInstance;
}
private static int findFreePort() {
ServerSocket socket = null;
try {
socket = new ServerSocket(0);
socket.setReuseAddress(true);
int port = socket.getLocalPort();
try {
socket.close();
} catch (IOException e) {
// Ignore IOException on close()
}
return port;
} catch (IOException e) {
} finally {
if (socket != null) {
try {
socket.close();
} catch (IOException e) {
}
}
}
throw new IllegalStateException("Could not find a free TCP/IP port to start embedded Jetty HTTP Server on");
}
}

@ -23,7 +23,7 @@ public class RedissonCountDownLatchConcurrentTest {
@ClassRule
public static Timeout classTimeout = new Timeout(1, TimeUnit.HOURS);
@Rule
public static Timeout testTimeout = new Timeout(15, TimeUnit.MINUTES);
public Timeout testTimeout = new Timeout(15, TimeUnit.MINUTES);
@BeforeClass
public static void beforeClass() throws IOException, InterruptedException {

@ -23,7 +23,7 @@ public class RedissonMultiLockTest {
@ClassRule
public static Timeout classTimeout = new Timeout(1, TimeUnit.HOURS);
@Rule
public static Timeout testTimeout = new Timeout(15, TimeUnit.MINUTES);
public Timeout testTimeout = new Timeout(15, TimeUnit.MINUTES);
@Test
public void testMultiThreads() throws IOException, InterruptedException {

@ -25,7 +25,7 @@ public class RedissonRedLockTest {
@ClassRule
public static Timeout classTimeout = new Timeout(1, TimeUnit.HOURS);
@Rule
public static Timeout testTimeout = new Timeout(15, TimeUnit.MINUTES);
public Timeout testTimeout = new Timeout(15, TimeUnit.MINUTES);
@Test
public void testLockFailed() throws IOException, InterruptedException {

@ -42,7 +42,7 @@ public class RedissonTest {
@ClassRule
public static Timeout classTimeout = new Timeout(1, TimeUnit.HOURS);
@Rule
public static Timeout testTimeout = new Timeout(15, TimeUnit.MINUTES);
public Timeout testTimeout = new Timeout(15, TimeUnit.MINUTES);
protected RedissonClient redisson;
protected static RedissonClient defaultRedisson;

@ -39,7 +39,7 @@ public class RedissonTopicPatternTest {
@ClassRule
public static Timeout classTimeout = new Timeout(1, TimeUnit.HOURS);
@Rule
public static Timeout testTimeout = new Timeout(15, TimeUnit.MINUTES);
public Timeout testTimeout = new Timeout(15, TimeUnit.MINUTES);
@BeforeClass
public static void beforeClass() throws IOException, InterruptedException {

@ -45,7 +45,7 @@ public class RedissonTopicTest {
@ClassRule
public static Timeout classTimeout = new Timeout(1, TimeUnit.HOURS);
@Rule
public static Timeout testTimeout = new Timeout(15, TimeUnit.MINUTES);
public Timeout testTimeout = new Timeout(15, TimeUnit.MINUTES);
@BeforeClass
public static void beforeClass() throws IOException, InterruptedException {

@ -31,7 +31,7 @@ public class RedissonTwoLockedThread {
@ClassRule
public static Timeout classTimeout = new Timeout(1, TimeUnit.HOURS);
@Rule
public static Timeout testTimeout = new Timeout(15, TimeUnit.MINUTES);
public Timeout testTimeout = new Timeout(15, TimeUnit.MINUTES);
@Parameterized.Parameters(name= "{index} - {0}")
public static Iterable<Object[]> data() {

Loading…
Cancel
Save