Skip to content

Commit 1c250b0

Browse files
committed
Fix JUnit 4 -> JUnit 5 conversion
1 parent 996d2e0 commit 1c250b0

File tree

2 files changed

+30
-28
lines changed

2 files changed

+30
-28
lines changed

log4j-core-test/src/test/java/org/apache/logging/log4j/core/util/datetime/FixedDateFormatTest.java

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -183,10 +183,11 @@ public void testDaylightSavingToSummerTime() throws Exception {
183183

184184
for (int i = 0; i < 36; i++) {
185185
final Date date = calendar.getTime();
186-
assertEquals("SimpleDateFormat TZ=US Central", expectedDstAndNoDst[i][0], usCentral.format(date));
187-
assertEquals("SimpleDateFormat TZ=UTC", expectedDstAndNoDst[i][1], utc.format(date));
188-
assertEquals("FixedDateFormat TZ=US Central", expectedDstAndNoDst[i][0], fixedUsCentral.format(date.getTime()));
189-
assertEquals("FixedDateFormat TZ=UTC", expectedDstAndNoDst[i][1], fixedUtc.format(date.getTime()));
186+
assertEquals(expectedDstAndNoDst[i][0], usCentral.format(date), "SimpleDateFormat TZ=US Central");
187+
assertEquals(expectedDstAndNoDst[i][1], utc.format(date), "SimpleDateFormat TZ=UTC");
188+
assertEquals(expectedDstAndNoDst[i][0], fixedUsCentral.format(date.getTime()),
189+
"FixedDateFormat TZ=US Central");
190+
assertEquals(expectedDstAndNoDst[i][1], fixedUtc.format(date.getTime()), "FixedDateFormat TZ=UTC");
190191
calendar.add(Calendar.HOUR_OF_DAY, 1);
191192
}
192193
}
@@ -248,10 +249,11 @@ public void testDaylightSavingToWinterTime() throws Exception {
248249
for (int i = 0; i < 36; i++) {
249250
final Date date = calendar.getTime();
250251
//System.out.println(usCentral.format(date) + ", Fixed: " + fixedUsCentral.format(date.getTime()) + ", utc: " + utc.format(date));
251-
assertEquals("SimpleDateFormat TZ=US Central", expectedDstAndNoDst[i][0], usCentral.format(date));
252-
assertEquals("SimpleDateFormat TZ=UTC", expectedDstAndNoDst[i][1], utc.format(date));
253-
assertEquals("FixedDateFormat TZ=US Central", expectedDstAndNoDst[i][0], fixedUsCentral.format(date.getTime()));
254-
assertEquals("FixedDateFormat TZ=UTC", expectedDstAndNoDst[i][1], fixedUtc.format(date.getTime()));
252+
assertEquals(expectedDstAndNoDst[i][0], usCentral.format(date), "SimpleDateFormat TZ=US Central");
253+
assertEquals(expectedDstAndNoDst[i][1], utc.format(date), "SimpleDateFormat TZ=UTC");
254+
assertEquals(expectedDstAndNoDst[i][0], fixedUsCentral.format(date.getTime()),
255+
"FixedDateFormat TZ=US Central");
256+
assertEquals(expectedDstAndNoDst[i][1], fixedUtc.format(date.getTime()), "FixedDateFormat TZ=US Central");
255257
calendar.add(Calendar.HOUR_OF_DAY, 1);
256258
}
257259
}
@@ -309,7 +311,7 @@ public void testFormatLong() {
309311
for (long time = start; time < end; time += 12345) {
310312
final String actual = customTF.format(time);
311313
final String expected = simpleDF.format(new Date(time));
312-
assertEquals(format + "(" + pattern + ")" + "/" + time, expected, actual);
314+
assertEquals(expected, actual, format + "(" + pattern + ")" + "/" + time);
313315
}
314316
}
315317
}
@@ -329,7 +331,7 @@ public void testFormatLong_goingBackInTime() {
329331
for (long time = end; time > start; time -= 12345) {
330332
final String actual = customTF.format(time);
331333
final String expected = simpleDF.format(new Date(time));
332-
assertEquals(format + "(" + pattern + ")" + "/" + time, expected, actual);
334+
assertEquals(expected, actual, format + "(" + pattern + ")" + "/" + time);
333335
}
334336
}
335337
}
@@ -357,7 +359,7 @@ public void testFormatLong_goingBackInTime_DST() {
357359
for (long time = end; time > start; time -= 12345) {
358360
final String actual = customTF.format(time);
359361
final String expected = simpleDF.format(new Date(time));
360-
assertEquals(format + "(" + pattern + ")" + "/" + time, expected, actual);
362+
assertEquals(expected, actual, format + "(" + pattern + ")" + "/" + time);
361363
}
362364
}
363365
}
@@ -381,7 +383,7 @@ public void testFormatLongCharArrayInt() {
381383
final int length = customTF.format(time, buffer, 23);
382384
final String actual = new String(buffer, 23, length);
383385
final String expected = simpleDF.format(new Date(time));
384-
assertEquals(format + "(" + pattern + ")" + "/" + time, expected, actual);
386+
assertEquals(expected, actual, format + "(" + pattern + ")" + "/" + time);
385387
}
386388
}
387389
}
@@ -403,7 +405,7 @@ public void testFormatLongCharArrayInt_goingBackInTime() {
403405
final int length = customTF.format(time, buffer, 23);
404406
final String actual = new String(buffer, 23, length);
405407
final String expected = simpleDF.format(new Date(time));
406-
assertEquals(format + "(" + pattern + ")" + "/" + time, expected, actual);
408+
assertEquals(expected, actual, format + "(" + pattern + ")" + "/" + time);
407409
}
408410
}
409411
}

src/changelog/.2.x.x/1418_fix_ArrayOutOfBound_in_Log4jFixedFormatter.xml

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,20 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<!--
3-
Licensed to the Apache Software Foundation (ASF) under one or more
4-
contributor license agreements. See the NOTICE file distributed with
5-
this work for additional information regarding copyright ownership.
6-
The ASF licenses this file to You under the Apache License, Version 2.0
7-
(the "License"); you may not use this file except in compliance with
8-
the License. You may obtain a copy of the License at
9-
10-
http://www.apache.org/licenses/LICENSE-2.0
11-
12-
Unless required by applicable law or agreed to in writing, software
13-
distributed under the License is distributed on an "AS IS" BASIS,
14-
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15-
See the License for the specific language governing permissions and
16-
limitations under the License.
17-
-->
3+
~ Licensed to the Apache Software Foundation (ASF) under one or more
4+
~ contributor license agreements. See the NOTICE file distributed with
5+
~ this work for additional information regarding copyright ownership.
6+
~ The ASF licenses this file to you under the Apache License, Version 2.0
7+
~ (the "License"); you may not use this file except in compliance with
8+
~ the License. You may obtain a copy of the License at
9+
~
10+
~ http://www.apache.org/licenses/LICENSE-2.0
11+
~
12+
~ Unless required by applicable law or agreed to in writing, software
13+
~ distributed under the License is distributed on an "AS IS" BASIS,
14+
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
~ See the License for the specific language governing permissions and
16+
~ limitations under the License.
17+
-->
1818
<entry xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
1919
xmlns="http://logging.apache.org/log4j/changelog"
2020
xsi:schemaLocation="http://logging.apache.org/log4j/changelog https://logging.apache.org/log4j/changelog-0.1.1.xsd"

0 commit comments

Comments
 (0)