@Override protected void after() { try { this.server.stop(); } catch (Exception e) { if (!suppressExceptions) { throw e; } } } }
@Override protected void before() throws IOException { try { this.server = new RedisServer(this.port); this.server.start(); } catch (Exception e) { if (!suppressExceptions) { throw e; } } }
EmbeddedRedis() throws IOException, URISyntaxException { redisServer = new RedisServer(); }
@Override protected void before() { try { redisServer = RedisServer.builder().port(port).setting("maxmemory 16MB").build(); redisServer.start(); } catch (final Exception e) { if (port == DEFAULT_REDIS_PORT && ignoreDefaultPortFailure) { log.info("Unable to start embedded Redis on default port. Ignoring error. Assuming redis is already running."); } else { throw new RuntimeException(format("Error while initializing the Redis server" + " on port %d", port), e); } } }
@Test public void testAutoReconnect() throws Exception { RedisStorageClient client = createClient(); // Issue a command to create a connection assertTrue(client.add("key1", 0, toBytes("foo")).get()); assertEquals("foo", toString(client.get("key1"))); // Stop and start server to close all connections if (!redisProvided) { embeddedRedisServer.stop(); embeddedRedisServer.start(); } // If we now issue commands, the old connection is defunct and will be replaced assertTrue(client.add("key1", 0, toBytes("foo")).get()); assertEquals("foo", toString(client.get("key1"))); client.shutdown(); }
public RedisServer build() { tryResolveConfAndExec(); List<String> args = buildCommandArgs(); return new RedisServer(args, port); }
public void start() throws IOException { redisServer.start(); jedisPool = new JedisPool(new JedisPoolConfig(), getConnectString(), getPort()); }
public int getPort() { return redisServer.getPort(); }
@BeforeSuite(alwaysRun = true) public void globalBeforeSuite() { if (Boolean.valueOf(System.getProperty("killbill.test.redis", "false"))) { redisServer = new RedisServer(56379); redisServer.start(); redissonClient = new RedissonCacheClientProvider("redis://127.0.0.1:56379", 1).get(); theRealClock = new DistributedClockMock(); ((DistributedClockMock) theRealClock).setRedissonClient(redissonClient); extraPropertiesForTestSuite = ImmutableMap.<String, String>of("org.killbill.cache.config.redis", "true", "org.killbill.cache.config.redis.url", "redis://127.0.0.1:56379"); } else { theRealClock.resetDeltaFromReality(); extraPropertiesForTestSuite = ImmutableMap.<String, String>of(); } // The clock needs to be setup early in @BeforeSuite, as it is needed when starting the server, but see below clock = theRealClock; }
@Override protected void after() { redisServer.stop(); }
@PostConstruct public void setUp() throws IOException { this.redisServer = new RedisServer(DEFAULT_PORT); if (available(DEFAULT_PORT)) { this.redisServer.start(); } }
@Override public void close() { jedisPool.destroy(); try { redisServer.stop(); } catch (InterruptedException e) { Thread.currentThread().interrupt(); throw new RuntimeException(e); } }
@PostConstruct public void setUp() throws IOException { this.redisServer = new RedisServer(DEFAULT_PORT); if (available(DEFAULT_PORT)) { this.redisServer.start(); } }
@AfterSuite(alwaysRun = true) public void globalAfterSuite() { if (redissonClient != null) { redissonClient.shutdown(); } if (redisServer != null) { redisServer.stop(); } }
@BeforeMethod public void setUp(final Method testMethod) throws Exception { redisProvided = Boolean.parseBoolean(System.getProperty("redis.provided", "false")); redisPort = Integer.parseInt(System.getProperty("redis.port", "16379")); if (!redisProvided) { embeddedRedisServer = new RedisServer(redisPort); embeddedRedisServer.start(); } }
@PreDestroy public void destroy() { this.redisServer.stop(); } }
@BeforeMethod public void setUp(final Method testMethod) throws Throwable { redisProvided = Boolean.parseBoolean(System.getProperty("redis.provided", "false")); final int redisPort = Integer.parseInt(System.getProperty("redis.port", "16379")); if (!redisProvided) { embeddedRedisServer = new RedisServer(redisPort); embeddedRedisServer.start(); } try { System.setProperty( "org.apache.catalina.startup.EXIT_ON_INIT_FAILURE", "true" ); _tomcat1 = getTestUtils().tomcatBuilder().port(_portTomcat1).memcachedNodes("redis://localhost:"+ redisPort) .sticky(true).buildAndStart(); } catch ( final Throwable e ) { LOG.error( "could not start tomcat.", e ); throw e; } redisClient = new BinaryJedis("localhost", redisPort); transcoderService = new TranscoderService(new JavaSerializationTranscoder(_tomcat1.getManager())); }
@PreDestroy public void destroy() { this.redisServer.stop(); } }
@AfterMethod public void tearDown() throws Exception { if (embeddedRedisServer != null) { embeddedRedisServer.stop(); embeddedRedisServer = null; } }
@AfterMethod public void tearDown() throws Exception { if (redisClient != null) { redisClient.close(); redisClient = null; } if (embeddedRedisServer != null) { embeddedRedisServer.stop(); embeddedRedisServer = null; } _tomcat1.stop(); }