From 625e10cedf80401033029e013dd81a0fd324ac3c Mon Sep 17 00:00:00 2001 From: Martin Bobak Date: Mon, 6 Oct 2014 12:52:12 +0200 Subject: [PATCH] Bug 1254 - added test of basic funcionality for ErrorHandlerSimpleImpl Change-Id: Ide8c121d0bef3807aa707eafa36a8de156fe7522 Signed-off-by: Martin Bobak --- .../md/core/ErrorHandlerSimpleImplTest.java | 46 +++++++++++++++++++ 1 file changed, 46 insertions(+) create mode 100644 openflowplugin/src/test/java/org/opendaylight/openflowplugin/openflow/md/core/ErrorHandlerSimpleImplTest.java 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 index 0000000000..4cfaf0c2e6 --- /dev/null +++ b/openflowplugin/src/test/java/org/opendaylight/openflowplugin/openflow/md/core/ErrorHandlerSimpleImplTest.java @@ -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 -- 2.36.6