2 * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved.
4 * This program and the accompanying materials are made available under the
5 * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6 * and is available at http://www.eclipse.org/legal/epl-v10.html
9 package org.opendaylight.openflowjava.protocol.impl.util;
11 import io.netty.buffer.ByteBuf;
12 import io.netty.buffer.UnpooledByteBufAllocator;
14 import java.util.ArrayList;
15 import java.util.List;
17 import org.junit.Assert;
18 import org.junit.Before;
19 import org.junit.Test;
20 import org.opendaylight.openflowjava.protocol.api.extensibility.OFSerializer;
21 import org.opendaylight.openflowjava.protocol.api.extensibility.SerializerRegistry;
22 import org.opendaylight.openflowjava.protocol.api.keys.MessageTypeKey;
23 import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants;
24 import org.opendaylight.openflowjava.protocol.impl.serialization.SerializerRegistryImpl;
25 import org.opendaylight.openflowjava.util.ByteBufUtils;
26 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Address;
27 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv6Address;
28 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv6FlowLabel;
29 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.approved.extensions.rev160802.TcpFlags;
30 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.approved.extensions.rev160802.oxm.container.match.entry.value.experimenter.id._case.TcpFlagsBuilder;
31 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.oxm.container.match.entry.value.ExperimenterIdCaseBuilder;
32 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.oxm.container.match.entry.value.experimenter.id._case.ExperimenterBuilder;
33 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.ExperimenterId;
34 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.StandardMatchType;
35 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.ExperimenterClass;
36 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.Ipv4Src;
37 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.Ipv6Dst;
38 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.Ipv6Flabel;
39 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.Ipv6NdTarget;
40 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.Ipv6Src;
41 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.MatchField;
42 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.OpenflowBasicClass;
43 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.OxmMatchType;
44 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entries.grouping.MatchEntry;
45 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entries.grouping.MatchEntryBuilder;
46 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.Ipv4SrcCaseBuilder;
47 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.Ipv6DstCaseBuilder;
48 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.Ipv6FlabelCaseBuilder;
49 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.Ipv6NdTargetCaseBuilder;
50 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.Ipv6SrcCaseBuilder;
51 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.ipv4.src._case.Ipv4SrcBuilder;
52 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.ipv6.dst._case.Ipv6DstBuilder;
53 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.ipv6.flabel._case.Ipv6FlabelBuilder;
54 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.ipv6.nd.target._case.Ipv6NdTargetBuilder;
55 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.ipv6.src._case.Ipv6SrcBuilder;
56 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.grouping.Match;
57 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.grouping.MatchBuilder;
58 import org.slf4j.Logger;
59 import org.slf4j.LoggerFactory;
62 * @author michal.polkorab
65 public class OF13MatchSerializerTest {
67 private static final Logger LOG = LoggerFactory
68 .getLogger(OF13MatchSerializerTest.class);
69 private SerializerRegistry registry;
70 private OFSerializer<Match> matchSerializer;
73 * Initializes serializer table and stores correct factory in field
76 public void startUp() {
77 registry = new SerializerRegistryImpl();
79 matchSerializer = registry.getSerializer(
80 new MessageTypeKey<>(EncodeConstants.OF13_VERSION_ID, Match.class));
84 * Test for correct serialization of Ipv4Address match entry
87 public void testIpv4Src() {
88 MatchBuilder builder = new MatchBuilder();
89 builder.setType(OxmMatchType.class);
90 List<MatchEntry> entries = new ArrayList<>();
91 MatchEntryBuilder entriesBuilder = new MatchEntryBuilder();
92 entriesBuilder.setOxmClass(OpenflowBasicClass.class);
93 entriesBuilder.setOxmMatchField(Ipv4Src.class);
94 entriesBuilder.setHasMask(false);
95 Ipv4SrcCaseBuilder ipv4SrcCaseBuilder = new Ipv4SrcCaseBuilder();
96 Ipv4SrcBuilder ipv4SrcBuilder = new Ipv4SrcBuilder();
97 ipv4SrcBuilder.setIpv4Address(new Ipv4Address("1.2.3.4"));
98 ipv4SrcCaseBuilder.setIpv4Src(ipv4SrcBuilder.build());
99 entriesBuilder.setMatchEntryValue(ipv4SrcCaseBuilder.build());
100 entries.add(entriesBuilder.build());
101 builder.setMatchEntry(entries);
102 Match match = builder.build();
104 ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer();
105 matchSerializer.serialize(match, out);
107 Assert.assertEquals("Wrong type", 1, out.readUnsignedShort());
108 out.skipBytes(EncodeConstants.SIZE_OF_SHORT_IN_BYTES);
109 Assert.assertEquals("Wrong class", 0x8000, out.readUnsignedShort());
110 Assert.assertEquals("Wrong field and mask", 22, out.readUnsignedByte());
111 out.skipBytes(EncodeConstants.SIZE_OF_BYTE_IN_BYTES);
112 Assert.assertEquals("Wrong ip address (first number)", 1, out.readUnsignedByte());
113 Assert.assertEquals("Wrong ip address (second number)", 2, out.readUnsignedByte());
114 Assert.assertEquals("Wrong ip address (third number)", 3, out.readUnsignedByte());
115 Assert.assertEquals("Wrong ip address (fourth number)", 4, out.readUnsignedByte());
119 * Test for correct serialization of Ipv6Address match entry
122 public void testIpv6Various() {
123 MatchBuilder builder = new MatchBuilder();
124 builder.setType(OxmMatchType.class);
125 List<MatchEntry> entries = new ArrayList<>();
126 // ipv6 match entry with correct Ipv6 address
127 MatchEntryBuilder entriesBuilder = new MatchEntryBuilder();
128 entriesBuilder.setOxmClass(OpenflowBasicClass.class);
129 entriesBuilder.setOxmMatchField(Ipv6Src.class);
130 entriesBuilder.setHasMask(false);
131 Ipv6SrcCaseBuilder ipv6SrcCaseBuilder = new Ipv6SrcCaseBuilder();
132 Ipv6SrcBuilder ipv6SrcBuilder = new Ipv6SrcBuilder();
133 ipv6SrcBuilder.setIpv6Address(new Ipv6Address("1:2:3:4:5:6:7:8"));
134 ipv6SrcCaseBuilder.setIpv6Src(ipv6SrcBuilder.build());
135 entriesBuilder.setMatchEntryValue(ipv6SrcCaseBuilder.build());
136 entries.add(entriesBuilder.build());
137 // ipv6 match entry with abbreviated Ipv6 address
138 entriesBuilder = new MatchEntryBuilder();
139 entriesBuilder.setOxmClass(OpenflowBasicClass.class);
140 entriesBuilder.setOxmMatchField(Ipv6NdTarget.class);
141 entriesBuilder.setHasMask(false);
142 Ipv6NdTargetCaseBuilder ipv6NdTargetCaseBuilder = new Ipv6NdTargetCaseBuilder();
143 Ipv6NdTargetBuilder ipv6NdTargetBuilder = new Ipv6NdTargetBuilder();
144 ipv6NdTargetBuilder.setIpv6Address(new Ipv6Address("1:2::6:7:8"));
145 ipv6NdTargetCaseBuilder.setIpv6NdTarget(ipv6NdTargetBuilder.build());
146 entriesBuilder.setMatchEntryValue(ipv6NdTargetCaseBuilder.build());
147 entries.add(entriesBuilder.build());
148 // ipv6 match entry with abbreviated Ipv6 address
149 entriesBuilder = new MatchEntryBuilder();
150 entriesBuilder.setOxmClass(OpenflowBasicClass.class);
151 entriesBuilder.setOxmMatchField(Ipv6Dst.class);
152 entriesBuilder.setHasMask(false);
153 Ipv6DstCaseBuilder ipv6DstCaseBuilder = new Ipv6DstCaseBuilder();
154 Ipv6DstBuilder ipv6DstBuilder = new Ipv6DstBuilder();
155 ipv6DstBuilder.setIpv6Address(new Ipv6Address("1::8"));
156 ipv6DstCaseBuilder.setIpv6Dst(ipv6DstBuilder.build());
157 entriesBuilder.setMatchEntryValue(ipv6DstCaseBuilder.build());
158 entries.add(entriesBuilder.build());
159 // ipv6 match entry with abbreviated Ipv6 address
160 entriesBuilder = new MatchEntryBuilder();
161 entriesBuilder.setOxmClass(OpenflowBasicClass.class);
162 entriesBuilder.setOxmMatchField(Ipv6Dst.class);
163 entriesBuilder.setHasMask(false);
164 ipv6DstCaseBuilder = new Ipv6DstCaseBuilder();
165 ipv6DstBuilder = new Ipv6DstBuilder();
166 ipv6DstBuilder.setIpv6Address(new Ipv6Address("::1"));
167 ipv6DstCaseBuilder.setIpv6Dst(ipv6DstBuilder.build());
168 entriesBuilder.setMatchEntryValue(ipv6DstCaseBuilder.build());
169 entries.add(entriesBuilder.build());
170 // ipv6 match entry with abbreviated Ipv6 address
171 entriesBuilder = new MatchEntryBuilder();
172 entriesBuilder.setOxmClass(OpenflowBasicClass.class);
173 entriesBuilder.setOxmMatchField(Ipv6Dst.class);
174 entriesBuilder.setHasMask(false);
175 ipv6DstCaseBuilder = new Ipv6DstCaseBuilder();
176 ipv6DstBuilder = new Ipv6DstBuilder();
177 ipv6DstBuilder.setIpv6Address(new Ipv6Address("::"));
178 ipv6DstCaseBuilder.setIpv6Dst(ipv6DstBuilder.build());
179 entriesBuilder.setMatchEntryValue(ipv6DstCaseBuilder.build());
180 entries.add(entriesBuilder.build());
181 builder.setMatchEntry(entries);
182 Match match = builder.build();
183 ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer();
184 matchSerializer.serialize(match, out);
186 Assert.assertEquals("Wrong type", 1, out.readUnsignedShort());
187 out.skipBytes(EncodeConstants.SIZE_OF_SHORT_IN_BYTES);
188 Assert.assertEquals("Wrong class", 0x8000, out.readUnsignedShort());
189 Assert.assertEquals("Wrong field and mask", 52, out.readUnsignedByte());
190 Assert.assertEquals("Wrong entry length", 16, out.readUnsignedByte());
191 Assert.assertEquals("Wrong ipv6 address", 1, out.readUnsignedShort());
192 Assert.assertEquals("Wrong ipv6 address", 2, out.readUnsignedShort());
193 Assert.assertEquals("Wrong ipv6 address", 3, out.readUnsignedShort());
194 Assert.assertEquals("Wrong ipv6 address", 4, out.readUnsignedShort());
195 Assert.assertEquals("Wrong ipv6 address", 5, out.readUnsignedShort());
196 Assert.assertEquals("Wrong ipv6 address", 6, out.readUnsignedShort());
197 Assert.assertEquals("Wrong ipv6 address", 7, out.readUnsignedShort());
198 Assert.assertEquals("Wrong ipv6 address", 8, out.readUnsignedShort());
199 Assert.assertEquals("Wrong class", 0x8000, out.readUnsignedShort());
200 Assert.assertEquals("Wrong field and mask", 62, out.readUnsignedByte());
201 Assert.assertEquals("Wrong entry length", 16, out.readUnsignedByte());
202 Assert.assertEquals("Wrong ipv6 address", 1, out.readUnsignedShort());
203 Assert.assertEquals("Wrong ipv6 address", 2, out.readUnsignedShort());
204 Assert.assertEquals("Wrong ipv6 address", 0, out.readUnsignedShort());
205 Assert.assertEquals("Wrong ipv6 address", 0, out.readUnsignedShort());
206 Assert.assertEquals("Wrong ipv6 address", 0, out.readUnsignedShort());
207 Assert.assertEquals("Wrong ipv6 address", 6, out.readUnsignedShort());
208 Assert.assertEquals("Wrong ipv6 address", 7, out.readUnsignedShort());
209 Assert.assertEquals("Wrong ipv6 address", 8, out.readUnsignedShort());
210 Assert.assertEquals("Wrong class", 0x8000, out.readUnsignedShort());
211 Assert.assertEquals("Wrong field and mask", 54, out.readUnsignedByte());
212 Assert.assertEquals("Wrong entry length", 16, out.readUnsignedByte());
213 Assert.assertEquals("Wrong ipv6 address", 1, out.readUnsignedShort());
214 Assert.assertEquals("Wrong ipv6 address", 0, out.readUnsignedShort());
215 Assert.assertEquals("Wrong ipv6 address", 0, out.readUnsignedShort());
216 Assert.assertEquals("Wrong ipv6 address", 0, out.readUnsignedShort());
217 Assert.assertEquals("Wrong ipv6 address", 0, out.readUnsignedShort());
218 Assert.assertEquals("Wrong ipv6 address", 0, out.readUnsignedShort());
219 Assert.assertEquals("Wrong ipv6 address", 0, out.readUnsignedShort());
220 Assert.assertEquals("Wrong ipv6 address", 8, out.readUnsignedShort());
221 Assert.assertEquals("Wrong class", 0x8000, out.readUnsignedShort());
222 Assert.assertEquals("Wrong field and mask", 54, out.readUnsignedByte());
223 Assert.assertEquals("Wrong entry length", 16, out.readUnsignedByte());
224 Assert.assertEquals("Wrong ipv6 address", 0, out.readUnsignedShort());
225 Assert.assertEquals("Wrong ipv6 address", 0, out.readUnsignedShort());
226 Assert.assertEquals("Wrong ipv6 address", 0, out.readUnsignedShort());
227 Assert.assertEquals("Wrong ipv6 address", 0, out.readUnsignedShort());
228 Assert.assertEquals("Wrong ipv6 address", 0, out.readUnsignedShort());
229 Assert.assertEquals("Wrong ipv6 address", 0, out.readUnsignedShort());
230 Assert.assertEquals("Wrong ipv6 address", 0, out.readUnsignedShort());
231 Assert.assertEquals("Wrong ipv6 address", 1, out.readUnsignedShort());
232 Assert.assertEquals("Wrong class", 0x8000, out.readUnsignedShort());
233 Assert.assertEquals("Wrong field and mask", 54, out.readUnsignedByte());
234 Assert.assertEquals("Wrong entry length", 16, out.readUnsignedByte());
235 Assert.assertEquals("Wrong ipv6 address", 0, out.readUnsignedShort());
236 Assert.assertEquals("Wrong ipv6 address", 0, out.readUnsignedShort());
237 Assert.assertEquals("Wrong ipv6 address", 0, out.readUnsignedShort());
238 Assert.assertEquals("Wrong ipv6 address", 0, out.readUnsignedShort());
239 Assert.assertEquals("Wrong ipv6 address", 0, out.readUnsignedShort());
240 Assert.assertEquals("Wrong ipv6 address", 0, out.readUnsignedShort());
241 Assert.assertEquals("Wrong ipv6 address", 0, out.readUnsignedShort());
242 Assert.assertEquals("Wrong ipv6 address", 0, out.readUnsignedShort());
246 * Test for correct serialization of incorrect Ipv6Address match entry
248 @Test(expected=IllegalArgumentException.class)
249 public void testIpv6Incorrect() {
250 MatchBuilder builder = new MatchBuilder();
251 builder.setType(OxmMatchType.class);
252 List<MatchEntry> entries = new ArrayList<>();
253 // ipv6 match entry with incorrect Ipv6 address
254 MatchEntryBuilder entriesBuilder = new MatchEntryBuilder();
255 entriesBuilder.setOxmClass(OpenflowBasicClass.class);
256 entriesBuilder.setOxmMatchField(Ipv6Src.class);
257 entriesBuilder.setHasMask(false);
258 Ipv6SrcCaseBuilder ipv6SrcCaseBuilder = new Ipv6SrcCaseBuilder();
259 Ipv6SrcBuilder ipv6SrcBuilder = new Ipv6SrcBuilder();
260 ipv6SrcBuilder.setIpv6Address(new Ipv6Address("1:2::::8"));
261 ipv6SrcCaseBuilder.setIpv6Src(ipv6SrcBuilder.build());
262 entriesBuilder.setMatchEntryValue(ipv6SrcCaseBuilder.build());
263 entries.add(entriesBuilder.build());
264 builder.setMatchEntry(entries);
265 Match match = builder.build();
266 ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer();
267 matchSerializer.serialize(match, out);
271 * Test for correct serialization of Ipv4Address match entry
274 public void testIpv6Flabel() {
275 Match match = buildIpv6FLabelMatch(0x0f9e8dL, false, null);
277 ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer();
278 matchSerializer.serialize(match, out);
280 Assert.assertEquals("Wrong type", 1, out.readUnsignedShort());
281 out.skipBytes(EncodeConstants.SIZE_OF_SHORT_IN_BYTES);
282 Assert.assertEquals("Wrong class", 0x8000, out.readUnsignedShort());
283 Assert.assertEquals("Wrong field and mask", 56, out.readUnsignedByte());
284 out.skipBytes(EncodeConstants.SIZE_OF_BYTE_IN_BYTES);
285 byte[] label = new byte[4];
286 out.readBytes(label);
288 LOG.debug("label: {}", ByteBufUtils.bytesToHexString(label));
289 Assert.assertArrayEquals("Wrong ipv6FLabel", new byte[]{0, 0x0f, (byte) 0x9e, (byte) 0x8d}, label);
293 * Test for correct serialization of Ipv4Address match entry
296 public void testIpv6FlabelWithMask() {
297 Match match = buildIpv6FLabelMatch(0x0f9e8dL, true, new byte[]{0, 1, 2, 3});
299 ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer();
300 matchSerializer.serialize(match, out);
302 Assert.assertEquals("Wrong type", 1, out.readUnsignedShort());
303 out.skipBytes(EncodeConstants.SIZE_OF_SHORT_IN_BYTES);
304 Assert.assertEquals("Wrong class", 0x8000, out.readUnsignedShort());
305 Assert.assertEquals("Wrong field and mask", 57, out.readUnsignedByte());
306 out.skipBytes(EncodeConstants.SIZE_OF_BYTE_IN_BYTES);
307 byte[] label = new byte[4];
308 out.readBytes(label);
309 Assert.assertArrayEquals("Wrong ipv6FLabel", new byte[]{0, 0x0f, (byte) 0x9e, (byte) 0x8d}, label);
310 byte[] mask = new byte[4];
312 Assert.assertArrayEquals("Wrong ipv6FLabel mask", new byte[]{0, 1, 2, 3}, mask);
316 * Test for correct serialization of Ipv4Address match entry with wrong mask
319 public void testIpv6FlabelWithMaskBad() {
320 Match match = buildIpv6FLabelMatch(0x0f9e8dL, true, new byte[]{0x0c, 0x7b, 0x6a});
321 ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer();
324 matchSerializer.serialize(match, out);
325 Assert.fail("incorrect length of mask ignored");
326 } catch (IllegalArgumentException e) {
332 * @param labelValue ipv6 flow label
334 * @param mask ipv6 flow label mask
337 private static Match buildIpv6FLabelMatch(long labelValue, boolean hasMask, byte[] mask) {
338 MatchBuilder builder = new MatchBuilder();
339 builder.setType(OxmMatchType.class);
340 List<MatchEntry> entries = new ArrayList<>();
341 MatchEntryBuilder entriesBuilder = new MatchEntryBuilder();
342 entriesBuilder.setOxmClass(OpenflowBasicClass.class);
343 entriesBuilder.setOxmMatchField(Ipv6Flabel.class);
344 entriesBuilder.setHasMask(hasMask);
345 Ipv6FlabelCaseBuilder ipv6FlabelCaseBuilder = new Ipv6FlabelCaseBuilder();
346 Ipv6FlabelBuilder ipv6FlabelBuilder = new Ipv6FlabelBuilder();
347 ipv6FlabelBuilder.setIpv6Flabel(new Ipv6FlowLabel(labelValue));
348 ipv6FlabelBuilder.setMask(mask);
349 ipv6FlabelCaseBuilder.setIpv6Flabel(ipv6FlabelBuilder.build());
350 entriesBuilder.setMatchEntryValue(ipv6FlabelCaseBuilder.build());
351 entries.add(entriesBuilder.build());
352 builder.setMatchEntry(entries);
353 Match match = builder.build();
358 * Test Standard match type
361 public void testStandardMatchType() {
362 MatchBuilder builder = new MatchBuilder();
363 builder.setType(StandardMatchType.class);
364 Match match = builder.build();
365 ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer();
367 matchSerializer.serialize(match, out);
369 Assert.assertEquals("Wrong match type", 0, out.readUnsignedShort());
370 Assert.assertEquals("Wrong match length", 4, out.readUnsignedShort());
371 Assert.assertEquals("Wrong padding", 0, out.readUnsignedInt());
372 Assert.assertEquals("Unexpected data", 0, out.readableBytes());
376 * Test serialize experimenter match entry - with no experimenter
377 * match entry serializer registered
379 @Test(expected=IllegalStateException.class)
380 public void testSerializeExperimenterMatchEntry() {
381 List<MatchEntry> entries = new ArrayList<>();
382 MatchEntryBuilder builder = new MatchEntryBuilder();
383 builder.setOxmClass(ExperimenterClass.class);
384 builder.setOxmMatchField(OxmMatchFieldClass.class);
385 builder.setHasMask(true);
386 ExperimenterIdCaseBuilder caseBuilder = new ExperimenterIdCaseBuilder();
387 ExperimenterBuilder expBuilder = new ExperimenterBuilder();
388 expBuilder.setExperimenter(new ExperimenterId(42L));
389 caseBuilder.setExperimenter(expBuilder.build());
390 builder.setMatchEntryValue(caseBuilder.build());
391 entries.add(builder.build());
392 ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer();
394 ((OF13MatchSerializer) matchSerializer).serializeMatchEntries(entries, out);
397 private class OxmMatchFieldClass extends MatchField {
398 // only for testing purposes