X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;f=openflow-protocol-api%2Fsrc%2Ftest%2Fjava%2Forg%2Fopendaylight%2Fopenflowjava%2Fprotocol%2Fapi%2Fextensibility%2FMessageTypeKeyTest.java;h=83f426c4e126dd57038a88e3a4b6ab53a632bc7a;hb=519a86d1ddcfb8f0fe264174e62e5424e1efba1f;hp=05db7457ce29d42ed91b577d01477e302190d2cf;hpb=d6250c36c63faf5f5dc13d06bc5bfec7013cc141;p=openflowjava.git diff --git a/openflow-protocol-api/src/test/java/org/opendaylight/openflowjava/protocol/api/extensibility/MessageTypeKeyTest.java b/openflow-protocol-api/src/test/java/org/opendaylight/openflowjava/protocol/api/extensibility/MessageTypeKeyTest.java index 05db7457..83f426c4 100644 --- a/openflow-protocol-api/src/test/java/org/opendaylight/openflowjava/protocol/api/extensibility/MessageTypeKeyTest.java +++ b/openflow-protocol-api/src/test/java/org/opendaylight/openflowjava/protocol/api/extensibility/MessageTypeKeyTest.java @@ -1,44 +1,76 @@ -/* - * 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.extensibility; - -import org.junit.Assert; -import org.junit.Test; -import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.BarrierInput; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.BarrierOutput; - -/** - * @author michal.polkorab - * - */ -public class MessageTypeKeyTest { - - /** - * Test MessageTypeKey equals and hashCode - */ - @Test - public void test() { - MessageTypeKey key1 = - new MessageTypeKey<>(EncodeConstants.OF10_VERSION_ID, BarrierInput.class); - MessageTypeKey key2 = - new MessageTypeKey<>(EncodeConstants.OF10_VERSION_ID, BarrierInput.class); - Assert.assertTrue("Wrong equals", key1.equals(key2)); - Assert.assertTrue("Wrong hashcode", key1.hashCode() == key2.hashCode()); - key2 = new MessageTypeKey<>(EncodeConstants.OF13_VERSION_ID, BarrierInput.class); - Assert.assertFalse("Wrong equals", key1.equals(key2)); - Assert.assertFalse("Wrong hashcode", key1.hashCode() == key2.hashCode()); - key2 = new MessageTypeKey<>(EncodeConstants.OF10_VERSION_ID, null); - Assert.assertFalse("Wrong equals", key1.equals(key2)); - Assert.assertFalse("Wrong hashcode", key1.hashCode() == key2.hashCode()); - key2 = new MessageTypeKey<>(EncodeConstants.OF10_VERSION_ID, BarrierOutput.class); - 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.extensibility; + +import org.junit.Assert; +import org.junit.Test; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.BarrierInput; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.BarrierOutput; + +/** + * @author michal.polkorab + * + */ +public class MessageTypeKeyTest { + + /** + * Test MessageTypeKey equals and hashCode + */ + @Test + public void test() { + MessageTypeKey key1 = + new MessageTypeKey<>(EncodeConstants.OF10_VERSION_ID, BarrierInput.class); + MessageTypeKey key2 = + new MessageTypeKey<>(EncodeConstants.OF10_VERSION_ID, BarrierInput.class); + Assert.assertTrue("Wrong equals", key1.equals(key2)); + Assert.assertTrue("Wrong hashcode", key1.hashCode() == key2.hashCode()); + key2 = new MessageTypeKey<>(EncodeConstants.OF13_VERSION_ID, BarrierInput.class); + Assert.assertFalse("Wrong equals", key1.equals(key2)); + Assert.assertFalse("Wrong hashcode", key1.hashCode() == key2.hashCode()); + key2 = new MessageTypeKey<>(EncodeConstants.OF10_VERSION_ID, null); + Assert.assertFalse("Wrong equals", key1.equals(key2)); + Assert.assertFalse("Wrong hashcode", key1.hashCode() == key2.hashCode()); + key2 = new MessageTypeKey<>(EncodeConstants.OF10_VERSION_ID, BarrierOutput.class); + Assert.assertFalse("Wrong equals", key1.equals(key2)); + Assert.assertFalse("Wrong hashcode", key1.hashCode() == key2.hashCode()); + } + + /** + * Test MessageTypeKey equals - additional test + */ + @Test + public void testEquals() { + MessageTypeKey key1; + MessageTypeKey key2; + key1 = new MessageTypeKey<>(EncodeConstants.OF10_VERSION_ID, BarrierInput.class); + + Assert.assertTrue("Wrong equal to identical object.", key1.equals(key1)); + Assert.assertFalse("Wrong equal to null.", key1.equals(null)); + Assert.assertFalse("Wrong equal to different class.", key1.equals(new Object())); + + key1 = new MessageTypeKey<>(EncodeConstants.OF10_VERSION_ID, null); + key2 = new MessageTypeKey<>(EncodeConstants.OF10_VERSION_ID, BarrierInput.class); + Assert.assertFalse("Wrong equal by msgType.", key1.equals(key2)); + + key2 = new MessageTypeKey<>(EncodeConstants.OF10_VERSION_ID, null); + Assert.assertTrue("Wrong equal by msgType.", key1.equals(key2)); + } + + /** + * Test MessageTypeKey toString() + */ + @Test + public void testToString() { + MessageTypeKey key1 = new MessageTypeKey<>(EncodeConstants.OF10_VERSION_ID, BarrierInput.class); + + Assert.assertEquals("Wrong toString()", "msgVersion: 1 objectType: org.opendaylight.yang.gen.v1.urn" + + ".opendaylight.openflow.protocol.rev130731.BarrierInput", key1.toString()); + } } \ No newline at end of file