2 * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved.
\r
4 * This program and the accompanying materials are made available under the
\r
5 * terms of the Eclipse Public License v1.0 which accompanies this distribution,
\r
6 * and is available at http://www.eclipse.org/legal/epl-v10.html
\r
8 package org.opendaylight.openflowjava.protocol.impl.util;
\r
10 import io.netty.buffer.ByteBuf;
\r
12 import java.util.List;
\r
14 import org.junit.Assert;
\r
15 import org.junit.Test;
\r
16 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Ipv4Address;
\r
17 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Ipv6Address;
\r
18 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.Ipv4AddressMatchEntry;
\r
19 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.Ipv6AddressMatchEntry;
\r
20 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.MatchEntries;
\r
23 * @author michal.polkorab
\r
26 public class MatchDeserializerTest {
\r
29 * Testing match deserialization
\r
32 public void testIpv4Address() {
\r
33 ByteBuf buffer = ByteBufUtils.hexStringToByteBuf("80 00 18 04 00 01 02 03");
\r
35 List<MatchEntries> list = MatchDeserializer.createMatchEntry(buffer, 8);
\r
36 MatchEntries entry = list.get(0);
\r
37 Assert.assertEquals("Wrong Ipv4 address format", new Ipv4Address("0.1.2.3"),
\r
38 entry.getAugmentation(Ipv4AddressMatchEntry.class).getIpv4Address());
\r
42 * Testing match deserialization
\r
45 public void testIpv6Address() {
\r
46 ByteBuf buffer = ByteBufUtils.hexStringToByteBuf("80 00 34 10 00 00 00 01 00 02 00 03 00 04 00 05 00 06 0F 07");
\r
48 List<MatchEntries> list = MatchDeserializer.createMatchEntry(buffer, 20);
\r
49 MatchEntries entry = list.get(0);
\r
50 Assert.assertEquals("Wrong Ipv6 address format", new Ipv6Address("0000:0001:0002:0003:0004:0005:0006:0F07"),
\r
51 entry.getAugmentation(Ipv6AddressMatchEntry.class).getIpv6Address());
\r