2 * Copyright (c) 2017 Pantheon Technologies s.r.o. and others. All rights reserved.
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
9 package org.opendaylight.openflowplugin.impl.services.util;
11 import static org.mockito.ArgumentMatchers.any;
12 import static org.mockito.Mockito.doThrow;
13 import static org.mockito.Mockito.verify;
14 import static org.mockito.Mockito.verifyNoMoreInteractions;
16 import org.junit.After;
17 import org.junit.Test;
18 import org.junit.runner.RunWith;
19 import org.mockito.Mock;
20 import org.mockito.runners.MockitoJUnitRunner;
21 import org.opendaylight.openflowplugin.api.openflow.device.RequestContext;
23 @RunWith(MockitoJUnitRunner.class)
24 public class RequestContextUtilTest {
26 private RequestContext<Void> requestContext;
29 public void tearDown() throws Exception {
30 verifyNoMoreInteractions(requestContext);
34 public void closeRequestContextWithRpcError() throws Exception {
35 final String errorMessage = "Test error";
36 RequestContextUtil.closeRequestContextWithRpcError(
40 verify(requestContext).setResult(any());
41 verify(requestContext).getFuture();
42 verify(requestContext).close();
46 public void closeRequestContext() throws Exception {
47 doThrow(new IllegalStateException()).when(requestContext).close();
48 RequestContextUtil.closeRequestContext(requestContext);
49 verify(requestContext).close();