Jian Li
Committed by Gerrit Code Review

Try to use ModMplsHeaderInstruction and ModVlanHeaderInstruction

Change-Id: I0b486907ef718a6dfa3e92696397fe5a7e851aed
...@@ -333,7 +333,7 @@ public final class Instructions { ...@@ -333,7 +333,7 @@ public final class Instructions {
333 * @return a L2 modification. 333 * @return a L2 modification.
334 */ 334 */
335 public static Instruction pushMpls() { 335 public static Instruction pushMpls() {
336 - return new L2ModificationInstruction.PushHeaderInstructions( 336 + return new L2ModificationInstruction.ModMplsHeaderInstruction(
337 L2ModificationInstruction.L2SubType.MPLS_PUSH, 337 L2ModificationInstruction.L2SubType.MPLS_PUSH,
338 EthType.EtherType.MPLS_UNICAST.ethType()); 338 EthType.EtherType.MPLS_UNICAST.ethType());
339 } 339 }
...@@ -344,7 +344,7 @@ public final class Instructions { ...@@ -344,7 +344,7 @@ public final class Instructions {
344 * @return a L2 modification. 344 * @return a L2 modification.
345 */ 345 */
346 public static Instruction popMpls() { 346 public static Instruction popMpls() {
347 - return new L2ModificationInstruction.PushHeaderInstructions( 347 + return new L2ModificationInstruction.ModMplsHeaderInstruction(
348 L2ModificationInstruction.L2SubType.MPLS_POP, 348 L2ModificationInstruction.L2SubType.MPLS_POP,
349 EthType.EtherType.MPLS_UNICAST.ethType()); 349 EthType.EtherType.MPLS_UNICAST.ethType());
350 } 350 }
...@@ -357,7 +357,7 @@ public final class Instructions { ...@@ -357,7 +357,7 @@ public final class Instructions {
357 */ 357 */
358 public static Instruction popMpls(EthType etherType) { 358 public static Instruction popMpls(EthType etherType) {
359 checkNotNull(etherType, "Ethernet type cannot be null"); 359 checkNotNull(etherType, "Ethernet type cannot be null");
360 - return new L2ModificationInstruction.PushHeaderInstructions( 360 + return new L2ModificationInstruction.ModMplsHeaderInstruction(
361 L2ModificationInstruction.L2SubType.MPLS_POP, etherType); 361 L2ModificationInstruction.L2SubType.MPLS_POP, etherType);
362 } 362 }
363 363
...@@ -367,7 +367,7 @@ public final class Instructions { ...@@ -367,7 +367,7 @@ public final class Instructions {
367 * @return a L2 modification 367 * @return a L2 modification
368 */ 368 */
369 public static Instruction popVlan() { 369 public static Instruction popVlan() {
370 - return new L2ModificationInstruction.PopVlanInstruction( 370 + return new L2ModificationInstruction.ModVlanHeaderInstruction(
371 L2ModificationInstruction.L2SubType.VLAN_POP); 371 L2ModificationInstruction.L2SubType.VLAN_POP);
372 } 372 }
373 373
...@@ -377,7 +377,7 @@ public final class Instructions { ...@@ -377,7 +377,7 @@ public final class Instructions {
377 * @return a L2 modification 377 * @return a L2 modification
378 */ 378 */
379 public static Instruction pushVlan() { 379 public static Instruction pushVlan() {
380 - return new L2ModificationInstruction.PushHeaderInstructions( 380 + return new L2ModificationInstruction.ModVlanHeaderInstruction(
381 L2ModificationInstruction.L2SubType.VLAN_PUSH, 381 L2ModificationInstruction.L2SubType.VLAN_PUSH,
382 EthType.EtherType.VLAN.ethType()); 382 EthType.EtherType.VLAN.ethType());
383 } 383 }
......
...@@ -15,8 +15,7 @@ ...@@ -15,8 +15,7 @@
15 */ 15 */
16 package org.onosproject.net.flow.instructions; 16 package org.onosproject.net.flow.instructions;
17 17
18 -import java.util.List; 18 +import com.google.common.testing.EqualsTester;
19 -
20 import org.junit.Test; 19 import org.junit.Test;
21 import org.onlab.packet.EthType; 20 import org.onlab.packet.EthType;
22 import org.onlab.packet.IpAddress; 21 import org.onlab.packet.IpAddress;
...@@ -34,7 +33,7 @@ import org.onosproject.net.OduSignalId; ...@@ -34,7 +33,7 @@ import org.onosproject.net.OduSignalId;
34 import org.onosproject.net.PortNumber; 33 import org.onosproject.net.PortNumber;
35 import org.onosproject.net.meter.MeterId; 34 import org.onosproject.net.meter.MeterId;
36 35
37 -import com.google.common.testing.EqualsTester; 36 +import java.util.List;
38 37
39 import static org.hamcrest.MatcherAssert.assertThat; 38 import static org.hamcrest.MatcherAssert.assertThat;
40 import static org.hamcrest.Matchers.equalTo; 39 import static org.hamcrest.Matchers.equalTo;
...@@ -106,11 +105,10 @@ public class InstructionsTest { ...@@ -106,11 +105,10 @@ public class InstructionsTest {
106 assertThatClassIsImmutable(L2ModificationInstruction.ModEtherInstruction.class); 105 assertThatClassIsImmutable(L2ModificationInstruction.ModEtherInstruction.class);
107 assertThatClassIsImmutable(L2ModificationInstruction.ModVlanIdInstruction.class); 106 assertThatClassIsImmutable(L2ModificationInstruction.ModVlanIdInstruction.class);
108 assertThatClassIsImmutable(L2ModificationInstruction.ModVlanPcpInstruction.class); 107 assertThatClassIsImmutable(L2ModificationInstruction.ModVlanPcpInstruction.class);
109 - assertThatClassIsImmutable(L2ModificationInstruction.PopVlanInstruction.class);
110 assertThatClassIsImmutable(L3ModificationInstruction.ModIPInstruction.class); 108 assertThatClassIsImmutable(L3ModificationInstruction.ModIPInstruction.class);
111 assertThatClassIsImmutable(L3ModificationInstruction.ModIPv6FlowLabelInstruction.class); 109 assertThatClassIsImmutable(L3ModificationInstruction.ModIPv6FlowLabelInstruction.class);
112 assertThatClassIsImmutable(L2ModificationInstruction.ModMplsLabelInstruction.class); 110 assertThatClassIsImmutable(L2ModificationInstruction.ModMplsLabelInstruction.class);
113 - assertThatClassIsImmutable(L2ModificationInstruction.PushHeaderInstructions.class); 111 + assertThatClassIsImmutable(L2ModificationInstruction.ModMplsHeaderInstruction.class);
114 assertThatClassIsImmutable(L2ModificationInstruction.ModMplsBosInstruction.class); 112 assertThatClassIsImmutable(L2ModificationInstruction.ModMplsBosInstruction.class);
115 assertThatClassIsImmutable(L2ModificationInstruction.ModMplsTtlInstruction.class); 113 assertThatClassIsImmutable(L2ModificationInstruction.ModMplsTtlInstruction.class);
116 assertThatClassIsImmutable(L2ModificationInstruction.ModTunnelIdInstruction.class); 114 assertThatClassIsImmutable(L2ModificationInstruction.ModTunnelIdInstruction.class);
...@@ -970,13 +968,13 @@ public class InstructionsTest { ...@@ -970,13 +968,13 @@ public class InstructionsTest {
970 extensionInstruction2); 968 extensionInstruction2);
971 } 969 }
972 970
973 - // PushHeaderInstructions 971 + // ModMplsHeaderInstructions
974 972
975 private final EthType ethType1 = new EthType(1); 973 private final EthType ethType1 = new EthType(1);
976 private final EthType ethType2 = new EthType(2); 974 private final EthType ethType2 = new EthType(2);
977 - private final Instruction pushHeaderInstruction1 = Instructions.popMpls(ethType1); 975 + private final Instruction modMplsHeaderInstruction1 = Instructions.popMpls(ethType1);
978 - private final Instruction sameAsPushHeaderInstruction1 = Instructions.popMpls(ethType1); 976 + private final Instruction sameAsModMplsHeaderInstruction1 = Instructions.popMpls(ethType1);
979 - private final Instruction pushHeaderInstruction2 = Instructions.popMpls(ethType2); 977 + private final Instruction modMplsHeaderInstruction2 = Instructions.popMpls(ethType2);
980 978
981 /** 979 /**
982 * Test the pushMpls method. 980 * Test the pushMpls method.
...@@ -984,10 +982,10 @@ public class InstructionsTest { ...@@ -984,10 +982,10 @@ public class InstructionsTest {
984 @Test 982 @Test
985 public void testPushMplsMethod() { 983 public void testPushMplsMethod() {
986 final Instruction instruction = Instructions.pushMpls(); 984 final Instruction instruction = Instructions.pushMpls();
987 - final L2ModificationInstruction.PushHeaderInstructions pushHeaderInstruction = 985 + final L2ModificationInstruction.ModMplsHeaderInstruction pushHeaderInstruction =
988 checkAndConvert(instruction, 986 checkAndConvert(instruction,
989 Instruction.Type.L2MODIFICATION, 987 Instruction.Type.L2MODIFICATION,
990 - L2ModificationInstruction.PushHeaderInstructions.class); 988 + L2ModificationInstruction.ModMplsHeaderInstruction.class);
991 assertThat(pushHeaderInstruction.ethernetType().toString(), 989 assertThat(pushHeaderInstruction.ethernetType().toString(),
992 is(EthType.EtherType.MPLS_MULTICAST.toString())); 990 is(EthType.EtherType.MPLS_MULTICAST.toString()));
993 assertThat(pushHeaderInstruction.subtype(), 991 assertThat(pushHeaderInstruction.subtype(),
...@@ -1000,10 +998,10 @@ public class InstructionsTest { ...@@ -1000,10 +998,10 @@ public class InstructionsTest {
1000 @Test 998 @Test
1001 public void testPopMplsMethod() { 999 public void testPopMplsMethod() {
1002 final Instruction instruction = Instructions.popMpls(); 1000 final Instruction instruction = Instructions.popMpls();
1003 - final L2ModificationInstruction.PushHeaderInstructions pushHeaderInstruction = 1001 + final L2ModificationInstruction.ModMplsHeaderInstruction pushHeaderInstruction =
1004 checkAndConvert(instruction, 1002 checkAndConvert(instruction,
1005 Instruction.Type.L2MODIFICATION, 1003 Instruction.Type.L2MODIFICATION,
1006 - L2ModificationInstruction.PushHeaderInstructions.class); 1004 + L2ModificationInstruction.ModMplsHeaderInstruction.class);
1007 assertThat(pushHeaderInstruction.ethernetType().toString(), 1005 assertThat(pushHeaderInstruction.ethernetType().toString(),
1008 is(EthType.EtherType.MPLS_MULTICAST.toString())); 1006 is(EthType.EtherType.MPLS_MULTICAST.toString()));
1009 assertThat(pushHeaderInstruction.subtype(), 1007 assertThat(pushHeaderInstruction.subtype(),
...@@ -1016,10 +1014,10 @@ public class InstructionsTest { ...@@ -1016,10 +1014,10 @@ public class InstructionsTest {
1016 @Test 1014 @Test
1017 public void testPopMplsEthertypeMethod() { 1015 public void testPopMplsEthertypeMethod() {
1018 final Instruction instruction = Instructions.popMpls(new EthType(1)); 1016 final Instruction instruction = Instructions.popMpls(new EthType(1));
1019 - final L2ModificationInstruction.PushHeaderInstructions pushHeaderInstruction = 1017 + final L2ModificationInstruction.ModMplsHeaderInstruction pushHeaderInstruction =
1020 checkAndConvert(instruction, 1018 checkAndConvert(instruction,
1021 Instruction.Type.L2MODIFICATION, 1019 Instruction.Type.L2MODIFICATION,
1022 - L2ModificationInstruction.PushHeaderInstructions.class); 1020 + L2ModificationInstruction.ModMplsHeaderInstruction.class);
1023 assertThat(pushHeaderInstruction.ethernetType().toShort(), is((short) 1)); 1021 assertThat(pushHeaderInstruction.ethernetType().toShort(), is((short) 1));
1024 assertThat(pushHeaderInstruction.subtype(), 1022 assertThat(pushHeaderInstruction.subtype(),
1025 is(L2ModificationInstruction.L2SubType.MPLS_POP)); 1023 is(L2ModificationInstruction.L2SubType.MPLS_POP));
...@@ -1031,10 +1029,10 @@ public class InstructionsTest { ...@@ -1031,10 +1029,10 @@ public class InstructionsTest {
1031 @Test 1029 @Test
1032 public void testPushVlanMethod() { 1030 public void testPushVlanMethod() {
1033 final Instruction instruction = Instructions.pushVlan(); 1031 final Instruction instruction = Instructions.pushVlan();
1034 - final L2ModificationInstruction.PushHeaderInstructions pushHeaderInstruction = 1032 + final L2ModificationInstruction.ModVlanHeaderInstruction pushHeaderInstruction =
1035 checkAndConvert(instruction, 1033 checkAndConvert(instruction,
1036 Instruction.Type.L2MODIFICATION, 1034 Instruction.Type.L2MODIFICATION,
1037 - L2ModificationInstruction.PushHeaderInstructions.class); 1035 + L2ModificationInstruction.ModVlanHeaderInstruction.class);
1038 assertThat(pushHeaderInstruction.ethernetType().toString(), 1036 assertThat(pushHeaderInstruction.ethernetType().toString(),
1039 is(EthType.EtherType.VLAN.toString())); 1037 is(EthType.EtherType.VLAN.toString()));
1040 assertThat(pushHeaderInstruction.subtype(), 1038 assertThat(pushHeaderInstruction.subtype(),
...@@ -1043,14 +1041,14 @@ public class InstructionsTest { ...@@ -1043,14 +1041,14 @@ public class InstructionsTest {
1043 1041
1044 /** 1042 /**
1045 * Tests the equals(), hashCode() and toString() methods of the 1043 * Tests the equals(), hashCode() and toString() methods of the
1046 - * PushHeaderInstructions class. 1044 + * ModMplsHeaderInstructions class.
1047 */ 1045 */
1048 1046
1049 @Test 1047 @Test
1050 - public void testPushHeaderInstructionsEquals() { 1048 + public void testModMplsHeaderInstructionsEquals() {
1051 - checkEqualsAndToString(pushHeaderInstruction1, 1049 + checkEqualsAndToString(modMplsHeaderInstruction1,
1052 - sameAsPushHeaderInstruction1, 1050 + sameAsModMplsHeaderInstruction1,
1053 - pushHeaderInstruction2); 1051 + modMplsHeaderInstruction2);
1054 } 1052 }
1055 1053
1056 // ModMplsTtlInstruction 1054 // ModMplsTtlInstruction
...@@ -1074,7 +1072,7 @@ public class InstructionsTest { ...@@ -1074,7 +1072,7 @@ public class InstructionsTest {
1074 1072
1075 /** 1073 /**
1076 * Tests the equals(), hashCode() and toString() methods of the 1074 * Tests the equals(), hashCode() and toString() methods of the
1077 - * PushHeaderInstructions class. 1075 + * ModMplsTtlInstructions class.
1078 */ 1076 */
1079 1077
1080 @Test 1078 @Test
...@@ -1107,7 +1105,7 @@ public class InstructionsTest { ...@@ -1107,7 +1105,7 @@ public class InstructionsTest {
1107 1105
1108 /** 1106 /**
1109 * Tests the equals(), hashCode() and toString() methods of the 1107 * Tests the equals(), hashCode() and toString() methods of the
1110 - * PushHeaderInstructions class. 1108 + * ModMplsBosInstructions class.
1111 */ 1109 */
1112 1110
1113 @Test 1111 @Test
...@@ -1117,10 +1115,10 @@ public class InstructionsTest { ...@@ -1117,10 +1115,10 @@ public class InstructionsTest {
1117 modMplsBosInstruction2); 1115 modMplsBosInstruction2);
1118 } 1116 }
1119 1117
1120 - // PopVlanInstruction 1118 + // ModVlanHeaderInstruction
1121 1119
1122 - private final Instruction popVlanInstruction1 = Instructions.popVlan(); 1120 + private final Instruction modVlanHeaderInstruction1 = Instructions.popVlan();
1123 - private final Instruction sameAsPopVlanInstruction1 = Instructions.popVlan(); 1121 + private final Instruction sameAsModVlanHeaderInstruction1 = Instructions.popVlan();
1124 1122
1125 /** 1123 /**
1126 * Test the popVlan method. 1124 * Test the popVlan method.
...@@ -1128,23 +1126,23 @@ public class InstructionsTest { ...@@ -1128,23 +1126,23 @@ public class InstructionsTest {
1128 @Test 1126 @Test
1129 public void testPopVlanMethod() { 1127 public void testPopVlanMethod() {
1130 final Instruction instruction = Instructions.popVlan(); 1128 final Instruction instruction = Instructions.popVlan();
1131 - final L2ModificationInstruction.PopVlanInstruction popVlanInstruction = 1129 + final L2ModificationInstruction.ModVlanHeaderInstruction popVlanInstruction =
1132 checkAndConvert(instruction, 1130 checkAndConvert(instruction,
1133 Instruction.Type.L2MODIFICATION, 1131 Instruction.Type.L2MODIFICATION,
1134 - L2ModificationInstruction.PopVlanInstruction.class); 1132 + L2ModificationInstruction.ModVlanHeaderInstruction.class);
1135 assertThat(popVlanInstruction.subtype(), 1133 assertThat(popVlanInstruction.subtype(),
1136 is(L2ModificationInstruction.L2SubType.VLAN_POP)); 1134 is(L2ModificationInstruction.L2SubType.VLAN_POP));
1137 } 1135 }
1138 1136
1139 /** 1137 /**
1140 * Tests the equals(), hashCode() and toString() methods of the 1138 * Tests the equals(), hashCode() and toString() methods of the
1141 - * PushHeaderInstructions class. 1139 + * ModVlanHeaderInstructions class.
1142 */ 1140 */
1143 1141
1144 @Test 1142 @Test
1145 - public void testPopVlanInstructionsEquals() { 1143 + public void testModVlanHeaderInstructionsEquals() {
1146 new EqualsTester() 1144 new EqualsTester()
1147 - .addEqualityGroup(popVlanInstruction1, sameAsPopVlanInstruction1) 1145 + .addEqualityGroup(modVlanHeaderInstruction1, sameAsModVlanHeaderInstruction1)
1148 .testEquals(); 1146 .testEquals();
1149 } 1147 }
1150 1148
......
...@@ -142,9 +142,8 @@ public final class EncodeInstructionCodecHelper { ...@@ -142,9 +142,8 @@ public final class EncodeInstructionCodecHelper {
142 result.put(InstructionCodec.MPLS_LABEL, modMplsLabelInstruction.label().toInt()); 142 result.put(InstructionCodec.MPLS_LABEL, modMplsLabelInstruction.label().toInt());
143 break; 143 break;
144 case MPLS_PUSH: 144 case MPLS_PUSH:
145 - final L2ModificationInstruction.PushHeaderInstructions pushHeaderInstructions = 145 + final L2ModificationInstruction.ModMplsHeaderInstruction pushHeaderInstructions =
146 - (L2ModificationInstruction.PushHeaderInstructions) l2Instruction; 146 + (L2ModificationInstruction.ModMplsHeaderInstruction) l2Instruction;
147 -
148 result.put(InstructionCodec.ETHERNET_TYPE, 147 result.put(InstructionCodec.ETHERNET_TYPE,
149 pushHeaderInstructions.ethernetType().toShort()); 148 pushHeaderInstructions.ethernetType().toShort());
150 break; 149 break;
......
...@@ -425,14 +425,14 @@ public class FlowRuleCodecTest { ...@@ -425,14 +425,14 @@ public class FlowRuleCodecTest {
425 instruction = getInstruction(Instruction.Type.L2MODIFICATION, 425 instruction = getInstruction(Instruction.Type.L2MODIFICATION,
426 L2ModificationInstruction.L2SubType.MPLS_PUSH.name()); 426 L2ModificationInstruction.L2SubType.MPLS_PUSH.name());
427 assertThat(instruction.type(), is(Instruction.Type.L2MODIFICATION)); 427 assertThat(instruction.type(), is(Instruction.Type.L2MODIFICATION));
428 - assertThat(((L2ModificationInstruction.PushHeaderInstructions) instruction) 428 + assertThat(((L2ModificationInstruction.ModMplsHeaderInstruction) instruction)
429 .ethernetType().toShort(), 429 .ethernetType().toShort(),
430 is(Ethernet.MPLS_UNICAST)); 430 is(Ethernet.MPLS_UNICAST));
431 431
432 instruction = getInstruction(Instruction.Type.L2MODIFICATION, 432 instruction = getInstruction(Instruction.Type.L2MODIFICATION,
433 L2ModificationInstruction.L2SubType.MPLS_POP.name()); 433 L2ModificationInstruction.L2SubType.MPLS_POP.name());
434 assertThat(instruction.type(), is(Instruction.Type.L2MODIFICATION)); 434 assertThat(instruction.type(), is(Instruction.Type.L2MODIFICATION));
435 - assertThat(((L2ModificationInstruction.PushHeaderInstructions) instruction) 435 + assertThat(((L2ModificationInstruction.ModMplsHeaderInstruction) instruction)
436 .ethernetType().toShort(), 436 .ethernetType().toShort(),
437 is(Ethernet.MPLS_UNICAST)); 437 is(Ethernet.MPLS_UNICAST));
438 438
...@@ -444,12 +444,12 @@ public class FlowRuleCodecTest { ...@@ -444,12 +444,12 @@ public class FlowRuleCodecTest {
444 instruction = getInstruction(Instruction.Type.L2MODIFICATION, 444 instruction = getInstruction(Instruction.Type.L2MODIFICATION,
445 L2ModificationInstruction.L2SubType.VLAN_POP.name()); 445 L2ModificationInstruction.L2SubType.VLAN_POP.name());
446 assertThat(instruction.type(), is(Instruction.Type.L2MODIFICATION)); 446 assertThat(instruction.type(), is(Instruction.Type.L2MODIFICATION));
447 - assertThat(instruction, instanceOf(L2ModificationInstruction.PopVlanInstruction.class)); 447 + assertThat(instruction, instanceOf(L2ModificationInstruction.ModVlanHeaderInstruction.class));
448 448
449 instruction = getInstruction(Instruction.Type.L2MODIFICATION, 449 instruction = getInstruction(Instruction.Type.L2MODIFICATION,
450 L2ModificationInstruction.L2SubType.VLAN_PUSH.name()); 450 L2ModificationInstruction.L2SubType.VLAN_PUSH.name());
451 assertThat(instruction.type(), is(Instruction.Type.L2MODIFICATION)); 451 assertThat(instruction.type(), is(Instruction.Type.L2MODIFICATION));
452 - assertThat(instruction, instanceOf(L2ModificationInstruction.PushHeaderInstructions.class)); 452 + assertThat(instruction, instanceOf(L2ModificationInstruction.ModVlanHeaderInstruction.class));
453 453
454 instruction = getInstruction(Instruction.Type.L2MODIFICATION, 454 instruction = getInstruction(Instruction.Type.L2MODIFICATION,
455 L2ModificationInstruction.L2SubType.TUNNEL_ID.name()); 455 L2ModificationInstruction.L2SubType.TUNNEL_ID.name());
......
...@@ -15,10 +15,7 @@ ...@@ -15,10 +15,7 @@
15 */ 15 */
16 package org.onosproject.codec.impl; 16 package org.onosproject.codec.impl;
17 17
18 -import static org.hamcrest.MatcherAssert.assertThat; 18 +import com.fasterxml.jackson.databind.node.ObjectNode;
19 -import static org.hamcrest.Matchers.notNullValue;
20 -import static org.onosproject.codec.impl.InstructionJsonMatcher.matchesInstruction;
21 -
22 import org.junit.Before; 19 import org.junit.Before;
23 import org.junit.Test; 20 import org.junit.Test;
24 import org.onlab.packet.Ip4Address; 21 import org.onlab.packet.Ip4Address;
...@@ -40,7 +37,9 @@ import org.onosproject.net.flow.instructions.L1ModificationInstruction; ...@@ -40,7 +37,9 @@ import org.onosproject.net.flow.instructions.L1ModificationInstruction;
40 import org.onosproject.net.flow.instructions.L2ModificationInstruction; 37 import org.onosproject.net.flow.instructions.L2ModificationInstruction;
41 import org.onosproject.net.flow.instructions.L3ModificationInstruction; 38 import org.onosproject.net.flow.instructions.L3ModificationInstruction;
42 39
43 -import com.fasterxml.jackson.databind.node.ObjectNode; 40 +import static org.hamcrest.MatcherAssert.assertThat;
41 +import static org.hamcrest.Matchers.notNullValue;
42 +import static org.onosproject.codec.impl.InstructionJsonMatcher.matchesInstruction;
44 43
45 /** 44 /**
46 * Unit tests for Instruction codec. 45 * Unit tests for Instruction codec.
...@@ -60,12 +59,12 @@ public class InstructionCodecTest { ...@@ -60,12 +59,12 @@ public class InstructionCodecTest {
60 } 59 }
61 60
62 /** 61 /**
63 - * Tests the encoding of push header instructions. 62 + * Tests the encoding of push mpls header instructions.
64 */ 63 */
65 @Test 64 @Test
66 public void pushHeaderInstructionsTest() { 65 public void pushHeaderInstructionsTest() {
67 - final L2ModificationInstruction.PushHeaderInstructions instruction = 66 + final L2ModificationInstruction.ModMplsHeaderInstruction instruction =
68 - (L2ModificationInstruction.PushHeaderInstructions) Instructions.pushMpls(); 67 + (L2ModificationInstruction.ModMplsHeaderInstruction) Instructions.pushMpls();
69 final ObjectNode instructionJson = instructionCodec.encode(instruction, context); 68 final ObjectNode instructionJson = instructionCodec.encode(instruction, context);
70 69
71 assertThat(instructionJson, matchesInstruction(instruction)); 70 assertThat(instructionJson, matchesInstruction(instruction));
......
...@@ -29,10 +29,10 @@ import org.onosproject.net.flow.instructions.Instructions.SetQueueInstruction; ...@@ -29,10 +29,10 @@ import org.onosproject.net.flow.instructions.Instructions.SetQueueInstruction;
29 import org.onosproject.net.flow.instructions.L0ModificationInstruction.ModOchSignalInstruction; 29 import org.onosproject.net.flow.instructions.L0ModificationInstruction.ModOchSignalInstruction;
30 import org.onosproject.net.flow.instructions.L1ModificationInstruction.ModOduSignalIdInstruction; 30 import org.onosproject.net.flow.instructions.L1ModificationInstruction.ModOduSignalIdInstruction;
31 import org.onosproject.net.flow.instructions.L2ModificationInstruction.ModEtherInstruction; 31 import org.onosproject.net.flow.instructions.L2ModificationInstruction.ModEtherInstruction;
32 +import org.onosproject.net.flow.instructions.L2ModificationInstruction.ModMplsHeaderInstruction;
32 import org.onosproject.net.flow.instructions.L2ModificationInstruction.ModMplsLabelInstruction; 33 import org.onosproject.net.flow.instructions.L2ModificationInstruction.ModMplsLabelInstruction;
33 import org.onosproject.net.flow.instructions.L2ModificationInstruction.ModVlanIdInstruction; 34 import org.onosproject.net.flow.instructions.L2ModificationInstruction.ModVlanIdInstruction;
34 import org.onosproject.net.flow.instructions.L2ModificationInstruction.ModVlanPcpInstruction; 35 import org.onosproject.net.flow.instructions.L2ModificationInstruction.ModVlanPcpInstruction;
35 -import org.onosproject.net.flow.instructions.L2ModificationInstruction.PushHeaderInstructions;
36 import org.onosproject.net.flow.instructions.L3ModificationInstruction.ModIPInstruction; 36 import org.onosproject.net.flow.instructions.L3ModificationInstruction.ModIPInstruction;
37 import org.onosproject.net.flow.instructions.L3ModificationInstruction.ModIPv6FlowLabelInstruction; 37 import org.onosproject.net.flow.instructions.L3ModificationInstruction.ModIPv6FlowLabelInstruction;
38 38
...@@ -54,10 +54,10 @@ public final class InstructionJsonMatcher extends TypeSafeDiagnosingMatcher<Json ...@@ -54,10 +54,10 @@ public final class InstructionJsonMatcher extends TypeSafeDiagnosingMatcher<Json
54 * @param description Description object used for recording errors 54 * @param description Description object used for recording errors
55 * @return true if contents match, false otherwise 55 * @return true if contents match, false otherwise
56 */ 56 */
57 - private boolean matchPushHeaderInstruction(JsonNode instructionJson, 57 + private boolean matchModMplsHeaderInstruction(JsonNode instructionJson,
58 - Description description) { 58 + Description description) {
59 - PushHeaderInstructions instructionToMatch = 59 + ModMplsHeaderInstruction instructionToMatch =
60 - (PushHeaderInstructions) instruction; 60 + (ModMplsHeaderInstruction) instruction;
61 final String jsonSubtype = instructionJson.get("subtype").textValue(); 61 final String jsonSubtype = instructionJson.get("subtype").textValue();
62 if (!instructionToMatch.subtype().name().equals(jsonSubtype)) { 62 if (!instructionToMatch.subtype().name().equals(jsonSubtype)) {
63 description.appendText("subtype was " + jsonSubtype); 63 description.appendText("subtype was " + jsonSubtype);
...@@ -84,6 +84,8 @@ public final class InstructionJsonMatcher extends TypeSafeDiagnosingMatcher<Json ...@@ -84,6 +84,8 @@ public final class InstructionJsonMatcher extends TypeSafeDiagnosingMatcher<Json
84 return true; 84 return true;
85 } 85 }
86 86
87 + // TODO: need to add matchModVlanHeaderInstruction
88 +
87 /** 89 /**
88 * Matches the contents of an output instruction. 90 * Matches the contents of an output instruction.
89 * 91 *
...@@ -513,8 +515,8 @@ public final class InstructionJsonMatcher extends TypeSafeDiagnosingMatcher<Json ...@@ -513,8 +515,8 @@ public final class InstructionJsonMatcher extends TypeSafeDiagnosingMatcher<Json
513 return false; 515 return false;
514 } 516 }
515 517
516 - if (instruction instanceof PushHeaderInstructions) { 518 + if (instruction instanceof ModMplsHeaderInstruction) {
517 - return matchPushHeaderInstruction(jsonInstruction, description); 519 + return matchModMplsHeaderInstruction(jsonInstruction, description);
518 } else if (instruction instanceof OutputInstruction) { 520 } else if (instruction instanceof OutputInstruction) {
519 return matchOutputInstruction(jsonInstruction, description); 521 return matchOutputInstruction(jsonInstruction, description);
520 } else if (instruction instanceof GroupInstruction) { 522 } else if (instruction instanceof GroupInstruction) {
......
...@@ -15,16 +15,8 @@ ...@@ -15,16 +15,8 @@
15 */ 15 */
16 package org.onosproject.net.intent.impl.compiler; 16 package org.onosproject.net.intent.impl.compiler;
17 17
18 -import java.util.Collections; 18 +import com.google.common.collect.ImmutableList;
19 -import java.util.HashMap; 19 +import com.google.common.collect.Sets;
20 -import java.util.Iterator;
21 -import java.util.List;
22 -import java.util.Map;
23 -import java.util.Optional;
24 -import java.util.Set;
25 -import java.util.stream.Collectors;
26 -import java.util.stream.Stream;
27 -
28 import org.onlab.packet.EthType; 20 import org.onlab.packet.EthType;
29 import org.onlab.packet.Ethernet; 21 import org.onlab.packet.Ethernet;
30 import org.onlab.packet.MplsLabel; 22 import org.onlab.packet.MplsLabel;
...@@ -52,8 +44,15 @@ import org.onosproject.net.resource.ResourceService; ...@@ -52,8 +44,15 @@ import org.onosproject.net.resource.ResourceService;
52 import org.onosproject.net.resource.Resources; 44 import org.onosproject.net.resource.Resources;
53 import org.slf4j.Logger; 45 import org.slf4j.Logger;
54 46
55 -import com.google.common.collect.ImmutableList; 47 +import java.util.Collections;
56 -import com.google.common.collect.Sets; 48 +import java.util.HashMap;
49 +import java.util.Iterator;
50 +import java.util.List;
51 +import java.util.Map;
52 +import java.util.Optional;
53 +import java.util.Set;
54 +import java.util.stream.Collectors;
55 +import java.util.stream.Stream;
57 56
58 import static org.onosproject.net.LinkKey.linkKey; 57 import static org.onosproject.net.LinkKey.linkKey;
59 58
...@@ -214,10 +213,11 @@ public class PathCompiler<T> { ...@@ -214,10 +213,11 @@ public class PathCompiler<T> {
214 instruction -> instruction instanceof L2ModificationInstruction.ModVlanIdInstruction) 213 instruction -> instruction instanceof L2ModificationInstruction.ModVlanIdInstruction)
215 .map(x -> (L2ModificationInstruction.ModVlanIdInstruction) x).findAny(); 214 .map(x -> (L2ModificationInstruction.ModVlanIdInstruction) x).findAny();
216 215
217 - Optional<L2ModificationInstruction.PopVlanInstruction> popVlanInstruction = intent.treatment() 216 + Optional<L2ModificationInstruction.ModVlanHeaderInstruction> popVlanInstruction = intent.treatment()
218 .allInstructions().stream().filter( 217 .allInstructions().stream().filter(
219 - instruction -> instruction instanceof L2ModificationInstruction.PopVlanInstruction) 218 + instruction -> instruction instanceof
220 - .map(x -> (L2ModificationInstruction.PopVlanInstruction) x).findAny(); 219 + L2ModificationInstruction.ModVlanHeaderInstruction)
220 + .map(x -> (L2ModificationInstruction.ModVlanHeaderInstruction) x).findAny();
221 221
222 if (!modVlanIdInstruction.isPresent() && !popVlanInstruction.isPresent()) { 222 if (!modVlanIdInstruction.isPresent() && !popVlanInstruction.isPresent()) {
223 if (vlanCriterion.isPresent()) { 223 if (vlanCriterion.isPresent()) {
......
...@@ -317,7 +317,7 @@ public class PathIntentCompilerTest { ...@@ -317,7 +317,7 @@ public class PathIntentCompilerTest {
317 .collect(Collectors.toSet()), hasSize(1)); 317 .collect(Collectors.toSet()), hasSize(1));
318 assertThat(vlanMod.iterator().next().vlanId(), is(egressVlan)); 318 assertThat(vlanMod.iterator().next().vlanId(), is(egressVlan));
319 assertThat(rule3.treatment().allInstructions().stream() 319 assertThat(rule3.treatment().allInstructions().stream()
320 - .filter(treat -> treat instanceof L2ModificationInstruction.PopVlanInstruction) 320 + .filter(treat -> treat instanceof L2ModificationInstruction.ModVlanHeaderInstruction)
321 .collect(Collectors.toSet()), hasSize(0)); 321 .collect(Collectors.toSet()), hasSize(0));
322 322
323 sut.deactivate(); 323 sut.deactivate();
...@@ -350,7 +350,7 @@ public class PathIntentCompilerTest { ...@@ -350,7 +350,7 @@ public class PathIntentCompilerTest {
350 .filter(treat -> treat instanceof L2ModificationInstruction.ModVlanIdInstruction) 350 .filter(treat -> treat instanceof L2ModificationInstruction.ModVlanIdInstruction)
351 .collect(Collectors.toSet()), hasSize(0)); 351 .collect(Collectors.toSet()), hasSize(0));
352 assertThat(trafficTreatment.allInstructions().stream() 352 assertThat(trafficTreatment.allInstructions().stream()
353 - .filter(treat -> treat instanceof L2ModificationInstruction.PopVlanInstruction) 353 + .filter(treat -> treat instanceof L2ModificationInstruction.ModVlanHeaderInstruction)
354 .collect(Collectors.toSet()), hasSize(1)); 354 .collect(Collectors.toSet()), hasSize(1));
355 355
356 } 356 }
...@@ -436,7 +436,7 @@ public class PathIntentCompilerTest { ...@@ -436,7 +436,7 @@ public class PathIntentCompilerTest {
436 .filter(treat -> treat instanceof L2ModificationInstruction.ModMplsLabelInstruction) 436 .filter(treat -> treat instanceof L2ModificationInstruction.ModMplsLabelInstruction)
437 .collect(Collectors.toSet()), hasSize(0)); 437 .collect(Collectors.toSet()), hasSize(0));
438 assertThat(trafficTreatment.allInstructions().stream() 438 assertThat(trafficTreatment.allInstructions().stream()
439 - .filter(treat -> treat instanceof L2ModificationInstruction.PushHeaderInstructions) 439 + .filter(treat -> treat instanceof L2ModificationInstruction.ModMplsHeaderInstruction)
440 .collect(Collectors.toSet()), hasSize(1)); 440 .collect(Collectors.toSet()), hasSize(1));
441 441
442 } 442 }
......
...@@ -189,6 +189,10 @@ import org.onosproject.net.intent.constraint.PartialFailureConstraint; ...@@ -189,6 +189,10 @@ import org.onosproject.net.intent.constraint.PartialFailureConstraint;
189 import org.onosproject.net.intent.constraint.WaypointConstraint; 189 import org.onosproject.net.intent.constraint.WaypointConstraint;
190 import org.onosproject.net.link.DefaultLinkDescription; 190 import org.onosproject.net.link.DefaultLinkDescription;
191 import org.onosproject.net.meter.MeterId; 191 import org.onosproject.net.meter.MeterId;
192 +import org.onosproject.net.packet.DefaultOutboundPacket;
193 +import org.onosproject.net.packet.DefaultPacketRequest;
194 +import org.onosproject.net.packet.PacketPriority;
195 +import org.onosproject.net.provider.ProviderId;
192 import org.onosproject.net.resource.ContinuousResource; 196 import org.onosproject.net.resource.ContinuousResource;
193 import org.onosproject.net.resource.ContinuousResourceId; 197 import org.onosproject.net.resource.ContinuousResourceId;
194 import org.onosproject.net.resource.DiscreteResource; 198 import org.onosproject.net.resource.DiscreteResource;
...@@ -196,10 +200,6 @@ import org.onosproject.net.resource.DiscreteResourceCodec; ...@@ -196,10 +200,6 @@ import org.onosproject.net.resource.DiscreteResourceCodec;
196 import org.onosproject.net.resource.DiscreteResourceId; 200 import org.onosproject.net.resource.DiscreteResourceId;
197 import org.onosproject.net.resource.ResourceAllocation; 201 import org.onosproject.net.resource.ResourceAllocation;
198 import org.onosproject.net.resource.ResourceConsumerId; 202 import org.onosproject.net.resource.ResourceConsumerId;
199 -import org.onosproject.net.packet.DefaultOutboundPacket;
200 -import org.onosproject.net.packet.DefaultPacketRequest;
201 -import org.onosproject.net.packet.PacketPriority;
202 -import org.onosproject.net.provider.ProviderId;
203 import org.onosproject.security.Permission; 203 import org.onosproject.security.Permission;
204 import org.onosproject.store.Timestamp; 204 import org.onosproject.store.Timestamp;
205 import org.onosproject.store.primitives.MapUpdate; 205 import org.onosproject.store.primitives.MapUpdate;
...@@ -399,9 +399,11 @@ public final class KryoNamespaces { ...@@ -399,9 +399,11 @@ public final class KryoNamespaces {
399 L2ModificationInstruction.L2SubType.class, 399 L2ModificationInstruction.L2SubType.class,
400 L2ModificationInstruction.ModEtherInstruction.class, 400 L2ModificationInstruction.ModEtherInstruction.class,
401 L2ModificationInstruction.PushHeaderInstructions.class, 401 L2ModificationInstruction.PushHeaderInstructions.class,
402 + L2ModificationInstruction.PopVlanInstruction.class,
403 + L2ModificationInstruction.ModMplsHeaderInstruction.class,
402 L2ModificationInstruction.ModVlanIdInstruction.class, 404 L2ModificationInstruction.ModVlanIdInstruction.class,
403 L2ModificationInstruction.ModVlanPcpInstruction.class, 405 L2ModificationInstruction.ModVlanPcpInstruction.class,
404 - L2ModificationInstruction.PopVlanInstruction.class, 406 + L2ModificationInstruction.ModVlanHeaderInstruction.class,
405 L2ModificationInstruction.ModMplsLabelInstruction.class, 407 L2ModificationInstruction.ModMplsLabelInstruction.class,
406 L2ModificationInstruction.ModMplsBosInstruction.class, 408 L2ModificationInstruction.ModMplsBosInstruction.class,
407 L2ModificationInstruction.ModMplsTtlInstruction.class, 409 L2ModificationInstruction.ModMplsTtlInstruction.class,
......
...@@ -40,11 +40,12 @@ import org.onosproject.net.flow.instructions.L1ModificationInstruction.ModOduSig ...@@ -40,11 +40,12 @@ import org.onosproject.net.flow.instructions.L1ModificationInstruction.ModOduSig
40 import org.onosproject.net.flow.instructions.L2ModificationInstruction; 40 import org.onosproject.net.flow.instructions.L2ModificationInstruction;
41 import org.onosproject.net.flow.instructions.L2ModificationInstruction.ModEtherInstruction; 41 import org.onosproject.net.flow.instructions.L2ModificationInstruction.ModEtherInstruction;
42 import org.onosproject.net.flow.instructions.L2ModificationInstruction.ModMplsBosInstruction; 42 import org.onosproject.net.flow.instructions.L2ModificationInstruction.ModMplsBosInstruction;
43 +import org.onosproject.net.flow.instructions.L2ModificationInstruction.ModMplsHeaderInstruction;
43 import org.onosproject.net.flow.instructions.L2ModificationInstruction.ModMplsLabelInstruction; 44 import org.onosproject.net.flow.instructions.L2ModificationInstruction.ModMplsLabelInstruction;
44 import org.onosproject.net.flow.instructions.L2ModificationInstruction.ModTunnelIdInstruction; 45 import org.onosproject.net.flow.instructions.L2ModificationInstruction.ModTunnelIdInstruction;
46 +import org.onosproject.net.flow.instructions.L2ModificationInstruction.ModVlanHeaderInstruction;
45 import org.onosproject.net.flow.instructions.L2ModificationInstruction.ModVlanIdInstruction; 47 import org.onosproject.net.flow.instructions.L2ModificationInstruction.ModVlanIdInstruction;
46 import org.onosproject.net.flow.instructions.L2ModificationInstruction.ModVlanPcpInstruction; 48 import org.onosproject.net.flow.instructions.L2ModificationInstruction.ModVlanPcpInstruction;
47 -import org.onosproject.net.flow.instructions.L2ModificationInstruction.PushHeaderInstructions;
48 import org.onosproject.net.flow.instructions.L3ModificationInstruction; 49 import org.onosproject.net.flow.instructions.L3ModificationInstruction;
49 import org.onosproject.net.flow.instructions.L3ModificationInstruction.ModArpEthInstruction; 50 import org.onosproject.net.flow.instructions.L3ModificationInstruction.ModArpEthInstruction;
50 import org.onosproject.net.flow.instructions.L3ModificationInstruction.ModArpIPInstruction; 51 import org.onosproject.net.flow.instructions.L3ModificationInstruction.ModArpIPInstruction;
...@@ -394,13 +395,13 @@ public class FlowModBuilderVer13 extends FlowModBuilder { ...@@ -394,13 +395,13 @@ public class FlowModBuilderVer13 extends FlowModBuilder {
394 oxm = factory().oxms().vlanPcp(VlanPcp.of(vlanPcp.vlanPcp())); 395 oxm = factory().oxms().vlanPcp(VlanPcp.of(vlanPcp.vlanPcp()));
395 break; 396 break;
396 case MPLS_PUSH: 397 case MPLS_PUSH:
397 - PushHeaderInstructions pushHeaderInstructions = 398 + ModMplsHeaderInstruction pushHeaderInstructions =
398 - (PushHeaderInstructions) l2m; 399 + (ModMplsHeaderInstruction) l2m;
399 return factory().actions().pushMpls(EthType.of(pushHeaderInstructions 400 return factory().actions().pushMpls(EthType.of(pushHeaderInstructions
400 .ethernetType().toShort())); 401 .ethernetType().toShort()));
401 case MPLS_POP: 402 case MPLS_POP:
402 - PushHeaderInstructions popHeaderInstructions = 403 + ModMplsHeaderInstruction popHeaderInstructions =
403 - (PushHeaderInstructions) l2m; 404 + (ModMplsHeaderInstruction) l2m;
404 return factory().actions().popMpls(EthType.of(popHeaderInstructions 405 return factory().actions().popMpls(EthType.of(popHeaderInstructions
405 .ethernetType().toShort())); 406 .ethernetType().toShort()));
406 case MPLS_LABEL: 407 case MPLS_LABEL:
...@@ -419,7 +420,7 @@ public class FlowModBuilderVer13 extends FlowModBuilder { ...@@ -419,7 +420,7 @@ public class FlowModBuilderVer13 extends FlowModBuilder {
419 case VLAN_POP: 420 case VLAN_POP:
420 return factory().actions().popVlan(); 421 return factory().actions().popVlan();
421 case VLAN_PUSH: 422 case VLAN_PUSH:
422 - PushHeaderInstructions pushVlanInstruction = (PushHeaderInstructions) l2m; 423 + ModVlanHeaderInstruction pushVlanInstruction = (ModVlanHeaderInstruction) l2m;
423 return factory().actions().pushVlan( 424 return factory().actions().pushVlan(
424 EthType.of(pushVlanInstruction.ethernetType().toShort())); 425 EthType.of(pushVlanInstruction.ethernetType().toShort()));
425 case TUNNEL_ID: 426 case TUNNEL_ID:
......
...@@ -15,14 +15,6 @@ ...@@ -15,14 +15,6 @@
15 */ 15 */
16 package org.onosproject.provider.of.group.impl; 16 package org.onosproject.provider.of.group.impl;
17 17
18 -import static org.slf4j.LoggerFactory.getLogger;
19 -
20 -import java.util.ArrayList;
21 -import java.util.Collections;
22 -import java.util.LinkedList;
23 -import java.util.List;
24 -import java.util.Optional;
25 -
26 import org.onlab.packet.Ip4Address; 18 import org.onlab.packet.Ip4Address;
27 import org.onlab.packet.Ip6Address; 19 import org.onlab.packet.Ip6Address;
28 import org.onosproject.core.GroupId; 20 import org.onosproject.core.GroupId;
...@@ -67,6 +59,14 @@ import org.projectfloodlight.openflow.types.U64; ...@@ -67,6 +59,14 @@ import org.projectfloodlight.openflow.types.U64;
67 import org.projectfloodlight.openflow.types.VlanPcp; 59 import org.projectfloodlight.openflow.types.VlanPcp;
68 import org.slf4j.Logger; 60 import org.slf4j.Logger;
69 61
62 +import java.util.ArrayList;
63 +import java.util.Collections;
64 +import java.util.LinkedList;
65 +import java.util.List;
66 +import java.util.Optional;
67 +
68 +import static org.slf4j.LoggerFactory.getLogger;
69 +
70 /* 70 /*
71 * Builder for GroupMod. 71 * Builder for GroupMod.
72 */ 72 */
...@@ -319,18 +319,18 @@ public final class GroupModBuilder { ...@@ -319,18 +319,18 @@ public final class GroupModBuilder {
319 case VLAN_POP: 319 case VLAN_POP:
320 return factory.actions().popVlan(); 320 return factory.actions().popVlan();
321 case VLAN_PUSH: 321 case VLAN_PUSH:
322 - L2ModificationInstruction.PushHeaderInstructions pushVlanInstruction 322 + L2ModificationInstruction.ModVlanHeaderInstruction pushVlanInstruction
323 - = (L2ModificationInstruction.PushHeaderInstructions) l2m; 323 + = (L2ModificationInstruction.ModVlanHeaderInstruction) l2m;
324 return factory.actions().pushVlan( 324 return factory.actions().pushVlan(
325 EthType.of(pushVlanInstruction.ethernetType().toShort())); 325 EthType.of(pushVlanInstruction.ethernetType().toShort()));
326 case MPLS_PUSH: 326 case MPLS_PUSH:
327 - L2ModificationInstruction.PushHeaderInstructions pushHeaderInstructions = 327 + L2ModificationInstruction.ModMplsHeaderInstruction pushHeaderInstructions =
328 - (L2ModificationInstruction.PushHeaderInstructions) l2m; 328 + (L2ModificationInstruction.ModMplsHeaderInstruction) l2m;
329 return factory.actions().pushMpls(EthType.of(pushHeaderInstructions 329 return factory.actions().pushMpls(EthType.of(pushHeaderInstructions
330 .ethernetType().toShort())); 330 .ethernetType().toShort()));
331 case MPLS_POP: 331 case MPLS_POP:
332 - L2ModificationInstruction.PushHeaderInstructions popHeaderInstructions = 332 + L2ModificationInstruction.ModMplsHeaderInstruction popHeaderInstructions =
333 - (L2ModificationInstruction.PushHeaderInstructions) l2m; 333 + (L2ModificationInstruction.ModMplsHeaderInstruction) l2m;
334 return factory.actions().popMpls(EthType.of(popHeaderInstructions 334 return factory.actions().popMpls(EthType.of(popHeaderInstructions
335 .ethernetType().toShort())); 335 .ethernetType().toShort()));
336 case MPLS_LABEL: 336 case MPLS_LABEL:
......