Skip to content

Commit fbebd93

Browse files
committed
replaced mockito-core with mockito-inline and addressed compilation error
1 parent ece0aa5 commit fbebd93

File tree

54 files changed

+94
-65
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

54 files changed

+94
-65
lines changed

hadoop-client-modules/hadoop-client-minicluster/pom.xml

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -403,7 +403,7 @@
403403
<!-- Add back in Mockito since the hadoop-hdfs test jar needs it. -->
404404
<dependency>
405405
<groupId>org.mockito</groupId>
406-
<artifactId>mockito-core</artifactId>
406+
<artifactId>mockito-inline</artifactId>
407407
<optional>true</optional>
408408
</dependency>
409409
<!-- Add back in the transitive dependencies excluded from hadoop-common in client TODO remove once we have a filter for "is in these artifacts" -->
@@ -761,7 +761,7 @@
761761

762762
<!-- Mockito tries to include its own unrelocated copy of hamcrest. :( -->
763763
<filter>
764-
<artifact>org.mockito:mockito-core</artifact>
764+
<artifact>org.mockito:mockito-inline</artifact>
765765
<excludes>
766766
<exclude>asm-license.txt</exclude>
767767
<exclude>cglib-license.txt</exclude>
@@ -773,6 +773,15 @@
773773
<exclude>org/objenesis/*.class</exclude>
774774
</excludes>
775775
</filter>
776+
<!-- Additional filters to exclude unexpected contents -->
777+
<filter>
778+
<artifact>*:*</artifact>
779+
<excludes>
780+
<exclude>mockito-extensions/**</exclude>
781+
<exclude>win32-x86/**</exclude>
782+
<exclude>win32-x86-64/**</exclude>
783+
</excludes>
784+
</filter>
776785
<!-- skip grizzly internals we don't need to run. -->
777786
<filter>
778787
<artifact>org.glassfish.grizzly:grizzly-http-servlet</artifact>

hadoop-cloud-storage-project/hadoop-huaweicloud/pom.xml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -176,12 +176,24 @@
176176
<artifactId>powermock-api-mockito</artifactId>
177177
<version>1.7.4</version>
178178
<scope>test</scope>
179+
<exclusions>
180+
<exclusion>
181+
<groupId>org.mockito</groupId>
182+
<artifactId>mockito-core</artifactId>
183+
</exclusion>
184+
</exclusions>
179185
</dependency>
180186
<dependency>
181187
<groupId>org.powermock</groupId>
182188
<artifactId>powermock-module-junit4</artifactId>
183189
<version>1.7.4</version>
184190
<scope>test</scope>
191+
<exclusions>
192+
<exclusion>
193+
<groupId>org.mockito</groupId>
194+
<artifactId>mockito-core</artifactId>
195+
</exclusion>
196+
</exclusions>
185197
</dependency>
186198
</dependencies>
187199
</project>

hadoop-common-project/hadoop-auth/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@
4848
</dependency>
4949
<dependency>
5050
<groupId>org.mockito</groupId>
51-
<artifactId>mockito-core</artifactId>
51+
<artifactId>mockito-inline</artifactId>
5252
<scope>test</scope>
5353
</dependency>
5454
<dependency>

hadoop-common-project/hadoop-common/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -245,7 +245,7 @@
245245
</dependency>
246246
<dependency>
247247
<groupId>org.mockito</groupId>
248-
<artifactId>mockito-core</artifactId>
248+
<artifactId>mockito-inline</artifactId>
249249
<scope>test</scope>
250250
</dependency>
251251
<dependency>

hadoop-common-project/hadoop-kms/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@
4545
</dependency>
4646
<dependency>
4747
<groupId>org.mockito</groupId>
48-
<artifactId>mockito-core</artifactId>
48+
<artifactId>mockito-inline</artifactId>
4949
<scope>test</scope>
5050
</dependency>
5151
<dependency>

hadoop-common-project/hadoop-nfs/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@
6060
</dependency>
6161
<dependency>
6262
<groupId>org.mockito</groupId>
63-
<artifactId>mockito-core</artifactId>
63+
<artifactId>mockito-inline</artifactId>
6464
<scope>test</scope>
6565
</dependency>
6666
<dependency>

hadoop-hdfs-project/hadoop-hdfs-client/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ https://maven.apache.org/xsd/maven-4.0.0.xsd">
6666
</dependency>
6767
<dependency>
6868
<groupId>org.mockito</groupId>
69-
<artifactId>mockito-core</artifactId>
69+
<artifactId>mockito-inline</artifactId>
7070
<scope>test</scope>
7171
</dependency>
7272
<dependency>

hadoop-hdfs-project/hadoop-hdfs-httpfs/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@
4949
</dependency>
5050
<dependency>
5151
<groupId>org.mockito</groupId>
52-
<artifactId>mockito-core</artifactId>
52+
<artifactId>mockito-inline</artifactId>
5353
<scope>test</scope>
5454
</dependency>
5555
<dependency>

hadoop-hdfs-project/hadoop-hdfs-native-client/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ https://maven.apache.org/xsd/maven-4.0.0.xsd">
6969
</dependency>
7070
<dependency>
7171
<groupId>org.mockito</groupId>
72-
<artifactId>mockito-core</artifactId>
72+
<artifactId>mockito-inline</artifactId>
7373
<scope>test</scope>
7474
</dependency>
7575
<dependency>

hadoop-hdfs-project/hadoop-hdfs-nfs/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@ https://maven.apache.org/xsd/maven-4.0.0.xsd">
160160
</dependency>
161161
<dependency>
162162
<groupId>org.mockito</groupId>
163-
<artifactId>mockito-core</artifactId>
163+
<artifactId>mockito-inline</artifactId>
164164
<scope>test</scope>
165165
</dependency>
166166
<dependency>

hadoop-hdfs-project/hadoop-hdfs-rbf/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ https://maven.apache.org/xsd/maven-4.0.0.xsd">
164164
</dependency>
165165
<dependency>
166166
<groupId>org.mockito</groupId>
167-
<artifactId>mockito-core</artifactId>
167+
<artifactId>mockito-inline</artifactId>
168168
<scope>test</scope>
169169
</dependency>
170170
<dependency>

hadoop-hdfs-project/hadoop-hdfs-rbf/src/test/java/org/apache/hadoop/hdfs/server/federation/router/TestRouterAdmin.java

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
import static org.junit.Assert.assertTrue;
2626

2727
import java.io.IOException;
28+
import java.lang.reflect.Field;
2829
import java.security.PrivilegedExceptionAction;
2930
import java.util.Collections;
3031
import java.util.HashMap;
@@ -68,7 +69,6 @@
6869
import org.junit.BeforeClass;
6970
import org.junit.Test;
7071
import org.mockito.Mockito;
71-
import org.mockito.internal.util.reflection.FieldSetter;
7272

7373
/**
7474
* The administrator interface of the {@link Router} implemented by
@@ -118,18 +118,22 @@ public static void globalSetUp() throws Exception {
118118
* @throws IOException
119119
* @throws NoSuchFieldException
120120
*/
121-
private static void setUpMocks() throws IOException, NoSuchFieldException {
121+
public static void setField(Object target, String fieldName, Object value) throws NoSuchFieldException, IllegalAccessException {
122+
Field field = target.getClass().getDeclaredField(fieldName);
123+
field.setAccessible(true);
124+
field.set(target, value);
125+
}
126+
private static void setUpMocks() throws IOException, NoSuchFieldException, IllegalAccessException {
122127
RouterRpcServer spyRpcServer =
123128
Mockito.spy(routerContext.getRouter().createRpcServer());
124-
FieldSetter.setField(routerContext.getRouter(),
125-
Router.class.getDeclaredField("rpcServer"), spyRpcServer);
129+
//Used reflection to set the 'rpcServer field'
130+
setField(routerContext.getRouter(), "rpcServer", spyRpcServer);
126131
Mockito.doReturn(null).when(spyRpcServer).getFileInfo(Mockito.anyString());
127132

128133
// mock rpc client for destination check when editing mount tables.
134+
//spy RPC client and used reflection to set the 'rpcClient' field
129135
mockRpcClient = Mockito.spy(spyRpcServer.getRPCClient());
130-
FieldSetter.setField(spyRpcServer,
131-
RouterRpcServer.class.getDeclaredField("rpcClient"),
132-
mockRpcClient);
136+
setField(spyRpcServer, "rpcClient", mockRpcClient);
133137
RemoteLocation remoteLocation0 =
134138
new RemoteLocation("ns0", "/testdir", null);
135139
RemoteLocation remoteLocation1 =

hadoop-hdfs-project/hadoop-hdfs-rbf/src/test/java/org/apache/hadoop/hdfs/server/federation/router/TestRouterRpcMultiDestination.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
import static org.junit.Assert.assertNotNull;
2525
import static org.junit.Assert.assertTrue;
2626
import static org.junit.Assert.fail;
27-
import static org.mockito.Matchers.any;
27+
import static org.mockito.ArgumentMatchers.any;
2828
import static org.mockito.Mockito.doThrow;
2929
import static org.mockito.Mockito.mock;
3030
import static org.apache.hadoop.test.Whitebox.getInternalState;

hadoop-hdfs-project/hadoop-hdfs/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ https://maven.apache.org/xsd/maven-4.0.0.xsd">
166166
</dependency>
167167
<dependency>
168168
<groupId>org.mockito</groupId>
169-
<artifactId>mockito-core</artifactId>
169+
<artifactId>mockito-inline</artifactId>
170170
<scope>test</scope>
171171
</dependency>
172172
<dependency>

hadoop-mapreduce-project/hadoop-mapreduce-client/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@
9595
</dependency>
9696
<dependency>
9797
<groupId>org.mockito</groupId>
98-
<artifactId>mockito-core</artifactId>
98+
<artifactId>mockito-inline</artifactId>
9999
<scope>test</scope>
100100
</dependency>
101101
<dependency>

hadoop-project/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1324,7 +1324,7 @@
13241324
</dependency>
13251325
<dependency>
13261326
<groupId>org.mockito</groupId>
1327-
<artifactId>mockito-core</artifactId>
1327+
<artifactId>mockito-inline</artifactId>
13281328
<version>4.11.0</version>
13291329
<exclusions>
13301330
<exclusion>

hadoop-tools/hadoop-archive-logs/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@
125125
<!-- 'mvn dependency:analyze' fails to detect use of this dependency -->
126126
<dependency>
127127
<groupId>org.mockito</groupId>
128-
<artifactId>mockito-core</artifactId>
128+
<artifactId>mockito-inline</artifactId>
129129
<scope>test</scope>
130130
</dependency>
131131
<!-- 'mvn dependency:analyze' fails to detect use of this dependency -->

hadoop-tools/hadoop-archives/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@
4141
</dependency>
4242
<dependency>
4343
<groupId>org.mockito</groupId>
44-
<artifactId>mockito-core</artifactId>
44+
<artifactId>mockito-inline</artifactId>
4545
<scope>test</scope>
4646
</dependency>
4747
<dependency>

hadoop-tools/hadoop-aws/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -528,7 +528,7 @@
528528
</dependency>
529529
<dependency>
530530
<groupId>org.mockito</groupId>
531-
<artifactId>mockito-core</artifactId>
531+
<artifactId>mockito-inline</artifactId>
532532
<scope>test</scope>
533533
</dependency>
534534
<dependency>

hadoop-tools/hadoop-azure/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -322,7 +322,7 @@
322322

323323
<dependency>
324324
<groupId>org.mockito</groupId>
325-
<artifactId>mockito-core</artifactId>
325+
<artifactId>mockito-inline</artifactId>
326326
<scope>test</scope>
327327
</dependency>
328328
<dependency>

hadoop-tools/hadoop-compat-bench/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@
6666
</dependency>
6767
<dependency>
6868
<groupId>org.mockito</groupId>
69-
<artifactId>mockito-core</artifactId>
69+
<artifactId>mockito-inline</artifactId>
7070
<scope>test</scope>
7171
</dependency>
7272
</dependencies>

hadoop-tools/hadoop-datajoin/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@
4141
</dependency>
4242
<dependency>
4343
<groupId>org.mockito</groupId>
44-
<artifactId>mockito-core</artifactId>
44+
<artifactId>mockito-inline</artifactId>
4545
<scope>test</scope>
4646
</dependency>
4747
<dependency>

hadoop-tools/hadoop-distcp/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@
106106
</dependency>
107107
<dependency>
108108
<groupId>org.mockito</groupId>
109-
<artifactId>mockito-core</artifactId>
109+
<artifactId>mockito-inline</artifactId>
110110
<scope>test</scope>
111111
</dependency>
112112
<dependency>

hadoop-tools/hadoop-dynamometer/hadoop-dynamometer-blockgen/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636
</dependency>
3737
<dependency>
3838
<groupId>org.mockito</groupId>
39-
<artifactId>mockito-core</artifactId>
39+
<artifactId>mockito-inline</artifactId>
4040
<scope>test</scope>
4141
</dependency>
4242
<dependency>

hadoop-tools/hadoop-dynamometer/hadoop-dynamometer-infra/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@
8080
</dependency>
8181
<dependency>
8282
<groupId>org.mockito</groupId>
83-
<artifactId>mockito-core</artifactId>
83+
<artifactId>mockito-inline</artifactId>
8484
<scope>test</scope>
8585
</dependency>
8686
<dependency>

hadoop-tools/hadoop-dynamometer/hadoop-dynamometer-workload/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@
4141
</dependency>
4242
<dependency>
4343
<groupId>org.mockito</groupId>
44-
<artifactId>mockito-core</artifactId>
44+
<artifactId>mockito-inline</artifactId>
4545
<scope>test</scope>
4646
</dependency>
4747
<dependency>

hadoop-tools/hadoop-extras/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@
4141
</dependency>
4242
<dependency>
4343
<groupId>org.mockito</groupId>
44-
<artifactId>mockito-core</artifactId>
44+
<artifactId>mockito-inline</artifactId>
4545
<scope>test</scope>
4646
</dependency>
4747
<dependency>

hadoop-tools/hadoop-federation-balance/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@
111111
</dependency>
112112
<dependency>
113113
<groupId>org.mockito</groupId>
114-
<artifactId>mockito-core</artifactId>
114+
<artifactId>mockito-inline</artifactId>
115115
<scope>test</scope>
116116
</dependency>
117117
<dependency>

hadoop-tools/hadoop-fs2img/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@
6969
</dependency>
7070
<dependency>
7171
<groupId>org.mockito</groupId>
72-
<artifactId>mockito-core</artifactId>
72+
<artifactId>mockito-inline</artifactId>
7373
<scope>test</scope>
7474
</dependency>
7575
<dependency>

hadoop-tools/hadoop-gridmix/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@
111111
</dependency>
112112
<dependency>
113113
<groupId>org.mockito</groupId>
114-
<artifactId>mockito-core</artifactId>
114+
<artifactId>mockito-inline</artifactId>
115115
<scope>test</scope>
116116
</dependency>
117117
<dependency>

hadoop-tools/hadoop-kafka/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@
111111
</dependency>
112112
<dependency>
113113
<groupId>org.mockito</groupId>
114-
<artifactId>mockito-core</artifactId>
114+
<artifactId>mockito-inline</artifactId>
115115
<scope>test</scope>
116116
</dependency>
117117
<dependency>

hadoop-tools/hadoop-sls/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@
7575
</dependency>
7676
<dependency>
7777
<groupId>org.mockito</groupId>
78-
<artifactId>mockito-core</artifactId>
78+
<artifactId>mockito-inline</artifactId>
7979
<scope>test</scope>
8080
</dependency>
8181
</dependencies>

hadoop-tools/hadoop-streaming/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@
4242
</dependency>
4343
<dependency>
4444
<groupId>org.mockito</groupId>
45-
<artifactId>mockito-core</artifactId>
45+
<artifactId>mockito-inline</artifactId>
4646
<scope>test</scope>
4747
</dependency>
4848
<dependency>

hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@
112112
</dependency>
113113
<dependency>
114114
<groupId>org.mockito</groupId>
115-
<artifactId>mockito-core</artifactId>
115+
<artifactId>mockito-inline</artifactId>
116116
<scope>test</scope>
117117
</dependency>
118118
</dependencies>

hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-applications-distributedshell/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@
119119
</dependency>
120120
<dependency>
121121
<groupId>org.mockito</groupId>
122-
<artifactId>mockito-core</artifactId>
122+
<artifactId>mockito-inline</artifactId>
123123
<scope>test</scope>
124124
</dependency>
125125
<dependency>

0 commit comments

Comments
 (0)