import com.google.common.collect.Lists;
import java.math.BigInteger;
import junit.framework.TestCase;
-import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.runners.MockitoJUnitRunner;
import org.opendaylight.openflowplugin.api.OFConstants;
-import org.opendaylight.openflowplugin.openflow.md.util.OpenflowPortsUtil;
import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeConnectorRef;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PacketInReason;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortNumber;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.PacketIn;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.PacketInMessageBuilder;
-/**
- * Created by Tomas Slusny on 24.3.2016.
- */
@RunWith(MockitoJUnitRunner.class)
public class NodeConnectorRefToPortTranslatorTest extends TestCase {
- static final String PACKET_DATA = "Test_Data";
- static final Long PORT_NO = 5l;
- static final Long SECOND_PORT_NO = 6l;
- static final BigInteger DATA_PATH_ID = BigInteger.TEN;
- static final short OF_VERSION = OFConstants.OFP_VERSION_1_3;
- static final String ID_VALUE = "openflow:" + DATA_PATH_ID;
- static final Long TABLE_ID = 42L;
+ private static final String PACKET_DATA = "Test_Data";
+ private static final Long PORT_NO = 5L;
+ private static final BigInteger DATA_PATH_ID = BigInteger.TEN;
+ private static final short OF_VERSION = OFConstants.OFP_VERSION_1_3;
+ private static final Long TABLE_ID = 42L;
private static PacketIn createPacketIn(long portNo) {
InPortBuilder inPortBuilder = new InPortBuilder()
.build();
}
- @Before
- public void setUp() throws Exception {
- // Initialize the OpenFlow version/port map
- OpenflowPortsUtil.init();
- }
-
- @Test(expected = NullPointerException.class)
- public void testForNotNullablePacketInInGetPortNo() throws Exception {
- NodeConnectorRefToPortTranslator.getPortNoFromPacketIn(null);
- }
-
- @Test(expected = NullPointerException.class)
- public void testForNotNullablePacketInInToNodeConnectorRef() throws Exception {
- NodeConnectorRefToPortTranslator.toNodeConnectorRef(null, DATA_PATH_ID);
- }
-
- @Test(expected = NullPointerException.class)
- public void testForNotNullableNodeConnectorRefInFromNodeConnectorRef() throws Exception {
- NodeConnectorRefToPortTranslator.fromNodeConnectorRef(null, OF_VERSION);
- }
-
@Test
- public void testGetPortNoFromPacketIn() throws Exception {
+ public void testGetPortNoFromPacketIn() {
PacketIn packetIn = createPacketIn(PORT_NO);
Long portNo = NodeConnectorRefToPortTranslator.getPortNoFromPacketIn(packetIn);
assertEquals(portNo, PORT_NO);
}
@Test
- public void testNodeConnectorConversion() throws Exception {
+ public void testNodeConnectorConversion() {
// Mock the packet in message
PacketIn packetIn = createPacketIn(PORT_NO);