*/\r
@Test\r
public void testEquals(){\r
- \r
MatchEntrySerializerKey<?, ?> key1;\r
MatchEntrySerializerKey<?, ?> key2;\r
- \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
- \r
Assert.assertTrue("Wrong equal to identical object.", key1.equals(key1));\r
- \r
Assert.assertFalse("Wrong equal to different class.", key1.equals(new Object()));\r
\r
Long expId1 = 987654331L;\r
\r
key1.setExperimenterId(null);\r
key2.setExperimenterId(expId2);\r
- \r
Assert.assertFalse("Wrong equal by experimenterId", key1.equals(key2));\r
- \r
key1.setExperimenterId(expId1);\r
Assert.assertFalse("Wrong equal by experimenterId", key1.equals(key2));\r
- \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
- \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
}\r
}
\ No newline at end of file
+/*
+ * 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.impl.connection;
import static org.mockito.Mockito.when;
import io.netty.channel.Channel;
-import io.netty.channel.ChannelFuture;
import io.netty.channel.ChannelPipeline;
import java.net.InetSocketAddress;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
-
+/**
+ *
+ * @author madamjak
+ *
+ */
public class ConnectionAdapterFactoryImplTest {
@Mock ChannelPipeline channnelPipe;
@Mock Channel channel;
- @Mock ChannelFuture channelFuture;
@Mock InetSocketAddress address;
-
+
@Before
public void startUp(){
MockitoAnnotations.initMocks(this);
when(channel.pipeline()).thenReturn(channnelPipe);
- when(channel.disconnect()).thenReturn(channelFuture);
}
-
+
@Test
public void test(){
- ConnectionAdapterFactoryImpl caf = new ConnectionAdapterFactoryImpl();
- ConnectionFacade conn = caf.createConnectionFacade(channel, address);
-
- // otestovat isAlive
+ ConnectionAdapterFactoryImpl connAdapterFactory = new ConnectionAdapterFactoryImpl();
+ ConnectionFacade connFacade = connAdapterFactory.createConnectionFacade(channel, address);
+ Assert.assertNotNull("Wrong - ConnectionFacade has not created.", connFacade);
+ Assert.assertEquals("Wrong - diffrence between channel.isOpen() and ConnectionFacade.isAlive()", channel.isOpen(), connFacade.isAlive());
}
}
--- /dev/null
+/*
+ * 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.impl.deserialization;
+
+import org.junit.Assert;
+import org.junit.Test;
+import org.opendaylight.openflowjava.protocol.api.extensibility.MessageCodeKey;
+import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants;
+import org.opendaylight.openflowjava.protocol.impl.util.MatchDeserializer;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.match.grouping.Match;
+/**
+ *
+ * @author madamjak
+ *
+ */
+public class DeserializerRegistryImplTest {
+
+ private static final short OF13 = EncodeConstants.OF13_VERSION_ID;
+ private static final short OF10 = EncodeConstants.OF10_VERSION_ID;
+ public static final int EMPTY_VALUE = EncodeConstants.EMPTY_VALUE;
+
+ /**
+ * Test - register deserializer without arguments
+ */
+ @Test(expected = IllegalArgumentException.class)
+ public void testRegisterDeserializerNoArgs(){
+ DeserializerRegistryImpl serReg = new DeserializerRegistryImpl();
+ serReg.registerDeserializer(null, null);
+ }
+
+ /**
+ * Test - unregister deserializer without MessageTypeKye
+ */
+ @Test(expected = IllegalArgumentException.class)
+ public void testUnRegisterDeserializerNoMessageTypeKey(){
+ DeserializerRegistryImpl derserReg = new DeserializerRegistryImpl();
+ derserReg.init();
+ derserReg.registerDeserializer(new MessageCodeKey(OF13,EMPTY_VALUE, Match.class), new MatchDeserializer());
+ derserReg.unregisterDeserializer(null);
+ }
+
+ /**
+ * Test - unregister deserializer
+ */
+ @Test
+ public void testUnRegisterDeserializer(){
+ DeserializerRegistryImpl derserReg = new DeserializerRegistryImpl();
+ derserReg.init();
+ derserReg.registerDeserializer(new MessageCodeKey(OF13,EMPTY_VALUE, Match.class), new MatchDeserializer());
+ Assert.assertTrue("Wrong - unregister serializer",derserReg.unregisterDeserializer(new MessageCodeKey(OF13,EMPTY_VALUE, Match.class)));
+ derserReg.registerDeserializer(new MessageCodeKey(OF13, EMPTY_VALUE, Match.class), new MatchDeserializer());
+ Assert.assertFalse("Wrong - unregister serializer",derserReg.unregisterDeserializer(new MessageCodeKey(OF10,EMPTY_VALUE, Match.class)));
+ }
+}
--- /dev/null
+/*
+ * 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.impl.deserialization;
+
+import junit.framework.Assert;
+import org.junit.Test;
+import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants;
+/**
+ *
+ * @author madamjak
+ *
+ */
+public class TypeToClassKeyTest {
+
+ /**
+ * Test equals
+ */
+ @Test
+ public void test(){
+ final short ver10 = EncodeConstants.OF10_VERSION_ID;
+ final short ver13 = EncodeConstants.OF13_VERSION_ID;
+ final int type1 = 1;
+ TypeToClassKey typeToClsKey10 = new TypeToClassKey(ver10,type1);
+ Assert.assertTrue("Wrong - equals to same object", typeToClsKey10.equals(typeToClsKey10));
+ Assert.assertFalse("Wrong - equals to null", typeToClsKey10.equals(null));
+ Assert.assertFalse("Wrong - equals to different class", typeToClsKey10.equals(new Object()));
+ TypeToClassKey typeToClsKey13 = new TypeToClassKey(ver13,type1);
+ Assert.assertFalse("Wrong - equals by different version", typeToClsKey13.equals(new Object()));
+ }
+}
-
/*
* Copyright (c) 2014 Pantheon Technologies s.r.o. and others. All rights reserved.
*
* Test - unregister serializer
*/
@Test
- public void testUnRegisterSerialize(){
+ public void testUnRegisterSerializer(){
SerializerRegistryImpl serReg = new SerializerRegistryImpl();
serReg.init();
serReg.registerSerializer(new MessageTypeKey<>(OF13, Match.class), new OF13MatchSerializer());