BUG-5619 Enable maven parallel build for bgpcep I
[bgpcep.git] / pcep / impl / src / test / java / org / opendaylight / protocol / pcep / impl / AbstractPCEPSessionTest.java
index 9b78a5b9abe5233e054219833dabb3d9f8d69078..f42aca5f751e7da532709349d888e931f2337b0b 100644 (file)
@@ -31,6 +31,7 @@ import org.mockito.Mock;
 import org.mockito.MockitoAnnotations;
 import org.mockito.invocation.InvocationOnMock;
 import org.mockito.stubbing.Answer;
+import org.opendaylight.protocol.util.InetSocketAddressUtil;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.message.rev131007.Keepalive;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.message.rev131007.KeepaliveBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.message.rev131007.Open;
@@ -44,7 +45,6 @@ import org.opendaylight.yangtools.yang.binding.Notification;
 
 public class AbstractPCEPSessionTest {
 
-    protected static final String IP_ADDRESS = "127.0.0.1";
     protected static final short KEEP_ALIVE = 15;
     protected static final short DEADTIMER = 40;
 
@@ -66,6 +66,8 @@ public class AbstractPCEPSessionTest {
     @Mock
     private SocketAddress address;
 
+    protected final String ipAddress = InetSocketAddressUtil.getRandomLoopbackIpAddress();
+    protected final int port = InetSocketAddressUtil.getRandomPort();
     protected final List<Notification> msgsSend = Lists.newArrayList();
 
     protected Open openMsg;
@@ -101,8 +103,8 @@ public class AbstractPCEPSessionTest {
         doReturn(this.pipeline).when(this.pipeline).addFirst(any(ChannelHandler.class));
         doReturn(true).when(this.channel).isActive();
         doReturn(mock(ChannelFuture.class)).when(this.channel).close();
-        doReturn(new InetSocketAddress(IP_ADDRESS, 4189)).when(this.channel).remoteAddress();
-        doReturn(new InetSocketAddress(IP_ADDRESS, 4189)).when(this.channel).localAddress();
+        doReturn(new InetSocketAddress(ipAddress, port)).when(this.channel).remoteAddress();
+        doReturn(new InetSocketAddress(ipAddress, port)).when(this.channel).localAddress();
         this.openMsg = new OpenBuilder().setOpenMessage(
                 new OpenMessageBuilder().setOpen(
                         new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.open.object.OpenBuilder().setDeadTimer(