Skip to content

Commit 49a4dc3

Browse files
authored
Update version to 15.5.0-SNAPSHOT (#6)
* Update version to 15.5.0-SNAPSHOT * Migrate tests to JUnit 5 / utflute 2.5.0
1 parent e9e2c44 commit 49a4dc3

3 files changed

Lines changed: 123 additions & 24 deletions

File tree

pom.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
<artifactId>fess-webapp-example</artifactId>
77
<packaging>jar</packaging>
88
<name>Example Webapp Plugin</name>
9-
<version>15.4.0-SNAPSHOT</version>
9+
<version>15.5.0-SNAPSHOT</version>
1010
<scm>
1111
<connection>scm:git:git@github.com:codelibs/fess-webapp-example.git</connection>
1212
<developerConnection>scm:git:git@github.com:codelibs/fess-webapp-example.git</developerConnection>
@@ -15,7 +15,7 @@
1515
<parent>
1616
<groupId>org.codelibs.fess</groupId>
1717
<artifactId>fess-parent</artifactId>
18-
<version>15.4.0</version>
18+
<version>15.5.0-SNAPSHOT</version>
1919
<relativePath />
2020
</parent>
2121
<build>

src/test/java/org/codelibs/fess/plugin/webapp/helper/CustomSystemHelperTest.java

Lines changed: 12 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@
1515
*/
1616
package org.codelibs.fess.plugin.webapp.helper;
1717

18+
import org.junit.jupiter.api.TestInfo;
19+
1820
import java.nio.file.Path;
1921
import java.nio.file.Paths;
2022

@@ -25,9 +27,9 @@
2527
import org.apache.logging.log4j.core.config.LoggerConfig;
2628
import org.codelibs.fess.mylasta.direction.FessConfig;
2729
import org.codelibs.fess.util.ComponentUtil;
28-
import org.dbflute.utflute.lastaflute.LastaFluteTestCase;
30+
import org.codelibs.fess.webapp.example.UnitWebappTestCase;
2931

30-
public class CustomSystemHelperTest extends LastaFluteTestCase {
32+
public class CustomSystemHelperTest extends UnitWebappTestCase {
3133

3234
@Override
3335
protected String prepareConfigFile() {
@@ -40,7 +42,7 @@ protected boolean isSuppressTestCaseTransaction() {
4042
}
4143

4244
@Override
43-
public void setUp() throws Exception {
45+
public void setUp(TestInfo testInfo) throws Exception {
4446
ComponentUtil.setFessConfig(new FessConfig.SimpleImpl() {
4547
private static final long serialVersionUID = 1L;
4648

@@ -60,13 +62,13 @@ public String[] getSupportedLanguagesAsArray() {
6062
}
6163

6264
});
63-
super.setUp();
65+
super.setUp(testInfo);
6466
}
6567

6668
@Override
67-
public void tearDown() throws Exception {
69+
public void tearDown(TestInfo testInfo) throws Exception {
6870
ComponentUtil.setFessConfig(null);
69-
super.tearDown();
71+
super.tearDown(testInfo);
7072
}
7173

7274
public void test_checkProperty() {
@@ -314,14 +316,8 @@ public void test_parseProjectProperties_consistencyAcrossInstances() {
314316
public void test_parseProjectProperties_withDifferentPathTypes() {
315317
// Given
316318
CustomSystemHelper helper = new CustomSystemHelper();
317-
Path[] testPaths = {
318-
null,
319-
Paths.get(""),
320-
Paths.get("relative/path"),
321-
Paths.get("/absolute/path"),
322-
Paths.get("../parent/path"),
323-
Paths.get("./current/path")
324-
};
319+
Path[] testPaths = { null, Paths.get(""), Paths.get("relative/path"), Paths.get("/absolute/path"), Paths.get("../parent/path"),
320+
Paths.get("./current/path") };
325321

326322
// When & Then
327323
for (Path testPath : testPaths) {
@@ -374,14 +370,8 @@ public void test_parseProjectProperties_idempotency() {
374370
public void test_parseProjectProperties_doesNotThrowException() {
375371
// Given
376372
CustomSystemHelper helper = new CustomSystemHelper();
377-
Path[] problematicPaths = {
378-
null,
379-
Paths.get(""),
380-
Paths.get("/"),
381-
Paths.get("non/existent/path"),
382-
Paths.get("\\invalid\\path"),
383-
Paths.get("special!@#$%/path")
384-
};
373+
Path[] problematicPaths = { null, Paths.get(""), Paths.get("/"), Paths.get("non/existent/path"), Paths.get("\\invalid\\path"),
374+
Paths.get("special!@#$%/path") };
385375

386376
// When & Then
387377
for (Path testPath : problematicPaths) {
Lines changed: 109 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,109 @@
1+
/*
2+
* Copyright 2012-2025 CodeLibs Project and the Others.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
13+
* either express or implied. See the License for the specific language
14+
* governing permissions and limitations under the License.
15+
*/
16+
package org.codelibs.fess.webapp.example;
17+
18+
import org.codelibs.fess.util.ComponentUtil;
19+
import org.dbflute.utflute.lastaflute.LastaFluteTestCase;
20+
import org.junit.jupiter.api.Assertions;
21+
import org.junit.jupiter.api.TestInfo;
22+
23+
public abstract class UnitWebappTestCase extends LastaFluteTestCase {
24+
private static final ThreadLocal<TestInfo> currentTestInfo = new ThreadLocal<>();
25+
26+
@Override
27+
protected String prepareConfigFile() {
28+
return "test_app.xml";
29+
}
30+
31+
@Override
32+
protected void setUp(TestInfo testInfo) throws Exception {
33+
currentTestInfo.set(testInfo);
34+
super.setUp(testInfo);
35+
}
36+
37+
@Override
38+
protected void tearDown(TestInfo testInfo) throws Exception {
39+
ComponentUtil.setFessConfig(null);
40+
super.tearDown(testInfo);
41+
}
42+
43+
protected String getName() {
44+
TestInfo info = currentTestInfo.get();
45+
return info != null ? info.getDisplayName() : "unknown";
46+
}
47+
48+
// ===== Assert methods for JUnit 4/5 compatibility =====
49+
50+
protected void fail(String message) {
51+
Assertions.fail(message);
52+
}
53+
54+
protected void assertTrue(String message, boolean condition) {
55+
Assertions.assertTrue(condition, message);
56+
}
57+
58+
protected void assertFalse(String message, boolean condition) {
59+
Assertions.assertFalse(condition, message);
60+
}
61+
62+
protected void assertEquals(String message, Object expected, Object actual) {
63+
Assertions.assertEquals(expected, actual, message);
64+
}
65+
66+
protected void assertEquals(String message, long expected, long actual) {
67+
Assertions.assertEquals(expected, actual, message);
68+
}
69+
70+
protected void assertEquals(String message, double expected, double actual, double delta) {
71+
Assertions.assertEquals(expected, actual, delta, message);
72+
}
73+
74+
protected void assertEquals(double expected, double actual, double delta) {
75+
Assertions.assertEquals(expected, actual, delta);
76+
}
77+
78+
protected void assertEquals(String message, float expected, float actual, float delta) {
79+
Assertions.assertEquals(expected, actual, delta, message);
80+
}
81+
82+
protected void assertEquals(float expected, float actual, float delta) {
83+
Assertions.assertEquals(expected, actual, delta);
84+
}
85+
86+
protected void assertNotNull(String message, Object object) {
87+
Assertions.assertNotNull(object, message);
88+
}
89+
90+
protected void assertNull(String message, Object object) {
91+
Assertions.assertNull(object, message);
92+
}
93+
94+
protected void assertSame(Object expected, Object actual) {
95+
Assertions.assertSame(expected, actual);
96+
}
97+
98+
protected void assertSame(String message, Object expected, Object actual) {
99+
Assertions.assertSame(expected, actual, message);
100+
}
101+
102+
protected void assertNotSame(Object expected, Object actual) {
103+
Assertions.assertNotSame(expected, actual);
104+
}
105+
106+
protected void assertNotSame(String message, Object expected, Object actual) {
107+
Assertions.assertNotSame(expected, actual, message);
108+
}
109+
}

0 commit comments

Comments
 (0)