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%2FActionDeserializerKeyTest.java;h=3b2be12c8917c6a339db92c22acbbebafaa3942b;hb=07de1ed897da9d7dc70c6d550f38c59339ed751e;hp=3acddc0fa46a02bf12a768108ebe5127feb2a823;hpb=d6250c36c63faf5f5dc13d06bc5bfec7013cc141;p=openflowjava.git diff --git a/openflow-protocol-api/src/test/java/org/opendaylight/openflowjava/protocol/api/keys/ActionDeserializerKeyTest.java b/openflow-protocol-api/src/test/java/org/opendaylight/openflowjava/protocol/api/keys/ActionDeserializerKeyTest.java index 3acddc0f..3b2be12c 100644 --- a/openflow-protocol-api/src/test/java/org/opendaylight/openflowjava/protocol/api/keys/ActionDeserializerKeyTest.java +++ b/openflow-protocol-api/src/test/java/org/opendaylight/openflowjava/protocol/api/keys/ActionDeserializerKeyTest.java @@ -1,43 +1,70 @@ -/* - * 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 ActionDeserializerKeyTest { - - /** - * Test ActionDeserializerKey equals and hashCode - */ - @Test - public void test() { - ActionDeserializerKey key1 = new ActionDeserializerKey(EncodeConstants.OF10_VERSION_ID, 11, 42L); - ActionDeserializerKey key2 = new ActionDeserializerKey(EncodeConstants.OF10_VERSION_ID, 11, 42L); - Assert.assertTrue("Wrong equals", key1.equals(key2)); - Assert.assertTrue("Wrong hashcode", key1.hashCode() == key2.hashCode()); - key2 = new ActionDeserializerKey(EncodeConstants.OF10_VERSION_ID, 11, null); - Assert.assertFalse("Wrong equals", key1.equals(key2)); - Assert.assertFalse("Wrong hashcode", key1.hashCode() == key2.hashCode()); - key2 = new ActionDeserializerKey(EncodeConstants.OF10_VERSION_ID, 11, 55L); - Assert.assertFalse("Wrong equals", key1.equals(key2)); - Assert.assertFalse("Wrong hashcode", key1.hashCode() == key2.hashCode()); - key2 = new ActionDeserializerKey(EncodeConstants.OF10_VERSION_ID, 0, 42L); - Assert.assertFalse("Wrong equals", key1.equals(key2)); - Assert.assertFalse("Wrong hashcode", key1.hashCode() == key2.hashCode()); - key2 = new ActionDeserializerKey(EncodeConstants.OF13_VERSION_ID, 11, 42L); - Assert.assertFalse("Wrong equals", key1.equals(key2)); - Assert.assertFalse("Wrong hashcode", key1.hashCode() == key2.hashCode()); - } +/* + * 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 ActionDeserializerKeyTest { + + /** + * Test ActionDeserializerKey equals and hashCode + */ + @Test + public void test() { + ActionDeserializerKey key1 = new ActionDeserializerKey(EncodeConstants.OF10_VERSION_ID, 11, 42L); + ActionDeserializerKey key2 = new ActionDeserializerKey(EncodeConstants.OF10_VERSION_ID, 11, 42L); + Assert.assertTrue("Wrong equals", key1.equals(key2)); + Assert.assertTrue("Wrong hashcode", key1.hashCode() == key2.hashCode()); + key2 = new ActionDeserializerKey(EncodeConstants.OF10_VERSION_ID, 11, null); + Assert.assertFalse("Wrong equals", key1.equals(key2)); + Assert.assertFalse("Wrong hashcode", key1.hashCode() == key2.hashCode()); + key2 = new ActionDeserializerKey(EncodeConstants.OF10_VERSION_ID, 11, 55L); + Assert.assertFalse("Wrong equals", key1.equals(key2)); + Assert.assertFalse("Wrong hashcode", key1.hashCode() == key2.hashCode()); + key2 = new ActionDeserializerKey(EncodeConstants.OF10_VERSION_ID, 0, 42L); + Assert.assertFalse("Wrong equals", key1.equals(key2)); + Assert.assertFalse("Wrong hashcode", key1.hashCode() == key2.hashCode()); + key2 = new ActionDeserializerKey(EncodeConstants.OF13_VERSION_ID, 11, 42L); + Assert.assertFalse("Wrong equals", key1.equals(key2)); + Assert.assertFalse("Wrong hashcode", key1.hashCode() == key2.hashCode()); + } + + /** + * Test ActionDeserializerKey equals - additional test + */ + @Test + public void testEquals(){ + ActionDeserializerKey key1 = new ActionDeserializerKey(EncodeConstants.OF10_VERSION_ID, 11, null); + ActionDeserializerKey key2 = new ActionDeserializerKey(EncodeConstants.OF10_VERSION_ID, 11, 42L); + + Assert.assertTrue("Wrong equal to identical object.", key1.equals(key1)); + Assert.assertFalse("Wrong equal to different class.", key1.equals(new Object())); + Assert.assertFalse("Wrong equal by experimenterId", key1.equals(key2)); + key2 = new ActionDeserializerKey(EncodeConstants.OF10_VERSION_ID, 11, null); + Assert.assertTrue("Wrong equal by experimenterId", key1.equals(key2)); + } + + /** + * Test InstructionDeserializerKey toString() + */ + @Test + public void testToString(){ + ActionDeserializerKey key1 = new ActionDeserializerKey(EncodeConstants.OF10_VERSION_ID, 11, null); + + Assert.assertEquals("Wrong toString()", "msgVersion: 1 objectClass: org.opendaylight.yang.gen.v1.urn" + + ".opendaylight.openflow.common.action.rev130731.actions.grouping.Action msgType: 11" + + " experimenterID: null", key1.toString()); + } } \ No newline at end of file