Merge pull request #441 from mrniko/revert-439-crossplatform-tests

Revert "Untie tests from Windows absolute paths"
pull/442/head^2
Nikita Koksharov 9 years ago
commit ecfd2502a1

@ -1,77 +1,22 @@
package org.redisson;
import java.io.*;
import java.io.File;
import java.io.IOException;
import java.net.URL;
import java.nio.charset.Charset;
import java.nio.file.*;
import java.util.Objects;
public class RedisRunner {
public static final int REDIS_EXIT_CODE;
private static final String defaultRedisDirectory = "C:\\Devel\\projects\\redis\\Redis-x64-3.0.500\\";
private static final String defaultRedisExecutable = defaultRedisDirectory + "redis-server.exe";
private static final String redisExecutable;
static {
String path = System.getenv("PATH");
if (path != null) {
String os = System.getProperty("os.name");
String pathSeparator = ":";
String executableName = "redis-server";
if (os.toLowerCase().startsWith("windows")) {
pathSeparator = ";";
executableName = "redis-server.exe";
REDIS_EXIT_CODE = 1;
} else {
REDIS_EXIT_CODE = 0;
}
String[] pathEntries = path.split(pathSeparator);
Path fullExecutablePath = null;
for (String pathEntry : pathEntries) {
fullExecutablePath = Paths.get(pathEntry, executableName);
if (Files.exists(fullExecutablePath)) {
break;
}
}
if (fullExecutablePath != null) {
redisExecutable = fullExecutablePath.toString();
} else {
redisExecutable = defaultRedisExecutable;
}
} else {
redisExecutable = defaultRedisExecutable;
REDIS_EXIT_CODE = 1;
}
if (!new File(redisExecutable).exists()) {
throw new RuntimeException("Redis executable not found");
}
}
private static final String redisFolder = "C:\\Devel\\projects\\redis\\Redis-x64-3.0.500\\";
public static Process runRedis(String configPath) throws IOException, InterruptedException {
URL resource = RedisRunner.class.getResource(configPath);
String fullConfigPath = Paths.get(resource.getFile()).toAbsolutePath().toString();
ProcessBuilder master = new ProcessBuilder(redisExecutable, fullConfigPath, "--dir", getWorkingDirectory());
master.directory(new File(getWorkingDirectory()));
ProcessBuilder master = new ProcessBuilder(redisFolder + "redis-server.exe", resource.getFile().substring(1));
master.directory(new File(redisFolder));
Process p = master.start();
Thread.sleep(1000);
if (!p.isAlive()) {
throw new RuntimeException("Redis executable stopped with exit code " + p.exitValue());
}
return p;
}
private static String getWorkingDirectory() {
if (redisExecutable.equals(defaultRedisExecutable)) {
return defaultRedisDirectory;
}
return System.getProperty("user.dir");
}
}

@ -66,13 +66,13 @@ public class RedissonMultiLockTest {
lock.unlock();
redis1.destroy();
assertThat(redis1.waitFor()).isEqualTo(RedisRunner.REDIS_EXIT_CODE);
assertThat(redis1.waitFor()).isEqualTo(1);
redis2.destroy();
assertThat(redis2.waitFor()).isEqualTo(RedisRunner.REDIS_EXIT_CODE);
assertThat(redis2.waitFor()).isEqualTo(1);
redis3.destroy();
assertThat(redis3.waitFor()).isEqualTo(RedisRunner.REDIS_EXIT_CODE);
assertThat(redis3.waitFor()).isEqualTo(1);
}
}

@ -127,7 +127,7 @@ public class RedissonTest {
r.getBucket("1").get();
p.destroy();
Assert.assertEquals(RedisRunner.REDIS_EXIT_CODE, p.waitFor());
Assert.assertEquals(1, p.waitFor());
try {
r.getBucket("1").get();
@ -141,7 +141,7 @@ public class RedissonTest {
r.shutdown();
p.destroy();
Assert.assertEquals(RedisRunner.REDIS_EXIT_CODE, p.waitFor());
Assert.assertEquals(1, p.waitFor());
await().atMost(1, TimeUnit.SECONDS).until(() -> assertThat(connectCounter.get()).isEqualTo(2));
await().until(() -> assertThat(disconnectCounter.get()).isEqualTo(1));

@ -150,7 +150,7 @@ rdbchecksum yes
# The Append Only File will also be created inside this directory.
#
# Note that you must specify a directory here, not a file name.
# dir "C:\\Devel\\projects\\redis"
dir "C:\\Devel\\projects\\redis"
################################# REPLICATION #################################

@ -150,7 +150,7 @@ rdbchecksum yes
# The Append Only File will also be created inside this directory.
#
# Note that you must specify a directory here, not a file name.
# dir "C:\\Devel\\projects\\redis"
dir "C:\\Devel\\projects\\redis"
################################# REPLICATION #################################

@ -150,7 +150,7 @@ rdbchecksum yes
# The Append Only File will also be created inside this directory.
#
# Note that you must specify a directory here, not a file name.
# dir "C:\\Devel\\projects\\redis"
dir "C:\\Devel\\projects\\redis"
################################# REPLICATION #################################

@ -150,7 +150,7 @@ rdbchecksum yes
# The Append Only File will also be created inside this directory.
#
# Note that you must specify a directory here, not a file name.
# dir "C:\\Devel\\projects\\redis"
dir "C:\\Devel\\projects\\redis"
################################# REPLICATION #################################

@ -150,7 +150,7 @@ rdbchecksum yes
# The Append Only File will also be created inside this directory.
#
# Note that you must specify a directory here, not a file name.
# dir "C:\\Devel\\projects\\redis"
dir "C:\\Devel\\projects\\redis"
################################# REPLICATION #################################

Loading…
Cancel
Save