From 346bc5e99ad13a630482f7afa879e232d9867f5e Mon Sep 17 00:00:00 2001 From: Ryan Moats Date: Sun, 22 Mar 2015 23:18:42 -0500 Subject: [PATCH] neutron-spi JUnit Test Cases Adding JUnit Test Cases for non-rest related methods. (Includes V6 tests and NeutronSubnet code in support of same) Change-Id: Ic72312fa6fadc3980ec48e6facd21d7f74787bd5 Signed-off-by: Ryan Moats --- neutron-spi/pom.xml | 5 + .../neutron/spi/NeutronSubnet.java | 33 +- .../neutron/spi/NeutronSubnetTest.java | 314 ++++++++++++++++++ .../NeutronSubnet_IPAllocationPoolTest.java | 241 ++++++++++++++ 4 files changed, 587 insertions(+), 6 deletions(-) create mode 100644 neutron-spi/src/test/java/org/opendaylight/neutron/spi/NeutronSubnetTest.java create mode 100644 neutron-spi/src/test/java/org/opendaylight/neutron/spi/NeutronSubnet_IPAllocationPoolTest.java diff --git a/neutron-spi/pom.xml b/neutron-spi/pom.xml index 568abfea4..0195f2a48 100644 --- a/neutron-spi/pom.xml +++ b/neutron-spi/pom.xml @@ -25,6 +25,11 @@ org.slf4j slf4j-api + + junit + junit + test + diff --git a/neutron-spi/src/main/java/org/opendaylight/neutron/spi/NeutronSubnet.java b/neutron-spi/src/main/java/org/opendaylight/neutron/spi/NeutronSubnet.java index c61854ea6..9fce97eeb 100644 --- a/neutron-spi/src/main/java/org/opendaylight/neutron/spi/NeutronSubnet.java +++ b/neutron-spi/src/main/java/org/opendaylight/neutron/spi/NeutronSubnet.java @@ -395,13 +395,34 @@ public class NeutronSubnet implements Serializable, INeutronObject { * is valid for this subnet or not */ public boolean isValidIP(String ipAddress) { - try { - SubnetUtils util = new SubnetUtils(cidr); - SubnetInfo info = util.getInfo(); - return info.isInRange(ipAddress); - } catch (Exception e) { - return false; + if (ipVersion == 4) { + try { + SubnetUtils util = new SubnetUtils(cidr); + SubnetInfo info = util.getInfo(); + return info.isInRange(ipAddress); + } catch (Exception e) { + return false; + } + } + if (ipVersion == 6) { + String[] parts = cidr.split("/"); + try { + int length = Integer.parseInt(parts[1]); + byte[] cidrBytes = ((Inet6Address) InetAddress.getByName(parts[0])).getAddress(); + byte[] ipBytes = ((Inet6Address) InetAddress.getByName(ipAddress)).getAddress(); + int i; + for (i=0; i aPools = new ArrayList(); + aPools.add(allocationPool); + objectUT.setAllocationPools(aPools); + + objectUT.setGatewayIP("10.18.0.1"); + Assert.assertFalse("gatewayIP_Pool_overlap Test 1: test with address below allocation pool failed", + objectUT.gatewayIP_Pool_overlap()); + + objectUT.setGatewayIP("10.18.0.4"); + Assert.assertTrue("gatewayIP_Pool_overlap Test 2: test with address in allocation pool failed", + objectUT.gatewayIP_Pool_overlap()); + + objectUT.setGatewayIP("10.18.0.7"); + Assert.assertFalse("gatewayIP_Pool_overlap Test 3: test with address above allocation pool failed", + objectUT.gatewayIP_Pool_overlap()); + + objectUT.setIpVersion(6); + objectUT.setCidr("2015::0/64"); + + allocationPool = new NeutronSubnet_IPAllocationPool(); + allocationPool.setPoolStart("2015::2"); + allocationPool.setPoolEnd("2015::6"); + aPools = new ArrayList(); + aPools.add(allocationPool); + objectUT.setAllocationPools(aPools); + + objectUT.setGatewayIP("2015::1"); + Assert.assertFalse("gatewayIP_Pool_overlap v6 Test 1: test with address below allocation pool failed", + objectUT.gatewayIP_Pool_overlap()); + + objectUT.setGatewayIP("2015::4"); + Assert.assertTrue("gatewayIP_Pool_overlap v6 Test 2: test with address in allocation pool failed", + objectUT.gatewayIP_Pool_overlap()); + + objectUT.setGatewayIP("2015::7"); + Assert.assertFalse("gatewayIP_Pool_overlap v6 Test 3: test with address above allocation pool failed", + objectUT.gatewayIP_Pool_overlap()); + } + + @Test + public void isValidIPTest() { + NeutronSubnet objectUT = new NeutronSubnet(); + objectUT.setIpVersion(4); + objectUT.setCidr("10.18.0.0/24"); + + Assert.assertFalse("isValidIP Negative Test 1: test of IP address outside of CIDR block failed", + objectUT.isValidIP("10.18.1.1")); + + Assert.assertTrue("isValidIP Test 1: test of IP address within CIDR block failed", + objectUT.isValidIP("10.18.0.1")); + + objectUT.setIpVersion(6); + objectUT.setCidr("2015::0/64"); + + Assert.assertFalse("isValidIP v6 Negative Test 1: test of IP address outside of CIDR block failed", + objectUT.isValidIP("2015:0:0:1:0:0:0:1")); + + Assert.assertTrue("isValidIP v6 Test 1: test of IP address within CIDR block failed", + objectUT.isValidIP("2015:0:0:0:1:0:0:1")); + } + + @Test + public void isIPInUseTest() { + NeutronSubnet objectUT = new NeutronSubnet(); + objectUT.setIpVersion(4); + objectUT.setCidr("10.18.0.0/24"); + + NeutronSubnet_IPAllocationPool allocationPool = new NeutronSubnet_IPAllocationPool(); + allocationPool.setPoolStart("10.18.0.2"); + allocationPool.setPoolEnd("10.18.0.6"); + List aPools = new ArrayList(); + aPools.add(allocationPool); + objectUT.setAllocationPools(aPools); + + objectUT.setGatewayIP("10.18.0.1"); + objectUT.resetGatewayIPAllocated(); + Assert.assertFalse("isIPInUse Test 1: test of unallocated gateway IP address failed", + objectUT.isIPInUse("10.18.0.1")); + + objectUT.setGatewayIPAllocated(); + Assert.assertTrue("isIPInUse Test 2: test of allocated gateway IP address failed", + objectUT.isIPInUse("10.18.0.1")); + + Assert.assertFalse("isIPInUse Test 3: test of address in allocation pool failed", + objectUT.isIPInUse("10.18.0.4")); + + Assert.assertTrue("isIPInUse Test 4: test of address outside of allocation pool failed", + objectUT.isIPInUse("10.18.0.10")); + + Assert.assertTrue("isIPInUse Test 5: test of address outside of CIDR block failed", + objectUT.isIPInUse("10.18.1.10")); + + objectUT.setIpVersion(6); + objectUT.setCidr("2015::0/64"); + + allocationPool = new NeutronSubnet_IPAllocationPool(); + allocationPool.setPoolStart("2015::2"); + allocationPool.setPoolEnd("2015::6"); + aPools = new ArrayList(); + aPools.add(allocationPool); + objectUT.setAllocationPools(aPools); + + objectUT.setGatewayIP("2015::1"); + objectUT.resetGatewayIPAllocated(); + Assert.assertFalse("isIPInUse v6 Test 1: test of unallocated gateway IP address failed", + objectUT.isIPInUse("2015::1")); + + objectUT.setGatewayIPAllocated(); + Assert.assertTrue("isIPInUse v6 Test 2: test of allocated gateway IP address failed", + objectUT.isIPInUse("2015::1")); + + Assert.assertFalse("isIPInUse v6 Test 3: test of address in allocation pool failed", + objectUT.isIPInUse("2015::4")); + + Assert.assertTrue("isIPInUse v6 Test 4: test of address outside of allocation pool failed", + objectUT.isIPInUse("2015::10")); + + Assert.assertTrue("isIPInUse v6 Test 5: test of address outside of CIDR block failed", + objectUT.isIPInUse("2016::10")); + } + + @Test + public void getLowAddrTest() { + NeutronSubnet objectUT = new NeutronSubnet(); + objectUT.setIpVersion(4); + objectUT.setCidr("10.18.0.0/24"); + + NeutronSubnet_IPAllocationPool allocationPool = new NeutronSubnet_IPAllocationPool(); + allocationPool.setPoolStart("10.18.0.2"); + allocationPool.setPoolEnd("10.18.0.6"); + List aPools = new ArrayList(); + aPools.add(allocationPool); + allocationPool = new NeutronSubnet_IPAllocationPool(); + allocationPool.setPoolStart("10.18.0.10"); + allocationPool.setPoolEnd("10.18.0.15"); + objectUT.setAllocationPools(aPools); + + Assert.assertEquals("getLowAddr Test 1: test of returned address", + "10.18.0.2", objectUT.getLowAddr()); + + objectUT.setIpVersion(6); + objectUT.setCidr("2015::0/24"); + + allocationPool = new NeutronSubnet_IPAllocationPool(); + allocationPool.setPoolStart("2015::2"); + allocationPool.setPoolEnd("2015::6"); + aPools = new ArrayList(); + aPools.add(allocationPool); + allocationPool = new NeutronSubnet_IPAllocationPool(); + allocationPool.setPoolStart("2015::10"); + allocationPool.setPoolEnd("2015::15"); + objectUT.setAllocationPools(aPools); + + Assert.assertEquals("getLowAddr v6 Test 1: test of returned address", + "2015::2", objectUT.getLowAddr()); + } + + @Test + public void allocate_releaseIPTests() { + NeutronSubnet objectUT = new NeutronSubnet(); + objectUT.setIpVersion(4); + objectUT.setCidr("10.18.0.0/24"); + + NeutronSubnet_IPAllocationPool allocationPool = new NeutronSubnet_IPAllocationPool(); + allocationPool.setPoolStart("10.18.0.2"); + allocationPool.setPoolEnd("10.18.0.6"); + List aPools = new ArrayList(); + aPools.add(allocationPool); + objectUT.setAllocationPools(aPools); + + String ipAddress = objectUT.getLowAddr(); + objectUT.allocateIP(ipAddress); + aPools = objectUT.getAllocationPools(); + Assert.assertEquals("allocateIP Test 1: test of resulting allocation pools size failed", + 1, aPools.size()); + + Assert.assertEquals("allocateIP Test 2: test of resulting allocation pools start address failed", + "10.18.0.3", aPools.get(0).getPoolStart()); + + Assert.assertEquals("allocateIP Test 3: test of resulting allocation pools end address failed", + "10.18.0.6", aPools.get(0).getPoolEnd()); + + objectUT.releaseIP(ipAddress); + aPools = objectUT.getAllocationPools(); + Assert.assertEquals("releaseIP Test 1: test of resulting allocation pools size failed", + 1, aPools.size()); + + Assert.assertEquals("releaseIP Test 2: test of resulting allocation pool 1 start address failed", + "10.18.0.2", aPools.get(0).getPoolStart()); + + Assert.assertEquals("releaseIP Test 3: test of resulting allocation pool 1 end address failed", + "10.18.0.6", aPools.get(0).getPoolEnd()); + + objectUT.releaseIP("10.18.0.20"); + aPools = objectUT.getAllocationPools(); + Assert.assertEquals("releaseIP Test 4: test of resulting allocation pools size failed", + 2, aPools.size()); + + Assert.assertEquals("releaseIP Test 5: test of resulting allocation pool 1 start address failed", + "10.18.0.20", aPools.get(1).getPoolStart()); + + Assert.assertEquals("releaseIP Test 6: test of resulting allocation pool 1 end address failed", + "10.18.0.20", aPools.get(1).getPoolEnd()); + + objectUT.allocateIP("10.18.0.20"); + aPools = objectUT.getAllocationPools(); + Assert.assertEquals("allocateIP Test 4: test of resulting allocation pools size failed", + 1, aPools.size()); + + objectUT.setIpVersion(6); + objectUT.setCidr("2015::0/64"); + + allocationPool = new NeutronSubnet_IPAllocationPool(); + allocationPool.setPoolStart("2015:0:0:0:0:0:0:2"); + allocationPool.setPoolEnd("2015:0:0:0:0:0:0:6"); + aPools = new ArrayList(); + aPools.add(allocationPool); + objectUT.setAllocationPools(aPools); + + ipAddress = objectUT.getLowAddr(); + objectUT.allocateIP(ipAddress); + aPools = objectUT.getAllocationPools(); + Assert.assertEquals("allocateIP v6 Test 1: test of resulting allocation pools size failed", + 1, aPools.size()); + + Assert.assertEquals("allocateIP v6 Test 2: test of resulting allocation pools start address failed", + "2015:0:0:0:0:0:0:3", aPools.get(0).getPoolStart()); + + Assert.assertEquals("allocateIP v6 Test 3: test of resulting allocation pools end address failed", + "2015:0:0:0:0:0:0:6", aPools.get(0).getPoolEnd()); + + objectUT.releaseIP(ipAddress); + aPools = objectUT.getAllocationPools(); + Assert.assertEquals("releaseIP Test 1: test of resulting allocation pools size failed", + 1, aPools.size()); + + Assert.assertEquals("releaseIP Test 2: test of resulting allocation pool 1 start address failed", + "2015:0:0:0:0:0:0:2", aPools.get(0).getPoolStart()); + + Assert.assertEquals("releaseIP Test 3: test of resulting allocation pool 1 end address failed", + "2015:0:0:0:0:0:0:6", aPools.get(0).getPoolEnd()); + + objectUT.releaseIP("2015:0:0:0:0:0:0:20"); + aPools = objectUT.getAllocationPools(); + Assert.assertEquals("releaseIP Test 4: test of resulting allocation pools size failed", + 2, aPools.size()); + + Assert.assertEquals("releaseIP Test 5: test of resulting allocation pool 1 start address failed", + "2015:0:0:0:0:0:0:20", aPools.get(1).getPoolStart()); + + Assert.assertEquals("releaseIP Test 6: test of resulting allocation pool 1 end address failed", + "2015:0:0:0:0:0:0:20", aPools.get(1).getPoolEnd()); + + objectUT.allocateIP("2015:0:0:0:0:0:0:20"); + aPools = objectUT.getAllocationPools(); + Assert.assertEquals("allocateIP Test 4: test of resulting allocation pools size failed", + 1, aPools.size()); + } +} diff --git a/neutron-spi/src/test/java/org/opendaylight/neutron/spi/NeutronSubnet_IPAllocationPoolTest.java b/neutron-spi/src/test/java/org/opendaylight/neutron/spi/NeutronSubnet_IPAllocationPoolTest.java new file mode 100644 index 000000000..cc9b38e44 --- /dev/null +++ b/neutron-spi/src/test/java/org/opendaylight/neutron/spi/NeutronSubnet_IPAllocationPoolTest.java @@ -0,0 +1,241 @@ +/* + * Copyright IBM Corporation, 2015. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ + +package org.opendaylight.neutron.spi; + +import java.math.BigInteger; +import java.util.List; + +import org.junit.Assert; +import org.junit.Test; + +import org.opendaylight.neutron.spi.NeutronSubnet_IPAllocationPool; + +public class NeutronSubnet_IPAllocationPoolTest { + @Test + public void convertTest() { + Assert.assertEquals("Convert Test 1: null Argument failed", + 0, NeutronSubnet_IPAllocationPool.convert(null)); + + Assert.assertEquals("Convert Test 2: convert of 32.20.10.0 failed", + 538184192, NeutronSubnet_IPAllocationPool.convert("32.20.10.0")); + + Assert.assertEquals("Convert Test 3: convert of 192.168.2.140 failed", + 3232236172L, NeutronSubnet_IPAllocationPool.convert("192.168.2.140")); + } + + @Test + public void convert_V6_Test() { + boolean result = BigInteger.ZERO.equals(NeutronSubnet_IPAllocationPool.convert_V6(null)); + Assert.assertTrue("Convert V6 Test 1: null Argument failed", result); + + result = new BigInteger("42550872755692912415807417417958686721"). + equals(NeutronSubnet_IPAllocationPool.convert_V6("2003:0:0:0:0:0:0:1")); + Assert.assertTrue("Convert V6 Test 2: 2003:0:0:0:0:0:0:1 Argument failed", result); + } + + + @Test + public void longToIPTest() { + Assert.assertEquals("longToIP Test 1: convert of 538184192L failed", + "32.20.10.0", NeutronSubnet_IPAllocationPool.longToIP(538184192L)); + + Assert.assertEquals("longToIP Test 2: convert of 3232236172L failed", + "192.168.2.140", NeutronSubnet_IPAllocationPool.longToIP(3232236172L)); + } + + @Test + public void bigIntegerToIPTest() { + BigInteger start = new BigInteger("42550872755692912415807417417958686721"); + Assert.assertEquals("longToIP Test 1: convert of 42550872755692912415807417417958686721 failed", + "2003:0:0:0:0:0:0:1", NeutronSubnet_IPAllocationPool.bigIntegerToIP(start)); + } + @Test + public void containsTest() { + NeutronSubnet_IPAllocationPool apUT = new NeutronSubnet_IPAllocationPool(); + apUT.setPoolStart("10.18.0.2"); + apUT.setPoolEnd("10.18.0.4"); + + Assert.assertFalse("Contains Test 1: address one below pool start failed", + apUT.contains("10.18.0.1")); + + Assert.assertTrue("Contains Test 2: address == pool start failed", + apUT.contains("10.18.0.2")); + + Assert.assertTrue("Contains Test 3: adress in pool failed", + apUT.contains("10.18.0.3")); + + Assert.assertTrue("Contains Test 4: address == pool end failed", + apUT.contains("10.18.0.4")); + + Assert.assertFalse("Contains Test 5: one above pool end failed", + apUT.contains("10.18.0.5")); + } + + @Test + public void contains_V6_Test() { + NeutronSubnet_IPAllocationPool apUT = new NeutronSubnet_IPAllocationPool(); + apUT.setPoolStart("2015:0:0:0:0:0:0:2"); + apUT.setPoolEnd("2015:0:0:0:0:0:0:4"); + + Assert.assertFalse("Contains V6 Test 1: address one below pool start failed", + apUT.contains_V6("2015:0:0:0:0:0:0:1")); + + Assert.assertTrue("Contains V6 Test 2: address == pool start failed", + apUT.contains_V6("2015:0:0:0:0:0:0:2")); + + Assert.assertTrue("Contains V6 Test 3: adress in pool failed", + apUT.contains_V6("2015:0:0:0:0:0:0:3")); + + Assert.assertTrue("Contains V6 Test 4: address == pool end failed", + apUT.contains_V6("2015:0:0:0:0:0:0:4")); + + Assert.assertFalse("Contains V6 Test 5: one above pool end failed", + apUT.contains_V6("2015:0:0:0:0:0:0:5")); + } + + @Test + public void splitPoolTest() { + NeutronSubnet_IPAllocationPool apUT = new NeutronSubnet_IPAllocationPool(); + apUT.setPoolStart("10.18.0.2"); + apUT.setPoolEnd("10.18.0.6"); + List result = apUT.splitPool("10.18.0.2"); + Assert.assertEquals("splitPool Test 1.1: address == pool start (result size) failed", + 1, result.size()); + Assert.assertEquals("splitPool Test 1.2: address == pool start (pool start) failed", + "10.18.0.3", result.get(0).getPoolStart()); + Assert.assertEquals("splitPool Test 1.3: address == pool start (pool end) failed", + "10.18.0.6", result.get(0).getPoolEnd()); + + apUT = new NeutronSubnet_IPAllocationPool(); + apUT.setPoolStart("10.18.0.2"); + apUT.setPoolEnd("10.18.0.6"); + result = apUT.splitPool("10.18.0.3"); + Assert.assertEquals("splitPool Test 2.1: address one above pool start (result size) failed", + 2, result.size()); + Assert.assertEquals("splitPool Test 2.2: address one above pool start (pool 1 start) failed", + "10.18.0.2", result.get(0).getPoolStart()); + Assert.assertEquals("splitPool Test 2.3: address one above pool start (pool 1 end) failed", + "10.18.0.2", result.get(0).getPoolEnd()); + Assert.assertEquals("splitPool Test 2.4: address one above pool start (pool 2 start) failed", + "10.18.0.4", result.get(1).getPoolStart()); + Assert.assertEquals("splitPool Test 2.5: address one above pool start (pool 2 end) failed", + "10.18.0.6", result.get(1).getPoolEnd()); + + apUT = new NeutronSubnet_IPAllocationPool(); + apUT.setPoolStart("10.18.0.2"); + apUT.setPoolEnd("10.18.0.6"); + result = apUT.splitPool("10.18.0.4"); + Assert.assertEquals("splitPool Test 3.1: address one above pool start (result size) failed", + 2, result.size()); + Assert.assertEquals("splitPool Test 3.2: address one above pool start (pool 1 start) failed", + "10.18.0.2", result.get(0).getPoolStart()); + Assert.assertEquals("splitPool Test 3.3: address one above pool start (pool 1 end) failed", + "10.18.0.3", result.get(0).getPoolEnd()); + Assert.assertEquals("splitPool Test 3.4: address one above pool start (pool 2 start) failed", + "10.18.0.5", result.get(1).getPoolStart()); + Assert.assertEquals("splitPool Test 3.5: address one above pool start (pool 2 end) failed", + "10.18.0.6", result.get(1).getPoolEnd()); + + apUT = new NeutronSubnet_IPAllocationPool(); + apUT.setPoolStart("10.18.0.2"); + apUT.setPoolEnd("10.18.0.6"); + result = apUT.splitPool("10.18.0.5"); + Assert.assertEquals("splitPool Test 4.1: address one above pool start (result size) failed", + 2, result.size()); + Assert.assertEquals("splitPool Test 4.2: address one above pool start (pool 1 start) failed", + "10.18.0.2", result.get(0).getPoolStart()); + Assert.assertEquals("splitPool Test 4.3: address one above pool start (pool 1 end) failed", + "10.18.0.4", result.get(0).getPoolEnd()); + Assert.assertEquals("splitPool Test 4.4: address one above pool start (pool 2 start) failed", + "10.18.0.6", result.get(1).getPoolStart()); + Assert.assertEquals("splitPool Test 4.5: address one above pool start (pool 2 end) failed", + "10.18.0.6", result.get(1).getPoolEnd()); + + apUT = new NeutronSubnet_IPAllocationPool(); + apUT.setPoolStart("10.18.0.2"); + apUT.setPoolEnd("10.18.0.6"); + result = apUT.splitPool("10.18.0.6"); + Assert.assertEquals("splitPool Test 5.1: address == pool start (result size) failed", + 1, result.size()); + Assert.assertEquals("splitPool Test 5.2: address == pool start (pool start) failed", + "10.18.0.2", result.get(0).getPoolStart()); + Assert.assertEquals("splitPool Test 5.3: address == pool start (pool end) failed", + "10.18.0.5", result.get(0).getPoolEnd()); + } + + @Test + public void splitPool_V6_Test() { + NeutronSubnet_IPAllocationPool apUT = new NeutronSubnet_IPAllocationPool(); + apUT.setPoolStart("2015:0:0:0:0:0:0:2"); + apUT.setPoolEnd("2015:0:0:0:0:0:0:6"); + List result = apUT.splitPool_V6("2015:0:0:0:0:0:0:2"); + Assert.assertEquals("splitPool_V6 Test 1.1: address == pool start (result size) failed", + 1, result.size()); + Assert.assertEquals("splitPool_V6 Test 1.2: address == pool start (pool start) failed", + "2015:0:0:0:0:0:0:3", result.get(0).getPoolStart()); + Assert.assertEquals("splitPool_V6 Test 1.3: address == pool start (pool end) failed", + "2015:0:0:0:0:0:0:6", result.get(0).getPoolEnd()); + + apUT = new NeutronSubnet_IPAllocationPool(); + apUT.setPoolStart("2015:0:0:0:0:0:0:2"); + apUT.setPoolEnd("2015:0:0:0:0:0:0:6"); + result = apUT.splitPool_V6("2015:0:0:0:0:0:0:3"); + Assert.assertEquals("splitPool_V6 Test 2.1: address one above pool start (result size) failed", + 2, result.size()); + Assert.assertEquals("splitPool_V6 Test 2.2: address one above pool start (pool 1 start) failed", + "2015:0:0:0:0:0:0:2", result.get(0).getPoolStart()); + Assert.assertEquals("splitPool_V6 Test 2.3: address one above pool start (pool 1 end) failed", + "2015:0:0:0:0:0:0:2", result.get(0).getPoolEnd()); + Assert.assertEquals("splitPool_V6 Test 2.4: address one above pool start (pool 2 start) failed", + "2015:0:0:0:0:0:0:4", result.get(1).getPoolStart()); + Assert.assertEquals("splitPool_V6 Test 2.5: address one above pool start (pool 2 end) failed", + "2015:0:0:0:0:0:0:6", result.get(1).getPoolEnd()); + + apUT = new NeutronSubnet_IPAllocationPool(); + apUT.setPoolStart("2015:0:0:0:0:0:0:2"); + apUT.setPoolEnd("2015:0:0:0:0:0:0:6"); + result = apUT.splitPool_V6("2015:0:0:0:0:0:0:4"); + Assert.assertEquals("splitPool_V6 Test 3.1: address one above pool start (result size) failed", + 2, result.size()); + Assert.assertEquals("splitPool_V6 Test 3.2: address one above pool start (pool 1 start) failed", + "2015:0:0:0:0:0:0:2", result.get(0).getPoolStart()); + Assert.assertEquals("splitPool_V6 Test 3.3: address one above pool start (pool 1 end) failed", + "2015:0:0:0:0:0:0:3", result.get(0).getPoolEnd()); + Assert.assertEquals("splitPool_V6 Test 3.4: address one above pool start (pool 2 start) failed", + "2015:0:0:0:0:0:0:5", result.get(1).getPoolStart()); + Assert.assertEquals("splitPool_V6 Test 3.5: address one above pool start (pool 2 end) failed", + "2015:0:0:0:0:0:0:6", result.get(1).getPoolEnd()); + + apUT = new NeutronSubnet_IPAllocationPool(); + apUT.setPoolStart("2015:0:0:0:0:0:0:2"); + apUT.setPoolEnd("2015:0:0:0:0:0:0:6"); + result = apUT.splitPool_V6("2015:0:0:0:0:0:0:5"); + Assert.assertEquals("splitPool_V6 Test 4.1: address one above pool start (result size) failed", + 2, result.size()); + Assert.assertEquals("splitPool_V6 Test 4.2: address one above pool start (pool 1 start) failed", + "2015:0:0:0:0:0:0:2", result.get(0).getPoolStart()); + Assert.assertEquals("splitPool_V6 Test 4.3: address one above pool start (pool 1 end) failed", + "2015:0:0:0:0:0:0:4", result.get(0).getPoolEnd()); + Assert.assertEquals("splitPool_V6 Test 4.4: address one above pool start (pool 2 start) failed", + "2015:0:0:0:0:0:0:6", result.get(1).getPoolStart()); + Assert.assertEquals("splitPool_V6 Test 4.5: address one above pool start (pool 2 end) failed", + "2015:0:0:0:0:0:0:6", result.get(1).getPoolEnd()); + + apUT = new NeutronSubnet_IPAllocationPool(); + apUT.setPoolStart("2015:0:0:0:0:0:0:2"); + apUT.setPoolEnd("2015:0:0:0:0:0:0:6"); + result = apUT.splitPool_V6("2015:0:0:0:0:0:0:6"); + Assert.assertEquals("splitPool_V6 Test 5.1: address == pool start (result size) failed", + 1, result.size()); + Assert.assertEquals("splitPool_V6 Test 5.2: address == pool start (pool start) failed", + "2015:0:0:0:0:0:0:2", result.get(0).getPoolStart()); + Assert.assertEquals("splitPool_V6 Test 5.3: address == pool start (pool end) failed", + "2015:0:0:0:0:0:0:5", result.get(0).getPoolEnd()); + } +} -- 2.36.6