From e52a68ae65cefe8c626f1ce6e4fa5ecf4995c47f Mon Sep 17 00:00:00 2001 From: =?utf8?q?David=20=E2=80=98Bombe=E2=80=99=20Roden?= Date: Fri, 13 Oct 2023 23:41:53 +0200 Subject: [PATCH] =?utf8?q?=E2=AC=86=EF=B8=8F=20Upgrade=20Mockito=20to=204.?= =?utf8?q?11.0?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit 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 | 2 +- .../jsite/application/Freenet7InterfaceTest.java | 28 +++++++++++----------- 2 files changed, 15 insertions(+), 15 deletions(-) diff --git a/build.gradle b/build.gradle index 47905ef..bb21b70 100644 --- a/build.gradle +++ b/build.gradle @@ -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 diff --git a/src/test/java/de/todesbaum/jsite/application/Freenet7InterfaceTest.java b/src/test/java/de/todesbaum/jsite/application/Freenet7InterfaceTest.java index 1f19977..3365327 100644 --- a/src/test/java/de/todesbaum/jsite/application/Freenet7InterfaceTest.java +++ b/src/test/java/de/todesbaum/jsite/application/Freenet7InterfaceTest.java @@ -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); -- 2.7.4