--- /dev/null
+/*
+ * 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();
+ }
+ }
+}
--- /dev/null
+/*
+ * 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();
+ }
+ }
+}
--- /dev/null
+/*
+ * 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();
+ }
+ }
+}
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;
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;
/**
* 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};
/**
*/
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.
*
}
}
}
+
/**
- * VtnmanagerImpl object creation
- * @return VtnmanagerImplList
- */
+ * VtnmanagerImpl object creation
+ * @return VtnmanagerImplList
+ */
public List<VTNManagerImpl> createVtnManagerImplobj() {
List<VTNManagerImpl> vtnMangerList = new ArrayList<VTNManagerImpl>();
try {
}
}
-
/**
* Common Method to create UpdateTye.
* @return UpdateType list.
}
}
- /*
- *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;
}
}
+ /**
+ * 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)
--- /dev/null
+/*
+ * 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();
+ }
+ }
+ }
+ }
+}
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();
+ }
}
}
}
--- /dev/null
+/*
+ * 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();
+ }
+ }
+}
*
* 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;
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.
try {
PathPolicyEvent.raise(mgr, idx, updateTye);
} catch (NullPointerException ex) {
- ex.printStackTrace();
+ //ex.printStackTrace();
}
}
}
--- /dev/null
+/*
+ * 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();
+ }
+ }
+}
--- /dev/null
+/*
+ * 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();
+ }
+ }
+}