Sho SHIMIZU
Committed by Gerrit Code Review

Remove IndexedLambda deprecated in Emu

Change-Id: I3dc3ea90049dd3331090472f8c4a0e83d430ba37
1 -/*
2 - * Copyright 2015 Open Networking Laboratory
3 - *
4 - * Licensed under the Apache License, Version 2.0 (the "License");
5 - * you may not use this file except in compliance with the License.
6 - * You may obtain a copy of the License at
7 - *
8 - * http://www.apache.org/licenses/LICENSE-2.0
9 - *
10 - * Unless required by applicable law or agreed to in writing, software
11 - * distributed under the License is distributed on an "AS IS" BASIS,
12 - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 - * See the License for the specific language governing permissions and
14 - * limitations under the License.
15 - */
16 -package org.onosproject.net;
17 -
18 -import com.google.common.base.MoreObjects;
19 -
20 -/**
21 - * Implementation of Lambda simply designated by an index number of wavelength.
22 - *
23 - * @deprecated in Emu (ONOS 1.4).
24 - */
25 -@Deprecated
26 -public class IndexedLambda implements Lambda {
27 -
28 - private final long index;
29 -
30 - /**
31 - * Creates an instance representing the wavelength specified by the given index number.
32 - *
33 - * @param index index number of wavelength
34 - */
35 - public IndexedLambda(long index) {
36 - this.index = index;
37 - }
38 -
39 - /**
40 - * Returns the index number of lambda.
41 - *
42 - * @return the index number of lambda
43 - */
44 - public long index() {
45 - return index;
46 - }
47 -
48 - @Override
49 - public int hashCode() {
50 - return Long.hashCode(index);
51 - }
52 -
53 - @Override
54 - public boolean equals(Object obj) {
55 - if (this == obj) {
56 - return true;
57 - }
58 - if (!(obj instanceof IndexedLambda)) {
59 - return false;
60 - }
61 -
62 - final IndexedLambda that = (IndexedLambda) obj;
63 - return this.index == that.index;
64 - }
65 -
66 - @Override
67 - public String toString() {
68 - return MoreObjects.toStringHelper(this)
69 - .add("lambda", index)
70 - .toString();
71 - }
72 -}
...@@ -24,13 +24,10 @@ import org.onlab.packet.TpPort; ...@@ -24,13 +24,10 @@ import org.onlab.packet.TpPort;
24 import org.onlab.packet.VlanId; 24 import org.onlab.packet.VlanId;
25 import org.onosproject.core.GroupId; 25 import org.onosproject.core.GroupId;
26 import org.onosproject.net.DeviceId; 26 import org.onosproject.net.DeviceId;
27 -import org.onosproject.net.IndexedLambda;
28 import org.onosproject.net.Lambda; 27 import org.onosproject.net.Lambda;
29 import org.onosproject.net.OchSignal; 28 import org.onosproject.net.OchSignal;
30 import org.onosproject.net.OduSignalId; 29 import org.onosproject.net.OduSignalId;
31 import org.onosproject.net.PortNumber; 30 import org.onosproject.net.PortNumber;
32 -import org.onosproject.net.flow.instructions.L0ModificationInstruction.L0SubType;
33 -import org.onosproject.net.flow.instructions.L0ModificationInstruction.ModLambdaInstruction;
34 import org.onosproject.net.flow.instructions.L0ModificationInstruction.ModOchSignalInstruction; 31 import org.onosproject.net.flow.instructions.L0ModificationInstruction.ModOchSignalInstruction;
35 import org.onosproject.net.flow.instructions.L1ModificationInstruction.ModOduSignalIdInstruction; 32 import org.onosproject.net.flow.instructions.L1ModificationInstruction.ModOduSignalIdInstruction;
36 import org.onosproject.net.flow.instructions.L3ModificationInstruction.L3SubType; 33 import org.onosproject.net.flow.instructions.L3ModificationInstruction.L3SubType;
...@@ -123,9 +120,7 @@ public final class Instructions { ...@@ -123,9 +120,7 @@ public final class Instructions {
123 public static L0ModificationInstruction modL0Lambda(Lambda lambda) { 120 public static L0ModificationInstruction modL0Lambda(Lambda lambda) {
124 checkNotNull(lambda, "L0 OCh signal cannot be null"); 121 checkNotNull(lambda, "L0 OCh signal cannot be null");
125 122
126 - if (lambda instanceof IndexedLambda) { 123 + if (lambda instanceof OchSignal) {
127 - return new ModLambdaInstruction(L0SubType.LAMBDA, (short) ((IndexedLambda) lambda).index());
128 - } else if (lambda instanceof OchSignal) {
129 return new ModOchSignalInstruction((OchSignal) lambda); 124 return new ModOchSignalInstruction((OchSignal) lambda);
130 } else { 125 } else {
131 throw new UnsupportedOperationException(String.format("Unsupported type: %s", lambda)); 126 throw new UnsupportedOperationException(String.format("Unsupported type: %s", lambda));
......
...@@ -15,22 +15,17 @@ ...@@ -15,22 +15,17 @@
15 */ 15 */
16 package org.onosproject.net.flow; 16 package org.onosproject.net.flow;
17 17
18 -import com.google.common.testing.EqualsTester;
19 import org.junit.Test; 18 import org.junit.Test;
20 import org.onlab.packet.IpAddress; 19 import org.onlab.packet.IpAddress;
21 import org.onlab.packet.MacAddress; 20 import org.onlab.packet.MacAddress;
22 import org.onlab.packet.VlanId; 21 import org.onlab.packet.VlanId;
23 -import org.onosproject.net.IndexedLambda;
24 import org.onosproject.net.PortNumber; 22 import org.onosproject.net.PortNumber;
25 import org.onosproject.net.flow.instructions.Instruction; 23 import org.onosproject.net.flow.instructions.Instruction;
26 -import org.onosproject.net.flow.instructions.Instructions;
27 24
28 import java.util.List; 25 import java.util.List;
29 26
30 -import static org.hamcrest.CoreMatchers.equalTo;
31 import static org.hamcrest.MatcherAssert.assertThat; 27 import static org.hamcrest.MatcherAssert.assertThat;
32 import static org.hamcrest.Matchers.hasSize; 28 import static org.hamcrest.Matchers.hasSize;
33 -import static org.hamcrest.Matchers.is;
34 29
35 /** 30 /**
36 * Unit tests for the DefaultTrafficTreatment class. 31 * Unit tests for the DefaultTrafficTreatment class.
...@@ -40,36 +35,16 @@ public class DefaultTrafficTreatmentTest { ...@@ -40,36 +35,16 @@ public class DefaultTrafficTreatmentTest {
40 // Tests for the nested Builder class 35 // Tests for the nested Builder class
41 36
42 /** 37 /**
43 - * Tests that the Builder constructors return equivalent objects
44 - * when given the same data.
45 - */
46 - @Test
47 - public void testTreatmentBuilderConstructors() {
48 - final TrafficTreatment treatment1 =
49 - DefaultTrafficTreatment.builder()
50 - .add(Instructions.modL0Lambda(new IndexedLambda(4)))
51 - .build();
52 - final TrafficTreatment treatment2 =
53 - DefaultTrafficTreatment.builder(treatment1).build();
54 - assertThat(treatment1, is(equalTo(treatment2)));
55 - }
56 -
57 - /**
58 * Tests methods defined on the Builder. 38 * Tests methods defined on the Builder.
59 */ 39 */
60 @Test 40 @Test
61 public void testBuilderMethods() { 41 public void testBuilderMethods() {
62 - final Instruction instruction1 =
63 - Instructions.modL0Lambda(new IndexedLambda(4));
64 -
65 final TrafficTreatment.Builder builder1 = 42 final TrafficTreatment.Builder builder1 =
66 DefaultTrafficTreatment.builder() 43 DefaultTrafficTreatment.builder()
67 - .add(instruction1)
68 .setEthDst(MacAddress.BROADCAST) 44 .setEthDst(MacAddress.BROADCAST)
69 .setEthSrc(MacAddress.BROADCAST) 45 .setEthSrc(MacAddress.BROADCAST)
70 .setIpDst(IpAddress.valueOf("1.1.1.1")) 46 .setIpDst(IpAddress.valueOf("1.1.1.1"))
71 .setIpSrc(IpAddress.valueOf("2.2.2.2")) 47 .setIpSrc(IpAddress.valueOf("2.2.2.2"))
72 - .add(Instructions.modL0Lambda(new IndexedLambda(4)))
73 .setOutput(PortNumber.portNumber(2)) 48 .setOutput(PortNumber.portNumber(2))
74 .setVlanId(VlanId.vlanId((short) 4)) 49 .setVlanId(VlanId.vlanId((short) 4))
75 .setVlanPcp((byte) 3); 50 .setVlanPcp((byte) 3);
...@@ -77,13 +52,12 @@ public class DefaultTrafficTreatmentTest { ...@@ -77,13 +52,12 @@ public class DefaultTrafficTreatmentTest {
77 final TrafficTreatment treatment1 = builder1.build(); 52 final TrafficTreatment treatment1 = builder1.build();
78 53
79 final List<Instruction> instructions1 = treatment1.immediate(); 54 final List<Instruction> instructions1 = treatment1.immediate();
80 - assertThat(instructions1, hasSize(9)); 55 + assertThat(instructions1, hasSize(7));
81 56
82 builder1.drop(); 57 builder1.drop();
83 - builder1.add(instruction1);
84 58
85 final List<Instruction> instructions2 = builder1.build().immediate(); 59 final List<Instruction> instructions2 = builder1.build().immediate();
86 - assertThat(instructions2, hasSize(11)); 60 + assertThat(instructions2, hasSize(8));
87 61
88 builder1.deferred() 62 builder1.deferred()
89 .popVlan() 63 .popVlan()
...@@ -91,34 +65,8 @@ public class DefaultTrafficTreatmentTest { ...@@ -91,34 +65,8 @@ public class DefaultTrafficTreatmentTest {
91 .setVlanId(VlanId.vlanId((short) 5)); 65 .setVlanId(VlanId.vlanId((short) 5));
92 66
93 final List<Instruction> instructions3 = builder1.build().immediate(); 67 final List<Instruction> instructions3 = builder1.build().immediate();
94 - assertThat(instructions3, hasSize(11)); 68 + assertThat(instructions3, hasSize(8));
95 final List<Instruction> instructions4 = builder1.build().deferred(); 69 final List<Instruction> instructions4 = builder1.build().deferred();
96 assertThat(instructions4, hasSize(3)); 70 assertThat(instructions4, hasSize(3));
97 } 71 }
98 -
99 - /**
100 - * Tests equals(), hashCode() and toString() methods of
101 - * DefaultTrafficTreatment.
102 - */
103 - @Test
104 - public void testEquals() {
105 - final IndexedLambda lambda1 = new IndexedLambda(4);
106 - final IndexedLambda lambda2 = new IndexedLambda(5);
107 - final TrafficTreatment treatment1 =
108 - DefaultTrafficTreatment.builder()
109 - .add(Instructions.modL0Lambda(lambda1))
110 - .build();
111 - final TrafficTreatment sameAsTreatment1 =
112 - DefaultTrafficTreatment.builder()
113 - .add(Instructions.modL0Lambda(lambda1))
114 - .build();
115 - final TrafficTreatment treatment2 =
116 - DefaultTrafficTreatment.builder()
117 - .add(Instructions.modL0Lambda(lambda2))
118 - .build();
119 - new EqualsTester()
120 - .addEqualityGroup(treatment1, sameAsTreatment1)
121 - .addEqualityGroup(treatment2)
122 - .testEquals();
123 - }
124 } 72 }
......
...@@ -29,7 +29,6 @@ import org.onosproject.core.GroupId; ...@@ -29,7 +29,6 @@ import org.onosproject.core.GroupId;
29 import org.onosproject.net.ChannelSpacing; 29 import org.onosproject.net.ChannelSpacing;
30 import org.onosproject.net.DeviceId; 30 import org.onosproject.net.DeviceId;
31 import org.onosproject.net.GridType; 31 import org.onosproject.net.GridType;
32 -import org.onosproject.net.IndexedLambda;
33 import org.onosproject.net.Lambda; 32 import org.onosproject.net.Lambda;
34 import org.onosproject.net.OduSignalId; 33 import org.onosproject.net.OduSignalId;
35 import org.onosproject.net.PortNumber; 34 import org.onosproject.net.PortNumber;
...@@ -197,48 +196,6 @@ public class InstructionsTest { ...@@ -197,48 +196,6 @@ public class InstructionsTest {
197 196
198 // ModLambdaInstruction 197 // ModLambdaInstruction
199 198
200 - private final IndexedLambda lambda1 = new IndexedLambda(1);
201 - private final IndexedLambda lambda2 = new IndexedLambda(2);
202 - private final Instruction lambdaInstruction1 = Instructions.modL0Lambda(lambda1);
203 - private final Instruction sameAsLambdaInstruction1 = Instructions.modL0Lambda(lambda1);
204 - private final Instruction lambdaInstruction2 = Instructions.modL0Lambda(lambda2);
205 -
206 - /**
207 - * Test the modL0Lambda method.
208 - */
209 - @Test
210 - public void testCreateLambdaMethod() {
211 - final Instruction instruction = Instructions.modL0Lambda(lambda1);
212 - final L0ModificationInstruction.ModLambdaInstruction lambdaInstruction =
213 - checkAndConvert(instruction,
214 - Instruction.Type.L0MODIFICATION,
215 - L0ModificationInstruction.ModLambdaInstruction.class);
216 - assertThat(lambdaInstruction.lambda(), is(equalTo((short) lambda1.index())));
217 - }
218 -
219 - /**
220 - * Test the equals() method of the ModLambdaInstruction class.
221 - */
222 -
223 - @Test
224 - public void testModLambdaInstructionEquals() throws Exception {
225 - checkEqualsAndToString(lambdaInstruction1,
226 - sameAsLambdaInstruction1,
227 - lambdaInstruction2);
228 - }
229 -
230 - /**
231 - * Test the hashCode() method of the ModLambdaInstruction class.
232 - */
233 -
234 - @Test
235 - public void testModLambdaInstructionHashCode() {
236 - assertThat(lambdaInstruction1.hashCode(),
237 - is(equalTo(sameAsLambdaInstruction1.hashCode())));
238 - assertThat(lambdaInstruction1.hashCode(),
239 - is(not(equalTo(lambdaInstruction2.hashCode()))));
240 - }
241 -
242 private final Lambda och1 = Lambda.ochSignal(GridType.DWDM, ChannelSpacing.CHL_100GHZ, 4, 8); 199 private final Lambda och1 = Lambda.ochSignal(GridType.DWDM, ChannelSpacing.CHL_100GHZ, 4, 8);
243 private final Lambda och2 = Lambda.ochSignal(GridType.CWDM, ChannelSpacing.CHL_100GHZ, 4, 8); 200 private final Lambda och2 = Lambda.ochSignal(GridType.CWDM, ChannelSpacing.CHL_100GHZ, 4, 8);
244 private final Instruction ochInstruction1 = Instructions.modL0Lambda(och1); 201 private final Instruction ochInstruction1 = Instructions.modL0Lambda(och1);
......
...@@ -30,7 +30,6 @@ import org.onosproject.codec.CodecContext; ...@@ -30,7 +30,6 @@ import org.onosproject.codec.CodecContext;
30 import org.onosproject.codec.JsonCodec; 30 import org.onosproject.codec.JsonCodec;
31 import org.onosproject.net.ChannelSpacing; 31 import org.onosproject.net.ChannelSpacing;
32 import org.onosproject.net.GridType; 32 import org.onosproject.net.GridType;
33 -import org.onosproject.net.IndexedLambda;
34 import org.onosproject.net.Lambda; 33 import org.onosproject.net.Lambda;
35 import org.onosproject.net.OduSignalId; 34 import org.onosproject.net.OduSignalId;
36 import org.onosproject.net.PortNumber; 35 import org.onosproject.net.PortNumber;
...@@ -85,19 +84,6 @@ public class InstructionCodecTest { ...@@ -85,19 +84,6 @@ public class InstructionCodecTest {
85 } 84 }
86 85
87 /** 86 /**
88 - * Tests the encoding of mod lambda instructions.
89 - */
90 - @Test
91 - public void modLambdaInstructionTest() {
92 - final L0ModificationInstruction.ModLambdaInstruction instruction =
93 - (L0ModificationInstruction.ModLambdaInstruction)
94 - Instructions.modL0Lambda(new IndexedLambda(55));
95 - final ObjectNode instructionJson =
96 - instructionCodec.encode(instruction, context);
97 - assertThat(instructionJson, matchesInstruction(instruction));
98 - }
99 -
100 - /**
101 * Tests the encoding of mod OCh signal instructions. 87 * Tests the encoding of mod OCh signal instructions.
102 */ 88 */
103 @Test 89 @Test
......
...@@ -35,7 +35,6 @@ import org.onosproject.net.ConnectPoint; ...@@ -35,7 +35,6 @@ import org.onosproject.net.ConnectPoint;
35 import org.onosproject.net.DeviceId; 35 import org.onosproject.net.DeviceId;
36 import org.onosproject.net.GridType; 36 import org.onosproject.net.GridType;
37 import org.onosproject.net.HostId; 37 import org.onosproject.net.HostId;
38 -import org.onosproject.net.IndexedLambda;
39 import org.onosproject.net.Lambda; 38 import org.onosproject.net.Lambda;
40 import org.onosproject.net.NetTestTools; 39 import org.onosproject.net.NetTestTools;
41 import org.onosproject.net.OchSignalType; 40 import org.onosproject.net.OchSignalType;
...@@ -45,7 +44,6 @@ import org.onosproject.net.flow.DefaultTrafficTreatment; ...@@ -45,7 +44,6 @@ import org.onosproject.net.flow.DefaultTrafficTreatment;
45 import org.onosproject.net.flow.TrafficSelector; 44 import org.onosproject.net.flow.TrafficSelector;
46 import org.onosproject.net.flow.TrafficTreatment; 45 import org.onosproject.net.flow.TrafficTreatment;
47 import org.onosproject.net.flow.criteria.Criteria; 46 import org.onosproject.net.flow.criteria.Criteria;
48 -import org.onosproject.net.flow.instructions.Instructions;
49 import org.onosproject.net.flow.criteria.Criterion; 47 import org.onosproject.net.flow.criteria.Criterion;
50 import org.onosproject.net.flow.criteria.EthCriterion; 48 import org.onosproject.net.flow.criteria.EthCriterion;
51 import org.onosproject.net.flow.instructions.Instruction; 49 import org.onosproject.net.flow.instructions.Instruction;
...@@ -170,7 +168,6 @@ public class IntentCodecTest extends AbstractIntentTest { ...@@ -170,7 +168,6 @@ public class IntentCodecTest extends AbstractIntentTest {
170 .matchIPDst(IpPrefix.valueOf("1.2.3.4/24")) 168 .matchIPDst(IpPrefix.valueOf("1.2.3.4/24"))
171 .build(); 169 .build();
172 final TrafficTreatment treatment = DefaultTrafficTreatment.builder() 170 final TrafficTreatment treatment = DefaultTrafficTreatment.builder()
173 - .add(Instructions.modL0Lambda(new IndexedLambda(33)))
174 .setMpls(MplsLabel.mplsLabel(44)) 171 .setMpls(MplsLabel.mplsLabel(44))
175 .setOutput(PortNumber.CONTROLLER) 172 .setOutput(PortNumber.CONTROLLER)
176 .setEthDst(MacAddress.BROADCAST) 173 .setEthDst(MacAddress.BROADCAST)
......
...@@ -67,7 +67,6 @@ import org.onosproject.net.Element; ...@@ -67,7 +67,6 @@ import org.onosproject.net.Element;
67 import org.onosproject.net.GridType; 67 import org.onosproject.net.GridType;
68 import org.onosproject.net.HostId; 68 import org.onosproject.net.HostId;
69 import org.onosproject.net.HostLocation; 69 import org.onosproject.net.HostLocation;
70 -import org.onosproject.net.IndexedLambda;
71 import org.onosproject.net.Link; 70 import org.onosproject.net.Link;
72 import org.onosproject.net.LinkKey; 71 import org.onosproject.net.LinkKey;
73 import org.onosproject.net.OchPort; 72 import org.onosproject.net.OchPort;
...@@ -485,7 +484,6 @@ public final class KryoNamespaces { ...@@ -485,7 +484,6 @@ public final class KryoNamespaces {
485 .register(ChannelSpacing.class) 484 .register(ChannelSpacing.class)
486 .register(OduCltPort.class) 485 .register(OduCltPort.class)
487 .register(CltSignalType.class) 486 .register(CltSignalType.class)
488 - .register(IndexedLambda.class)
489 .register(OchSignal.class) 487 .register(OchSignal.class)
490 .register(OduSignalId.class) 488 .register(OduSignalId.class)
491 .register(OduCltPortDescription.class) 489 .register(OduCltPortDescription.class)
......
...@@ -38,7 +38,6 @@ import org.onosproject.core.GroupId; ...@@ -38,7 +38,6 @@ import org.onosproject.core.GroupId;
38 import org.onosproject.net.DefaultDevice; 38 import org.onosproject.net.DefaultDevice;
39 import org.onosproject.net.Device; 39 import org.onosproject.net.Device;
40 import org.onosproject.net.DeviceId; 40 import org.onosproject.net.DeviceId;
41 -import org.onosproject.net.IndexedLambda;
42 import org.onosproject.net.NetTestTools; 41 import org.onosproject.net.NetTestTools;
43 import org.onosproject.net.device.DeviceService; 42 import org.onosproject.net.device.DeviceService;
44 import org.onosproject.net.flow.DefaultTrafficSelector; 43 import org.onosproject.net.flow.DefaultTrafficSelector;
...@@ -52,7 +51,6 @@ import org.onosproject.net.flow.TrafficSelector; ...@@ -52,7 +51,6 @@ import org.onosproject.net.flow.TrafficSelector;
52 import org.onosproject.net.flow.TrafficTreatment; 51 import org.onosproject.net.flow.TrafficTreatment;
53 import org.onosproject.net.flow.criteria.Criterion; 52 import org.onosproject.net.flow.criteria.Criterion;
54 import org.onosproject.net.flow.instructions.Instruction; 53 import org.onosproject.net.flow.instructions.Instruction;
55 -import org.onosproject.net.flow.instructions.Instructions;
56 54
57 import javax.ws.rs.NotFoundException; 55 import javax.ws.rs.NotFoundException;
58 import javax.ws.rs.client.Entity; 56 import javax.ws.rs.client.Entity;
...@@ -225,8 +223,6 @@ public class FlowsResourceTest extends ResourceTest { ...@@ -225,8 +223,6 @@ public class FlowsResourceTest extends ResourceTest {
225 */ 223 */
226 private void setupMockFlows() { 224 private void setupMockFlows() {
227 flow2.treatment = DefaultTrafficTreatment.builder() 225 flow2.treatment = DefaultTrafficTreatment.builder()
228 - .add(Instructions.modL0Lambda(new IndexedLambda((short) 4)))
229 - .add(Instructions.modL0Lambda(new IndexedLambda((short) 5)))
230 .setEthDst(MacAddress.BROADCAST) 226 .setEthDst(MacAddress.BROADCAST)
231 .build(); 227 .build();
232 flow2.selector = DefaultTrafficSelector.builder() 228 flow2.selector = DefaultTrafficSelector.builder()
...@@ -234,7 +230,6 @@ public class FlowsResourceTest extends ResourceTest { ...@@ -234,7 +230,6 @@ public class FlowsResourceTest extends ResourceTest {
234 .matchIPProtocol((byte) 9) 230 .matchIPProtocol((byte) 9)
235 .build(); 231 .build();
236 flow4.treatment = DefaultTrafficTreatment.builder() 232 flow4.treatment = DefaultTrafficTreatment.builder()
237 - .add(Instructions.modL0Lambda(new IndexedLambda((short) 6)))
238 .build(); 233 .build();
239 final Set<FlowEntry> flows1 = new HashSet<>(); 234 final Set<FlowEntry> flows1 = new HashSet<>();
240 flows1.add(flow1); 235 flows1.add(flow1);
......