2 * Copyright (c) 2014 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
9 package org.opendaylight.openflowjava.protocol.api.keys;
\r
11 import org.junit.Assert;
\r
12 import org.junit.Test;
\r
13 import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants;
\r
14 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.InPhyPort;
\r
15 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.InPort;
\r
16 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Nxm0Class;
\r
17 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OpenflowBasicClass;
\r
20 * @author michal.polkorab
\r
23 public class MatchEntrySerializerKeyTest {
\r
26 * Test MatchEntrySerializerKey equals and hashCode
\r
29 public void test() {
\r
30 MatchEntrySerializerKey<?, ?> key1 = new MatchEntrySerializerKey<>
\r
31 (EncodeConstants.OF13_VERSION_ID, OpenflowBasicClass.class, InPort.class);
\r
32 MatchEntrySerializerKey<?, ?> key2 = new MatchEntrySerializerKey<>
\r
33 (EncodeConstants.OF13_VERSION_ID, OpenflowBasicClass.class, InPort.class);
\r
34 Assert.assertTrue("Wrong equals", key1.equals(key2));
\r
35 Assert.assertTrue("Wrong hashCode", key1.hashCode() == key2.hashCode());
\r
36 key2 = new MatchEntrySerializerKey<>(EncodeConstants.OF13_VERSION_ID,
\r
37 OpenflowBasicClass.class, InPhyPort.class);
\r
38 Assert.assertFalse("Wrong equals", key1.equals(key2));
\r
39 Assert.assertFalse("Wrong hashCode", key1.hashCode() == key2.hashCode());
\r
40 key2 = new MatchEntrySerializerKey<>(EncodeConstants.OF13_VERSION_ID,
\r
41 Nxm0Class.class, InPort.class);
\r
42 Assert.assertFalse("Wrong equals", key1.equals(key2));
\r
43 Assert.assertFalse("Wrong hashCode", key1.hashCode() == key2.hashCode());
\r
44 key2 = new MatchEntrySerializerKey<>(EncodeConstants.OF10_VERSION_ID,
\r
45 OpenflowBasicClass.class, InPhyPort.class);
\r
46 Assert.assertFalse("Wrong equals", key1.equals(key2));
\r
47 Assert.assertFalse("Wrong hashCode", key1.hashCode() == key2.hashCode());
\r
48 key2 = new MatchEntrySerializerKey<>(EncodeConstants.OF13_VERSION_ID,
\r
49 OpenflowBasicClass.class, null);
\r
50 Assert.assertFalse("Wrong equals", key1.equals(key2));
\r
51 Assert.assertFalse("Wrong hashCode", key1.hashCode() == key2.hashCode());
\r
52 key2 = new MatchEntrySerializerKey<>(EncodeConstants.OF13_VERSION_ID,
\r
53 null, InPhyPort.class);
\r
54 Assert.assertFalse("Wrong equals", key1.equals(key2));
\r
55 Assert.assertFalse("Wrong hashCode", key1.hashCode() == key2.hashCode());
\r