-/*\r
- * Copyright (c) 2014 Pantheon Technologies s.r.o. and others. All rights reserved.\r
- *\r
- * This program and the accompanying materials are made available under the\r
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,\r
- * and is available at http://www.eclipse.org/legal/epl-v10.html\r
- */\r
-\r
-package org.opendaylight.openflowjava.protocol.api.keys;\r
-\r
-import org.junit.Assert;\r
-import org.junit.Test;\r
-import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.InPhyPort;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.InPort;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Nxm0Class;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OpenflowBasicClass;\r
-\r
-/**\r
- * @author michal.polkorab\r
- *\r
- */\r
-public class MatchEntrySerializerKeyTest {\r
-\r
- /**\r
- * Test MatchEntrySerializerKey equals and hashCode\r
- */\r
- @Test\r
- public void test() {\r
- MatchEntrySerializerKey<?, ?> key1 = new MatchEntrySerializerKey<>\r
- (EncodeConstants.OF13_VERSION_ID, OpenflowBasicClass.class, InPort.class);\r
- MatchEntrySerializerKey<?, ?> key2 = new MatchEntrySerializerKey<>\r
- (EncodeConstants.OF13_VERSION_ID, OpenflowBasicClass.class, InPort.class);\r
- Assert.assertTrue("Wrong equals", key1.equals(key2));\r
- Assert.assertTrue("Wrong hashCode", key1.hashCode() == key2.hashCode());\r
- key2 = new MatchEntrySerializerKey<>(EncodeConstants.OF13_VERSION_ID,\r
- OpenflowBasicClass.class, InPhyPort.class);\r
- Assert.assertFalse("Wrong equals", key1.equals(key2));\r
- Assert.assertFalse("Wrong hashCode", key1.hashCode() == key2.hashCode());\r
- key2 = new MatchEntrySerializerKey<>(EncodeConstants.OF13_VERSION_ID,\r
- Nxm0Class.class, InPort.class);\r
- Assert.assertFalse("Wrong equals", key1.equals(key2));\r
- Assert.assertFalse("Wrong hashCode", key1.hashCode() == key2.hashCode());\r
- key2 = new MatchEntrySerializerKey<>(EncodeConstants.OF10_VERSION_ID,\r
- OpenflowBasicClass.class, InPhyPort.class);\r
- Assert.assertFalse("Wrong equals", key1.equals(key2));\r
- Assert.assertFalse("Wrong hashCode", key1.hashCode() == key2.hashCode());\r
- key2 = new MatchEntrySerializerKey<>(EncodeConstants.OF13_VERSION_ID,\r
- OpenflowBasicClass.class, null);\r
- Assert.assertFalse("Wrong equals", key1.equals(key2));\r
- Assert.assertFalse("Wrong hashCode", key1.hashCode() == key2.hashCode());\r
- key2 = new MatchEntrySerializerKey<>(EncodeConstants.OF13_VERSION_ID,\r
- null, InPhyPort.class);\r
- Assert.assertFalse("Wrong equals", key1.equals(key2));\r
- Assert.assertFalse("Wrong hashCode", key1.hashCode() == key2.hashCode());\r
- key2.setExperimenterId(42L);\r
- Assert.assertFalse("Wrong hashCode", key1.hashCode() == key2.hashCode());\r
- }\r
- \r
- /**\r
- * Test MatchEntrySerializerKey equals - additional test \r
- */\r
- @Test\r
- public void testEquals(){\r
- MatchEntrySerializerKey<?, ?> key1;\r
- MatchEntrySerializerKey<?, ?> key2;\r
- key1 = new MatchEntrySerializerKey<>(EncodeConstants.OF13_VERSION_ID, OpenflowBasicClass.class, InPort.class);\r
- key2 = new MatchEntrySerializerKey<>(EncodeConstants.OF13_VERSION_ID, OpenflowBasicClass.class, InPort.class);\r
- Assert.assertTrue("Wrong equal to identical object.", key1.equals(key1));\r
- Assert.assertFalse("Wrong equal to different class.", key1.equals(new Object()));\r
- \r
- Long expId1 = 987654331L;\r
- Long expId2 = 123456789L;\r
- \r
- key1.setExperimenterId(null);\r
- key2.setExperimenterId(expId2);\r
- Assert.assertFalse("Wrong equal by experimenterId", key1.equals(key2));\r
- key1.setExperimenterId(expId1);\r
- Assert.assertFalse("Wrong equal by experimenterId", key1.equals(key2));\r
- key1 = new MatchEntrySerializerKey<>(EncodeConstants.OF13_VERSION_ID, null, InPort.class);\r
- key1.setExperimenterId(expId2);\r
- Assert.assertFalse("Wrong equal by oxmClass", key1.equals(key2));\r
- key2 = new MatchEntrySerializerKey<>(EncodeConstants.OF13_VERSION_ID, null, InPort.class);\r
- key2.setExperimenterId(expId2);\r
- Assert.assertTrue("Wrong equal by oxmClass", key1.equals(key2));\r
- key1 = new MatchEntrySerializerKey<>(EncodeConstants.OF13_VERSION_ID, OpenflowBasicClass.class, null);\r
- key1.setExperimenterId(expId2);\r
- Assert.assertFalse("Wrong equal by oxmField", key1.equals(key2));\r
- key2 = new MatchEntrySerializerKey<>(EncodeConstants.OF13_VERSION_ID, OpenflowBasicClass.class, null);\r
- key2.setExperimenterId(expId2);\r
- Assert.assertTrue("Wrong equal by oxmField", key1.equals(key2));\r
- }\r
-\r
- /**\r
- * Test MatchEntrySerializerKey toString()\r
- */\r
- @Test\r
- public void testToString(){\r
- MatchEntrySerializerKey<?, ?> key1;\r
- key1 = new MatchEntrySerializerKey<>(EncodeConstants.OF13_VERSION_ID, OpenflowBasicClass.class, InPort.class);\r
-\r
- Assert.assertEquals("Wrong toString()", "msgVersion: 4 objectType: org.opendaylight.yang.gen.v1.urn.opendaylight"\r
- + ".openflow.oxm.rev130731.oxm.fields.grouping.MatchEntries oxm_class: org.opendaylight.yang.gen.v1.urn"\r
- + ".opendaylight.openflow.oxm.rev130731.OpenflowBasicClass oxm_field: org.opendaylight.yang.gen.v1.urn"\r
- + ".opendaylight.openflow.oxm.rev130731.InPort experimenterID: null", key1.toString());\r
- }\r
+/*
+ * 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.oxm.rev130731.InPhyPort;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.InPort;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Nxm0Class;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OpenflowBasicClass;
+
+/**
+ * @author michal.polkorab
+ *
+ */
+public class MatchEntrySerializerKeyTest {
+
+ /**
+ * Test MatchEntrySerializerKey equals and hashCode
+ */
+ @Test
+ public void test() {
+ MatchEntrySerializerKey<?, ?> key1 = new MatchEntrySerializerKey<>
+ (EncodeConstants.OF13_VERSION_ID, OpenflowBasicClass.class, InPort.class);
+ MatchEntrySerializerKey<?, ?> key2 = new MatchEntrySerializerKey<>
+ (EncodeConstants.OF13_VERSION_ID, OpenflowBasicClass.class, InPort.class);
+ Assert.assertTrue("Wrong equals", key1.equals(key2));
+ Assert.assertTrue("Wrong hashCode", key1.hashCode() == key2.hashCode());
+ key2 = new MatchEntrySerializerKey<>(EncodeConstants.OF13_VERSION_ID,
+ OpenflowBasicClass.class, InPhyPort.class);
+ Assert.assertFalse("Wrong equals", key1.equals(key2));
+ Assert.assertFalse("Wrong hashCode", key1.hashCode() == key2.hashCode());
+ key2 = new MatchEntrySerializerKey<>(EncodeConstants.OF13_VERSION_ID,
+ Nxm0Class.class, InPort.class);
+ Assert.assertFalse("Wrong equals", key1.equals(key2));
+ Assert.assertFalse("Wrong hashCode", key1.hashCode() == key2.hashCode());
+ key2 = new MatchEntrySerializerKey<>(EncodeConstants.OF10_VERSION_ID,
+ OpenflowBasicClass.class, InPhyPort.class);
+ Assert.assertFalse("Wrong equals", key1.equals(key2));
+ Assert.assertFalse("Wrong hashCode", key1.hashCode() == key2.hashCode());
+ key2 = new MatchEntrySerializerKey<>(EncodeConstants.OF13_VERSION_ID,
+ OpenflowBasicClass.class, null);
+ Assert.assertFalse("Wrong equals", key1.equals(key2));
+ Assert.assertFalse("Wrong hashCode", key1.hashCode() == key2.hashCode());
+ key2 = new MatchEntrySerializerKey<>(EncodeConstants.OF13_VERSION_ID,
+ null, InPhyPort.class);
+ Assert.assertFalse("Wrong equals", key1.equals(key2));
+ Assert.assertFalse("Wrong hashCode", key1.hashCode() == key2.hashCode());
+ key2.setExperimenterId(42L);
+ Assert.assertFalse("Wrong hashCode", key1.hashCode() == key2.hashCode());
+ }
+
+ /**
+ * Test MatchEntrySerializerKey equals - additional test
+ */
+ @Test
+ public void testEquals(){
+ MatchEntrySerializerKey<?, ?> key1;
+ MatchEntrySerializerKey<?, ?> key2;
+ key1 = new MatchEntrySerializerKey<>(EncodeConstants.OF13_VERSION_ID, OpenflowBasicClass.class, InPort.class);
+ key2 = new MatchEntrySerializerKey<>(EncodeConstants.OF13_VERSION_ID, OpenflowBasicClass.class, InPort.class);
+ Assert.assertTrue("Wrong equal to identical object.", key1.equals(key1));
+ Assert.assertFalse("Wrong equal to different class.", key1.equals(new Object()));
+
+ Long expId1 = 987654331L;
+ Long expId2 = 123456789L;
+
+ key1.setExperimenterId(null);
+ key2.setExperimenterId(expId2);
+ Assert.assertFalse("Wrong equal by experimenterId", key1.equals(key2));
+ key1.setExperimenterId(expId1);
+ Assert.assertFalse("Wrong equal by experimenterId", key1.equals(key2));
+ key1 = new MatchEntrySerializerKey<>(EncodeConstants.OF13_VERSION_ID, null, InPort.class);
+ key1.setExperimenterId(expId2);
+ Assert.assertFalse("Wrong equal by oxmClass", key1.equals(key2));
+ key2 = new MatchEntrySerializerKey<>(EncodeConstants.OF13_VERSION_ID, null, InPort.class);
+ key2.setExperimenterId(expId2);
+ Assert.assertTrue("Wrong equal by oxmClass", key1.equals(key2));
+ key1 = new MatchEntrySerializerKey<>(EncodeConstants.OF13_VERSION_ID, OpenflowBasicClass.class, null);
+ key1.setExperimenterId(expId2);
+ Assert.assertFalse("Wrong equal by oxmField", key1.equals(key2));
+ key2 = new MatchEntrySerializerKey<>(EncodeConstants.OF13_VERSION_ID, OpenflowBasicClass.class, null);
+ key2.setExperimenterId(expId2);
+ Assert.assertTrue("Wrong equal by oxmField", key1.equals(key2));
+ }
+
+ /**
+ * Test MatchEntrySerializerKey toString()
+ */
+ @Test
+ public void testToString(){
+ MatchEntrySerializerKey<?, ?> key1;
+ key1 = new MatchEntrySerializerKey<>(EncodeConstants.OF13_VERSION_ID, OpenflowBasicClass.class, InPort.class);
+
+ Assert.assertEquals("Wrong toString()", "msgVersion: 4 objectType: org.opendaylight.yang.gen.v1.urn.opendaylight"
+ + ".openflow.oxm.rev130731.oxm.fields.grouping.MatchEntries oxm_class: org.opendaylight.yang.gen.v1.urn"
+ + ".opendaylight.openflow.oxm.rev130731.OpenflowBasicClass oxm_field: org.opendaylight.yang.gen.v1.urn"
+ + ".opendaylight.openflow.oxm.rev130731.InPort experimenterID: null", key1.toString());
+ }