BUG-4763 Green unit tests with exceptions 99/31199/1
authorJozef Bacigal <jbacigal@cisco.com>
Fri, 11 Dec 2015 15:21:45 +0000 (16:21 +0100)
committerJozef Bacigal <jbacigal@cisco.com>
Fri, 11 Dec 2015 15:33:22 +0000 (16:33 +0100)
Change-Id: I92e6ebb2ffcdcabcecfabe5ab9b341e68739a373
Signed-off-by: Jozef Bacigal <jbacigal@cisco.com>
openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/device/DeviceContextImplTest.java
openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/services/NodeConfigServiceImplTest.java

index 7c918a839a5702245dfd0f7b1747f9054dcdb951..34ee686fd872201c267b2a2319c7e7a6daac3710 100644 (file)
@@ -1,3 +1,11 @@
+/*
+ * Copyright (c) 2015 Cisco Systems, Inc. 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.openflowplugin.impl.device;
 
 import static org.junit.Assert.assertEquals;
@@ -16,9 +24,6 @@ import com.google.common.util.concurrent.ListenableFuture;
 import com.google.common.util.concurrent.SettableFuture;
 import io.netty.util.HashedWheelTimer;
 import io.netty.util.Timeout;
-import java.math.BigInteger;
-import java.net.InetSocketAddress;
-import java.util.concurrent.atomic.AtomicLong;
 import org.junit.Assert;
 import org.junit.Before;
 import org.junit.Test;
@@ -97,6 +102,9 @@ import org.opendaylight.yangtools.yang.binding.KeyedInstanceIdentifier;
 import org.opendaylight.yangtools.yang.common.RpcResult;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
+import java.math.BigInteger;
+import java.net.InetSocketAddress;
+import java.util.concurrent.atomic.AtomicLong;
 
 @RunWith(MockitoJUnitRunner.class)
 public class DeviceContextImplTest {
@@ -359,7 +367,7 @@ public class DeviceContextImplTest {
     @Test
     public void testClose() {
         ConnectionAdapter mockedConnectionAdapter = mock(ConnectionAdapter.class);
-        InetSocketAddress mockRemoteAddress = mock(InetSocketAddress.class);
+        InetSocketAddress mockRemoteAddress = InetSocketAddress.createUnresolved("odl-unit.example.org",999);
         when(mockedConnectionAdapter.getRemoteAddress()).thenReturn(mockRemoteAddress);
         when(connectionContext.getConnectionAdapter()).thenReturn(mockedConnectionAdapter);
 
index d4e564b792833f558faaec731c6178bf84da5dc8..b33beb40553ace5b68c12d6e44b1ef38e77f16d8 100644 (file)
@@ -1,16 +1,24 @@
+/*
+ * Copyright (c) 2015 Cisco Systems, Inc. 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.openflowplugin.impl.services;
 
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+import static org.mockito.Mockito.verify;
+
 import org.junit.Test;
 import org.opendaylight.openflowplugin.api.openflow.device.Xid;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.module.config.rev141015.NodeConfigService;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.module.config.rev141015.SetConfigInput;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.module.config.rev141015.SetConfigInputBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.SwitchConfigFlag;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.OfHeader;
 
-import static org.junit.Assert.*;
-import static org.mockito.Mockito.verify;
-
 public class NodeConfigServiceImplTest extends ServiceMocking{
 
     private static final Long DUMMY_XID_VALUE = 150L;
@@ -22,18 +30,14 @@ public class NodeConfigServiceImplTest extends ServiceMocking{
     @Test
     public void testSetConfig() throws Exception {
         nodeConfigService = new NodeConfigServiceImpl(mockedRequestContextStack, mockedDeviceContext);
-        SetConfigInput setConfigInput = new SetConfigInputBuilder().build();
-        nodeConfigService.setConfig(setConfigInput);
+        nodeConfigService.setConfig(dummyConfigInput());
         verify(mockedRequestContextStack).createRequestContext();
     }
 
     @Test
     public void testBuildRequest() throws Exception {
         nodeConfigService = new NodeConfigServiceImpl(mockedRequestContextStack, mockedDeviceContext);
-        SetConfigInputBuilder setConfigInputBuilder = new SetConfigInputBuilder();
-        setConfigInputBuilder.setFlag(DUMMY_FLAG_STR);
-        setConfigInputBuilder.setMissSearchLength(DUMMY_MISS_SEARCH_LENGTH);
-        final OfHeader request = nodeConfigService.buildRequest(new Xid(DUMMY_XID_VALUE), setConfigInputBuilder.build());
+        final OfHeader request = nodeConfigService.buildRequest(new Xid(DUMMY_XID_VALUE), dummyConfigInput());
 
         assertTrue(request instanceof org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.SetConfigInput);
         org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.SetConfigInput setConfigInput
@@ -42,4 +46,11 @@ public class NodeConfigServiceImplTest extends ServiceMocking{
         assertEquals(DUMMY_MISS_SEARCH_LENGTH, setConfigInput.getMissSendLen());
         assertEquals(DUMMY_XID_VALUE, setConfigInput.getXid());
     }
-}
\ No newline at end of file
+
+    private SetConfigInput dummyConfigInput(){
+        SetConfigInputBuilder setConfigInputBuilder = new SetConfigInputBuilder();
+        setConfigInputBuilder.setFlag(DUMMY_FLAG_STR);
+        setConfigInputBuilder.setMissSearchLength(DUMMY_MISS_SEARCH_LENGTH);
+        return setConfigInputBuilder.build();
+    }
+}