Java Code Examples for redis.embedded.RedisServer#start()

The following examples show how to use redis.embedded.RedisServer#start() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: KeyRotationExampleIT.java    From fernet-java8 with Apache License 2.0 7 votes vote down vote up
@Before
public void setUp() throws IOException {
    initMocks(this);
    final SecureRandom random = new SecureRandom();
    redisServer = new RedisServer();
    redisServer.start();

    pool = new JedisPool();
    repository = new RedisKeyRepository(pool);
    manager = new RedisKeyManager(random, pool, repository);
    manager.setMaxActiveKeys(3);

    clearData();
    manager.initialiseNewRepository();

    resource = new ProtectedResource(repository, random);
}
 
Example 2
Source File: LocalRedisLockTest.java    From dyno with Apache License 2.0 6 votes vote down vote up
@Before
public void setUp() throws IOException {
    redisServer = new RedisServer(REDIS_PORT);
    redisServer.start();
    Assume.assumeFalse(System.getProperty("os.name").toLowerCase().startsWith("win"));
    host = new HostBuilder()
            .setHostname("localhost")
            .setIpAddress("127.0.0.1")
            .setDatastorePort(REDIS_PORT)
            .setPort(REDIS_PORT)
            .setRack(REDIS_RACK)
            .setStatus(Host.Status.Up)
            .createHost();

    tokenMapSupplier = new TokenMapSupplierImpl(host);
    dynoLockClient = constructDynoLockClient();
}
 
Example 3
Source File: RedisLockTest.java    From conductor with Apache License 2.0 6 votes vote down vote up
@BeforeClass
public static void setUp() throws Exception {
    String testServerAddress = "redis://127.0.0.1:6371";
    redisServer = new RedisServer(6371);
    if (redisServer.isActive()) {
        redisServer.stop();
    }
    redisServer.start();

    RedisLockConfiguration redisLockConfiguration = new SystemPropertiesRedisLockConfiguration() {
        @Override
        public String getRedisServerAddress() {
            return testServerAddress;
        }
    };

    Config redissonConfig = new Config();
    redissonConfig.useSingleServer().setAddress(testServerAddress).setTimeout(10000);
    redisLock = new RedisLock((Redisson) Redisson.create(redissonConfig), redisLockConfiguration);

    // Create another instance of redisson for tests.
    config = new Config();
    config.useSingleServer().setAddress(testServerAddress).setTimeout(10000);
    redisson = Redisson.create(config);
}
 
Example 4
Source File: RedisAuthenticationIntegrationTest.java    From dyno with Apache License 2.0 6 votes vote down vote up
@Test
public void testJedisConnFactory_noAuthSuccess() throws Exception {
    redisServer = new RedisServer(REDIS_PORT);
    redisServer.start();

    Host noAuthHost = new HostBuilder().setHostname("localhost").setPort(REDIS_PORT).setRack(REDIS_RACK).setStatus(Status.Up).createHost();

    JedisConnectionFactory conFactory =
            new JedisConnectionFactory(new DynoOPMonitor("some-application-name"), null);
    ConnectionPoolConfiguration cpConfig = new ConnectionPoolConfigurationImpl("some-name");
    CountingConnectionPoolMonitor poolMonitor = new CountingConnectionPoolMonitor();
    HostConnectionPool<Jedis> hostConnectionPool =
            new HostConnectionPoolImpl<>(noAuthHost, conFactory, cpConfig, poolMonitor);
    Connection<Jedis> connection = conFactory
            .createConnection(hostConnectionPool);

    connection.execPing();
}
 
Example 5
Source File: DewTestAutoConfiguration.java    From dew with Apache License 2.0 5 votes vote down vote up
/**
 * Init.
 *
 * @throws IOException the io exception
 */
@PostConstruct
public void init() throws IOException {
    logger.info("Load Auto Configuration : {}", this.getClass().getName());
    logger.info("Enabled Dew Test");
    redisServer = new RedisServer();
    if (!redisServer.isActive()) {
        try {
            redisServer.start();
            redisTemplate.getConnectionFactory().getConnection();
        } catch (Exception e) {
            logger.warn("Start embedded redis error.");
        }
    }
}
 
Example 6
Source File: ConfigTest.java    From sshd-shell-spring-boot with Apache License 2.0 5 votes vote down vote up
@PostConstruct
void init() {
    try {
        redisServer = new RedisServer(6379);
        redisServer.start();
    } catch (Exception ex) {
        System.out.println(ex);
    }
}
 
Example 7
Source File: RedisBackendTest.java    From vertx-service-discovery with Apache License 2.0 5 votes vote down vote up
@BeforeClass
static public void startRedis() throws Exception {
  System.out.println("Creating redis server on port: " + DEFAULT_PORT);
  server = new RedisServer(DEFAULT_PORT);
  System.out.println("Created embedded redis server on port " + DEFAULT_PORT);
  server.start();
}
 
Example 8
Source File: RedisBackendConfiguredInJsonTest.java    From vertx-service-discovery with Apache License 2.0 5 votes vote down vote up
@BeforeClass
static public void startRedis() throws Exception {
  System.out.println("Creating redis server on port: " + PORT);
  server = new RedisServer(PORT);
  System.out.println("Created embedded redis server on port " + PORT);
  server.start();
}
 
Example 9
Source File: RedissonConfigurationIntegrationTest.java    From tutorials with MIT License 5 votes vote down vote up
@BeforeClass
public static void setUp() throws IOException {

    // Take an available port
    ServerSocket s = new ServerSocket(0);
    port = s.getLocalPort();
    s.close();

    redisServer = new RedisServer(port);
    redisServer.start();
}
 
Example 10
Source File: JedisIntegrationTest.java    From tutorials with MIT License 5 votes vote down vote up
@BeforeClass
public static void setUp() throws IOException {
    
    // Take an available port
    ServerSocket s = new ServerSocket(0);
    port = s.getLocalPort();
    s.close();
    
    redisServer = new RedisServer(port);
    redisServer.start();
    
    // Configure JEDIS
    jedis = new Jedis("localhost", port);
}
 
Example 11
Source File: RedisConfigStoreTest.java    From vertx-config with Apache License 2.0 5 votes vote down vote up
@Before
public void setUp(TestContext tc) throws IOException {
  vertx = Vertx.vertx();
  vertx.exceptionHandler(tc.exceptionHandler());

  redisServer = new RedisServer(6379);
  redisServer.start();

  redis = Redis.createClient(vertx, "redis://localhost:6379");
}
 
Example 12
Source File: TestRedisSource.java    From datacollector with Apache License 2.0 5 votes vote down vote up
@Before
public void setUp() {
  try {
    redisPort = RandomPortFinder.find();
    redisServer = new RedisServer(redisPort);
    redisServer.start();
    initTestData();
  } catch (IOException e) {
    Assert.fail(e.getMessage());
    if (null != redisServer) {
      redisServer.stop();
    }
  }
}
 
Example 13
Source File: RedisFeatureSinkTest.java    From feast with Apache License 2.0 4 votes vote down vote up
@Before
public void setUp() throws IOException {
  redis = new RedisServer(REDIS_PORT);
  redis.start();
  redisClient =
      RedisClient.create(new RedisURI(REDIS_HOST, REDIS_PORT, java.time.Duration.ofMillis(2000)));
  StatefulRedisConnection<byte[], byte[]> connection = redisClient.connect(new ByteArrayCodec());
  sync = connection.sync();

  FeatureSetSpec spec1 =
      FeatureSetSpec.newBuilder()
          .setName("fs")
          .setProject("myproject")
          .addEntities(EntitySpec.newBuilder().setName("entity").setValueType(Enum.INT64).build())
          .addFeatures(
              FeatureSpec.newBuilder().setName("feature").setValueType(Enum.STRING).build())
          .build();

  FeatureSetSpec spec2 =
      FeatureSetSpec.newBuilder()
          .setName("feature_set")
          .setProject("myproject")
          .addEntities(
              EntitySpec.newBuilder()
                  .setName("entity_id_primary")
                  .setValueType(Enum.INT32)
                  .build())
          .addEntities(
              EntitySpec.newBuilder()
                  .setName("entity_id_secondary")
                  .setValueType(Enum.STRING)
                  .build())
          .addFeatures(
              FeatureSpec.newBuilder().setName("feature_1").setValueType(Enum.STRING).build())
          .addFeatures(
              FeatureSpec.newBuilder().setName("feature_2").setValueType(Enum.INT64).build())
          .build();

  specMap =
      ImmutableMap.of(
          FeatureSetReference.of("myproject", "fs", 1), spec1,
          FeatureSetReference.of("myproject", "feature_set", 1), spec2);
  StoreProto.Store.RedisConfig redisConfig =
      StoreProto.Store.RedisConfig.newBuilder().setHost(REDIS_HOST).setPort(REDIS_PORT).build();

  redisFeatureSink = RedisFeatureSink.builder().setRedisConfig(redisConfig).build();
  redisFeatureSink.prepareWrite(p.apply("Specs-1", Create.of(specMap)));
}
 
Example 14
Source File: RedisBackedJobServiceTest.java    From feast with Apache License 2.0 4 votes vote down vote up
@Before
public void setUp() throws IOException {
  redis = new RedisServer(REDIS_PORT);
  redis.start();
}
 
Example 15
Source File: BootmonClientServiceIT.java    From boot-mon with Apache License 2.0 4 votes vote down vote up
@Before
public void setUp() throws IOException {
    redisServer = new RedisServer();
    redisServer.start();
}
 
Example 16
Source File: EmbededRedis.java    From synapse with Apache License 2.0 4 votes vote down vote up
@PostConstruct
public void startRedis() throws IOException {
    LOG.info("Starting embedded Redis server on port {}", redisPort);
    redisServer = new RedisServer(redisPort);
    redisServer.start();
}
 
Example 17
Source File: RedisStoreBasicTest.java    From sofa-dashboard-client with Apache License 2.0 4 votes vote down vote up
@BeforeClass
public static void initServer() throws IOException {
    redisServer = new RedisServer(26379);
    redisServer.start();
}
 
Example 18
Source File: InventoryApiTest.java    From vertx-blueprint-microservice with Apache License 2.0 4 votes vote down vote up
@BeforeClass
static public void startRedis() throws Exception {
  server = new RedisServer(6379);
  System.out.println("Created embedded redis server on port 6379");
  server.start();
}
 
Example 19
Source File: SessionControllerIntegrationTest.java    From tutorials with MIT License 4 votes vote down vote up
@BeforeClass
public static void startRedisServer() throws IOException {
    redisServer = new RedisServer(6379);
    redisServer.start();
}
 
Example 20
Source File: StartRedis.java    From redis-scheduler with MIT License 4 votes vote down vote up
@Override
protected void before() throws Throwable {
    server = new RedisServer();
    server.start();
}