Bug 1764 - moved Session related interfaces to openflowplugin-api
[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.api.openflow.md.core.ErrorHandler;
19 import org.opendaylight.openflowplugin.api.openflow.md.core.session.SessionContext;
20 import org.opendaylight.openflowplugin.api.openflow.md.core.session.SwitchSessionKeyOF;
21
22 public class ErrorHandlerSimpleImplTest extends TestCase {
23
24     ErrorHandler errorHandler = new ErrorHandlerSimpleImpl();
25
26     @MockitoAnnotations.Mock
27     SessionContext sessionContext;
28
29     @MockitoAnnotations.Mock
30     SwitchSessionKeyOF switchSessionKeyOF;
31
32     @Before
33     public void setup() {
34         when(sessionContext.getSessionKey()).thenReturn(switchSessionKeyOF);
35         when(switchSessionKeyOF.getId()).thenReturn(new byte[0]);
36     }
37
38     @Test
39     public void testHandleException() throws Exception {
40         ConnectionException connectionException = new ConnectionException("Exception for testing purpose only.");
41         errorHandler.handleException(connectionException, sessionContext);
42
43         Exception someException = new Exception("Exception for testing purpose only.");
44         errorHandler.handleException(someException, sessionContext);
45
46     }
47 }