diff --git a/src/test/scala/com/twitter/zookeeper/ZooKeeperClientSpec.scala b/src/test/scala/com/twitter/zookeeper/ZooKeeperClientSpec.scala index 1877192..937f370 100644 --- a/src/test/scala/com/twitter/zookeeper/ZooKeeperClientSpec.scala +++ b/src/test/scala/com/twitter/zookeeper/ZooKeeperClientSpec.scala @@ -1,6 +1,6 @@ package com.twitter.zookeeper -import java.net.{Socket, SocketException} +import java.net.{Socket, ConnectException} import org.scala_tools.javautils.Imports._ import org.apache.zookeeper.{CreateMode, Watcher, WatchedEvent, ZooKeeper} import org.apache.zookeeper.CreateMode._ @@ -11,17 +11,25 @@ import net.lag.configgy.Configgy import scala.collection.mutable class ZookeeperClientSpec extends Specification { - "ZookeeperClient" should { - Configgy.configure("src/main/resources/config.conf") + Configgy.configure("src/main/resources/config.conf") + + val configMap = Configgy.config + val hostlist = configMap.getString("zookeeper-client.hostlist", "localhost:2181") - val configMap = Configgy.config - val zkClient = new ZooKeeperClient(configMap, Some((zk : ZooKeeper) => {})) + doBeforeSpec { + // we need to be sure that a ZooKeeper server is running in order to test + println("Testing connection to ZooKeeper server at %s...".format(hostlist)) + val socketPort = hostlist.split(":") + new Socket(socketPort(0), socketPort(1).toInt) mustNot throwA[ConnectException] + } + + "ZookeeperClient" should { + shareVariables() + var zkClient : ZooKeeperClient = null - doBefore { - // we need to be sure that a ZooKeeper server is running in order to test - val hostlist = configMap.getString("zookeeper-client.hostlist", "localhost:2181") - val socketPort = hostlist.split(":") - new Socket(socketPort(0), socketPort(1).toInt) must throwA[SocketException] + doFirst { + println("Attempting to connect to ZooKeeper server %s...".format(hostlist)) + zkClient = new ZooKeeperClient(configMap, None) } doLast {