1 package org.openflow.codec.protocol.instruction;
3 import junit.framework.TestCase;
5 import org.openflow.codec.io.DataBuffers;
6 import org.openflow.codec.io.IDataBuffer;
7 import org.openflow.codec.protocol.instruction.OFPInstructionGoToTable;
8 import org.openflow.codec.protocol.instruction.OFPInstructionType;
11 * test class to verify instruction structure
16 public class OFPInstructionGoToTableTest extends TestCase {
18 private IDataBuffer buffer = DataBuffers.allocate(1024);
20 protected void tearDown() throws Exception {
24 public void testOFInstructionGoToTableCreation() {
25 OFPInstructionGoToTable instruction = new OFPInstructionGoToTable();
26 assertTrue(instruction.type.equals(OFPInstructionType.GOTO_TABLE));
30 public void testClone() throws CloneNotSupportedException {
31 OFPInstructionGoToTable instruction = new OFPInstructionGoToTable();
32 instruction.setTableId((byte) 2);
33 OFPInstructionGoToTable instructionCloned = (OFPInstructionGoToTable) instruction.clone();
34 TestCase.assertEquals(instruction, instructionCloned);
36 instruction.setTableId((byte) 1);
37 TestCase.assertNotSame(instruction, instructionCloned);
39 instruction = (OFPInstructionGoToTable) instructionCloned.clone();
40 TestCase.assertEquals(instruction, instructionCloned);
43 public void testReadWriteSuccess() {
44 OFPInstructionGoToTable instruction = new OFPInstructionGoToTable();
45 instruction.setTableId((byte) 2);
46 instruction.writeTo(buffer);
49 OFPInstructionGoToTable instructionTemp = new OFPInstructionGoToTable();
50 instructionTemp.readFrom(buffer);
51 TestCase.assertEquals(instruction, instructionTemp);
55 public void testToString() {
56 OFPInstructionGoToTable instruction = new OFPInstructionGoToTable();
57 instruction.setTableId((byte) 2);
58 instruction.writeTo(buffer);
61 OFPInstructionGoToTable instructionTemp = new OFPInstructionGoToTable();
62 instructionTemp.readFrom(buffer);
63 TestCase.assertEquals(instruction.toString(), instructionTemp.toString());
66 public void testEqualHashcode() {
68 OFPInstructionGoToTable instruction = new OFPInstructionGoToTable();
69 instruction.setTableId((byte) 2);
70 instruction.writeTo(buffer);
73 OFPInstructionGoToTable instructionTemp = new OFPInstructionGoToTable();
74 instructionTemp.readFrom(buffer);
76 TestCase.assertTrue(instruction.equals(instructionTemp));
77 TestCase.assertEquals(instruction.hashCode(), instructionTemp.hashCode());