Bug 1254 - added test of basic funcionality for ErrorHandlerSimpleImpl
[openflowplugin.git] / openflowplugin / src / test / java / org / opendaylight / openflowplugin / openflow / md / core / ErrorHandlerSimpleImplTest.java
1 /*
2  * Copyright (c) 2014 Cisco Systems, Inc. and others.  All rights reserved.
3  *
4  * This program and the accompanying materials are made available under the
5  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6  * and is available at http://www.eclipse.org/legal/epl-v10.html
7  */
8
9 package org.opendaylight.openflowplugin.openflow.md.core;
10
11 import static org.mockito.Mockito.when;
12
13 import junit.framework.TestCase;
14 import org.junit.Before;
15 import org.junit.Test;
16 import org.mockito.MockitoAnnotations;
17 import org.opendaylight.openflowplugin.ConnectionException;
18 import org.opendaylight.openflowplugin.openflow.md.core.session.SessionContext;
19 import org.opendaylight.openflowplugin.openflow.md.core.session.SwitchSessionKeyOF;
20
21 public class ErrorHandlerSimpleImplTest extends TestCase {
22
23     ErrorHandler errorHandler = new ErrorHandlerSimpleImpl();
24
25     @MockitoAnnotations.Mock
26     SessionContext sessionContext;
27
28     @MockitoAnnotations.Mock
29     SwitchSessionKeyOF switchSessionKeyOF;
30
31     @Before
32     public void setup() {
33         when(sessionContext.getSessionKey()).thenReturn(switchSessionKeyOF);
34         when(switchSessionKeyOF.getId()).thenReturn(new byte[0]);
35     }
36
37     @Test
38     public void testHandleException() throws Exception {
39         ConnectionException connectionException = new ConnectionException("Exception for testing purpose only.");
40         errorHandler.handleException(connectionException, sessionContext);
41
42         Exception someException = new Exception("Exception for testing purpose only.");
43         errorHandler.handleException(someException, sessionContext);
44
45     }
46 }