Add new tests, fix several mistakes, add and edit copyright comments
[openflowjava.git] / openflow-protocol-impl / src / test / java / org / opendaylight / openflowjava / protocol / impl / connection / ConnectionAdapterFactoryImplTest.java
index ae6d0ac97d6b02379017d9264d25b0d04dc90bfa..010953b3e9d1f0595ae7623f796d6992f026bc70 100644 (file)
@@ -1,8 +1,14 @@
+/*
+ * 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;
@@ -12,26 +18,28 @@ import org.mockito.MockitoAnnotations;
 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());
     }
 }