diff --git a/waggle-dance-integration-tests/src/main/java/com/hotels/bdp/waggledance/junit/ServerSocketRule.java b/waggle-dance-integration-tests/src/main/java/com/hotels/bdp/waggledance/junit/ServerSocketRule.java index 83748ad43..0a13a6f5a 100644 --- a/waggle-dance-integration-tests/src/main/java/com/hotels/bdp/waggledance/junit/ServerSocketRule.java +++ b/waggle-dance-integration-tests/src/main/java/com/hotels/bdp/waggledance/junit/ServerSocketRule.java @@ -38,15 +38,18 @@ public class ServerSocketRule extends ExternalResource { private static final Logger LOG = LoggerFactory.getLogger(ServerSocketRule.class); - private final InetSocketAddress address; - private final ByteArrayOutputStream output = new ByteArrayOutputStream(); - - private final ServerSocketChannel serverSocketChannel; + private InetSocketAddress address; + private ByteArrayOutputStream output; + private ServerSocketChannel serverSocketChannel; private int requests = 0; - public ServerSocketRule() { + public ServerSocketRule() {} + + @Override + protected void before() throws Throwable { try { + output = new ByteArrayOutputStream(); serverSocketChannel = (ServerSocketChannel) ServerSocketChannel .open() .bind(new InetSocketAddress(0)) diff --git a/waggle-dance-integration-tests/src/test/java/com/hotels/bdp/waggledance/junit/ServerSocketRuleTest.java b/waggle-dance-integration-tests/src/test/java/com/hotels/bdp/waggledance/junit/ServerSocketRuleTest.java index 4d17b5770..fa6cf449b 100644 --- a/waggle-dance-integration-tests/src/test/java/com/hotels/bdp/waggledance/junit/ServerSocketRuleTest.java +++ b/waggle-dance-integration-tests/src/test/java/com/hotels/bdp/waggledance/junit/ServerSocketRuleTest.java @@ -21,6 +21,7 @@ import java.net.ConnectException; import java.net.Socket; +import org.junit.Before; import org.junit.Test; public class ServerSocketRuleTest { @@ -33,6 +34,11 @@ private void sendData(int port, byte[] bytes) throws Exception { } } + @Before + public void setUp() throws Throwable { + rule.before(); + } + @Test public void typical() throws Throwable { sendData(rule.port(), "my-data".getBytes());