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.experimenter;
\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.common.action.rev130731.ExperimenterActionSubType;
\r
17 * @author michal.polkorab
\r
20 public class ExperimenterActionSerializerKeyTest {
\r
24 * Test ExperimenterActionSerializerKey equals and hashCode
\r
27 public void test() {
\r
28 ExperimenterActionSerializerKey key1 =
\r
29 new ExperimenterActionSerializerKey(EncodeConstants.OF10_VERSION_ID, 42L, TestSubType.class);
\r
30 ExperimenterActionSerializerKey key2 =
\r
31 new ExperimenterActionSerializerKey(EncodeConstants.OF10_VERSION_ID, 42L, TestSubType.class);
\r
32 Assert.assertTrue("Wrong equals", key1.equals(key2));
\r
33 Assert.assertTrue("Wrong hashcode", key1.hashCode() == key2.hashCode());
\r
34 key2 = new ExperimenterActionSerializerKey(EncodeConstants.OF13_VERSION_ID, 42L, TestSubType.class);
\r
35 Assert.assertFalse("Wrong equals", key1.equals(key2));
\r
36 Assert.assertFalse("Wrong hashcode", key1.hashCode() == key2.hashCode());
\r
37 key2 = new ExperimenterActionSerializerKey(EncodeConstants.OF10_VERSION_ID, null, TestSubType.class);
\r
38 Assert.assertFalse("Wrong equals", key1.equals(key2));
\r
39 Assert.assertFalse("Wrong hashcode", key1.hashCode() == key2.hashCode());
\r
40 key2 = new ExperimenterActionSerializerKey(EncodeConstants.OF10_VERSION_ID, 55L, TestSubType.class);
\r
41 Assert.assertFalse("Wrong equals", key1.equals(key2));
\r
42 Assert.assertFalse("Wrong hashcode", key1.hashCode() == key2.hashCode());
\r
43 key2 = new ExperimenterActionSerializerKey(EncodeConstants.OF10_VERSION_ID, 55L, null);
\r
44 Assert.assertFalse("Wrong equals", key1.equals(key2));
\r
45 Assert.assertFalse("Wrong hashcode", key1.hashCode() == key2.hashCode());
\r
46 key2 = new ExperimenterActionSerializerKey(EncodeConstants.OF10_VERSION_ID, 55L, TestSubType2.class);
\r
47 Assert.assertFalse("Wrong equals", key1.equals(key2));
\r
48 Assert.assertFalse("Wrong hashcode", key1.hashCode() == key2.hashCode());
\r
52 public void testEquals() {
\r
53 ExperimenterActionSerializerKey key1;
\r
54 ExperimenterActionSerializerKey key2;
\r
55 key1 = new ExperimenterActionSerializerKey(EncodeConstants.OF10_VERSION_ID, 42L, null);
\r
56 Assert.assertTrue("Wrong equal to identical object.", key1.equals(key1));
\r
57 key2 = new ExperimenterActionSerializerKey(EncodeConstants.OF10_VERSION_ID, 42L, TestSubType2.class);
\r
58 Assert.assertFalse("Wrong equal by actionSubType.", key1.equals(key2));
\r
59 key1 = new ExperimenterActionSerializerKey(EncodeConstants.OF10_VERSION_ID, 42L, TestSubType.class);
\r
60 Assert.assertFalse("Wrong equal by actionSubType.", key1.equals(key2));
\r
64 private static class TestSubType extends ExperimenterActionSubType {
\r
65 // empty class - only used in test for comparation
\r
68 private static class TestSubType2 extends ExperimenterActionSubType {
\r
69 // empty class - only used in test for comparation
\r