⬆️ Upgrade Mockito to 4.11.0
authorDavid ‘Bombe’ Roden <bombe@freenetproject.org>
Fri, 13 Oct 2023 21:41:53 +0000 (23:41 +0200)
committerDavid ‘Bombe’ Roden <bombe@freenetproject.org>
Fri, 13 Oct 2023 21:41:53 +0000 (23:41 +0200)
This is the latest version that will run with Java 8, and as long as I’m not
distributing my own JVM with jSite, Java 8 support is still required because
Freenet is using Java 8.

build.gradle
src/test/java/de/todesbaum/jsite/application/Freenet7InterfaceTest.java

index 47905ef..bb21b70 100644 (file)
@@ -13,7 +13,7 @@ dependencies {
 
     testCompile group: 'junit', name: 'junit', version: '4.12'
     testCompile group: 'org.hamcrest', name: 'hamcrest-library', version: '1.3'
-    testCompile group: 'org.mockito', name: 'mockito-core', version: '1.10.19'
+    testCompile group: 'org.mockito', name: 'mockito-core', version: '4.11.0'
 }
 
 sourceCompatibility = 1.8
index 1f19977..3365327 100644 (file)
@@ -2,10 +2,10 @@ package de.todesbaum.jsite.application;
 
 import static org.hamcrest.MatcherAssert.assertThat;
 import static org.hamcrest.Matchers.is;
-import static org.mockito.Matchers.any;
-import static org.mockito.Matchers.anyInt;
-import static org.mockito.Matchers.anyString;
-import static org.mockito.Matchers.eq;
+import static org.mockito.ArgumentMatchers.anyString;
+import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.ArgumentMatchers.anyInt;
+import static org.mockito.ArgumentMatchers.eq;
 import static org.mockito.Mockito.doThrow;
 import static org.mockito.Mockito.mock;
 import static org.mockito.Mockito.verify;
@@ -106,7 +106,7 @@ public class Freenet7InterfaceTest {
        @Test
        public void newConnectionCanBeCreated() {
                Connection connection = mock(Connection.class);
-               when(connectionSupplier.supply(any(Node.class), eq(IDENTIFIER))).thenReturn(connection);
+               when(connectionSupplier.supply(any(), eq(IDENTIFIER))).thenReturn(connection);
                Connection returnedConnection = freenet7Interface.getConnection(IDENTIFIER);
                assertThat(returnedConnection, is(connection));
        }
@@ -119,8 +119,8 @@ public class Freenet7InterfaceTest {
        @Test
        public void interfaceHasNodeOnceANodeWasSet() {
                Connection connection = mock(Connection.class);
-               when(nodeSupplier.supply(anyString(), anyInt())).thenReturn(mock(Node.class));
-               when(connectionSupplier.supply(any(Node.class), anyString())).thenReturn(connection);
+               when(nodeSupplier.supply(any(), anyInt())).thenReturn(mock(Node.class));
+               when(connectionSupplier.supply(any(), anyString())).thenReturn(connection);
                freenet7Interface.setNode(mock(Node.class));
                assertThat(freenet7Interface.hasNode(), is(true));
        }
@@ -128,8 +128,8 @@ public class Freenet7InterfaceTest {
        @Test
        public void interfaceHasNoNodeIfNodeIsSetToNull() {
                Connection connection = mock(Connection.class);
-               when(nodeSupplier.supply(anyString(), anyInt())).thenReturn(mock(Node.class));
-               when(connectionSupplier.supply(any(Node.class), anyString())).thenReturn(connection);
+               when(nodeSupplier.supply(any(), anyInt())).thenReturn(mock(Node.class));
+               when(connectionSupplier.supply(any(), anyString())).thenReturn(connection);
                freenet7Interface.setNode(mock(Node.class));
                freenet7Interface.setNode(null);
                assertThat(freenet7Interface.hasNode(), is(false));
@@ -140,7 +140,7 @@ public class Freenet7InterfaceTest {
        public void nodeIsPresentIfConnectionIsConnected() throws IOException {
                Connection connection = mock(Connection.class);
                when(connection.isConnected()).thenReturn(true);
-               when(connectionSupplier.supply(any(Node.class), anyString())).thenReturn(connection);
+               when(connectionSupplier.supply(any(), anyString())).thenReturn(connection);
                freenet7Interface.setNode(mock(Node.class));
                assertThat(freenet7Interface.isNodePresent(), is(true));
        }
@@ -149,7 +149,7 @@ public class Freenet7InterfaceTest {
        public void nodeIsPresentIfConnectionCanBeCreated() throws IOException {
                Connection connection = mock(Connection.class);
                when(connection.connect()).thenReturn(true);
-               when(connectionSupplier.supply(any(Node.class), anyString())).thenReturn(connection);
+               when(connectionSupplier.supply(any(), anyString())).thenReturn(connection);
                freenet7Interface.setNode(mock(Node.class));
                assertThat(freenet7Interface.isNodePresent(), is(true));
        }
@@ -158,7 +158,7 @@ public class Freenet7InterfaceTest {
        public void exceptionIsThrownIfNodeIsNotPresentAndConnectionCanNotBeCreated() throws IOException {
                Connection connection = mock(Connection.class);
                doThrow(IOException.class).when(connection).connect();
-               when(connectionSupplier.supply(any(Node.class), anyString())).thenReturn(connection);
+               when(connectionSupplier.supply(any(), anyString())).thenReturn(connection);
                freenet7Interface.setNode(mock(Node.class));
                expectedException.expect(IOException.class);
                freenet7Interface.isNodePresent();
@@ -167,7 +167,7 @@ public class Freenet7InterfaceTest {
        @Test
        public void keyPairIsNotGeneratedIfNodeIsNotPresent() throws IOException {
                Connection connection = mock(Connection.class);
-               when(connectionSupplier.supply(any(Node.class), anyString())).thenReturn(connection);
+               when(connectionSupplier.supply(any(), anyString())).thenReturn(connection);
                freenet7Interface.setNode(mock(Node.class));
                expectedException.expect(IOException.class);
                freenet7Interface.generateKeyPair();
@@ -177,7 +177,7 @@ public class Freenet7InterfaceTest {
        public void keyPairIsGeneratedSuccessfully() throws IOException {
                Connection connection = mock(Connection.class);
                when(connection.isConnected()).thenReturn(true);
-               when(connectionSupplier.supply(any(Node.class), anyString())).thenReturn(connection);
+               when(connectionSupplier.supply(any(), anyString())).thenReturn(connection);
                freenet7Interface.setNode(mock(Node.class));
                Message message = new Message("SSKKeyPair");
                message.put("InsertURI", INSERT_URI);