@Test
  public void testRedisToNats() throws Exception {

    System.clearProperty(RedisPubSubPlugin.CONFIG_URL);

    Connector c = new Connector();

    ExecutorService executor = Executors.newFixedThreadPool(6);

    RedisPublisher rp = new RedisPublisher("rp", "Export_NATS", 5);
    NatsSubscriber ns = new NatsSubscriber("ns", "Import.Redis", 5);

    // start the connector
    executor.execute(c);

    // start the subsciber app
    executor.execute(ns);

    // wait for subscriber to be ready.
    ns.waitUntilReady();

    // let the connector start
    Thread.sleep(2000);

    // start the publisher
    executor.execute(rp);

    // wait for the subscriber to complete.
    ns.waitForCompletion();

    Assert.assertTrue("Invalid count", ns.getMessageCount() == 5);

    c.shutdown();
  }
  @Test
  public void testRedisSubjectFanoutToNats() throws Exception {

    int count = 5;

    String config =
        "{"
            + "\"redis_to_nats_map\" : ["
            + "{"
            + "\"channel\" : \"Export_NATS\","
            + "\"subject\" : \"Import.Redis\""
            + "},"
            + "{"
            + "\"channel\" : \"Export_NATS\","
            + "\"subject\" : \"Import.Redis2\""
            + "}"
            + "]"
            + "}";

    System.setProperty(RedisPubSubPlugin.CONFIG_URL, generateContentFile(config));

    Connector c = new Connector();

    ExecutorService executor = Executors.newFixedThreadPool(10);

    RedisPublisher rp1 = new RedisPublisher("rp1", "Export_NATS", count);

    NatsSubscriber ns1 = new NatsSubscriber("ns1", "Import.Redis", count);
    NatsSubscriber ns2 = new NatsSubscriber("ns2", "Import.Redis2", count);

    // start the connector
    executor.execute(c);

    // start the subsciber apps
    executor.execute(ns1);
    executor.execute(ns2);

    // wait for subscribers to be ready.
    ns1.waitUntilReady();
    ns2.waitUntilReady();

    // let the connector start
    Thread.sleep(1000);

    // start the publishers
    executor.execute(rp1);

    // wait for the subscribers to complete.
    ns1.waitForCompletion();
    ns2.waitForCompletion();

    Assert.assertTrue("Invalid count", ns1.getMessageCount() == count);
    Assert.assertTrue("Invalid count", ns2.getMessageCount() == count);

    c.shutdown();
  }
  private void testOneToOneWithDefaultConfig(int count) throws Exception {

    System.clearProperty(RedisPubSubPlugin.CONFIG_URL);

    Connector c = new Connector();

    ExecutorService executor = Executors.newFixedThreadPool(6);

    RedisSubscriber rs = new RedisSubscriber("rs", "Import_NATS", count);
    RedisPublisher rp = new RedisPublisher("rp", "Export_NATS", count);

    NatsPublisher np = new NatsPublisher("np", "Export.Redis", count);
    NatsSubscriber ns = new NatsSubscriber("ns", "Import.Redis", count);

    // start the connector
    executor.execute(c);

    // start the subsciber apps
    executor.execute(rs);
    executor.execute(ns);

    // wait for subscribers to be ready.
    rs.waitUntilReady();
    ns.waitUntilReady();

    // let the connector start
    Thread.sleep(1000);

    // start the publishers
    executor.execute(np);
    executor.execute(rp);

    // wait for the subscribers to complete.
    rs.waitForCompletion();
    ns.waitForCompletion();

    Assert.assertTrue("Invalid count", rs.getMessageCount() == count);
    Assert.assertTrue("Invalid count", ns.getMessageCount() == count);

    c.shutdown();
  }