Additional UT coverage on VTN Manager-Implementation.internal.cluster. 74/13474/1
authordhandayadhapani-b <dhandayadhapani-b@hcl.com>
Tue, 9 Dec 2014 15:09:00 +0000 (20:39 +0530)
committerdhandayadhapani-b <dhandayadhapani-b@hcl.com>
Tue, 9 Dec 2014 15:09:00 +0000 (20:39 +0530)
Change-Id: I04ad30fc1f02804c9c17d40b02ce6b88b22cdf97
Signed-off-by: dhandayadhapani-b <dhandayadhapani-b@hcl.com>
manager/implementation/src/test/java/org/opendaylight/vtn/manager/internal/FlowConditionComparatorTest.java [new file with mode: 0644]
manager/implementation/src/test/java/org/opendaylight/vtn/manager/internal/PathMapComparatorTest.java [new file with mode: 0644]
manager/implementation/src/test/java/org/opendaylight/vtn/manager/internal/PathMapImplComparatorTest.java [new file with mode: 0644]
manager/implementation/src/test/java/org/opendaylight/vtn/manager/internal/TestBase.java
manager/implementation/src/test/java/org/opendaylight/vtn/manager/internal/cluster/ContainerPathMapImplTest.java [new file with mode: 0644]
manager/implementation/src/test/java/org/opendaylight/vtn/manager/internal/cluster/PassFlowFilterImplTest.java
manager/implementation/src/test/java/org/opendaylight/vtn/manager/internal/cluster/PathMapImplTest.java [new file with mode: 0644]
manager/implementation/src/test/java/org/opendaylight/vtn/manager/internal/cluster/PathPolicyEventTest.java
manager/implementation/src/test/java/org/opendaylight/vtn/manager/internal/cluster/PathPolicyImplTest.java [new file with mode: 0644]
manager/implementation/src/test/java/org/opendaylight/vtn/manager/internal/cluster/VTenantPathMapImplTest.java [new file with mode: 0644]

diff --git a/manager/implementation/src/test/java/org/opendaylight/vtn/manager/internal/FlowConditionComparatorTest.java b/manager/implementation/src/test/java/org/opendaylight/vtn/manager/internal/FlowConditionComparatorTest.java
new file mode 100644 (file)
index 0000000..d085092
--- /dev/null
@@ -0,0 +1,51 @@
+/*
+ * Copyright (c) 2014 NEC Corporation
+ * 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.vtn.manager.internal;
+
+import org.junit.Test;
+import org.opendaylight.vtn.manager.flow.cond.FlowCondition;
+
+/**
+ * JUnit test for {@link FlowConditionComparator}.
+ */
+
+public class FlowConditionComparatorTest extends TestBase {
+
+    /**
+     * Test method for
+     * {@link FlowConditionComparator#hashCode(),
+     *  @link FlowConditionComparator#equals(Object),
+     *  @link FlowConditionComparator#compare(FlowCondition, FlowCondition)}.
+     */
+    @Test
+    public void testComparator() {
+        try {
+            FlowConditionComparator flowConditionomparator = new FlowConditionComparator();
+
+            assertTrue(flowConditionomparator.equals(flowConditionomparator));
+            assertFalse(flowConditionomparator.equals(null));
+            assertFalse(flowConditionomparator.equals(new Integer(1)));
+            assertNotNull(flowConditionomparator.hashCode());
+
+            for (FlowCondition flowCondition1 : createFlowConditions()) {
+                for (FlowCondition flowCondition2 : createFlowConditions()) {
+                    try {
+                        assertEquals(0, flowConditionomparator.compare(flowCondition2, flowCondition2));
+                        assertNotNull(flowConditionomparator.compare(flowCondition2, flowCondition1));
+                    } catch (Exception ex) {
+                        //ex.printStackTrace();
+                    }
+                }
+            }
+        } catch (Exception ex) {
+            //ex.printStackTrace();
+        }
+    }
+}
diff --git a/manager/implementation/src/test/java/org/opendaylight/vtn/manager/internal/PathMapComparatorTest.java b/manager/implementation/src/test/java/org/opendaylight/vtn/manager/internal/PathMapComparatorTest.java
new file mode 100644 (file)
index 0000000..8a9c4aa
--- /dev/null
@@ -0,0 +1,51 @@
+/*
+ * Copyright (c) 2014 NEC Corporation
+ * 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.vtn.manager.internal;
+
+import org.junit.Test;
+import org.opendaylight.vtn.manager.PathMap;
+
+/**
+ * JUnit test for {@link PathMapComparator}.
+ */
+
+public class PathMapComparatorTest extends TestBase {
+
+    /**
+     * Test method for
+     * {@link PathMapComparator#hashCode(),
+     *  @link PathMapComparator#equals(Object),
+     *  @link PathMapComparator#compare(PathMap, PathMap)}.
+     */
+    @Test
+    public void testComparator() {
+        try {
+            PathMapComparator pathcomparator = new PathMapComparator();
+
+            assertTrue(pathcomparator.equals(pathcomparator));
+            assertFalse(pathcomparator.equals(null));
+            assertFalse(pathcomparator.equals(new Integer(1)));
+            assertNotNull(pathcomparator.hashCode());
+
+            for (PathMap pmap : createPathMapsWithIndex()) {
+                for (PathMap pmapobj : createPathMapsWithIndex()) {
+                    try {
+                        assertEquals(0, pathcomparator.compare(pmapobj, pmapobj));
+                        assertNotNull(pathcomparator.compare(pmapobj, pmap));
+                    } catch (Exception ex) {
+                        //ex.printStackTrace();
+                    }
+                }
+            }
+        } catch (Exception ex) {
+            //ex.printStackTrace();
+        }
+    }
+}
diff --git a/manager/implementation/src/test/java/org/opendaylight/vtn/manager/internal/PathMapImplComparatorTest.java b/manager/implementation/src/test/java/org/opendaylight/vtn/manager/internal/PathMapImplComparatorTest.java
new file mode 100644 (file)
index 0000000..24ec61f
--- /dev/null
@@ -0,0 +1,58 @@
+/*
+ * Copyright (c) 2014 NEC Corporation
+ * 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.vtn.manager.internal;
+
+import org.junit.Test;
+import org.opendaylight.vtn.manager.PathMap;
+import org.opendaylight.vtn.manager.internal.cluster.ContainerPathMapImpl;
+
+/**
+ * JUnit test for {@link PathMapImplComparator}.
+ */
+
+public class PathMapImplComparatorTest extends TestBase {
+
+    /**
+     * Test method for
+     * {@link PathMapImplComparator#hashCode(),
+     *  @link PathMapImplComparator#equals(Object),
+     *  @link PathMapImplComparator#compare(PathMapImpl, PathMapImpl)}.
+     */
+    @Test
+    public void testComparator() {
+        try {
+            PathMapImplComparator pathMapImplComparator = new PathMapImplComparator();
+
+            assertTrue(pathMapImplComparator.equals(pathMapImplComparator));
+            assertFalse(pathMapImplComparator.equals(null));
+            assertFalse(pathMapImplComparator.equals(new Integer(1)));
+            assertNotNull(pathMapImplComparator.hashCode());
+
+            for (PathMap pathMap : createPathMapsWithIndex()) {
+                if ((pathMap != null) && (pathMap.getIndex() != null)) {
+                    ContainerPathMapImpl containerPathMapImpl1 = new ContainerPathMapImpl(pathMap.getIndex(), pathMap);
+                    for (PathMap objPathMap : createPathMapsWithIndex()) {
+                        if ((objPathMap != null) && (objPathMap.getIndex() != null)) {
+                            ContainerPathMapImpl containerPathMapImpl2 = new ContainerPathMapImpl(objPathMap.getIndex(), objPathMap);
+                            try {
+                                assertEquals(0, pathMapImplComparator.compare(containerPathMapImpl2, containerPathMapImpl2));
+                                assertNotNull(pathMapImplComparator.compare(containerPathMapImpl2, containerPathMapImpl1));
+                            } catch (Exception ex) {
+                                //ex.printStackTrace();
+                            }
+                        }
+                    }
+                }
+            }
+        } catch (Exception ex) {
+            //ex.printStackTrace();
+        }
+    }
+}
index d62d310164906dc67c28862d26c05b57582c4781..04030ee54ed0cc606ee5e12a60f2e18842767bee 100644 (file)
@@ -28,6 +28,10 @@ import org.junit.After;
 import org.junit.Assert;
 import org.opendaylight.vtn.manager.DataLinkHost;
 import org.opendaylight.vtn.manager.EthernetHost;
+import org.opendaylight.vtn.manager.PathCost;
+import org.opendaylight.vtn.manager.PathMap;
+import org.opendaylight.vtn.manager.PathPolicy;
+import org.opendaylight.vtn.manager.PortLocation;
 import org.opendaylight.vtn.manager.SwitchPort;
 import org.opendaylight.vtn.manager.VBridgeConfig;
 import org.opendaylight.vtn.manager.VBridgeIfPath;
@@ -39,12 +43,14 @@ import org.opendaylight.vtn.manager.VTerminalIfPath;
 import org.opendaylight.vtn.manager.VTerminalPath;
 import org.opendaylight.vtn.manager.flow.action.FlowAction;
 import org.opendaylight.vtn.manager.flow.action.SetTpSrcAction;
+import org.opendaylight.vtn.manager.flow.cond.FlowCondition;
 import org.opendaylight.vtn.manager.flow.filter.FlowFilter;
 import org.opendaylight.vtn.manager.flow.filter.PassFilter;
 import org.opendaylight.vtn.manager.internal.cluster.MacMapPath;
 import org.opendaylight.vtn.manager.internal.cluster.MapReference;
 import org.opendaylight.vtn.manager.internal.cluster.MapType;
 import org.opendaylight.vtn.manager.internal.cluster.VlanMapPath;
+import org.opendaylight.vtn.manager.internal.cluster.VTenantImpl;
 import org.opendaylight.controller.sal.core.Edge;
 import org.opendaylight.controller.sal.core.Node;
 import org.opendaylight.controller.sal.core.NodeConnector;
@@ -86,11 +92,13 @@ public abstract class TestBase extends Assert {
     /**
      * String Declaration for Switch Reserved .
      */
+
     protected static final String SWITCH_RESERVED =
         "switch port is reserved: host={";
      /**
      * An array of index values with positive and negative values.
      */
+
     public static final int[] INDEX_ARRAY = {3, 0, 65536};
 
      /**
@@ -98,6 +106,16 @@ public abstract class TestBase extends Assert {
      */
     public static final String[] TENANT_NAME = {"tenant", "", null};
 
+    /**
+     * An array of Cost values with valid and invalid values.
+     */
+    public static final long[] COST = {0L, 333L, Long.MAX_VALUE};
+
+    /**
+     * An array of FlowCondition names with valid and invalid values.
+     */
+    public static final String[] FLOW_CONDITION_NAME = {"flowCondition", "", null};
+
     /**
      * Throw an error which indicates an unexpected throwable is caught.
      *
@@ -1781,10 +1799,11 @@ public abstract class TestBase extends Assert {
             }
         }
     }
+
     /**
-    * VtnmanagerImpl  object creation
-    * @return VtnmanagerImplList
-    */
+     * VtnmanagerImpl  object creation
+     * @return VtnmanagerImplList
+     */
     public List<VTNManagerImpl> createVtnManagerImplobj() {
         List<VTNManagerImpl> vtnMangerList = new ArrayList<VTNManagerImpl>();
         try {
@@ -1797,7 +1816,6 @@ public abstract class TestBase extends Assert {
         }
     }
 
-
     /**
      * Common Method to create UpdateTye.
      *  @return UpdateType list.
@@ -1835,10 +1853,10 @@ public abstract class TestBase extends Assert {
         }
     }
 
-    /*
-    *Common Method to create FlowFilter.
-    *  @return flowfilter object.
-    */
+    /**
+     * Common Method to create FlowFilter.
+     *  @return flowfilter object.
+     */
     public FlowFilter createFlowFilterobj() {
         int idx = 3;
         int port = 0;
@@ -1874,6 +1892,216 @@ public abstract class TestBase extends Assert {
         }
     }
 
+    /**
+     * Common Method to create FlowCondition.
+     *  @return FlowCondition list object.
+     */
+    public List<FlowCondition> createFlowConditions() {
+        List<FlowCondition> flowConditionList = new ArrayList<FlowCondition>();
+
+        try {
+            FlowCondition flowCondition = null;
+            flowConditionList.add(null);
+            flowConditionList.add(flowCondition);
+
+            for (String conditionName : FLOW_CONDITION_NAME) {
+                flowCondition = new FlowCondition(conditionName, null);
+                flowConditionList.add(flowCondition);
+            }
+            return flowConditionList;
+        } catch (Exception ex) {
+            return null;
+        }
+    }
+
+    /**
+     * Common Method to create PathMap.
+     *  @return PathMap list object.
+     */
+    public List<PathMap> createPathMaps() {
+        List<PathMap> pathmaplist = new ArrayList<PathMap>();
+
+        try {
+            PathMap pathmap = null;
+            pathmaplist.add(null);
+            pathmaplist.add(pathmap);
+
+            // PathMap with ConditionName and PolicyId
+            for (String conditionName : TENANT_NAME) {
+                for (int policyId: createIntegers(-1, 4, false)) {
+                    pathmap = new PathMap(conditionName, policyId);
+                    pathmaplist.add(pathmap);
+                }
+            }
+
+            // PathMap with Index, ConditionName and PolicyId
+            pathmaplist.addAll(createPathMapsWithIndex());
+
+            // PathMap with Index, ConditionName, PolicyId, IdleTimeout and HardTimeout
+            pathmaplist.addAll(createPathMapsWithAllParameters());
+
+            return pathmaplist;
+        } catch (Exception ex) {
+            ex.printStackTrace();
+            return null;
+        }
+    }
+
+    /**
+     * Common Method to create PathMap with Index, ConditionName, PolicyId.
+     *  @return PathMap list object.
+     */
+    public List<PathMap> createPathMapsWithIndex() {
+        List<PathMap> pathmaplist = new ArrayList<PathMap>();
+
+        try {
+            // PathMap with Index, ConditionName and PolicyId
+            for (int policyId : createIntegers(1, 1, false)) {
+                for (int idx : createIntegers(5, 3, false)) {
+                    PathMap pathmap = new PathMap(idx, TENANT_NAME[0], policyId);
+                    pathmaplist.add(pathmap);
+                }
+            }
+
+            return pathmaplist;
+        } catch (Exception ex) {
+            ex.printStackTrace();
+            return null;
+        }
+    }
+
+    /**
+     * Common Method to create PathMap with Index, ConditionName, PolicyId, IdleTimeout and HardTimeout.
+     *  @return PathMap list object.
+     */
+    public List<PathMap> createPathMapsWithAllParameters() {
+        List<PathMap> pathmaplist = new ArrayList<PathMap>();
+
+        try {
+            PathMap pathmap = null;
+            // PathMap with Index, ConditionName, PolicyId, IdleTimeout and HardTimeout
+            for (String conditionName : TENANT_NAME) {
+                for (int policyId : createIntegers(0, 2, false)) {
+                    for (int idx : INDEX_ARRAY) {
+                        // VTenantConfig.idleTimeout List
+                        for (Integer idleTimeout: createIntegers(-1, 3, false)) {
+                            // VTenantConfig.hardTimeout List
+                            for (Integer hardTimeout: createIntegers(-1, 3, false)) {
+                                pathmap = new PathMap(idx, conditionName, policyId, idleTimeout, hardTimeout);
+                                pathmaplist.add(pathmap);
+                            }
+                        }
+                    }
+                }
+            }
+
+            return pathmaplist;
+        } catch (Exception ex) {
+            ex.printStackTrace();
+            return null;
+        }
+    }
+
+    /**
+     * Common Method to create VTenantImpl.
+     *
+     *  @param description      The description of the VTN.
+     *  @param vContainerName   The name of the container to which the tenant belongs.
+     *  @param tenantName       The name of the tenant.
+     *  @return VTenantImpl list object.
+     */
+    public List<VTenantImpl> createVTenantImpl(String description, String vContainerName, String tenantName) {
+        List<VTenantImpl> vTenantImplList = new ArrayList<VTenantImpl>();
+
+        try {
+            VTenantImpl vTenantImpl = null;
+            vTenantImplList.add(null);
+            vTenantImplList.add(vTenantImpl);
+
+
+            // VTenantConfig.idleTimeout List
+            for (Integer idleTimeout: createIntegers(-1, 4, false)) {
+                // VTenantConfig.hardTimeout List
+                for (Integer hardTimeout: createIntegers(-1, 4, false)) {
+                    VTenantConfig tconf = createVTenantConfig(description, idleTimeout, hardTimeout);
+                    VTenantImpl vtenantImpl = new VTenantImpl(vContainerName, tenantName, tconf);
+
+                    vTenantImplList.add(vTenantImpl);
+                }
+            }
+            return vTenantImplList;
+        } catch (Exception ex) {
+            return null;
+        }
+    }
+
+    /**
+     * Create lists of {@link PortLocation} instances for test.
+     *
+     * @return A list of {@link PortLocation} lists.
+     */
+
+    public List<PortLocation> createPortLocation() {
+        try {
+
+            List<PortLocation> portLocation = new ArrayList<PortLocation>();
+            for (NodeConnector nodeConnector : createNodeConnectors(5)) {
+                for (String name : createStrings("portName")) {
+                    PortLocation locationobj = new PortLocation(nodeConnector, name);
+                    portLocation.add(locationobj);
+                }
+            }
+            return portLocation;
+        } catch (Exception ex) {
+            //ex.printStackTrace();
+            return null;
+        }
+    }
+
+    /**
+     * Create lists of {@link PathPolicy} instances for test.
+     *
+     * @return A list of {@link PathPolicy} lists.
+     */
+    public List<PathPolicy> createPathPolicy() {
+        try {
+            int[] ids = {0, 1, 30};
+
+            ArrayList<List<PathCost>> list = new ArrayList<List<PathCost>>();
+            ArrayList<PathPolicy> pathPolicyList = new ArrayList<PathPolicy>();
+            list.add(new ArrayList<PathCost>());
+            ArrayList<PathCost> pathCostList = new ArrayList<PathCost>();
+
+            for (Node node : createNodes(2)) {
+                for (SwitchPort port : createSwitchPorts(2)) {
+                    for (long cost : COST) {
+                        PortLocation ploc = new PortLocation(node, port);
+                        PathCost pc = new PathCost(ploc, cost);
+                        pathCostList.add(pc);
+                        list.add(new ArrayList<PathCost>(pathCostList));
+                    }
+                }
+            }
+
+            PathPolicy ppolicy = null;
+            pathPolicyList.add(null);
+            pathPolicyList.add(ppolicy);
+
+            for (int id : ids) {
+                for (long cost : COST) {
+                    for (List<PathCost> pathCost : list) {
+                        ppolicy = new PathPolicy(cost, pathCost);
+                        pathPolicyList.add(ppolicy);
+                    }
+                }
+            }
+            return pathPolicyList;
+        } catch (Exception ex) {
+            //ex.printStackTrace();
+            return null;
+        }
+    }
+
     /**
      * check a Ethernet packet whether expected parameters are set.
      * (for IPv4 packet)
diff --git a/manager/implementation/src/test/java/org/opendaylight/vtn/manager/internal/cluster/ContainerPathMapImplTest.java b/manager/implementation/src/test/java/org/opendaylight/vtn/manager/internal/cluster/ContainerPathMapImplTest.java
new file mode 100644 (file)
index 0000000..3a30a6e
--- /dev/null
@@ -0,0 +1,62 @@
+/*
+ * Copyright (c) 2014 NEC Corporation
+ * 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.vtn.manager.internal.cluster;
+
+import org.junit.Test;
+import org.opendaylight.vtn.manager.PathMap;
+import org.opendaylight.vtn.manager.VTNException;
+import org.opendaylight.vtn.manager.internal.TestBase;
+import org.opendaylight.vtn.manager.internal.VTNManagerImpl;
+
+/**
+ * JUnit test for {@link ContainerPathMapImpl}.
+ */
+
+public class ContainerPathMapImplTest extends TestBase {
+    /**
+     * Junit for method calls.
+     */
+    @Test
+    public void testAllMethod() {
+        for (PathMap pmap1 : createPathMapsWithAllParameters()) {
+            PathMap[] pmaps = {pmap1};
+            for (PathMap pmap : pmaps) {
+                try {
+                    int idx = pmap.getIndex();
+                    ContainerPathMapImpl containerPathMapImpl = new ContainerPathMapImpl(idx, pmap);
+
+                    assertEquals(idx, containerPathMapImpl.getIndex());
+                    assertEquals(pmap, containerPathMapImpl.getPathMap());
+                    assertTrue(containerPathMapImpl.equals(containerPathMapImpl));
+                    assertNotNull(containerPathMapImpl.hashCode());
+                    assertEquals(containerPathMapImpl.getLogPrefix(), "." + idx);
+                    assertEquals(containerPathMapImpl.getLogger().getName(), ContainerPathMapImpl.class.getName());
+
+                    for (VTNManagerImpl mgr1 : createVtnManagerImplobj()) {
+                        VTNManagerImpl[] mgrs = {mgr1};
+                        for (VTNManagerImpl mgr : mgrs) {
+                            try {
+                                assertNotNull(containerPathMapImpl.saveConfig(mgr));
+                                containerPathMapImpl.destroy(mgr);
+                                assertFalse(containerPathMapImpl.equals(mgr));
+                                assertFalse(containerPathMapImpl.equals(pmap));
+                                assertFalse(containerPathMapImpl.equals(null));
+                            } catch (Exception ex) {
+                                //ex.printStackTrace();
+                            }
+                        }
+                    }
+                } catch (VTNException | NullPointerException ex) {
+                    //ex.printStackTrace();
+                }
+            }
+        }
+    }
+}
index a643c5027b733afc83651e49dca200be7b14800f..b8b4d5be5392b67a9d33a90b8ef6f6cf691a56aa 100644 (file)
 package org.opendaylight.vtn.manager.internal.cluster;
 
 import org.junit.Test;
-import java.util.List;
-import org.opendaylight.vtn.manager.VTNException;
-import org.opendaylight.vtn.manager.flow.filter.FlowFilter;
 import org.opendaylight.vtn.manager.internal.TestBase;
-
+import org.opendaylight.vtn.manager.flow.filter.FlowFilter;
 /**
  * JUnit test for {@link PassFlowFilterImpl}.
  */
 public class PassFlowFilterImplTest extends TestBase {
     /**
-     * Testing the Get methods in {@link PassFlowFilterImpl}.
-    */
+     * Testing the all the methods in {@link PassFlowFilterImpl}.
+     */
     @Test
     public void testGetter() {
         PassFlowFilterImpl filterImpl = null;
+
         //Checking for all the scenarios for PassFlowFilterImpl raise method.
         for (int idx:INDEX_ARRAY) {
-            List<FlowFilter> filterList = createFlowFilter();
-            for (FlowFilter flowfilter: filterList) {
-                try {
-                    filterImpl = new PassFlowFilterImpl(idx, flowfilter);
-                    assertEquals(filterImpl.getIndex(), idx);
-                    assertNotNull(filterImpl.getFlowFilter());
-                } catch (VTNException | NullPointerException ex) {
-                    ex.printStackTrace();
+            for (FlowFilter flowFilters: createFlowFilter()) {
+                FlowFilter[] filterList = {flowFilters};
+                for (FlowFilter flowfilter: filterList) {
+                    try {
+                        filterImpl = new PassFlowFilterImpl(idx, flowfilter);
+                        filterImpl.apply(null, null, null);
+
+                        assertEquals(filterImpl.getIndex(), idx);
+                        assertEquals(filterImpl.getLogger().getName(), PassFlowFilterImpl.class.getName());
+                        assertNotNull(filterImpl.getFlowFilter());
+                        assertNotNull(filterImpl.getFilterType());
+                    } catch (Exception ex) {
+                        //ex.printStackTrace();
+                    }
                 }
             }
         }
diff --git a/manager/implementation/src/test/java/org/opendaylight/vtn/manager/internal/cluster/PathMapImplTest.java b/manager/implementation/src/test/java/org/opendaylight/vtn/manager/internal/cluster/PathMapImplTest.java
new file mode 100644 (file)
index 0000000..19a0466
--- /dev/null
@@ -0,0 +1,97 @@
+/*
+ * Copyright (c) 2014 NEC Corporation
+ * 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.vtn.manager.internal.cluster;
+
+import org.junit.Test;
+
+import org.opendaylight.vtn.manager.PathMap;
+import org.opendaylight.vtn.manager.VTNException;
+import org.opendaylight.vtn.manager.internal.TestBase;
+
+/**
+ * JUnit test for the abstract clase{@link PathMapImpl}.
+ * Using the extended class-ContainerPathMapImpl.
+ */
+
+public class PathMapImplTest extends TestBase {
+    /**
+     * Test method for
+     * {@link PathMapImpl#PathMapImpl(int, PathMap),
+     *  @link PathMapImpl#getTimeout(Integer, String),
+     *  @link PathMapImpl#getIndex(),
+     *  @link PathMapImpl#getPathMap(),
+     *  @link PathMapImpl#hashCode(),
+     *  @link PathMapImpl#equals(Object),
+     *  @link PathMapImpl#toString()}.
+     */
+    @Test
+    public void testAllMethodExceptEvaluate() {
+        ContainerPathMapImpl tempContainerPathMapImpl = null;
+
+        for (int idx : INDEX_ARRAY) {
+            for (PathMap pmaps : createPathMaps()) {
+                PathMap[] pmapList = {pmaps};
+                for (PathMap pmap : pmapList) {
+                    try {
+                        // Test - Constructor and getTimeout
+                        ContainerPathMapImpl containerPathMapImpl = new ContainerPathMapImpl(idx, pmap);
+
+                        // Test - getIndex()
+                        assertEquals(idx, containerPathMapImpl.getIndex());
+
+                        // Test - getPathMap()
+                        assertNotNull(containerPathMapImpl.getPathMap());
+
+                        // Test - hashCode()
+                        assertNotNull(containerPathMapImpl.hashCode());
+
+                        // Test - equals()
+                        containerPathMapImpl.equals(tempContainerPathMapImpl);
+                        containerPathMapImpl.equals(pmap);
+
+                        // Test - toString()
+                        assertNotNull(containerPathMapImpl.toString());
+
+                        if (tempContainerPathMapImpl == null) {
+                            if ((containerPathMapImpl != null) && (containerPathMapImpl.getPathMap() != null)) {
+                                PathMap pathMap = containerPathMapImpl.getPathMap();
+                                if ((pathMap.getIndex() != null) && (pathMap.getFlowConditionName() != null)
+                                    && (pathMap.getIdleTimeout() != null) && (pathMap.getHardTimeout() != null)) {
+                                    tempContainerPathMapImpl = containerPathMapImpl;
+                                }
+                            }
+                        }
+                    } catch (VTNException | NullPointerException ex) {
+                        //ex.printStackTrace();
+                    }
+                }
+            }
+        }
+    }
+
+    /**
+     * Test method for
+     * {@link PathMapImpl#evaluate(VTNManagerImpl, PacketContext)}.
+     */
+    //@Test
+    public void testEvaluate() {
+        ContainerPathMapImpl tempContainerPathMapImpl = null;
+        try {
+            for (int idx : INDEX_ARRAY) {
+                for (PathMap pmap : createPathMaps()) {
+                    // Test - Constructor and getTimeout
+                    ContainerPathMapImpl containerPathMapImpl = new ContainerPathMapImpl(idx, pmap);
+                }
+            }
+        } catch (VTNException | NullPointerException ex) {
+            //ex.printStackTrace();
+        }
+    }
+}
index 10c438d67496b83e162ddd0f5143bdfca4d4dc46..49629fe89ba2a840ba8addac7a8796e086413b62 100644 (file)
@@ -4,7 +4,7 @@
  *
  * 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
+ * distribution, and is available at http://www.eclipse.org/legal/epl-v10.html
  */
 package org.opendaylight.vtn.manager.internal.cluster;
 
@@ -14,13 +14,13 @@ import org.opendaylight.vtn.manager.internal.VTNManagerImpl;
 import org.opendaylight.controller.sal.core.UpdateType;
 
 /**
- * JUnit test for {@link FlowConditionEvent}.
+ * JUnit test for {@link PathPolicyEvent}.
  */
 public class PathPolicyEventTest extends TestBase {
 
     /**
      * Junit for PathPolicyEvent method.
-    */
+     */
     @Test
     public void testRaise() {
         //Checking for all the scenarios for raise method in FlowConditionEvent.
@@ -30,7 +30,7 @@ public class PathPolicyEventTest extends TestBase {
                     try {
                         PathPolicyEvent.raise(mgr, idx, updateTye);
                     } catch (NullPointerException ex) {
-                        ex.printStackTrace();
+                        //ex.printStackTrace();
                     }
                 }
             }
diff --git a/manager/implementation/src/test/java/org/opendaylight/vtn/manager/internal/cluster/PathPolicyImplTest.java b/manager/implementation/src/test/java/org/opendaylight/vtn/manager/internal/cluster/PathPolicyImplTest.java
new file mode 100644 (file)
index 0000000..d33ad09
--- /dev/null
@@ -0,0 +1,64 @@
+/*
+ * Copyright (c) 2014 NEC Corporation
+ * 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.vtn.manager.internal.cluster;
+
+import org.junit.Test;
+
+import org.opendaylight.vtn.manager.PathPolicy;
+import org.opendaylight.vtn.manager.PortLocation;
+import org.opendaylight.vtn.manager.VTNException;
+import org.opendaylight.vtn.manager.internal.TestBase;
+import org.opendaylight.vtn.manager.internal.VTNManagerImpl;
+import org.opendaylight.controller.sal.core.NodeConnector;
+
+/**
+ * JUnit test for {@link PathPolicyImpl}.
+ */
+
+public class PathPolicyImplTest extends TestBase {
+
+    /**
+     * Testing the methods in {@link PathPolicyImpl}.
+     */
+    @Test
+    public void testGetter() {
+        try {
+            for (int idx : INDEX_ARRAY) {
+                for (PathPolicy polcy : createPathPolicy()) {
+                    PathPolicyImpl policyImpl = new PathPolicyImpl(idx, polcy);
+
+                    assertNotNull(policyImpl.getPathPolicy());
+                    assertNotNull(policyImpl.getPolicyId());
+                    assertNotNull(policyImpl.hashCode());
+                    assertTrue(policyImpl.equals(policyImpl));
+                    assertFalse(policyImpl.equals(polcy));
+                    assertFalse(policyImpl.equals(null));
+
+                    for (PortLocation location : createPortLocation()) {
+                        for (long cost : COST) {
+                            policyImpl.setPathCost(location, cost);
+                            assertNotNull(policyImpl.getPathCost(location));
+                            assertNotNull(policyImpl.removePathCost(location));
+                        }
+                    }
+
+                    for (VTNManagerImpl impl : createVtnManagerImplobj()) {
+                        for (NodeConnector connector : createNodeConnectors(5)) {
+                            assertNotNull(policyImpl.getCost(impl, connector));
+                            assertNotNull(policyImpl.saveConfig(impl));
+                            policyImpl.destroy(impl);
+                        }
+                    }
+                }
+            }
+        } catch (VTNException | NullPointerException ex) {
+            //ex.printStackTrace();
+        }
+    }
+}
diff --git a/manager/implementation/src/test/java/org/opendaylight/vtn/manager/internal/cluster/VTenantPathMapImplTest.java b/manager/implementation/src/test/java/org/opendaylight/vtn/manager/internal/cluster/VTenantPathMapImplTest.java
new file mode 100644 (file)
index 0000000..62d1a63
--- /dev/null
@@ -0,0 +1,81 @@
+/*
+ * Copyright (c) 2014 NEC Corporation
+ * 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.vtn.manager.internal.cluster;
+
+import org.junit.Test;
+import org.opendaylight.vtn.manager.PathMap;
+import org.opendaylight.vtn.manager.internal.TestBase;
+
+/**
+ * JUnit test for {@link VTenantPathMapImpl}.
+ */
+public class VTenantPathMapImplTest extends TestBase{
+
+    /**
+     * Name of the VTenantImpl instance.
+     */
+    private static final String VTENANT_IMPL_INSTANCE_NAME = "VTenantName";
+
+    /**
+     * Name of the VTenantImpl-Container instance.
+     */
+    private static final String VTENANT_IMPL_CONTAINER_NAME = "default";
+
+    /**
+     * Name of the VTenantConfig Description.
+     */
+    private static final String VTENANT_CONFIG_DESC = "desc";
+
+    /**
+     * VTenantPathMapImpl-Logger prefix identifier.
+     */
+    private static final String LOGGER_PREFIX = ":" + VTENANT_IMPL_INSTANCE_NAME + ".";
+
+    /**
+     * Test method for
+     * {@link VTenantPathMapImpl#VTenantPathMapImpl(VTenantImpl, int, PathMap),
+     *  @link VTenantPathMapImpl#setVTenant(VTenantImpl),
+     *  @link VTenantPathMapImpl#getLogger(),
+     *  @link VTenantPathMapImpl#getLogPrefix()}.
+     */
+    @Test
+    public void testAllMethods() {
+        try {
+            // Checking for all the scenarios for the constructor in VTenantPathMapImpl.
+            // VTenantImpl List
+            for (VTenantImpl vTenantImpl : createVTenantImpl(VTENANT_CONFIG_DESC, VTENANT_IMPL_CONTAINER_NAME, VTENANT_IMPL_INSTANCE_NAME)) {
+                // VTenantPathMapImpl.index List
+                for (int idx : INDEX_ARRAY) {
+                    // VTenantPathMapImpl.PathMap List
+                    for (PathMap pathMap : createPathMapsWithIndex()) {
+                        try {
+                            VTenantPathMapImpl vTenantPathMapImpl = new VTenantPathMapImpl(vTenantImpl, idx, pathMap);
+                            vTenantPathMapImpl.setVTenant(vTenantImpl);
+
+                            assertNotNull(vTenantPathMapImpl.getLogger());
+                            assertEquals(vTenantPathMapImpl.getLogPrefix(), new String(LOGGER_PREFIX + idx));
+
+                            assertEquals(pathMap, vTenantPathMapImpl.getPathMap());
+                            assertEquals(idx, vTenantPathMapImpl.getIndex());
+                            assertNotNull(vTenantPathMapImpl.hashCode());
+
+                            assertTrue(vTenantPathMapImpl.equals(vTenantPathMapImpl));
+                            assertFalse(vTenantPathMapImpl.equals(pathMap));
+                        } catch (Exception ex) {
+                            //ex.printStackTrace();
+                        }
+                    }
+                }
+            }
+        } catch (Exception ex) {
+            //ex.printStackTrace();
+        }
+    }
+}