use of org.apache.curator.test.TestingServer in project curator by Netflix.
the class ZkPathUtilTest method testToString.
public void testToString() throws Exception {
_zkServer = new TestingServer(4711);
_client = ZkTestSystem.createZkClient("localhost:4711");
final String file1 = "/files/file1";
final String file2 = "/files/file2";
final String file3 = "/files/file2/file3";
_client.createPersistent(file1, true);
_client.createPersistent(file2, true);
_client.createPersistent(file3, true);
String stringRepresentation = ZkPathUtil.toString(_client);
System.out.println(stringRepresentation);
System.out.println("-------------------------");
assertTrue(stringRepresentation.contains("file1"));
assertTrue(stringRepresentation.contains("file2"));
assertTrue(stringRepresentation.contains("file3"));
// path filtering
stringRepresentation = ZkPathUtil.toString(_client, "/", new ZkPathUtil.PathFilter() {
@Override
public boolean showChilds(String path) {
return !file2.equals(path);
}
});
assertTrue(stringRepresentation.contains("file1"));
assertTrue(stringRepresentation.contains("file2"));
assertFalse(stringRepresentation.contains("file3"));
// start path
stringRepresentation = ZkPathUtil.toString(_client, file2, ZkPathUtil.PathFilter.ALL);
assertFalse(stringRepresentation.contains("file1"));
assertTrue(stringRepresentation.contains("file2"));
assertTrue(stringRepresentation.contains("file3"));
_zkServer.close();
}
use of org.apache.curator.test.TestingServer in project pinpoint by naver.
the class ZookeeperClusterTest method createZookeeperServer.
private static TestingServer createZookeeperServer(int port) throws Exception {
TestingServer mockZookeeperServer = new TestingServer(port);
mockZookeeperServer.start();
return mockZookeeperServer;
}
use of org.apache.curator.test.TestingServer in project helios by spotify.
the class DeploymentGroupTest method setUp.
@Before
public void setUp() throws Exception {
MockitoAnnotations.initMocks(this);
zkServer = new TestingServer(true);
final CuratorFramework curatorFramework = CuratorFrameworkFactory.builder().connectString(zkServer.getConnectString()).retryPolicy(new ExponentialBackoffRetry(100, 3)).build();
client = new DefaultZooKeeperClient(curatorFramework);
client.start();
}
use of org.apache.curator.test.TestingServer in project helios by spotify.
the class ZooKeeperTestingServerManager method start.
@Override
public void start() {
log.info("starting zookeeper TestingServer at port={}, dataDir={}", port, dataDir);
try {
server = new TestingServer(port, dataDir);
awaitUp(2, MINUTES);
} catch (Exception e) {
throw Throwables.propagate(e);
}
}
use of org.apache.curator.test.TestingServer in project opennms by OpenNMS.
the class JUnitKafkaServer method before.
@Override
public void before() throws Exception {
zkServer = new TestingServer();
// Start ZooKeeper, this method will block until the service has started
zkServer.start();
getAvailablePort(kafkaPort, 9192);
// Delete any existing Kafka log directory
FileUtils.deleteDirectory(new File("target/kafka-log"));
localhost = getLocalhost();
final Properties properties = new Properties();
properties.put("broker.id", "1");
properties.put("auto.create.topics.enable", "true");
properties.put("num.partitions", "100");
properties.put("enable.zookeeper", "true");
properties.put("host.name", localhost);
properties.put("log.dir", "target/kafka-log");
properties.put("port", String.valueOf(kafkaPort.get()));
properties.put("zookeeper.connect", zkServer.getConnectString());
System.err.println("Kafka server properties: " + properties);
kafkaConfig = new KafkaConfig(properties);
final List<KafkaMetricsReporter> kmrList = new ArrayList<>();
final Buffer<KafkaMetricsReporter> metricsList = scala.collection.JavaConversions.asScalaBuffer(kmrList);
kafkaServer = new KafkaServer(kafkaConfig, new SystemTime(), Option.<String>empty(), metricsList);
kafkaServer.startup();
await().atMost(1, MINUTES).until(() -> getBrokerMetadatas(), hasSize(greaterThanOrEqualTo(1)));
System.err.println("Kafka Address: " + getKafkaConnectString());
System.err.println("Zookeeper Address: " + getZookeeperConnectString());
}
Aggregations