From 8894f16741c383b6995e957dd2be2f33ded6e63a Mon Sep 17 00:00:00 2001 From: dupirefr Date: Sun, 1 Mar 2020 10:58:06 +0100 Subject: [PATCH 1/8] [JAVA-134] Mockito versio update --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index a295439951..d320e989f7 100644 --- a/pom.xml +++ b/pom.xml @@ -1330,7 +1330,7 @@ 4.12 2.2 1.3 - 2.21.0 + 3.3.0 1.7.30 From 1c50dedb91031dfcebaaf7d0dcd9440e671b75d5 Mon Sep 17 00:00:00 2001 From: dupirefr Date: Mon, 2 Mar 2020 23:37:40 +0100 Subject: [PATCH 2/8] [JAVA-134] Added byte-buddy dependencies with version used by mockito to avoid versions conflict --- pom.xml | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index d320e989f7..3e8e5f7ac7 100644 --- a/pom.xml +++ b/pom.xml @@ -69,6 +69,12 @@ ${hamcrest-all.version} test + + net.bytebuddy + byte-buddy + ${byte-buddy.version} + test + org.mockito mockito-core @@ -1330,7 +1336,8 @@ 4.12 2.2 1.3 - 3.3.0 + 3.3.0 + 1.10.5 1.7.30 From 08e93e8da504fe7533ebab70b6a5047095c72cfd Mon Sep 17 00:00:00 2001 From: dupirefr Date: Sun, 8 Mar 2020 09:06:30 +0100 Subject: [PATCH 3/8] [JAVA-134] Created a powermockito module that uses version 2.21.0 version of Mockito --- testing-modules/mockito/pom.xml | 13 -------- testing-modules/pom.xml | 1 + testing-modules/powermockito/pom.xml | 33 +++++++++++++++++++ .../CollaboratorForPartialMocking.java | 0 .../CollaboratorWithFinalMethods.java | 0 .../CollaboratorWithStaticMethods.java | 0 .../introduction/LuckyNumberGenerator.java | 0 .../LuckyNumberGeneratorUnitTest.java | 0 .../introduction/PowerMockitoUnitTest.java | 2 +- 9 files changed, 35 insertions(+), 14 deletions(-) create mode 100644 testing-modules/powermockito/pom.xml rename testing-modules/{mockito => powermockito}/src/test/java/com/baeldung/powermockito/introduction/CollaboratorForPartialMocking.java (100%) rename testing-modules/{mockito => powermockito}/src/test/java/com/baeldung/powermockito/introduction/CollaboratorWithFinalMethods.java (100%) rename testing-modules/{mockito => powermockito}/src/test/java/com/baeldung/powermockito/introduction/CollaboratorWithStaticMethods.java (100%) rename testing-modules/{mockito => powermockito}/src/test/java/com/baeldung/powermockito/introduction/LuckyNumberGenerator.java (100%) rename testing-modules/{mockito => powermockito}/src/test/java/com/baeldung/powermockito/introduction/LuckyNumberGeneratorUnitTest.java (100%) rename testing-modules/{mockito => powermockito}/src/test/java/com/baeldung/powermockito/introduction/PowerMockitoUnitTest.java (98%) diff --git a/testing-modules/mockito/pom.xml b/testing-modules/mockito/pom.xml index aae3981c66..ea5ef4c322 100644 --- a/testing-modules/mockito/pom.xml +++ b/testing-modules/mockito/pom.xml @@ -44,19 +44,6 @@ - - - org.powermock - powermock-module-junit4 - ${powermock.version} - test - - - org.powermock - powermock-api-mockito2 - ${powermock.version} - test - org.springframework.boot spring-boot-starter diff --git a/testing-modules/pom.xml b/testing-modules/pom.xml index f4a8368581..e413e02e48 100644 --- a/testing-modules/pom.xml +++ b/testing-modules/pom.xml @@ -40,6 +40,7 @@ xmlunit-2 junit-4 testing-libraries + powermockito diff --git a/testing-modules/powermockito/pom.xml b/testing-modules/powermockito/pom.xml new file mode 100644 index 0000000000..fde7bfe78c --- /dev/null +++ b/testing-modules/powermockito/pom.xml @@ -0,0 +1,33 @@ + + + + testing-modules + com.baeldung + 1.0.0-SNAPSHOT + + 4.0.0 + + powermockito + + + + org.powermock + powermock-module-junit4 + ${powermock.version} + test + + + org.powermock + powermock-api-mockito2 + ${powermock.version} + test + + + + + 2.21.0 + 2.0.2 + + \ No newline at end of file diff --git a/testing-modules/mockito/src/test/java/com/baeldung/powermockito/introduction/CollaboratorForPartialMocking.java b/testing-modules/powermockito/src/test/java/com/baeldung/powermockito/introduction/CollaboratorForPartialMocking.java similarity index 100% rename from testing-modules/mockito/src/test/java/com/baeldung/powermockito/introduction/CollaboratorForPartialMocking.java rename to testing-modules/powermockito/src/test/java/com/baeldung/powermockito/introduction/CollaboratorForPartialMocking.java diff --git a/testing-modules/mockito/src/test/java/com/baeldung/powermockito/introduction/CollaboratorWithFinalMethods.java b/testing-modules/powermockito/src/test/java/com/baeldung/powermockito/introduction/CollaboratorWithFinalMethods.java similarity index 100% rename from testing-modules/mockito/src/test/java/com/baeldung/powermockito/introduction/CollaboratorWithFinalMethods.java rename to testing-modules/powermockito/src/test/java/com/baeldung/powermockito/introduction/CollaboratorWithFinalMethods.java diff --git a/testing-modules/mockito/src/test/java/com/baeldung/powermockito/introduction/CollaboratorWithStaticMethods.java b/testing-modules/powermockito/src/test/java/com/baeldung/powermockito/introduction/CollaboratorWithStaticMethods.java similarity index 100% rename from testing-modules/mockito/src/test/java/com/baeldung/powermockito/introduction/CollaboratorWithStaticMethods.java rename to testing-modules/powermockito/src/test/java/com/baeldung/powermockito/introduction/CollaboratorWithStaticMethods.java diff --git a/testing-modules/mockito/src/test/java/com/baeldung/powermockito/introduction/LuckyNumberGenerator.java b/testing-modules/powermockito/src/test/java/com/baeldung/powermockito/introduction/LuckyNumberGenerator.java similarity index 100% rename from testing-modules/mockito/src/test/java/com/baeldung/powermockito/introduction/LuckyNumberGenerator.java rename to testing-modules/powermockito/src/test/java/com/baeldung/powermockito/introduction/LuckyNumberGenerator.java diff --git a/testing-modules/mockito/src/test/java/com/baeldung/powermockito/introduction/LuckyNumberGeneratorUnitTest.java b/testing-modules/powermockito/src/test/java/com/baeldung/powermockito/introduction/LuckyNumberGeneratorUnitTest.java similarity index 100% rename from testing-modules/mockito/src/test/java/com/baeldung/powermockito/introduction/LuckyNumberGeneratorUnitTest.java rename to testing-modules/powermockito/src/test/java/com/baeldung/powermockito/introduction/LuckyNumberGeneratorUnitTest.java diff --git a/testing-modules/mockito/src/test/java/com/baeldung/powermockito/introduction/PowerMockitoUnitTest.java b/testing-modules/powermockito/src/test/java/com/baeldung/powermockito/introduction/PowerMockitoUnitTest.java similarity index 98% rename from testing-modules/mockito/src/test/java/com/baeldung/powermockito/introduction/PowerMockitoUnitTest.java rename to testing-modules/powermockito/src/test/java/com/baeldung/powermockito/introduction/PowerMockitoUnitTest.java index 4943b0486a..1b2bb99896 100644 --- a/testing-modules/mockito/src/test/java/com/baeldung/powermockito/introduction/PowerMockitoUnitTest.java +++ b/testing-modules/powermockito/src/test/java/com/baeldung/powermockito/introduction/PowerMockitoUnitTest.java @@ -68,7 +68,7 @@ public class PowerMockitoUnitTest { when(mock.finalMethod()).thenReturn("I am a final mock method."); returnValue = mock.finalMethod(); - verify(mock,times(3)).finalMethod(); + verify(mock).finalMethod(); assertEquals("I am a final mock method.", returnValue); when(mock, "privateMethod").thenReturn("I am a private mock method."); From 4226bdc983fcdfbd37d8a598369757290d49b58e Mon Sep 17 00:00:00 2001 From: dupirefr Date: Tue, 10 Mar 2020 08:03:40 +0100 Subject: [PATCH 4/8] [JAVA-134] Retrograding Mockito and Byte-Buddy versions for ejb-beans module as they conflict with dependencies of this module --- spring-ejb/ejb-beans/pom.xml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/spring-ejb/ejb-beans/pom.xml b/spring-ejb/ejb-beans/pom.xml index eecf8c1d23..c9edfc21f8 100644 --- a/spring-ejb/ejb-beans/pom.xml +++ b/spring-ejb/ejb-beans/pom.xml @@ -121,6 +121,8 @@ 5.2.3.RELEASE 5.10.2 5.13.1 + 2.21.0 + 1.8.5 From fb8f9f1f6237388ffc964ba4a5b06c3665d831bd Mon Sep 17 00:00:00 2001 From: dupirefr Date: Tue, 10 Mar 2020 08:09:57 +0100 Subject: [PATCH 5/8] [JAVA-134] Creating README.md in new powermockito module --- testing-modules/mockito/README.md | 2 -- testing-modules/powermockito/README.md | 3 +++ 2 files changed, 3 insertions(+), 2 deletions(-) create mode 100644 testing-modules/powermockito/README.md diff --git a/testing-modules/mockito/README.md b/testing-modules/mockito/README.md index 7cef9ee8f6..5f307c2f0b 100644 --- a/testing-modules/mockito/README.md +++ b/testing-modules/mockito/README.md @@ -8,8 +8,6 @@ - [Mockito When/Then Cookbook](https://www.baeldung.com/mockito-behavior) - [Getting Started with Mockito @Mock, @Spy, @Captor and @InjectMocks](https://www.baeldung.com/mockito-annotations) - [Mockito’s Mock Methods](https://www.baeldung.com/mockito-mock-methods) -- [Introduction to PowerMock](https://www.baeldung.com/intro-to-powermock) -- [Mocking of Private Methods Using PowerMock](https://www.baeldung.com/powermock-private-method) - [Mocking Exception Throwing using Mockito](https://www.baeldung.com/mockito-exceptions) - [Mocking Void Methods with Mockito](https://www.baeldung.com/mockito-void-methods) - [Mock Final Classes and Methods with Mockito](https://www.baeldung.com/mockito-final) diff --git a/testing-modules/powermockito/README.md b/testing-modules/powermockito/README.md new file mode 100644 index 0000000000..df9fb0088c --- /dev/null +++ b/testing-modules/powermockito/README.md @@ -0,0 +1,3 @@ +### Relevant Articles: +- [Introduction to PowerMock](https://www.baeldung.com/intro-to-powermock) +- [Mocking of Private Methods Using PowerMock](https://www.baeldung.com/powermock-private-method) From a2c7348831e548bd880e32ac4c1824a063409c27 Mon Sep 17 00:00:00 2001 From: dupirefr Date: Wed, 18 Mar 2020 08:17:19 +0100 Subject: [PATCH 6/8] [JAVA-134] Renamed powermockito module to powermock --- testing-modules/{powermockito => powermock}/README.md | 0 testing-modules/{powermockito => powermock}/pom.xml | 0 .../powermockito/introduction/CollaboratorForPartialMocking.java | 0 .../powermockito/introduction/CollaboratorWithFinalMethods.java | 0 .../powermockito/introduction/CollaboratorWithStaticMethods.java | 0 .../baeldung/powermockito/introduction/LuckyNumberGenerator.java | 0 .../powermockito/introduction/LuckyNumberGeneratorUnitTest.java | 0 .../baeldung/powermockito/introduction/PowerMockitoUnitTest.java | 0 8 files changed, 0 insertions(+), 0 deletions(-) rename testing-modules/{powermockito => powermock}/README.md (100%) rename testing-modules/{powermockito => powermock}/pom.xml (100%) rename testing-modules/{powermockito => powermock}/src/test/java/com/baeldung/powermockito/introduction/CollaboratorForPartialMocking.java (100%) rename testing-modules/{powermockito => powermock}/src/test/java/com/baeldung/powermockito/introduction/CollaboratorWithFinalMethods.java (100%) rename testing-modules/{powermockito => powermock}/src/test/java/com/baeldung/powermockito/introduction/CollaboratorWithStaticMethods.java (100%) rename testing-modules/{powermockito => powermock}/src/test/java/com/baeldung/powermockito/introduction/LuckyNumberGenerator.java (100%) rename testing-modules/{powermockito => powermock}/src/test/java/com/baeldung/powermockito/introduction/LuckyNumberGeneratorUnitTest.java (100%) rename testing-modules/{powermockito => powermock}/src/test/java/com/baeldung/powermockito/introduction/PowerMockitoUnitTest.java (100%) diff --git a/testing-modules/powermockito/README.md b/testing-modules/powermock/README.md similarity index 100% rename from testing-modules/powermockito/README.md rename to testing-modules/powermock/README.md diff --git a/testing-modules/powermockito/pom.xml b/testing-modules/powermock/pom.xml similarity index 100% rename from testing-modules/powermockito/pom.xml rename to testing-modules/powermock/pom.xml diff --git a/testing-modules/powermockito/src/test/java/com/baeldung/powermockito/introduction/CollaboratorForPartialMocking.java b/testing-modules/powermock/src/test/java/com/baeldung/powermockito/introduction/CollaboratorForPartialMocking.java similarity index 100% rename from testing-modules/powermockito/src/test/java/com/baeldung/powermockito/introduction/CollaboratorForPartialMocking.java rename to testing-modules/powermock/src/test/java/com/baeldung/powermockito/introduction/CollaboratorForPartialMocking.java diff --git a/testing-modules/powermockito/src/test/java/com/baeldung/powermockito/introduction/CollaboratorWithFinalMethods.java b/testing-modules/powermock/src/test/java/com/baeldung/powermockito/introduction/CollaboratorWithFinalMethods.java similarity index 100% rename from testing-modules/powermockito/src/test/java/com/baeldung/powermockito/introduction/CollaboratorWithFinalMethods.java rename to testing-modules/powermock/src/test/java/com/baeldung/powermockito/introduction/CollaboratorWithFinalMethods.java diff --git a/testing-modules/powermockito/src/test/java/com/baeldung/powermockito/introduction/CollaboratorWithStaticMethods.java b/testing-modules/powermock/src/test/java/com/baeldung/powermockito/introduction/CollaboratorWithStaticMethods.java similarity index 100% rename from testing-modules/powermockito/src/test/java/com/baeldung/powermockito/introduction/CollaboratorWithStaticMethods.java rename to testing-modules/powermock/src/test/java/com/baeldung/powermockito/introduction/CollaboratorWithStaticMethods.java diff --git a/testing-modules/powermockito/src/test/java/com/baeldung/powermockito/introduction/LuckyNumberGenerator.java b/testing-modules/powermock/src/test/java/com/baeldung/powermockito/introduction/LuckyNumberGenerator.java similarity index 100% rename from testing-modules/powermockito/src/test/java/com/baeldung/powermockito/introduction/LuckyNumberGenerator.java rename to testing-modules/powermock/src/test/java/com/baeldung/powermockito/introduction/LuckyNumberGenerator.java diff --git a/testing-modules/powermockito/src/test/java/com/baeldung/powermockito/introduction/LuckyNumberGeneratorUnitTest.java b/testing-modules/powermock/src/test/java/com/baeldung/powermockito/introduction/LuckyNumberGeneratorUnitTest.java similarity index 100% rename from testing-modules/powermockito/src/test/java/com/baeldung/powermockito/introduction/LuckyNumberGeneratorUnitTest.java rename to testing-modules/powermock/src/test/java/com/baeldung/powermockito/introduction/LuckyNumberGeneratorUnitTest.java diff --git a/testing-modules/powermockito/src/test/java/com/baeldung/powermockito/introduction/PowerMockitoUnitTest.java b/testing-modules/powermock/src/test/java/com/baeldung/powermockito/introduction/PowerMockitoUnitTest.java similarity index 100% rename from testing-modules/powermockito/src/test/java/com/baeldung/powermockito/introduction/PowerMockitoUnitTest.java rename to testing-modules/powermock/src/test/java/com/baeldung/powermockito/introduction/PowerMockitoUnitTest.java From 27620bb3e7a9cc885282d53a4baf5c3f398941d8 Mon Sep 17 00:00:00 2001 From: dupirefr Date: Thu, 19 Mar 2020 08:05:23 +0100 Subject: [PATCH 7/8] [JAVA-134] Actually renamed that module since IntelliJ didn't do it right the first time --- testing-modules/pom.xml | 2 +- testing-modules/powermock/pom.xml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/testing-modules/pom.xml b/testing-modules/pom.xml index e413e02e48..951909b36f 100644 --- a/testing-modules/pom.xml +++ b/testing-modules/pom.xml @@ -40,7 +40,7 @@ xmlunit-2 junit-4 testing-libraries - powermockito + powermock diff --git a/testing-modules/powermock/pom.xml b/testing-modules/powermock/pom.xml index fde7bfe78c..21b2e98af0 100644 --- a/testing-modules/powermock/pom.xml +++ b/testing-modules/powermock/pom.xml @@ -9,7 +9,7 @@ 4.0.0 - powermockito + powermock From c6bd70983692310fc828db21210ab0d527ef7ea9 Mon Sep 17 00:00:00 2001 From: dupirefr Date: Thu, 19 Mar 2020 20:30:57 +0100 Subject: [PATCH 8/8] [JAVA-134] Fixed whitespacing in parent pom.xml --- pom.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pom.xml b/pom.xml index 3e8e5f7ac7..443d79a355 100644 --- a/pom.xml +++ b/pom.xml @@ -1336,8 +1336,8 @@ 4.12 2.2 1.3 - 3.3.0 - 1.10.5 + 3.3.0 + 1.10.5 1.7.30