From 0fb09122e660de111bdf019bd15d9f89d081b542 Mon Sep 17 00:00:00 2001 From: Shinsuke Sugaya Date: Thu, 29 Jan 2026 10:44:45 +0900 Subject: [PATCH 1/2] Update version to 15.5.0-SNAPSHOT --- pom.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pom.xml b/pom.xml index 7d13c6f..b5e6963 100644 --- a/pom.xml +++ b/pom.xml @@ -6,7 +6,7 @@ fess-webapp-example jar Example Webapp Plugin - 15.4.0-SNAPSHOT + 15.5.0-SNAPSHOT scm:git:git@github.com:codelibs/fess-webapp-example.git scm:git:git@github.com:codelibs/fess-webapp-example.git @@ -15,7 +15,7 @@ org.codelibs.fess fess-parent - 15.4.0 + 15.5.0-SNAPSHOT From bcb2e95481ea47c0a60e029dc985076082f62f43 Mon Sep 17 00:00:00 2001 From: Shinsuke Sugaya Date: Thu, 29 Jan 2026 14:18:00 +0900 Subject: [PATCH 2/2] Migrate tests to JUnit 5 / utflute 2.5.0 --- .../webapp/helper/CustomSystemHelperTest.java | 34 ++---- .../webapp/example/UnitWebappTestCase.java | 109 ++++++++++++++++++ 2 files changed, 121 insertions(+), 22 deletions(-) create mode 100644 src/test/java/org/codelibs/fess/webapp/example/UnitWebappTestCase.java diff --git a/src/test/java/org/codelibs/fess/plugin/webapp/helper/CustomSystemHelperTest.java b/src/test/java/org/codelibs/fess/plugin/webapp/helper/CustomSystemHelperTest.java index 89e3f37..4eec237 100644 --- a/src/test/java/org/codelibs/fess/plugin/webapp/helper/CustomSystemHelperTest.java +++ b/src/test/java/org/codelibs/fess/plugin/webapp/helper/CustomSystemHelperTest.java @@ -15,6 +15,8 @@ */ package org.codelibs.fess.plugin.webapp.helper; +import org.junit.jupiter.api.TestInfo; + import java.nio.file.Path; import java.nio.file.Paths; @@ -25,9 +27,9 @@ import org.apache.logging.log4j.core.config.LoggerConfig; import org.codelibs.fess.mylasta.direction.FessConfig; import org.codelibs.fess.util.ComponentUtil; -import org.dbflute.utflute.lastaflute.LastaFluteTestCase; +import org.codelibs.fess.webapp.example.UnitWebappTestCase; -public class CustomSystemHelperTest extends LastaFluteTestCase { +public class CustomSystemHelperTest extends UnitWebappTestCase { @Override protected String prepareConfigFile() { @@ -40,7 +42,7 @@ protected boolean isSuppressTestCaseTransaction() { } @Override - public void setUp() throws Exception { + public void setUp(TestInfo testInfo) throws Exception { ComponentUtil.setFessConfig(new FessConfig.SimpleImpl() { private static final long serialVersionUID = 1L; @@ -60,13 +62,13 @@ public String[] getSupportedLanguagesAsArray() { } }); - super.setUp(); + super.setUp(testInfo); } @Override - public void tearDown() throws Exception { + public void tearDown(TestInfo testInfo) throws Exception { ComponentUtil.setFessConfig(null); - super.tearDown(); + super.tearDown(testInfo); } public void test_checkProperty() { @@ -314,14 +316,8 @@ public void test_parseProjectProperties_consistencyAcrossInstances() { public void test_parseProjectProperties_withDifferentPathTypes() { // Given CustomSystemHelper helper = new CustomSystemHelper(); - Path[] testPaths = { - null, - Paths.get(""), - Paths.get("relative/path"), - Paths.get("/absolute/path"), - Paths.get("../parent/path"), - Paths.get("./current/path") - }; + Path[] testPaths = { null, Paths.get(""), Paths.get("relative/path"), Paths.get("/absolute/path"), Paths.get("../parent/path"), + Paths.get("./current/path") }; // When & Then for (Path testPath : testPaths) { @@ -374,14 +370,8 @@ public void test_parseProjectProperties_idempotency() { public void test_parseProjectProperties_doesNotThrowException() { // Given CustomSystemHelper helper = new CustomSystemHelper(); - Path[] problematicPaths = { - null, - Paths.get(""), - Paths.get("/"), - Paths.get("non/existent/path"), - Paths.get("\\invalid\\path"), - Paths.get("special!@#$%/path") - }; + Path[] problematicPaths = { null, Paths.get(""), Paths.get("/"), Paths.get("non/existent/path"), Paths.get("\\invalid\\path"), + Paths.get("special!@#$%/path") }; // When & Then for (Path testPath : problematicPaths) { diff --git a/src/test/java/org/codelibs/fess/webapp/example/UnitWebappTestCase.java b/src/test/java/org/codelibs/fess/webapp/example/UnitWebappTestCase.java new file mode 100644 index 0000000..58cb0f4 --- /dev/null +++ b/src/test/java/org/codelibs/fess/webapp/example/UnitWebappTestCase.java @@ -0,0 +1,109 @@ +/* + * Copyright 2012-2025 CodeLibs Project and the Others. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the specific language + * governing permissions and limitations under the License. + */ +package org.codelibs.fess.webapp.example; + +import org.codelibs.fess.util.ComponentUtil; +import org.dbflute.utflute.lastaflute.LastaFluteTestCase; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.TestInfo; + +public abstract class UnitWebappTestCase extends LastaFluteTestCase { + private static final ThreadLocal currentTestInfo = new ThreadLocal<>(); + + @Override + protected String prepareConfigFile() { + return "test_app.xml"; + } + + @Override + protected void setUp(TestInfo testInfo) throws Exception { + currentTestInfo.set(testInfo); + super.setUp(testInfo); + } + + @Override + protected void tearDown(TestInfo testInfo) throws Exception { + ComponentUtil.setFessConfig(null); + super.tearDown(testInfo); + } + + protected String getName() { + TestInfo info = currentTestInfo.get(); + return info != null ? info.getDisplayName() : "unknown"; + } + + // ===== Assert methods for JUnit 4/5 compatibility ===== + + protected void fail(String message) { + Assertions.fail(message); + } + + protected void assertTrue(String message, boolean condition) { + Assertions.assertTrue(condition, message); + } + + protected void assertFalse(String message, boolean condition) { + Assertions.assertFalse(condition, message); + } + + protected void assertEquals(String message, Object expected, Object actual) { + Assertions.assertEquals(expected, actual, message); + } + + protected void assertEquals(String message, long expected, long actual) { + Assertions.assertEquals(expected, actual, message); + } + + protected void assertEquals(String message, double expected, double actual, double delta) { + Assertions.assertEquals(expected, actual, delta, message); + } + + protected void assertEquals(double expected, double actual, double delta) { + Assertions.assertEquals(expected, actual, delta); + } + + protected void assertEquals(String message, float expected, float actual, float delta) { + Assertions.assertEquals(expected, actual, delta, message); + } + + protected void assertEquals(float expected, float actual, float delta) { + Assertions.assertEquals(expected, actual, delta); + } + + protected void assertNotNull(String message, Object object) { + Assertions.assertNotNull(object, message); + } + + protected void assertNull(String message, Object object) { + Assertions.assertNull(object, message); + } + + protected void assertSame(Object expected, Object actual) { + Assertions.assertSame(expected, actual); + } + + protected void assertSame(String message, Object expected, Object actual) { + Assertions.assertSame(expected, actual, message); + } + + protected void assertNotSame(Object expected, Object actual) { + Assertions.assertNotSame(expected, actual); + } + + protected void assertNotSame(String message, Object expected, Object actual) { + Assertions.assertNotSame(expected, actual, message); + } +}