X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?p=controller.git;a=blobdiff_plain;f=opendaylight%2Fsal%2Fapi%2Fsrc%2Ftest%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Fsal%2Fpacket%2FEthernetTest.java;h=494dd2abf28c0d0e660debeb6a9936c3c752315a;hp=2494eb6b2d459460c0ab825e9b18c0fc15d30029;hb=4be60297ba3835ac60e4910540c1b7646f3c4ca3;hpb=33ea0032f0837333a9181dd7556faa3266155080 diff --git a/opendaylight/sal/api/src/test/java/org/opendaylight/controller/sal/packet/EthernetTest.java b/opendaylight/sal/api/src/test/java/org/opendaylight/controller/sal/packet/EthernetTest.java index 2494eb6b2d..494dd2abf2 100644 --- a/opendaylight/sal/api/src/test/java/org/opendaylight/controller/sal/packet/EthernetTest.java +++ b/opendaylight/sal/api/src/test/java/org/opendaylight/controller/sal/packet/EthernetTest.java @@ -1,6 +1,6 @@ /* - * Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved. + * Copyright (c) 2013-2014 Cisco Systems, Inc. and others. All rights reserved. * * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v1.0 which accompanies this distribution, @@ -9,9 +9,14 @@ package org.opendaylight.controller.sal.packet; +import java.util.Arrays; + import junit.framework.Assert; import org.junit.Test; +import org.opendaylight.controller.sal.match.Match; +import org.opendaylight.controller.sal.match.MatchType; +import org.opendaylight.controller.sal.utils.EtherTypes; public class EthernetTest { @@ -95,4 +100,22 @@ public class EthernetTest { } + @Test + public void testGetMatch() throws Exception { + Ethernet eth = new Ethernet(); + byte smac[] = { (byte) 0xf0, (byte) 0xde, (byte) 0xf1, (byte) 0x71, (byte) 0x72, (byte) 0x8d }; + byte dmac[] = { (byte) 0xde, (byte) 0x28, (byte) 0xdb, (byte) 0xb3, (byte) 0x7c, (byte) 0xf8 }; + short ethType = EtherTypes.IPv4.shortValue(); + eth.setDestinationMACAddress(dmac); + eth.setSourceMACAddress(smac); + eth.setEtherType(ethType); + + Match match = eth.getMatch(); + + Assert.assertTrue(Arrays.equals(smac, (byte[]) match.getField(MatchType.DL_SRC).getValue())); + Assert.assertTrue(Arrays.equals(dmac, (byte[]) match.getField(MatchType.DL_DST).getValue())); + Assert.assertEquals(ethType, (short) match.getField(MatchType.DL_TYPE).getValue()); + + } + }