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%2FActionSerializerKeyTest.java;h=043a3cfb1fe37e4d3006f6ae4c8a18d2cfb5c8fe;hb=519a86d1ddcfb8f0fe264174e62e5424e1efba1f;hp=e145e8a23e01ba0044f7bbfb12b0f87ee791a575;hpb=056a2ad499879ced18909c24b3a22581715a961a;p=openflowjava.git diff --git a/openflow-protocol-api/src/test/java/org/opendaylight/openflowjava/protocol/api/keys/ActionSerializerKeyTest.java b/openflow-protocol-api/src/test/java/org/opendaylight/openflowjava/protocol/api/keys/ActionSerializerKeyTest.java index e145e8a2..043a3cfb 100644 --- a/openflow-protocol-api/src/test/java/org/opendaylight/openflowjava/protocol/api/keys/ActionSerializerKeyTest.java +++ b/openflow-protocol-api/src/test/java/org/opendaylight/openflowjava/protocol/api/keys/ActionSerializerKeyTest.java @@ -1,66 +1,81 @@ -/* - * 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; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.CopyTtlIn; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.CopyTtlOut; - -/** - * @author michal.polkorab - * - */ -public class ActionSerializerKeyTest { - - /** - * Test ActionSerializerKey equals and hashCode - */ - @Test - public void test() { - ActionSerializerKey key1 = - new ActionSerializerKey<>(EncodeConstants.OF10_VERSION_ID, CopyTtlIn.class, 42L); - ActionSerializerKey key2 = - new ActionSerializerKey<>(EncodeConstants.OF10_VERSION_ID, CopyTtlIn.class, 42L); - Assert.assertTrue("Wrong equals", key1.equals(key2)); - Assert.assertTrue("Wrong hashCode", key1.hashCode() == key2.hashCode()); - key2 = new ActionSerializerKey<>(EncodeConstants.OF10_VERSION_ID, CopyTtlIn.class, null); - Assert.assertFalse("Wrong equals", key1.equals(key2)); - Assert.assertFalse("Wrong hashCode", key1.hashCode() == key2.hashCode()); - key2 = new ActionSerializerKey<>(EncodeConstants.OF10_VERSION_ID, null, null); - Assert.assertFalse("Wrong equals", key1.equals(key2)); - Assert.assertFalse("Wrong hashCode", key1.hashCode() == key2.hashCode()); - key2 = new ActionSerializerKey<>(EncodeConstants.OF10_VERSION_ID, CopyTtlOut.class, 42L); - Assert.assertFalse("Wrong equals", key1.equals(key2)); - Assert.assertFalse("Wrong hashCode", key1.hashCode() == key2.hashCode()); - key2 = new ActionSerializerKey<>(EncodeConstants.OF10_VERSION_ID, CopyTtlIn.class, 55L); - Assert.assertFalse("Wrong equals", key1.equals(key2)); - Assert.assertFalse("Wrong hashCode", key1.hashCode() == key2.hashCode()); - key2 = new ActionSerializerKey<>(EncodeConstants.OF13_VERSION_ID, CopyTtlIn.class, 55L); - Assert.assertFalse("Wrong equals", key1.equals(key2)); - Assert.assertFalse("Wrong hashCode", key1.hashCode() == key2.hashCode()); - } - - /** - * Test ActionDeserializerKey equals - additional test - */ - @Test - public void testEquals(){ - ActionSerializerKey key1 = new ActionSerializerKey<>(EncodeConstants.OF10_VERSION_ID, null, 42L); - ActionSerializerKey key2 = new ActionSerializerKey<>(EncodeConstants.OF10_VERSION_ID, CopyTtlIn.class, 42L); - - Assert.assertTrue("Wrong equal to identical object.", key1.equals(key1)); - - Assert.assertFalse("Wrong equal by actionType", key1.equals(key2)); - - key1 = new ActionSerializerKey<>(EncodeConstants.OF10_VERSION_ID, CopyTtlIn.class, null); - Assert.assertFalse("Wrong equal by experimenterId", key1.equals(key2)); - } +/* + * 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; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.CopyTtlIn; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.CopyTtlOut; + +/** + * @author michal.polkorab + * + */ +public class ActionSerializerKeyTest { + + /** + * Test ActionSerializerKey equals and hashCode + */ + @Test + public void test() { + ActionSerializerKey key1 = + new ActionSerializerKey<>(EncodeConstants.OF10_VERSION_ID, CopyTtlIn.class, 42L); + ActionSerializerKey key2 = + new ActionSerializerKey<>(EncodeConstants.OF10_VERSION_ID, CopyTtlIn.class, 42L); + Assert.assertTrue("Wrong equals", key1.equals(key2)); + Assert.assertTrue("Wrong hashCode", key1.hashCode() == key2.hashCode()); + key2 = new ActionSerializerKey<>(EncodeConstants.OF10_VERSION_ID, CopyTtlIn.class, null); + Assert.assertFalse("Wrong equals", key1.equals(key2)); + Assert.assertFalse("Wrong hashCode", key1.hashCode() == key2.hashCode()); + key2 = new ActionSerializerKey<>(EncodeConstants.OF10_VERSION_ID, null, null); + Assert.assertFalse("Wrong equals", key1.equals(key2)); + Assert.assertFalse("Wrong hashCode", key1.hashCode() == key2.hashCode()); + key2 = new ActionSerializerKey<>(EncodeConstants.OF10_VERSION_ID, CopyTtlOut.class, 42L); + Assert.assertFalse("Wrong equals", key1.equals(key2)); + Assert.assertFalse("Wrong hashCode", key1.hashCode() == key2.hashCode()); + key2 = new ActionSerializerKey<>(EncodeConstants.OF10_VERSION_ID, CopyTtlIn.class, 55L); + Assert.assertFalse("Wrong equals", key1.equals(key2)); + Assert.assertFalse("Wrong hashCode", key1.hashCode() == key2.hashCode()); + key2 = new ActionSerializerKey<>(EncodeConstants.OF13_VERSION_ID, CopyTtlIn.class, 55L); + Assert.assertFalse("Wrong equals", key1.equals(key2)); + Assert.assertFalse("Wrong hashCode", key1.hashCode() == key2.hashCode()); + } + + /** + * Test ActionSerializerKey equals - additional test + */ + @Test + public void testEquals(){ + ActionSerializerKey key1 = new ActionSerializerKey<>(EncodeConstants.OF10_VERSION_ID, null, 42L); + ActionSerializerKey key2 = new ActionSerializerKey<>(EncodeConstants.OF10_VERSION_ID, CopyTtlIn.class, 42L); + + Assert.assertTrue("Wrong equal to identical object.", key1.equals(key1)); + Assert.assertFalse("Wrong equal by actionType", key1.equals(key2)); + + key2 = new ActionSerializerKey<>(EncodeConstants.OF10_VERSION_ID, null, 42L); + Assert.assertTrue("Wrong equal by action type", key1.equals(key2)); + key1 = new ActionSerializerKey<>(EncodeConstants.OF10_VERSION_ID, CopyTtlIn.class, null); + Assert.assertFalse("Wrong equal by experimenterId", key1.equals(key2)); + key2 = new ActionSerializerKey<>(EncodeConstants.OF10_VERSION_ID, CopyTtlIn.class, null); + Assert.assertTrue("Wrong equal by experimenterId", key1.equals(key2)); + } + + /** + * Test ActionSerializerKey toString() + */ + @Test + public void testToString(){ + ActionSerializerKey key1 = new ActionSerializerKey<>(EncodeConstants.OF10_VERSION_ID, CopyTtlIn.class, 42L); + + Assert.assertEquals("Wrong toString()", "msgVersion: 1 objectType: org.opendaylight.yang.gen.v1.urn.opendaylight" + + ".openflow.common.action.rev130731.actions.grouping.Action action type: org.opendaylight.yang.gen.v1.urn" + + ".opendaylight.openflow.common.action.rev130731.CopyTtlIn experimenterID: 42", key1.toString()); + } } \ No newline at end of file