BUG-7706: Fix ServiceUnavailableException
[bgpcep.git] / bgp / rib-impl / src / test / java / org / opendaylight / protocol / bgp / rib / impl / BGPDispatcherImplTest.java
index f31c3dbb2fd2cf2b31166aae4de375aacf143f35..d7e4bb3bcb8582f897cd48557aca397465d13865 100755 (executable)
@@ -7,7 +7,8 @@
  */
 package org.opendaylight.protocol.bgp.rib.impl;
 
-import static org.opendaylight.protocol.bgp.rib.impl.CheckUtil.waitFutureSuccess;
+
+import static org.opendaylight.protocol.util.CheckUtil.waitFutureSuccess;
 
 import com.google.common.base.Optional;
 import com.google.common.collect.Sets;
@@ -17,6 +18,7 @@ import java.net.InetSocketAddress;
 import java.util.concurrent.ExecutionException;
 import org.junit.Assert;
 import org.junit.Test;
+import org.opendaylight.protocol.bgp.rib.spi.State;
 import org.opendaylight.protocol.util.InetSocketAddressUtil;
 
 public class BGPDispatcherImplTest extends AbstractBGPDispatcherTest {
@@ -24,12 +26,12 @@ public class BGPDispatcherImplTest extends AbstractBGPDispatcherTest {
     public void testCreateClient() throws InterruptedException, ExecutionException {
         final InetSocketAddress serverAddress = InetSocketAddressUtil.getRandomLoopbackInetSocketAddress();
         final Channel serverChannel = createServer(serverAddress);
-        Thread.sleep(1000);
-        final Future<BGPSessionImpl> futureClient = this.clientDispatcher.createClient(this.clientAddress, serverAddress, this.registry, 2, true);
+        final Future<BGPSessionImpl> futureClient = this.clientDispatcher.createClient(this.clientAddress,
+            serverAddress, 2, true);
         waitFutureSuccess(futureClient);
         final BGPSessionImpl session = futureClient.get();
-        Assert.assertEquals(BGPSessionImpl.State.UP, this.clientListener.getState());
-        Assert.assertEquals(BGPSessionImpl.State.UP, this.serverListener.getState());
+        Assert.assertEquals(State.UP, this.clientListener.getState());
+        Assert.assertEquals(State.UP, this.serverListener.getState());
         Assert.assertEquals(AS_NUMBER, session.getAsNumber());
         Assert.assertEquals(Sets.newHashSet(IPV_4_TT), session.getAdvertisedTableTypes());
         Assert.assertTrue(serverChannel.isWritable());
@@ -42,11 +44,11 @@ public class BGPDispatcherImplTest extends AbstractBGPDispatcherTest {
     @Test
     public void testCreateReconnectingClient() throws Exception {
         final InetSocketAddress serverAddress = InetSocketAddressUtil.getRandomLoopbackInetSocketAddress();
-        final Future<Void> future = this.clientDispatcher.createReconnectingClient(serverAddress, this.registry, RETRY_TIMER, Optional.absent(),
-            this.clientAddress, true);
+        final Future<Void> future = this.clientDispatcher.createReconnectingClient(serverAddress, RETRY_TIMER,
+            Optional.absent(), this.clientAddress, true);
         waitFutureSuccess(future);
         final Channel serverChannel = createServer(serverAddress);
-        Assert.assertEquals(BGPSessionImpl.State.UP, this.serverListener.getState());
+        Assert.assertEquals(State.UP, this.serverListener.getState());
         Assert.assertTrue(serverChannel.isWritable());
         future.cancel(true);
         this.serverListener.releaseConnection();