X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;f=openflow-protocol-api%2Fsrc%2Ftest%2Fjava%2Forg%2Fopendaylight%2Fopenflowjava%2Fprotocol%2Fapi%2Fkeys%2FMatchEntryDeserializerKeyTest.java;h=c9c84688d13b19e6ed0dd83904957de6f082d3fe;hb=29a2a074c78708f6d18583779ece96bb6573f0c6;hp=be87d557792e6af09fff09891e993544b8c7b30f;hpb=1c1442a7f91699dc9be315cfa984838d162a468e;p=openflowjava.git diff --git a/openflow-protocol-api/src/test/java/org/opendaylight/openflowjava/protocol/api/keys/MatchEntryDeserializerKeyTest.java b/openflow-protocol-api/src/test/java/org/opendaylight/openflowjava/protocol/api/keys/MatchEntryDeserializerKeyTest.java index be87d557..c9c84688 100644 --- a/openflow-protocol-api/src/test/java/org/opendaylight/openflowjava/protocol/api/keys/MatchEntryDeserializerKeyTest.java +++ b/openflow-protocol-api/src/test/java/org/opendaylight/openflowjava/protocol/api/keys/MatchEntryDeserializerKeyTest.java @@ -1,83 +1,83 @@ -/* - * Copyright (c) 2014 Pantheon Technologies s.r.o. 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, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ - -package org.opendaylight.openflowjava.protocol.api.keys; - -import org.junit.Assert; -import org.junit.Test; -import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; - -/** - * @author michal.polkorab - * - */ -public class MatchEntryDeserializerKeyTest { - - /** - * Test MatchEntryDeserializerKey equals and hashCode - */ - @Test - public void test() { - MatchEntryDeserializerKey key1 = new MatchEntryDeserializerKey(EncodeConstants.OF10_VERSION_ID, 0x8000, 42); - MatchEntryDeserializerKey key2 = new MatchEntryDeserializerKey(EncodeConstants.OF10_VERSION_ID, 0x8000, 42); - Assert.assertTrue("Wrong equals", key1.equals(key2)); - Assert.assertTrue("Wrong hashcode", key1.hashCode() == key2.hashCode()); - key2 = new MatchEntryDeserializerKey(EncodeConstants.OF10_VERSION_ID, 0, 42); - Assert.assertFalse("Wrong equals", key1.equals(key2)); - Assert.assertFalse("Wrong hashcode", key1.hashCode() == key2.hashCode()); - key2 = new MatchEntryDeserializerKey(EncodeConstants.OF10_VERSION_ID, 0x8000, 0); - Assert.assertFalse("Wrong equals", key1.equals(key2)); - Assert.assertFalse("Wrong hashcode", key1.hashCode() == key2.hashCode()); - key2 = new MatchEntryDeserializerKey(EncodeConstants.OF13_VERSION_ID, 0x8000, 42); - Assert.assertFalse("Wrong equals", key1.equals(key2)); - Assert.assertFalse("Wrong hashcode", key1.hashCode() == key2.hashCode()); - key2 = new MatchEntryDeserializerKey(EncodeConstants.OF13_VERSION_ID, 0x8000, 42); - key2.setExperimenterId(158L); - Assert.assertFalse("Wrong equals", key1.equals(key2)); - Assert.assertFalse("Wrong hashcode", key1.hashCode() == key2.hashCode()); - key2 = new MatchEntryDeserializerKey(EncodeConstants.OF10_VERSION_ID, 0x8000, 42); - key2.setExperimenterId(158L); - key1.setExperimenterId(158L); - Assert.assertTrue("Wrong equals", key1.equals(key2)); - Assert.assertTrue("Wrong hashcode", key1.hashCode() == key2.hashCode()); - } - - /** - * Test MatchEntryDeserializerKey equals - additional test - */ - @Test - public void testEquals() { - MatchEntryDeserializerKey key1 = new MatchEntryDeserializerKey(EncodeConstants.OF10_VERSION_ID, 0x8000, 42); - MatchEntryDeserializerKey key2 = new MatchEntryDeserializerKey(EncodeConstants.OF10_VERSION_ID, 0x8000, 42); - - Assert.assertTrue("Wrong equal to identical object.", key1.equals(key1)); - Assert.assertFalse("Wrong equal to different class.", key1.equals(new Object())); - - Long expId1=123456L; - Long expId2=654321L; - key1.setExperimenterId(null); - key2.setExperimenterId(expId2); - Assert.assertFalse("Wrong equal by experimeterId.", key1.equals(key2)); - - key1.setExperimenterId(expId1); - Assert.assertFalse("Wrong equal by experimeterId.", key1.equals(key2)); - Assert.assertFalse("Wrong equals with different object class", key1.equals(key2)); - } - - /** - * Test MatchEntryDeserializerKey toString() - */ - @Test - public void testToString(){ - MatchEntryDeserializerKey key1 = new MatchEntryDeserializerKey(EncodeConstants.OF13_VERSION_ID, 0x8000, 42); - - Assert.assertEquals("Wrong toString()", "msgVersion: 4 objectClass: org.opendaylight.yang.gen.v1.urn.opendaylight" - + ".openflow.oxm.rev130731.oxm.fields.grouping.MatchEntries msgType: 32768 oxm_field: 42" - + " experimenterID: null", key1.toString()); - } +/* + * Copyright (c) 2014 Pantheon Technologies s.r.o. 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, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ + +package org.opendaylight.openflowjava.protocol.api.keys; + +import org.junit.Assert; +import org.junit.Test; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; + +/** + * @author michal.polkorab + * + */ +public class MatchEntryDeserializerKeyTest { + + /** + * Test MatchEntryDeserializerKey equals and hashCode + */ + @Test + public void test() { + MatchEntryDeserializerKey key1 = new MatchEntryDeserializerKey(EncodeConstants.OF10_VERSION_ID, 0x8000, 42); + MatchEntryDeserializerKey key2 = new MatchEntryDeserializerKey(EncodeConstants.OF10_VERSION_ID, 0x8000, 42); + Assert.assertTrue("Wrong equals", key1.equals(key2)); + Assert.assertTrue("Wrong hashcode", key1.hashCode() == key2.hashCode()); + key2 = new MatchEntryDeserializerKey(EncodeConstants.OF10_VERSION_ID, 0, 42); + Assert.assertFalse("Wrong equals", key1.equals(key2)); + Assert.assertFalse("Wrong hashcode", key1.hashCode() == key2.hashCode()); + key2 = new MatchEntryDeserializerKey(EncodeConstants.OF10_VERSION_ID, 0x8000, 0); + Assert.assertFalse("Wrong equals", key1.equals(key2)); + Assert.assertFalse("Wrong hashcode", key1.hashCode() == key2.hashCode()); + key2 = new MatchEntryDeserializerKey(EncodeConstants.OF13_VERSION_ID, 0x8000, 42); + Assert.assertFalse("Wrong equals", key1.equals(key2)); + Assert.assertFalse("Wrong hashcode", key1.hashCode() == key2.hashCode()); + key2 = new MatchEntryDeserializerKey(EncodeConstants.OF13_VERSION_ID, 0x8000, 42); + key2.setExperimenterId(158L); + Assert.assertFalse("Wrong equals", key1.equals(key2)); + Assert.assertFalse("Wrong hashcode", key1.hashCode() == key2.hashCode()); + key2 = new MatchEntryDeserializerKey(EncodeConstants.OF10_VERSION_ID, 0x8000, 42); + key2.setExperimenterId(158L); + key1.setExperimenterId(158L); + Assert.assertTrue("Wrong equals", key1.equals(key2)); + Assert.assertTrue("Wrong hashcode", key1.hashCode() == key2.hashCode()); + } + + /** + * Test MatchEntryDeserializerKey equals - additional test + */ + @Test + public void testEquals() { + MatchEntryDeserializerKey key1 = new MatchEntryDeserializerKey(EncodeConstants.OF10_VERSION_ID, 0x8000, 42); + MatchEntryDeserializerKey key2 = new MatchEntryDeserializerKey(EncodeConstants.OF10_VERSION_ID, 0x8000, 42); + + Assert.assertTrue("Wrong equal to identical object.", key1.equals(key1)); + Assert.assertFalse("Wrong equal to different class.", key1.equals(new Object())); + + Long expId1=123456L; + Long expId2=654321L; + key1.setExperimenterId(null); + key2.setExperimenterId(expId2); + Assert.assertFalse("Wrong equal by experimeterId.", key1.equals(key2)); + + key1.setExperimenterId(expId1); + Assert.assertFalse("Wrong equal by experimeterId.", key1.equals(key2)); + Assert.assertFalse("Wrong equals with different object class", key1.equals(key2)); + } + + /** + * Test MatchEntryDeserializerKey toString() + */ + @Test + public void testToString(){ + MatchEntryDeserializerKey key1 = new MatchEntryDeserializerKey(EncodeConstants.OF13_VERSION_ID, 0x8000, 42); + + Assert.assertEquals("Wrong toString()", "msgVersion: 4 objectClass: org.opendaylight.yang.gen.v1.urn" + + ".opendaylight.openflow.oxm.rev150225.match.entries.grouping.MatchEntry" + + " msgType: 32768 oxm_field: 42 experimenterID: null", key1.toString()); + } } \ No newline at end of file