Compare commits
5 Commits
master
...
jon/depend
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
0281c6058e | ||
|
|
0267fe48a3 | ||
|
|
922be96dc1 | ||
|
|
be9a95337c | ||
|
|
3389ba4a50 |
30
pom.xml
30
pom.xml
@ -45,13 +45,7 @@
|
||||
<dependency>
|
||||
<groupId>commons-io</groupId>
|
||||
<artifactId>commons-io</artifactId>
|
||||
<version>2.5</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>commons-logging</groupId>
|
||||
<artifactId>commons-logging</artifactId>
|
||||
<version>1.2</version>
|
||||
<version>2.7</version>
|
||||
</dependency>
|
||||
|
||||
<!-- TEST DEPENDENCIES -->
|
||||
@ -64,8 +58,8 @@
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.mockito</groupId>
|
||||
<artifactId>mockito-all</artifactId>
|
||||
<version>1.10.19</version>
|
||||
<artifactId>mockito-core</artifactId>
|
||||
<version>3.3.3</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
|
||||
@ -75,26 +69,8 @@
|
||||
<version>4.12</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.springframework.data</groupId>
|
||||
<artifactId>spring-data-redis</artifactId>
|
||||
<version>1.8.0.RELEASE</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.slf4j</groupId>
|
||||
<artifactId>slf4j-simple</artifactId>
|
||||
<version>1.7.21</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<prerequisites>
|
||||
<maven>3.0.4</maven>
|
||||
</prerequisites>
|
||||
|
||||
<distributionManagement>
|
||||
<repository>
|
||||
<id>ossrh</id>
|
||||
|
||||
@ -1,8 +1,6 @@
|
||||
package redis.embedded;
|
||||
|
||||
import org.apache.commons.io.IOUtils;
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import redis.embedded.exceptions.EmbeddedRedisException;
|
||||
|
||||
import java.io.*;
|
||||
@ -14,8 +12,6 @@ import java.util.concurrent.Executors;
|
||||
|
||||
abstract class AbstractRedisInstance implements Redis {
|
||||
|
||||
private static Log log = LogFactory.getLog(AbstractRedisInstance.class);
|
||||
|
||||
protected List<String> args = Collections.emptyList();
|
||||
private volatile boolean active = false;
|
||||
private Process redisProcess;
|
||||
@ -89,14 +85,11 @@ abstract class AbstractRedisInstance implements Redis {
|
||||
|
||||
public synchronized void stop() throws EmbeddedRedisException {
|
||||
if (active) {
|
||||
log.info("Stopping redis server...");
|
||||
|
||||
if (executor != null && !executor.isShutdown()) {
|
||||
executor.shutdown();
|
||||
}
|
||||
redisProcess.destroy();
|
||||
tryWaitFor();
|
||||
log.info("Redis exited");
|
||||
active = false;
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,49 +0,0 @@
|
||||
package redis.embedded;
|
||||
|
||||
import org.junit.After;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.springframework.data.redis.connection.jedis.JedisConnectionFactory;
|
||||
import org.springframework.data.redis.core.RedisTemplate;
|
||||
import org.springframework.data.redis.core.StringRedisTemplate;
|
||||
import redis.clients.jedis.JedisShardInfo;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
public class SpringDataConnectivityTest {
|
||||
|
||||
private RedisServer redisServer;
|
||||
private RedisTemplate<String, String> template;
|
||||
private JedisConnectionFactory connectionFactory;
|
||||
|
||||
@Before
|
||||
public void setUp() throws Exception {
|
||||
redisServer = new RedisServer(6379);
|
||||
redisServer.start();
|
||||
|
||||
JedisShardInfo shardInfo = new JedisShardInfo("localhost", 6379);
|
||||
connectionFactory = new JedisConnectionFactory();
|
||||
connectionFactory.setShardInfo(shardInfo);
|
||||
|
||||
template = new StringRedisTemplate();
|
||||
template.setConnectionFactory(connectionFactory);
|
||||
template.afterPropertiesSet();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void shouldBeAbleToUseSpringData() throws Exception {
|
||||
// given
|
||||
template.opsForValue().set("foo", "bar");
|
||||
|
||||
// when
|
||||
String result = template.opsForValue().get("foo");
|
||||
|
||||
// then
|
||||
assertEquals("bar", result);
|
||||
}
|
||||
|
||||
@After
|
||||
public void tearDown() throws Exception {
|
||||
redisServer.stop();
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user