summaryrefslogtreecommitdiffstats
path: root/core/core-infrastructure/src
diff options
context:
space:
mode:
authorliamfallon <liam.fallon@est.tech>2020-05-15 11:15:11 +0100
committerliamfallon <liam.fallon@est.tech>2020-05-15 11:15:15 +0100
commitc0b182649ee4ad6b963990ae15c3f3bcec2e09bc (patch)
treea6e0b9b7242ba964c97c77ea4745f0c8c98b7be3 /core/core-infrastructure/src
parentea317372413753320db681efb9a1e469c3776f42 (diff)
Unit test fails when port number occupied
If the port specified in the allocateAddress() is occupied, the method returns the next highest available port. The unit test is changed to reflect this behaviour. Issue-ID: POLICY-1916 Change-Id: I02f63476d5f8f3ef2b2363afb3e23de04264e810 Signed-off-by: liamfallon <liam.fallon@est.tech>
Diffstat (limited to 'core/core-infrastructure/src')
-rw-r--r--core/core-infrastructure/src/test/java/org/onap/policy/apex/core/infrastructure/messaging/MessagingUtilsTest.java17
1 files changed, 10 insertions, 7 deletions
diff --git a/core/core-infrastructure/src/test/java/org/onap/policy/apex/core/infrastructure/messaging/MessagingUtilsTest.java b/core/core-infrastructure/src/test/java/org/onap/policy/apex/core/infrastructure/messaging/MessagingUtilsTest.java
index 91b34e20c..9eaaeeef2 100644
--- a/core/core-infrastructure/src/test/java/org/onap/policy/apex/core/infrastructure/messaging/MessagingUtilsTest.java
+++ b/core/core-infrastructure/src/test/java/org/onap/policy/apex/core/infrastructure/messaging/MessagingUtilsTest.java
@@ -19,7 +19,9 @@
*/
package org.onap.policy.apex.core.infrastructure.messaging;
-import static org.junit.Assert.*;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
import java.io.IOException;
import java.net.InetAddress;
@@ -32,30 +34,31 @@ public class MessagingUtilsTest {
@Test
public void testCheckPort() throws UnknownHostException, IOException {
- assertEquals(1,MessagingUtils.checkPort(1));
- assertEquals(1,MessagingUtils.findPort(1));
+ assertEquals(1, MessagingUtils.checkPort(1));
+ assertEquals(1, MessagingUtils.findPort(1));
}
@Test(expected = IllegalArgumentException.class)
public void testIllegalArgumentException() {
- assertEquals(1,MessagingUtils.findPort(65536));
+ assertEquals(1, MessagingUtils.findPort(65536));
}
@Test
public void testGetHost() throws UnknownHostException {
InetAddress host = InetAddress.getLocalHost();
- assertEquals(host,MessagingUtils.getHost());
+ assertEquals(host, MessagingUtils.getHost());
}
@Test
public void testValidAllocateAddress() throws UnknownHostException {
assertNotNull(MessagingUtils.getLocalHostLanAddress());
- assertEquals(3306,MessagingUtils.allocateAddress(3306));
+ int allocatedPort = MessagingUtils.allocateAddress(3306);
+ assertTrue(allocatedPort >= 3306 && allocatedPort < 65536);
}
@Test(expected = IllegalArgumentException.class)
public void testInvalidAllocateAddress() {
- assertEquals(1,MessagingUtils.allocateAddress(1));
+ assertEquals(1, MessagingUtils.allocateAddress(1));
}
@Test