--- /dev/null
+/*
+ * Copyright IBM Corporation and others, 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.util.ArrayList;
+import java.util.List;
+
+import org.junit.Assert;
+import org.junit.Test;
+
+import org.opendaylight.neutron.spi.NeutronSubnet;
+import org.opendaylight.neutron.spi.NeutronSubnet_IPAllocationPool;
+
+public class NeutronSubnetTest {
+
+ @Test
+ public void isValidCIDRTest() {
+ NeutronSubnet objectUT = new NeutronSubnet();
+ objectUT.setIpVersion(4);
+ objectUT.setCidr("10.18.0.0/24");
+ Assert.assertTrue("isValidCIDR Test 1: Testing valid CIDR (10.18.0.0/24) failed",
+ objectUT.isValidCIDR());
+
+ objectUT.setCidr("10.18.0.0/16");
+ Assert.assertTrue("isValidCIDR Test 2: Testing valid CIDR (10.18.0.0/16) failed",
+ objectUT.isValidCIDR());
+
+ objectUT.setCidr("10.18.0.0/8");
+ Assert.assertFalse("isValidCIDR Negative Test 1: Testing invalid CIDR (10.18.0.0/8) failed",
+ objectUT.isValidCIDR());
+
+ objectUT.setIpVersion(6);
+ objectUT.setCidr("2015:0:0:0:0:0:0:0/24");
+ Assert.assertTrue("isValidCIDR Test 3: Testing valid V6 CIDR (2015:0:0:0:0:0:0:0/24) failed",
+ objectUT.isValidCIDR());
+ objectUT.setCidr("2015:0:0:0:0:0:0:1/24");
+ Assert.assertFalse("isValidCIDR Negative Test 1: Testing invalid CIDR (2015:0:0:0:0:0:0:1) failed",
+ objectUT.isValidCIDR());
+ }
+
+ @Test
+ public void gatewayIP_PoolOverlapTest() {
+ NeutronSubnet objectUT = new NeutronSubnet();
+ objectUT.setIpVersion(4);
+ objectUT.setCidr("10.18.0.0/16");
+
+ NeutronSubnet_IPAllocationPool allocationPool = new NeutronSubnet_IPAllocationPool();
+ allocationPool.setPoolStart("10.18.0.2");
+ allocationPool.setPoolEnd("10.18.0.6");
+ List<NeutronSubnet_IPAllocationPool> aPools = new ArrayList<NeutronSubnet_IPAllocationPool>();
+ 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<NeutronSubnet_IPAllocationPool>();
+ 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<NeutronSubnet_IPAllocationPool> aPools = new ArrayList<NeutronSubnet_IPAllocationPool>();
+ 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<NeutronSubnet_IPAllocationPool>();
+ 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<NeutronSubnet_IPAllocationPool> aPools = new ArrayList<NeutronSubnet_IPAllocationPool>();
+ 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<NeutronSubnet_IPAllocationPool>();
+ 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<NeutronSubnet_IPAllocationPool> aPools = new ArrayList<NeutronSubnet_IPAllocationPool>();
+ 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<NeutronSubnet_IPAllocationPool>();
+ 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());
+ }
+}
--- /dev/null
+/*
+ * 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<NeutronSubnet_IPAllocationPool> 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<NeutronSubnet_IPAllocationPool> 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());
+ }
+}