Merge remote-tracking branch 'origin/feature/travis-ci' into feature/travis-ci

pull/509/head
Rui Gu 9 years ago
commit 3ece79eb92

@ -37,4 +37,5 @@ before_script:
- $REDIS_BIN/redis-cli PING
- export REDIS_VERSION="$(redis-cli INFO SERVER | sed -n 2p)"
- echo $REDIS_VERSION
script: mvn -DargLine="-DredisBinary=$REDIS_BIN/redis-server -DtravisEnv=true" -Punit-test -Ptravis clean verify
- redis-cli SHUTDOWN NOSAVE
script: mvn -DargLine="-DredisBinary=$REDIS_BIN/redis-server -DtravisEnv=true" -Punit-test clean verify

@ -0,0 +1,107 @@
<?xml version="1.0" encoding="UTF-8"?>
<actions>
<action>
<actionName>test</actionName>
<packagings>
<packaging>*</packaging>
</packagings>
<goals>
<goal>test</goal>
</goals>
<properties>
<argLine>"-DredisBinary=/usr/local/bin/redis-server"</argLine>
</properties>
</action>
<action>
<actionName>test.single</actionName>
<packagings>
<packaging>*</packaging>
</packagings>
<goals>
<goal>test-compile</goal>
<goal>surefire:test</goal>
</goals>
<properties>
<test>${packageClassName}</test>
<argLine>"-DredisBinary=/usr/local/bin/redis-server"</argLine>
</properties>
</action>
<action>
<actionName>run.single.main</actionName>
<packagings>
<packaging>*</packaging>
</packagings>
<goals>
<goal>process-classes</goal>
<goal>org.codehaus.mojo:exec-maven-plugin:1.2.1:exec</goal>
</goals>
<properties>
<exec.args>-classpath %classpath ${packageClassName}</exec.args>
<exec.executable>java</exec.executable>
<exec.classpathScope>${classPathScope}</exec.classpathScope>
<argLine>"-DredisBinary=/usr/local/bin/redis-server"</argLine>
</properties>
</action>
<action>
<actionName>debug</actionName>
<properties>
<argLine>"-DredisBinary=/usr/local/bin/redis-server"</argLine>
</properties>
</action>
<action>
<actionName>debug.single.main</actionName>
<packagings>
<packaging>*</packaging>
</packagings>
<goals>
<goal>process-classes</goal>
<goal>org.codehaus.mojo:exec-maven-plugin:1.2.1:exec</goal>
</goals>
<properties>
<exec.args>-Xdebug -Xrunjdwp:transport=dt_socket,server=n,address=${jpda.address} -classpath %classpath ${packageClassName}</exec.args>
<exec.executable>java</exec.executable>
<exec.classpathScope>${classPathScope}</exec.classpathScope>
<jpda.listen>true</jpda.listen>
<argLine>"-DredisBinary=/usr/local/bin/redis-server"</argLine>
</properties>
</action>
<action>
<actionName>debug.test.single</actionName>
<packagings>
<packaging>*</packaging>
</packagings>
<goals>
<goal>test-compile</goal>
<goal>surefire:test</goal>
</goals>
<properties>
<test>${packageClassName}</test>
<forkMode>once</forkMode>
<maven.surefire.debug>-Xdebug -Xrunjdwp:transport=dt_socket,server=n,address=${jpda.address}</maven.surefire.debug>
<jpda.listen>true</jpda.listen>
<argLine>"-DredisBinary=/usr/local/bin/redis-server"</argLine>
</properties>
</action>
<action>
<actionName>profile</actionName>
<properties>
<argLine>"-DredisBinary=/usr/local/bin/redis-server"</argLine>
</properties>
</action>
<action>
<actionName>profile.single.main</actionName>
<packagings>
<packaging>*</packaging>
</packagings>
<goals>
<goal>process-classes</goal>
<goal>org.codehaus.mojo:exec-maven-plugin:1.2.1:exec</goal>
</goals>
<properties>
<exec.args>-classpath %classpath ${packageClassName}</exec.args>
<exec.executable>java</exec.executable>
<exec.classpathScope>${classPathScope}</exec.classpathScope>
<argLine>"-DredisBinary=/usr/local/bin/redis-server"</argLine>
</properties>
</action>
</actions>

@ -1,5 +1,8 @@
package org.redisson;
import java.io.IOException;
import java.util.logging.Level;
import java.util.logging.Logger;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
@ -7,15 +10,26 @@ import org.junit.BeforeClass;
public abstract class BaseTest {
protected static RedissonClient redisson;
protected static RedisRunner.RedisProcess redis;
@BeforeClass
public static void beforeClass() {
public static void beforeClass() throws IOException, InterruptedException {
System.out.println("Starting up...");
redis = defaultRedisTestInstance();
redisson = createInstance();
Runtime.getRuntime().addShutdownHook(new Thread(() -> {
try {
afterClass();
} catch (InterruptedException ex) {
}
}));
}
@AfterClass
public static void afterClass() {
public static void afterClass() throws InterruptedException {
System.out.println("Shutting down...");
redisson.shutdown();
redis.stop();
}
public static Config createConfig() {
@ -46,4 +60,8 @@ public abstract class BaseTest {
redisson.getKeys().flushall();
}
private static RedisRunner.RedisProcess defaultRedisTestInstance() throws IOException, InterruptedException {
return new RedisRunner().run();
}
}

@ -27,9 +27,45 @@ import org.redisson.client.protocol.pubsub.PubSubType;
import io.netty.util.concurrent.Future;
import io.netty.util.concurrent.FutureListener;
import io.netty.util.concurrent.Promise;
import java.io.IOException;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
import static org.redisson.BaseTest.afterClass;
public class RedisClientTest {
protected static RedisRunner.RedisProcess redis;
@BeforeClass
public static void beforeClass() throws IOException, InterruptedException {
System.out.println("Starting up...");
redis = defaultRedisTestInstance();
Runtime.getRuntime().addShutdownHook(new Thread(() -> {
try {
afterClass();
} catch (InterruptedException ex) {
}
}));
}
@AfterClass
public static void afterClass() throws InterruptedException {
System.out.println("Shutting down...");
redis.stop();
}
private static RedisRunner.RedisProcess defaultRedisTestInstance() throws IOException, InterruptedException {
return new RedisRunner().run();
}
@Before
public void before() {
System.out.println("Cleaning up...");
RedisClient c = new RedisClient("localhost", 6379);
c.connect().sync(RedisCommands.FLUSHDB);
}
@Test
public void testConnectAsync() throws InterruptedException {
RedisClient c = new RedisClient("localhost", 6379);
@ -43,7 +79,7 @@ public class RedisClientTest {
l.countDown();
}
});
l.await();
l.await(10, TimeUnit.SECONDS);
}
@Test
@ -71,7 +107,7 @@ public class RedisClientTest {
});
pubSubConnection.subscribe(StringCodec.INSTANCE, "test1", "test2");
latch.await();
latch.await(10, TimeUnit.SECONDS);
}
@Test

@ -213,7 +213,7 @@ public class RedisRunner {
System.out.println("Exception: " + ex.getLocalizedMessage());
}
}).start();
Thread.sleep(1000);
Thread.sleep(3000);
return new RedisProcess(p);
}

Loading…
Cancel
Save