Bug 1254 - added test of basic funcionality for ErrorHandlerSimpleImpl 58/11758/2
authorMartin Bobak <mbobak@cisco.com>
Mon, 6 Oct 2014 10:52:12 +0000 (12:52 +0200)
committermichal rehak <mirehak@cisco.com>
Sun, 12 Oct 2014 20:07:05 +0000 (20:07 +0000)
Change-Id: Ide8c121d0bef3807aa707eafa36a8de156fe7522
Signed-off-by: Martin Bobak <mbobak@cisco.com>
openflowplugin/src/test/java/org/opendaylight/openflowplugin/openflow/md/core/ErrorHandlerSimpleImplTest.java [new file with mode: 0644]

diff --git a/openflowplugin/src/test/java/org/opendaylight/openflowplugin/openflow/md/core/ErrorHandlerSimpleImplTest.java b/openflowplugin/src/test/java/org/opendaylight/openflowplugin/openflow/md/core/ErrorHandlerSimpleImplTest.java
new file mode 100644 (file)
index 0000000..4cfaf0c
--- /dev/null
@@ -0,0 +1,46 @@
+/*
+ * Copyright (c) 2014 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.openflow.md.core;
+
+import static org.mockito.Mockito.when;
+
+import junit.framework.TestCase;
+import org.junit.Before;
+import org.junit.Test;
+import org.mockito.MockitoAnnotations;
+import org.opendaylight.openflowplugin.ConnectionException;
+import org.opendaylight.openflowplugin.openflow.md.core.session.SessionContext;
+import org.opendaylight.openflowplugin.openflow.md.core.session.SwitchSessionKeyOF;
+
+public class ErrorHandlerSimpleImplTest extends TestCase {
+
+    ErrorHandler errorHandler = new ErrorHandlerSimpleImpl();
+
+    @MockitoAnnotations.Mock
+    SessionContext sessionContext;
+
+    @MockitoAnnotations.Mock
+    SwitchSessionKeyOF switchSessionKeyOF;
+
+    @Before
+    public void setup() {
+        when(sessionContext.getSessionKey()).thenReturn(switchSessionKeyOF);
+        when(switchSessionKeyOF.getId()).thenReturn(new byte[0]);
+    }
+
+    @Test
+    public void testHandleException() throws Exception {
+        ConnectionException connectionException = new ConnectionException("Exception for testing purpose only.");
+        errorHandler.handleException(connectionException, sessionContext);
+
+        Exception someException = new Exception("Exception for testing purpose only.");
+        errorHandler.handleException(someException, sessionContext);
+
+    }
+}
\ No newline at end of file