Skip to content

Commit 7a66020

Browse files
committed
HADOOP-19617 - [JDK17] Remove JUnit4 Dependency - Common.
1 parent 681f152 commit 7a66020

File tree

5 files changed

+75
-58
lines changed

5 files changed

+75
-58
lines changed

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

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -68,11 +68,6 @@
6868
<artifactId>junit-jupiter-engine</artifactId>
6969
<scope>provided</scope>
7070
</dependency>
71-
<dependency>
72-
<groupId>org.junit.vintage</groupId>
73-
<artifactId>junit-vintage-engine</artifactId>
74-
<scope>provided</scope>
75-
</dependency>
7671
<dependency>
7772
<groupId>org.junit.platform</groupId>
7873
<artifactId>junit-platform-launcher</artifactId>

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

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,31 @@
9292
<artifactId>assertj-core</artifactId>
9393
<scope>test</scope>
9494
</dependency>
95+
<dependency>
96+
<groupId>org.assertj</groupId>
97+
<artifactId>assertj-core</artifactId>
98+
<scope>test</scope>
99+
</dependency>
100+
<dependency>
101+
<groupId>org.junit.jupiter</groupId>
102+
<artifactId>junit-jupiter-api</artifactId>
103+
<scope>test</scope>
104+
</dependency>
105+
<dependency>
106+
<groupId>org.junit.jupiter</groupId>
107+
<artifactId>junit-jupiter-params</artifactId>
108+
<scope>test</scope>
109+
</dependency>
110+
<dependency>
111+
<groupId>org.junit.jupiter</groupId>
112+
<artifactId>junit-jupiter-engine</artifactId>
113+
<scope>test</scope>
114+
</dependency>
115+
<dependency>
116+
<groupId>org.junit.platform</groupId>
117+
<artifactId>junit-platform-launcher</artifactId>
118+
<scope>provided</scope>
119+
</dependency>
95120
</dependencies>
96121

97122
<build>

hadoop-common-project/hadoop-nfs/src/test/java/org/apache/hadoop/nfs/TestNfsExports.java

Lines changed: 44 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@
1818
package org.apache.hadoop.nfs;
1919

2020
import org.apache.hadoop.nfs.nfs3.Nfs3Constant;
21-
import org.junit.Assert;
22-
import org.junit.Test;
21+
import org.junit.jupiter.api.Assertions;
22+
import org.junit.jupiter.api.Test;
2323

2424
public class TestNfsExports {
2525

@@ -37,148 +37,141 @@ public class TestNfsExports {
3737
@Test
3838
public void testWildcardRW() {
3939
NfsExports matcher = new NfsExports(CacheSize, ExpirationPeriod, "* rw");
40-
Assert.assertEquals(AccessPrivilege.READ_WRITE,
40+
Assertions.assertEquals(AccessPrivilege.READ_WRITE,
4141
matcher.getAccessPrivilege(address1, hostname1));
4242
}
4343

4444
@Test
4545
public void testWildcardRO() {
4646
NfsExports matcher = new NfsExports(CacheSize, ExpirationPeriod, "* ro");
47-
Assert.assertEquals(AccessPrivilege.READ_ONLY,
47+
Assertions.assertEquals(AccessPrivilege.READ_ONLY,
4848
matcher.getAccessPrivilege(address1, hostname1));
4949
}
5050

5151
@Test
5252
public void testExactAddressRW() {
5353
NfsExports matcher = new NfsExports(CacheSize, ExpirationPeriod, address1
5454
+ " rw");
55-
Assert.assertEquals(AccessPrivilege.READ_WRITE,
55+
Assertions.assertEquals(AccessPrivilege.READ_WRITE,
5656
matcher.getAccessPrivilege(address1, hostname1));
57-
Assert.assertFalse(AccessPrivilege.READ_WRITE == matcher
57+
Assertions.assertFalse(AccessPrivilege.READ_WRITE == matcher
5858
.getAccessPrivilege(address2, hostname1));
5959
}
6060

6161
@Test
6262
public void testExactAddressRO() {
6363
NfsExports matcher = new NfsExports(CacheSize, ExpirationPeriod, address1);
64-
Assert.assertEquals(AccessPrivilege.READ_ONLY,
64+
Assertions.assertEquals(AccessPrivilege.READ_ONLY,
6565
matcher.getAccessPrivilege(address1, hostname1));
66-
Assert.assertEquals(AccessPrivilege.NONE,
67-
matcher.getAccessPrivilege(address2, hostname1));
66+
Assertions.assertEquals(AccessPrivilege.NONE, matcher.getAccessPrivilege(address2, hostname1));
6867
}
6968

7069
@Test
7170
public void testExactHostRW() {
7271
NfsExports matcher = new NfsExports(CacheSize, ExpirationPeriod, hostname1
7372
+ " rw");
74-
Assert.assertEquals(AccessPrivilege.READ_WRITE,
73+
Assertions.assertEquals(AccessPrivilege.READ_WRITE,
7574
matcher.getAccessPrivilege(address1, hostname1));
7675
}
7776

7877
@Test
7978
public void testExactHostRO() {
8079
NfsExports matcher = new NfsExports(CacheSize, ExpirationPeriod, hostname1);
81-
Assert.assertEquals(AccessPrivilege.READ_ONLY,
80+
Assertions.assertEquals(AccessPrivilege.READ_ONLY,
8281
matcher.getAccessPrivilege(address1, hostname1));
8382
}
8483

8584
@Test
8685
public void testCidrShortRW() {
8786
NfsExports matcher = new NfsExports(CacheSize, ExpirationPeriod,
8887
"192.168.0.0/22 rw");
89-
Assert.assertEquals(AccessPrivilege.READ_WRITE,
88+
Assertions.assertEquals(AccessPrivilege.READ_WRITE,
9089
matcher.getAccessPrivilege(address1, hostname1));
91-
Assert.assertEquals(AccessPrivilege.NONE,
92-
matcher.getAccessPrivilege(address2, hostname1));
90+
Assertions.assertEquals(AccessPrivilege.NONE, matcher.getAccessPrivilege(address2, hostname1));
9391
}
9492

9593
@Test
9694
public void testCidrShortRO() {
9795
NfsExports matcher = new NfsExports(CacheSize, ExpirationPeriod,
9896
"192.168.0.0/22");
99-
Assert.assertEquals(AccessPrivilege.READ_ONLY,
97+
Assertions.assertEquals(AccessPrivilege.READ_ONLY,
10098
matcher.getAccessPrivilege(address1, hostname1));
101-
Assert.assertEquals(AccessPrivilege.NONE,
102-
matcher.getAccessPrivilege(address2, hostname1));
99+
Assertions.assertEquals(AccessPrivilege.NONE, matcher.getAccessPrivilege(address2, hostname1));
103100
}
104101

105102
@Test
106103
public void testCidrLongRW() {
107104
NfsExports matcher = new NfsExports(CacheSize, ExpirationPeriod,
108105
"192.168.0.0/255.255.252.0 rw");
109-
Assert.assertEquals(AccessPrivilege.READ_WRITE,
106+
Assertions.assertEquals(AccessPrivilege.READ_WRITE,
110107
matcher.getAccessPrivilege(address1, hostname1));
111-
Assert.assertEquals(AccessPrivilege.NONE,
112-
matcher.getAccessPrivilege(address2, hostname1));
108+
Assertions.assertEquals(AccessPrivilege.NONE, matcher.getAccessPrivilege(address2, hostname1));
113109
}
114110

115111
@Test
116112
public void testCidrLongRO() {
117113
NfsExports matcher = new NfsExports(CacheSize, ExpirationPeriod,
118114
"192.168.0.0/255.255.252.0");
119-
Assert.assertEquals(AccessPrivilege.READ_ONLY,
115+
Assertions.assertEquals(AccessPrivilege.READ_ONLY,
120116
matcher.getAccessPrivilege(address1, hostname1));
121-
Assert.assertEquals(AccessPrivilege.NONE,
122-
matcher.getAccessPrivilege(address2, hostname1));
117+
Assertions.assertEquals(AccessPrivilege.NONE, matcher.getAccessPrivilege(address2, hostname1));
123118
}
124119

125120
@Test
126121
public void testRegexIPRW() {
127122
NfsExports matcher = new NfsExports(CacheSize, ExpirationPeriod,
128123
"192.168.0.[0-9]+ rw");
129-
Assert.assertEquals(AccessPrivilege.READ_WRITE,
124+
Assertions.assertEquals(AccessPrivilege.READ_WRITE,
130125
matcher.getAccessPrivilege(address1, hostname1));
131-
Assert.assertEquals(AccessPrivilege.NONE,
132-
matcher.getAccessPrivilege(address2, hostname1));
126+
Assertions.assertEquals(AccessPrivilege.NONE, matcher.getAccessPrivilege(address2, hostname1));
133127
}
134128

135129
@Test
136130
public void testRegexIPRO() {
137131
NfsExports matcher = new NfsExports(CacheSize, ExpirationPeriod,
138132
"192.168.0.[0-9]+");
139-
Assert.assertEquals(AccessPrivilege.READ_ONLY,
133+
Assertions.assertEquals(AccessPrivilege.READ_ONLY,
140134
matcher.getAccessPrivilege(address1, hostname1));
141-
Assert.assertEquals(AccessPrivilege.NONE,
142-
matcher.getAccessPrivilege(address2, hostname1));
135+
Assertions.assertEquals(AccessPrivilege.NONE, matcher.getAccessPrivilege(address2, hostname1));
143136
}
144137

145138
@Test
146139
public void testRegexHostRW() {
147140
NfsExports matcher = new NfsExports(CacheSize, ExpirationPeriod,
148141
"[a-z]+.b.com rw");
149-
Assert.assertEquals(AccessPrivilege.READ_WRITE,
142+
Assertions.assertEquals(AccessPrivilege.READ_WRITE,
150143
matcher.getAccessPrivilege(address1, hostname1));
151144
// address1 will hit the cache
152-
Assert.assertEquals(AccessPrivilege.READ_WRITE,
145+
Assertions.assertEquals(AccessPrivilege.READ_WRITE,
153146
matcher.getAccessPrivilege(address1, hostname2));
154147
}
155148

156149
@Test
157150
public void testRegexHostRO() {
158151
NfsExports matcher = new NfsExports(CacheSize, ExpirationPeriod,
159152
"[a-z]+.b.com");
160-
Assert.assertEquals(AccessPrivilege.READ_ONLY,
153+
Assertions.assertEquals(AccessPrivilege.READ_ONLY,
161154
matcher.getAccessPrivilege(address1, hostname1));
162155
// address1 will hit the cache
163-
Assert.assertEquals(AccessPrivilege.READ_ONLY,
156+
Assertions.assertEquals(AccessPrivilege.READ_ONLY,
164157
matcher.getAccessPrivilege(address1, hostname2));
165158
}
166159

167160
@Test
168161
public void testRegexGrouping() {
169162
NfsExports matcher = new NfsExports(CacheSize, ExpirationPeriod,
170163
"192.168.0.(12|34)");
171-
Assert.assertEquals(AccessPrivilege.READ_ONLY,
164+
Assertions.assertEquals(AccessPrivilege.READ_ONLY,
172165
matcher.getAccessPrivilege(address1, hostname1));
173166
// address1 will hit the cache
174-
Assert.assertEquals(AccessPrivilege.READ_ONLY,
167+
Assertions.assertEquals(AccessPrivilege.READ_ONLY,
175168
matcher.getAccessPrivilege(address1, hostname2));
176169

177170
matcher = new NfsExports(CacheSize, ExpirationPeriod, "\\w*.a.b.com");
178-
Assert.assertEquals(AccessPrivilege.READ_ONLY,
171+
Assertions.assertEquals(AccessPrivilege.READ_ONLY,
179172
matcher.getAccessPrivilege("1.2.3.4", "web.a.b.com"));
180173
// address "1.2.3.4" will hit the cache
181-
Assert.assertEquals(AccessPrivilege.READ_ONLY,
174+
Assertions.assertEquals(AccessPrivilege.READ_ONLY,
182175
matcher.getAccessPrivilege("1.2.3.4", "email.a.b.org"));
183176
}
184177

@@ -187,16 +180,16 @@ public void testMultiMatchers() throws Exception {
187180
long shortExpirationPeriod = 1 * 1000 * 1000 * 1000; // 1s
188181
NfsExports matcher = new NfsExports(CacheSize, shortExpirationPeriod,
189182
"192.168.0.[0-9]+;[a-z]+.b.com rw");
190-
Assert.assertEquals(AccessPrivilege.READ_ONLY,
183+
Assertions.assertEquals(AccessPrivilege.READ_ONLY,
191184
matcher.getAccessPrivilege(address1, hostname2));
192-
Assert.assertEquals(AccessPrivilege.READ_ONLY,
185+
Assertions.assertEquals(AccessPrivilege.READ_ONLY,
193186
matcher.getAccessPrivilege(address1, address1));
194-
Assert.assertEquals(AccessPrivilege.READ_ONLY,
187+
Assertions.assertEquals(AccessPrivilege.READ_ONLY,
195188
matcher.getAccessPrivilege(address1, hostname1));
196-
Assert.assertEquals(AccessPrivilege.READ_WRITE,
189+
Assertions.assertEquals(AccessPrivilege.READ_WRITE,
197190
matcher.getAccessPrivilege(address2, hostname1));
198191
// address2 will hit the cache
199-
Assert.assertEquals(AccessPrivilege.READ_WRITE,
192+
Assertions.assertEquals(AccessPrivilege.READ_WRITE,
200193
matcher.getAccessPrivilege(address2, hostname2));
201194

202195
Thread.sleep(1000);
@@ -210,18 +203,22 @@ public void testMultiMatchers() throws Exception {
210203
}
211204
Thread.sleep(500);
212205
} while ((System.nanoTime() - startNanos) / NanosPerMillis < 5000);
213-
Assert.assertEquals(AccessPrivilege.NONE, ap);
206+
Assertions.assertEquals(AccessPrivilege.NONE, ap);
214207
}
215208

216-
@Test(expected=IllegalArgumentException.class)
209+
@Test
217210
public void testInvalidHost() {
218-
NfsExports matcher = new NfsExports(CacheSize, ExpirationPeriod,
211+
Assertions.assertThrows(IllegalArgumentException.class, () -> {
212+
NfsExports matcher = new NfsExports(CacheSize, ExpirationPeriod,
219213
"foo#bar");
214+
});
220215
}
221216

222-
@Test(expected=IllegalArgumentException.class)
217+
@Test
223218
public void testInvalidSeparator() {
224-
NfsExports matcher = new NfsExports(CacheSize, ExpirationPeriod,
219+
Assertions.assertThrows(IllegalArgumentException.class, () -> {
220+
NfsExports matcher = new NfsExports(CacheSize, ExpirationPeriod,
225221
"foo ro : bar rw");
222+
});
226223
}
227224
}

hadoop-common-project/hadoop-nfs/src/test/java/org/apache/hadoop/nfs/TestNfsTime.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,18 +17,18 @@
1717
*/
1818
package org.apache.hadoop.nfs;
1919

20-
import org.junit.Assert;
20+
import org.junit.jupiter.api.Assertions;
2121

2222
import org.apache.hadoop.nfs.NfsTime;
2323
import org.apache.hadoop.oncrpc.XDR;
24-
import org.junit.Test;
24+
import org.junit.jupiter.api.Test;
2525

2626
public class TestNfsTime {
2727
@Test
2828
public void testConstructor() {
2929
NfsTime nfstime = new NfsTime(1001);
30-
Assert.assertEquals(1, nfstime.getSeconds());
31-
Assert.assertEquals(1000000, nfstime.getNseconds());
30+
Assertions.assertEquals(1, nfstime.getSeconds());
31+
Assertions.assertEquals(1000000, nfstime.getNseconds());
3232
}
3333

3434
@Test
@@ -42,6 +42,6 @@ public void testSerializeDeserialize() {
4242
NfsTime t2 = NfsTime.deserialize(xdr.asReadOnlyWrap());
4343

4444
// Ensure the NfsTimes are equal
45-
Assert.assertEquals(t1, t2);
45+
Assertions.assertEquals(t1, t2);
4646
}
4747
}

hadoop-common-project/hadoop-nfs/src/test/java/org/apache/hadoop/nfs/nfs3/TestFileHandle.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
package org.apache.hadoop.nfs.nfs3;
1919

2020
import org.apache.hadoop.oncrpc.XDR;
21-
import org.junit.Test;
21+
import org.junit.jupiter.api.Test;
2222

2323
import static org.assertj.core.api.Assertions.assertThat;
2424

0 commit comments

Comments
 (0)