Fix Mockito initMocks deprecation warnings
[transportpce.git] / servicehandler / src / test / java / org / opendaylight / transportpce / servicehandler / service / PCEServiceWrapperTest.java
index 30898a1bdcb21c58e765aa9200a5f6e96c02802f..8dab0884732a94b5227f0acdbb2cd30a055f450e 100644 (file)
@@ -11,6 +11,7 @@ import static org.mockito.ArgumentMatchers.any;
 import static org.mockito.Mockito.verify;
 
 import com.google.common.util.concurrent.ListenableFuture;
+import org.junit.After;
 import org.junit.Assert;
 import org.junit.Before;
 import org.junit.Test;
@@ -46,9 +47,11 @@ public class PCEServiceWrapperTest extends AbstractTest {
     @InjectMocks
     private PCEServiceWrapper pceServiceWrapperMock;
 
+    private AutoCloseable closeable;
+
     @Before
-    public void init() throws NoSuchMethodException {
-        MockitoAnnotations.initMocks(this);
+    public void openMocks() throws NoSuchMethodException {
+        closeable = MockitoAnnotations.openMocks(this);
     }
 
     @Test
@@ -160,4 +163,8 @@ public class PCEServiceWrapperTest extends AbstractTest {
                 pceResponse.getConfigurationResponseCommon().getResponseMessage());
         verify(this.pathComputationServiceMock).pathComputationRequest((any(PathComputationRequestInput.class)));
     }
+
+    @After public void releaseMocks() throws Exception {
+        closeable.close();
+    }
 }