--- /dev/null
+package org.opendaylight.nemo.renderer.openflow;
+
+import junit.framework.TestCase;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.Assert;
+import org.opendaylight.nemo.renderer.openflow.FlowTableManager;
+import org.opendaylight.controller.md.sal.binding.api.DataBroker;
+import org.opendaylight.nemo.renderer.openflow.ResourceManager;
+import org.opendaylight.nemo.renderer.openflow.entity.ResourceBean;
+
+import static org.junit.Assert.*;
+import static org.mockito.Mockito.*;
+/**
+ * Created by zhangmeng on 2015/11/11.
+ */
+public class FlowTableManagerTest extends TestCase {
+ private FlowTableManager flowTableManager;
+ private ResourceManager resourceManager;
+ private DataBroker dataProvider;
+ @Before
+ public void setUp() throws Exception {
+ resourceManager = mock(ResourceManager.class);
+ dataProvider = mock(DataBroker.class);
+
+ flowTableManager = new FlowTableManager(dataProvider,resourceManager);
+ }
+
+ @Test
+ public void testClose() throws Exception {
+ flowTableManager.close();
+ Assert.assertNotNull(flowTableManager);
+ }
+}
\ No newline at end of file
--- /dev/null
+package org.opendaylight.nemo.renderer.openflow;
+
+import junit.framework.TestCase;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+import org.opendaylight.nemo.renderer.openflow.FlowUtils;
+import org.opendaylight.controller.md.sal.binding.api.DataBroker;
+import org.opendaylight.controller.md.sal.binding.api.WriteTransaction;
+import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.IpAddress;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.IpPrefix;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Ipv4Prefix;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev100924.MacAddress;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.*;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.dec.mpls.ttl._case.DecMplsTtl;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.dec.mpls.ttl._case.DecMplsTtlBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.dec.nw.ttl._case.DecNwTtl;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.dec.nw.ttl._case.DecNwTtlBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.output.action._case.OutputAction;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.output.action._case.OutputActionBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.pop.mpls.action._case.PopMplsAction;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.pop.mpls.action._case.PopMplsActionBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.push.mpls.action._case.PushMplsAction;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.push.mpls.action._case.PushMplsActionBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.set.field._case.SetField;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.set.field._case.SetFieldBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.Action;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.ActionBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNode;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowId;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.meters.Meter;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.meters.MeterBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.meters.MeterKey;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.Table;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.TableKey;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.Flow;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.FlowBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.FlowKey;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.Instructions;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.InstructionsBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.Match;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.MatchBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.instruction.*;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.instruction.apply.actions._case.ApplyActions;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.instruction.apply.actions._case.ApplyActionsBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.instruction.go.to.table._case.GoToTable;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.instruction.go.to.table._case.GoToTableBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.instruction.write.metadata._case.WriteMetadata;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.instruction.write.metadata._case.WriteMetadataBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.list.Instruction;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.list.InstructionBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.*;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.node.NodeConnector;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.node.NodeConnectorKey;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.NodeKey;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.l2.types.rev130827.EtherType;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.BandId;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.MeterBandType;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.MeterFlags;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.MeterId;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.band.type.band.type.Drop;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.band.type.band.type.DropBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.meter.MeterBandHeadersBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.meter.meter.band.headers.MeterBandHeader;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.meter.meter.band.headers.MeterBandHeaderBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.meter.meter.band.headers.MeterBandHeaderKey;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.meter.meter.band.headers.meter.band.header.MeterBandTypesBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.ethernet.match.fields.EthernetDestinationBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.ethernet.match.fields.EthernetSourceBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.ethernet.match.fields.EthernetTypeBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.*;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._3.match.Ipv4Match;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._3.match.Ipv4MatchBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.generic.physical.network.rev151010.PhysicalNetwork;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.generic.physical.network.rev151010.physical.network.PhysicalLinks;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.generic.physical.network.rev151010.physical.network.PhysicalPaths;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.generic.physical.network.rev151010.physical.network.physical.links.PhysicalLink;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.generic.physical.network.rev151010.physical.network.physical.nodes.PhysicalNode;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.generic.physical.network.rev151010.physical.network.physical.paths.PhysicalPath;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.generic.physical.network.rev151010.physical.network.physical.paths.PhysicalPathBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.generic.physical.network.rev151010.physical.node.instance.PhysicalPort;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.generic.virtual.network.rev151010.virtual.networks.VirtualNetwork;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.generic.virtual.network.rev151010.virtual.networks.virtual.network.virtual.arps.VirtualArp;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.generic.virtual.network.rev151010.virtual.networks.virtual.network.virtual.arps.VirtualArpKey;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.generic.virtual.network.rev151010.virtual.networks.virtual.network.virtual.links.VirtualLink;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.generic.virtual.network.rev151010.virtual.networks.virtual.network.virtual.nodes.VirtualNode;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.generic.virtual.network.rev151010.virtual.networks.virtual.network.virtual.paths.VirtualPath;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.generic.virtual.network.rev151010.virtual.node.instance.VirtualPort;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.intent.mapping.result.rev151010.intent.vn.mapping.results.UserIntentVnMapping;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.intent.mapping.result.rev151010.intent.vn.mapping.results.user.intent.vn.mapping.IntentVnMappingResult;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.intent.mapping.result.rev151010.intent.vn.mapping.results.user.intent.vn.mapping.intent.vn.mapping.result.VirtualResource;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.intent.mapping.result.rev151010.vn.pn.mapping.results.UserVnPnMapping;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.intent.mapping.result.rev151010.vn.pn.mapping.results.user.vn.pn.mapping.VnPnMappingResult;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.nemo.common.rev151010.IntentId;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.nemo.common.rev151010.MatchItemName;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.nemo.common.rev151010.UserId;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.nemo.engine.common.rev151010.*;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.nemo.intent.rev151010.user.intent.operations.Operation;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.nemo.intent.rev151010.users.User;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.nemo.object.rev151010.flow.instance.MatchItem;
+import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.ArrayList;
+import java.util.List;
+
+import static org.junit.Assert.*;
+import static org.mockito.Mockito.*;
+/**
+ * Created by zhangmeng on 2015/11/11.
+ */
+public class FlowUtilsTest extends TestCase {
+ private FlowUtils flowUtils;
+ @Before
+ public void setUp() throws Exception {
+ flowUtils = mock(FlowUtils.class);
+
+ }
+
+ @Test
+ public void testInit() throws Exception {
+ List<PhysicalNode> physicalNodes = new ArrayList<PhysicalNode>();
+
+ flowUtils.init(physicalNodes);
+ verify(flowUtils).init(any(List.class));
+ Assert.assertNotNull(flowUtils);
+ }
+
+ @Test
+ public void testUpdateFlowTable() throws Exception {
+ User user = mock(User.class);
+ VirtualNetwork virtualNetwork = mock(VirtualNetwork.class);
+ UserIntentVnMapping userIntentVnMapping = mock(UserIntentVnMapping.class);
+ UserVnPnMapping userVnPnMapping = mock(UserVnPnMapping.class);
+ PhysicalNetwork physicalNetwor = mock(PhysicalNetwork.class);
+
+ flowUtils.updateFlowTable(user,virtualNetwork,userIntentVnMapping,userVnPnMapping,physicalNetwor);
+ verify(flowUtils).updateFlowTable(
+ any(User.class),
+ any(VirtualNetwork.class),
+ any(UserIntentVnMapping.class),
+ any(UserVnPnMapping.class),
+ any(PhysicalNetwork.class));
+ Assert.assertNotNull(flowUtils);
+ }
+
+ @Test
+ public void testDeleteFlowEntries() throws Exception {
+ UserId userId = mock(UserId.class);
+
+ flowUtils.deleteFlowEntries(userId);
+ verify(flowUtils).deleteFlowEntries(any(UserId.class));
+ Assert.assertNotNull(flowUtils);
+ }
+
+ @Test
+ public void testClose() throws Exception {
+ flowUtils.close();
+ verify(flowUtils).close();
+ Assert.assertNotNull(flowUtils);
+ }
+
+ @Test
+ public void testAssignMPLSLabelForPPath() throws Exception {
+ PhysicalPath physicalPath = mock(PhysicalPath.class);
+ List<org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.generic.physical.network.rev151010.physical.network.physical.links.PhysicalLink> physicalLinksList
+ = new ArrayList<org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.generic.physical.network.rev151010.physical.network.physical.links.PhysicalLink>();
+
+ flowUtils.assignMPLSLabelForPPath(physicalPath, physicalLinksList);
+ verify(flowUtils).assignMPLSLabelForPPath(
+ any(PhysicalPath.class),
+ any(List.class));
+ Assert.assertNotNull(flowUtils);
+ }
+}
\ No newline at end of file
--- /dev/null
+package org.opendaylight.nemo.renderer.openflow;
+
+import junit.framework.TestCase;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.Assert;
+import static org.junit.Assert.*;
+import org.opendaylight.controller.md.sal.binding.api.DataBroker;
+import org.opendaylight.controller.md.sal.binding.api.WriteTransaction;
+import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
+import org.opendaylight.nemo.renderer.openflow.FlowTableManager;
+import org.opendaylight.nemo.renderer.openflow.OpenflowRenderer;
+import org.opendaylight.nemo.renderer.openflow.ResourceManager;
+import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import com.google.common.util.concurrent.FutureCallback;
+import com.google.common.util.concurrent.Futures;
+import static org.mockito.Mockito.*;
+/**
+ * Created by zhangmeng on 2015/11/11.
+ */
+public class OpenflowRendererTest extends TestCase {
+ private OpenflowRenderer openflowRenderer;
+ private DataBroker dataBroker;
+ private ResourceManager resourceManager;
+ private FlowTableManager flowTableMng;
+ @Before
+ public void setUp() throws Exception {
+ dataBroker = mock(DataBroker.class);
+ openflowRenderer = new OpenflowRenderer(dataBroker);
+ }
+
+ @Test
+ public void testClose() throws Exception {
+ openflowRenderer.close();
+ Assert.assertNotNull(openflowRenderer);
+ }
+}
\ No newline at end of file
--- /dev/null
+package org.opendaylight.nemo.renderer.openflow;\r
+import junit.framework.TestCase;\r
+import org.junit.Assert;\r
+import org.junit.Before;\r
+import org.junit.Test;\r
+import org.opendaylight.nemo.renderer.openflow.ResourceManager;\r
+import com.google.common.collect.HashBasedTable;\r
+import com.google.common.collect.Table;\r
+import static org.junit.Assert.*;\r
+import static org.mockito.Mockito.*;\r
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.IpAddress;\r
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Ipv4Address;\r
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev100924.MacAddress;\r
+\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.generic.physical.network.rev151010.PhysicalNetworkBuilder;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.generic.physical.network.rev151010.PhysicalNetwork;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.generic.physical.network.rev151010.PhysicalNodeInstance;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.generic.physical.network.rev151010.PhysicalPortInstance;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.generic.physical.network.rev151010.attribute.instance.AttributeValue;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.generic.physical.network.rev151010.attribute.instance.AttributeValueBuilder;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.generic.physical.network.rev151010.physical.network.physical.nodes.PhysicalNode;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.generic.physical.network.rev151010.physical.network.physical.nodes.PhysicalNodeBuilder;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.generic.physical.network.rev151010.physical.network.physical.nodes.PhysicalNodeKey;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.generic.physical.network.rev151010.physical.network.physical.links.PhysicalLink;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.generic.physical.network.rev151010.physical.network.physical.links.PhysicalLinkBuilder;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.generic.physical.network.rev151010.physical.network.physical.links.PhysicalLinkKey;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.generic.physical.network.rev151010.physical.node.instance.PhysicalPort;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.generic.physical.network.rev151010.physical.node.instance.PhysicalPortBuilder;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.generic.physical.network.rev151010.physical.node.instance.PhysicalPortKey;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.generic.physical.network.rev151010.physical.port.instance.Attribute;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.generic.physical.network.rev151010.physical.port.instance.AttributeBuilder;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.generic.physical.network.rev151010.physical.port.instance.AttributeKey;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.nemo.engine.common.rev151010.AttributeName;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.nemo.engine.common.rev151010.PhysicalNodeId;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.nemo.engine.common.rev151010.PhysicalPortId;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.nemo.engine.common.rev151010.PhysicalLinkId;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.nemo.engine.common.rev151010.PhysicalHostId;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.nemo.engine.common.rev151010.PhysicalHostName;\r
+\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.generic.physical.network.rev151010.physical.network.physical.hosts.PhysicalHostBuilder;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.generic.physical.network.rev151010.physical.network.physical.hosts.PhysicalHostKey;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.generic.physical.network.rev151010.physical.network.physical.hosts.PhysicalHost;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.generic.physical.network.rev151010.physical.host.instance.IpAddresses;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.generic.physical.network.rev151010.physical.host.instance.IpAddressesBuilder;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.generic.physical.network.rev151010.physical.network.PhysicalNodes;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.generic.physical.network.rev151010.physical.network.PhysicalLinks;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.generic.physical.network.rev151010.physical.network.PhysicalHosts;\r
+/**\r
+ * Created by zhangmeng on 2015/11/11.\r
+ */\r
+public class ResourceManagerTest extends TestCase {\r
+ private ResourceManager resourceManager;\r
+ private Table<PhysicalNodeId, PhysicalPortId, MacAddress> externalNetworkMacTable;\r
+ @Before\r
+ public void setUp() throws Exception {\r
+ resourceManager = mock(ResourceManager.class);\r
+ externalNetworkMacTable = HashBasedTable.create();\r
+ }\r
+\r
+ @Test\r
+ public void testGetExternalNetworkMacTable() throws Exception {\r
+ resourceManager.getExternalNetworkMacTable();\r
+ when(resourceManager.getExternalNetworkMacTable()).thenReturn(externalNetworkMacTable);\r
+ Assert.assertEquals(HashBasedTable.create(),resourceManager.getExternalNetworkMacTable());\r
+ }\r
+\r
+ @Test\r
+ public void testClose() throws Exception {\r
+ resourceManager.close();\r
+ verify(resourceManager).close();\r
+ }\r
+}
\ No newline at end of file
--- /dev/null
+package org.opendaylight.nemo.renderer.openflow.entity;
+
+import junit.framework.TestCase;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+import org.opendaylight.nemo.renderer.openflow.entity.HostBean;
+import java.util.LinkedList;
+import static org.mockito.Mockito.*;
+import java.util.List;
+
+import static org.junit.Assert.*;
+
+/**
+ * Created by zhangmeng on 2015/11/8.
+ */
+public class HostBeanTest extends TestCase {
+
+ private HostBean hostBean;
+ private String hostName;
+ private List<String> IPAddressList;
+ private String macAddress;
+ private String nodeID;
+ private String connectorID;
+ @Before
+ public void setUp() throws Exception {
+ hostBean = new HostBean();
+ hostName = null;
+ IPAddressList = new LinkedList<String>();
+ macAddress = null;
+ nodeID = null;
+ connectorID = null;
+ }
+
+ @Test
+ public void testGetHostName() throws Exception {
+ Assert.assertNull(hostBean.getHostName());
+ hostName = "test";
+ hostBean.setHostName(hostName);
+ Assert.assertEquals("test",hostBean.getHostName());
+ hostName = null;
+ }
+
+ @Test
+ public void testSetHostName() throws Exception {
+ Assert.assertNull(hostBean.getHostName());
+ hostName = "test";
+ hostBean.setHostName(hostName);
+ Assert.assertEquals("test",hostBean.getHostName());
+ }
+
+ @Test
+ public void testGetIPAddressList() throws Exception {
+ Assert.assertNull(hostBean.getIPAddressList());
+ IPAddressList.add("test");
+ hostBean.setStringList(IPAddressList);
+ Assert.assertNotNull(hostBean.getIPAddressList());
+ IPAddressList.clear();
+ }
+
+ @Test
+ public void testSetStringList() throws Exception {
+ Assert.assertNull(hostBean.getIPAddressList());
+ IPAddressList.add("test");
+ hostBean.setStringList(IPAddressList);
+ Assert.assertNotNull(hostBean.getIPAddressList());
+ }
+
+ @Test
+ public void testGetMacAddress() throws Exception {
+ Assert.assertNull(hostBean.getMacAddress());
+ macAddress = "test";
+ hostBean.setMacAddress(macAddress);
+ Assert.assertEquals("test",hostBean.getMacAddress());
+ macAddress = null;
+ }
+
+ @Test
+ public void testSetMacAddress() throws Exception {
+ Assert.assertNull(hostBean.getMacAddress());
+ macAddress = "test";
+ hostBean.setMacAddress(macAddress);
+ Assert.assertEquals("test",hostBean.getMacAddress());
+ }
+
+ @Test
+ public void testGetNodeID() throws Exception {
+ Assert.assertNull(hostBean.getNodeID());
+ nodeID = "test";
+ hostBean.setNodeID(nodeID);
+ Assert.assertEquals("test",hostBean.getNodeID());
+ nodeID = null;
+ }
+
+ @Test
+ public void testSetNodeID() throws Exception {
+ Assert.assertNull(hostBean.getNodeID());
+ nodeID = "test";
+ hostBean.setNodeID(nodeID);
+ Assert.assertEquals("test",hostBean.getNodeID());
+ }
+
+ @Test
+ public void testGetConnectorID() throws Exception {
+ Assert.assertNull(hostBean.getConnectorID());
+ connectorID = "test";
+ hostBean.setConnectorID(connectorID);
+ Assert.assertEquals("test",hostBean.getConnectorID());
+ connectorID = null;
+ }
+
+ @Test
+ public void testSetConnectorID() throws Exception {
+ Assert.assertNull(hostBean.getConnectorID());
+ connectorID = "test";
+ hostBean.setConnectorID(connectorID);
+ Assert.assertEquals("test",hostBean.getConnectorID());
+ }
+}
\ No newline at end of file
--- /dev/null
+package org.opendaylight.nemo.renderer.openflow.entity;
+
+import junit.framework.TestCase;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.*;
+import java.util.LinkedList;
+import org.opendaylight.nemo.renderer.openflow.entity.LinkBean;
+import static org.mockito.Mockito.*;
+
+import static org.junit.Assert.*;
+
+/**
+ * Created by zhangmeng on 2015/11/8.
+ */
+public class LinkBeanTest extends TestCase {
+ private LinkBean linkBean;
+
+ private String linkID;
+ private String leftNodeID;
+ private String leftPortID;
+ private String rightPortID;
+ private String rightNodeID;
+ private String linkBandwidth;
+
+ @Before
+ public void setUp() throws Exception {
+ linkBean = new LinkBean();
+ linkID = leftNodeID = leftPortID = rightPortID = rightNodeID = linkBandwidth = null;
+ }
+
+ @Test
+ public void testGetLinkID() throws Exception {
+ Assert.assertNull(linkBean.getLinkID());
+ linkID = "test";
+ linkBean.setLinkID(linkID);
+ Assert.assertEquals(linkID,linkBean.getLinkID());
+ linkID = null;
+ }
+
+ @Test
+ public void testSetLinkID() throws Exception {
+ Assert.assertNull(linkBean.getLinkID());
+ linkID = "test";
+ linkBean.setLinkID(linkID);
+ Assert.assertEquals(linkID,linkBean.getLinkID());
+ }
+
+ @Test
+ public void testGetLeftNodeID() throws Exception {
+ Assert.assertNull(linkBean.getLeftNodeID());
+ leftNodeID = "test";
+ linkBean.setLeftNodeID(leftNodeID);
+ Assert.assertEquals(leftNodeID,linkBean.getLeftNodeID());
+ leftNodeID = null;
+ }
+
+ @Test
+ public void testSetLeftNodeID() throws Exception {
+ Assert.assertNull(linkBean.getLeftNodeID());
+ leftNodeID = "test";
+ linkBean.setLeftNodeID(leftNodeID);
+ Assert.assertEquals(leftNodeID,linkBean.getLeftNodeID());
+ }
+
+ @Test
+ public void testGetLeftPortID() throws Exception {
+ Assert.assertNull(linkBean.getLeftPortID());
+ leftPortID = "test";
+ linkBean.setLeftPortID(leftPortID);
+ Assert.assertEquals(leftPortID,linkBean.getLeftPortID());
+ leftPortID = null;
+ }
+
+ @Test
+ public void testSetLeftPortID() throws Exception {
+ Assert.assertNull(linkBean.getLeftPortID());
+ leftPortID = "test";
+ linkBean.setLeftPortID(leftPortID);
+ Assert.assertEquals(leftPortID,linkBean.getLeftPortID());
+ }
+
+ @Test
+ public void testGetRightNodeID() throws Exception {
+ Assert.assertNull(linkBean.getRightNodeID());
+ rightNodeID = "test";
+ linkBean.setRightNodeID(rightNodeID);
+ Assert.assertEquals(rightNodeID,linkBean.getRightNodeID());
+ rightNodeID = null;
+ }
+
+ @Test
+ public void testSetRightNodeID() throws Exception {
+ Assert.assertNull(linkBean.getRightNodeID());
+ rightNodeID = "test";
+ linkBean.setRightNodeID(rightNodeID);
+ Assert.assertEquals(rightNodeID,linkBean.getRightNodeID());
+ }
+
+ @Test
+ public void testGetRightPortID() throws Exception {
+ Assert.assertNull(linkBean.getRightPortID());
+ rightPortID = "test";
+ linkBean.setRightPortID(rightPortID);
+ Assert.assertEquals(rightPortID,linkBean.getRightPortID());
+ rightPortID = null;
+ }
+
+ @Test
+ public void testSetRightPortID() throws Exception {
+ Assert.assertNull(linkBean.getRightPortID());
+ rightPortID = "test";
+ linkBean.setRightPortID(rightPortID);
+ Assert.assertEquals(rightPortID,linkBean.getRightPortID());
+ }
+
+ @Test
+ public void testGetLinkBandwidth() throws Exception {
+ Assert.assertNull(linkBean.getLinkBandwidth());
+ linkBandwidth = "test";
+ linkBean.setLinkBandwidth(linkBandwidth);
+ Assert.assertEquals(linkBandwidth,linkBean.getLinkBandwidth());
+ linkBandwidth = null;
+ }
+
+ @Test
+ public void testSetLinkBandwidth() throws Exception {
+ Assert.assertNull(linkBean.getLinkBandwidth());
+ linkBandwidth = "test";
+ linkBean.setLinkBandwidth(linkBandwidth);
+ Assert.assertEquals(linkBandwidth,linkBean.getLinkBandwidth());
+ }
+}
\ No newline at end of file
--- /dev/null
+package org.opendaylight.nemo.renderer.openflow.entity;
+
+import junit.framework.TestCase;
+import org.junit.Before;
+import org.junit.Test;
+import org.opendaylight.nemo.renderer.openflow.entity.NodeBean;
+import org.opendaylight.nemo.renderer.openflow.entity.PortBean;
+import org.junit.*;
+import java.util.LinkedList;
+import java.util.List;
+
+import static org.junit.Assert.*;
+import static org.mockito.Mockito.*;
+
+/**
+ * Created by zhangmeng on 2015/11/8.
+ */
+public class NodeBeanTest extends TestCase {
+
+ private NodeBean nodeBean;
+ private String nodeID;
+ private String nodeType;
+ private String nodeCapacity;
+ private List<PortBean> portList;
+ @Before
+ public void setUp() throws Exception {
+ nodeBean = new NodeBean();
+ nodeID = nodeType = nodeCapacity = null;
+ portList = new LinkedList<PortBean>();
+ }
+
+ @Test
+ public void testGetNodeID() throws Exception {
+ Assert.assertNull(nodeBean.getNodeID());
+ nodeID = "test";
+ nodeBean.setNodeID(nodeID);
+ Assert.assertEquals(nodeID,nodeBean.getNodeID());
+ nodeID = null;
+ }
+
+ @Test
+ public void testSetNodeID() throws Exception {
+ Assert.assertNull(nodeBean.getNodeID());
+ nodeID = "test";
+ nodeBean.setNodeID(nodeID);
+ Assert.assertEquals(nodeID,nodeBean.getNodeID());
+ }
+
+ @Test
+ public void testGetNodeType() throws Exception {
+ Assert.assertNull(nodeBean.getNodeType());
+ nodeType = "test";
+ nodeBean.setNodeType(nodeType);
+ Assert.assertEquals(nodeType,nodeBean.getNodeType());
+ nodeType = null;
+ }
+
+ @Test
+ public void testSetNodeType() throws Exception {
+ Assert.assertNull(nodeBean.getNodeType());
+ nodeType = "test";
+ nodeBean.setNodeType(nodeType);
+ Assert.assertEquals(nodeType,nodeBean.getNodeType());
+ }
+
+ @Test
+ public void testGetNodeCapacity() throws Exception {
+ Assert.assertNull(nodeBean.getNodeCapacity());
+ nodeCapacity = "test";
+ nodeBean.setNodeCapacity(nodeCapacity);
+ Assert.assertEquals(nodeCapacity,nodeBean.getNodeCapacity());
+ nodeCapacity = null;
+ }
+
+ @Test
+ public void testSetNodeCapacity() throws Exception {
+ Assert.assertNull(nodeBean.getNodeCapacity());
+ nodeCapacity = "test";
+ nodeBean.setNodeCapacity(nodeCapacity);
+ Assert.assertEquals(nodeCapacity,nodeBean.getNodeCapacity());
+ }
+
+ @Test
+ public void testGetPortList() throws Exception {
+ Assert.assertNull(nodeBean.getPortList());
+ portList.add(new PortBean());
+ nodeBean.setPortList(portList);
+ Assert.assertNotNull(nodeBean.getPortList());
+ portList.clear();
+ }
+
+ @Test
+ public void testSetPortList() throws Exception {
+ Assert.assertNull(nodeBean.getPortList());
+ portList.add(new PortBean());
+ nodeBean.setPortList(portList);
+ Assert.assertNotNull(nodeBean.getPortList());
+ }
+}
\ No newline at end of file
--- /dev/null
+package org.opendaylight.nemo.renderer.openflow.entity;
+
+import junit.framework.TestCase;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.*;
+import org.opendaylight.nemo.renderer.openflow.entity.PortBean;
+import java.util.LinkedList;
+
+import static org.junit.Assert.*;
+import static org.mockito.Mockito.*;
+
+/**
+ * Created by zhangmeng on 2015/11/8.
+ */
+public class PortBeanTest extends TestCase {
+ private PortBean portBean;
+ private String portID;
+ private String portIPAddress;
+ private String mask;
+ private String location;
+ private String bandwidth;
+ @Before
+ public void setUp() throws Exception {
+ portBean = new PortBean();
+ portID = portIPAddress = mask = location = bandwidth = null;
+ }
+
+ @Test
+ public void testGetPortID() throws Exception {
+ Assert.assertNull(portBean.getPortID());
+ portID = "test";
+ portBean.setPortID(portID);
+ Assert.assertEquals(portID,portBean.getPortID());
+ portID = null;
+ }
+
+ @Test
+ public void testSetPortID() throws Exception {
+ Assert.assertNull(portBean.getPortID());
+ portID = "test";
+ portBean.setPortID(portID);
+ Assert.assertEquals(portID,portBean.getPortID());
+ }
+
+ @Test
+ public void testGetPortIPAddress() throws Exception {
+ Assert.assertNull(portBean.getPortIPAddress());
+ portIPAddress = "test";
+ portBean.setPortIPAddress(portIPAddress);
+ Assert.assertEquals(portIPAddress,portBean.getPortIPAddress());
+ portIPAddress = null;
+ }
+
+ @Test
+ public void testSetPortIPAddress() throws Exception {
+ Assert.assertNull(portBean.getPortIPAddress());
+ portIPAddress = "test";
+ portBean.setPortIPAddress(portIPAddress);
+ Assert.assertEquals(portIPAddress,portBean.getPortIPAddress());
+ }
+
+ @Test
+ public void testGetMask() throws Exception {
+ Assert.assertNull(portBean.getMask());
+ mask = "test";
+ portBean.setMask(mask);
+ Assert.assertEquals(mask,portBean.getMask());
+ mask = null;
+ }
+
+ @Test
+ public void testSetMask() throws Exception {
+ Assert.assertNull(portBean.getMask());
+ mask = "test";
+ portBean.setMask(mask);
+ Assert.assertEquals(mask,portBean.getMask());
+ }
+
+ @Test
+ public void testGetLocation() throws Exception {
+ Assert.assertNull(portBean.getLocation());
+ location = "test";
+ portBean.setLocation(location);
+ Assert.assertEquals(location,portBean.getLocation());
+ location = null;
+ }
+
+ @Test
+ public void testSetLocation() throws Exception {
+ Assert.assertNull(portBean.getLocation());
+ location = "test";
+ portBean.setLocation(location);
+ Assert.assertEquals(location,portBean.getLocation());
+ }
+
+ @Test
+ public void testGetBandwidth() throws Exception {
+ Assert.assertNull(portBean.getBandwidth());
+ bandwidth = "test";
+ portBean.setBandwidth(bandwidth);
+ Assert.assertEquals(bandwidth,portBean.getBandwidth());
+ bandwidth = null;
+ }
+
+ @Test
+ public void testSetBandwidth() throws Exception {
+ Assert.assertNull(portBean.getBandwidth());
+ bandwidth = "test";
+ portBean.setBandwidth(bandwidth);
+ Assert.assertEquals(bandwidth,portBean.getBandwidth());
+ }
+}
\ No newline at end of file
--- /dev/null
+package org.opendaylight.nemo.renderer.openflow.entity;
+
+import junit.framework.TestCase;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+import org.opendaylight.nemo.renderer.openflow.entity.HostBean;
+import org.opendaylight.nemo.renderer.openflow.entity.LinkBean;
+import org.opendaylight.nemo.renderer.openflow.entity.NodeBean;
+import org.opendaylight.nemo.renderer.openflow.entity.ResourceBean;
+import java.util.LinkedList;
+
+import java.util.List;
+
+import static org.junit.Assert.*;
+
+import static org.mockito.Mockito.*;
+import static org.junit.Assert.*;
+/**
+ * Created by zhangmeng on 2015/11/8.
+ */
+public class ResourceBeanTest extends TestCase {
+
+ private ResourceBean resourceBean;
+ private List<NodeBean> nodelist;
+ private List<LinkBean> linklist;
+ private List<HostBean> hostlist;
+
+ @Before
+ public void setUp() throws Exception {
+ resourceBean = new ResourceBean();
+ nodelist = new LinkedList<NodeBean>();
+ linklist = new LinkedList<LinkBean>();
+ hostlist = new LinkedList<HostBean>();
+ }
+
+ @Test
+ public void testGetNodelist() throws Exception {
+ Assert.assertNull(resourceBean.getNodelist());
+ nodelist.add(new NodeBean());
+ resourceBean.setNodelist(nodelist);
+ Assert.assertNotNull(resourceBean.getNodelist());
+ nodelist.clear();
+ }
+
+ @Test
+ public void testSetNodelist() throws Exception {
+ Assert.assertNull(resourceBean.getNodelist());
+ nodelist.add(new NodeBean());
+ resourceBean.setNodelist(nodelist);
+ Assert.assertNotNull(resourceBean.getNodelist());
+ }
+
+ @Test
+ public void testGetLinklist() throws Exception {
+ Assert.assertNull(resourceBean.getLinklist());
+ linklist.add(new LinkBean());
+ resourceBean.setLinklist(linklist);
+ Assert.assertNotNull(resourceBean.getLinklist());
+ linklist.clear();
+ }
+
+ @Test
+ public void testSetLinklist() throws Exception {
+ Assert.assertNull(resourceBean.getLinklist());
+ linklist.add(new LinkBean());
+ resourceBean.setLinklist(linklist);
+ Assert.assertNotNull(resourceBean.getLinklist());
+ }
+
+ @Test
+ public void testGetHostlist() throws Exception {
+ Assert.assertNull(resourceBean.getHostlist());
+ hostlist.add(new HostBean());
+ resourceBean.setHostlist(hostlist);
+ Assert.assertNotNull(resourceBean.getHostlist());
+ hostlist.clear();
+ }
+
+ @Test
+ public void testSetHostlist() throws Exception {
+ Assert.assertNull(resourceBean.getHostlist());
+ hostlist.add(new HostBean());
+ resourceBean.setHostlist(hostlist);
+ Assert.assertNotNull(resourceBean.getHostlist());
+ }
+}
\ No newline at end of file