From 14fac33e12e80c1c486c338153d590a0adb4321c Mon Sep 17 00:00:00 2001 From: Shinsuke Sugaya Date: Thu, 25 Jun 2026 15:03:48 +0900 Subject: [PATCH] fix(test): add missing JUnit 5 annotations so dormant tests run CustomSystemHelperTest extends UnitWebappTestCase, which derives from utflute's LastaFluteTestCase. utflute has migrated to JUnit 5 (Jupiter), where Surefire only executes methods carrying @Test. The test_* methods in this class had no @Test annotation, so the entire class was silently skipped (0 tests executed) even though it compiled and the assertions were valid. Add @Test to each no-argument test_* method (23 methods) and import org.junit.jupiter.api.Test. The overridden setUp(TestInfo)/tearDown(TestInfo) hooks are intentionally left WITHOUT @BeforeEach/@AfterEach: utflute's PlainTestCase already declares @BeforeEach frameworkEntrySetUp / @AfterEach frameworkEntryTearDown, which invoke these overridable hooks. Annotating the overrides directly would invoke them twice, and the duplicate teardown dereferences an already-reverted bound-component result (NullPointerException). This matches the existing pattern in UnitWebappTestCase. With the fix, the suite reports 23 tests run, 0 failures, 0 errors. Co-Authored-By: Claude --- .../webapp/helper/CustomSystemHelperTest.java | 24 +++++++++++++++++++ 1 file changed, 24 insertions(+) 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 4eec237..5faf50b 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,7 @@ */ package org.codelibs.fess.plugin.webapp.helper; +import org.junit.jupiter.api.Test; import org.junit.jupiter.api.TestInfo; import java.nio.file.Path; @@ -71,10 +72,12 @@ public void tearDown(TestInfo testInfo) throws Exception { super.tearDown(testInfo); } + @Test public void test_checkProperty() { assertEquals("true", System.getProperty("fess.webapp.plugin")); } + @Test public void test_parseProjectProperties_withValidPath() { // Given CustomSystemHelper helper = new CustomSystemHelper(); @@ -87,6 +90,7 @@ public void test_parseProjectProperties_withValidPath() { assertEquals("true", System.getProperty("fess.webapp.plugin")); } + @Test public void test_parseProjectProperties_withNullPath() { // Given CustomSystemHelper helper = new CustomSystemHelper(); @@ -98,6 +102,7 @@ public void test_parseProjectProperties_withNullPath() { assertEquals("true", System.getProperty("fess.webapp.plugin")); } + @Test public void test_parseProjectProperties_withNonExistentPath() { // Given CustomSystemHelper helper = new CustomSystemHelper(); @@ -110,6 +115,7 @@ public void test_parseProjectProperties_withNonExistentPath() { assertEquals("true", System.getProperty("fess.webapp.plugin")); } + @Test public void test_parseProjectProperties_systemPropertyAlwaysSet() { // Given CustomSystemHelper helper = new CustomSystemHelper(); @@ -123,6 +129,7 @@ public void test_parseProjectProperties_systemPropertyAlwaysSet() { assertEquals("true", System.getProperty("fess.webapp.plugin")); } + @Test public void test_parseProjectProperties_multipleCalls() { // Given CustomSystemHelper helper = new CustomSystemHelper(); @@ -137,6 +144,7 @@ public void test_parseProjectProperties_multipleCalls() { assertEquals("true", System.getProperty("fess.webapp.plugin")); } + @Test public void test_inheritance_extendsSystemHelper() { // Given CustomSystemHelper helper = new CustomSystemHelper(); @@ -145,6 +153,7 @@ public void test_inheritance_extendsSystemHelper() { assertTrue("CustomSystemHelper should extend SystemHelper", helper instanceof org.codelibs.fess.helper.SystemHelper); } + @Test public void test_loggerConfiguration() { // Given LoggerContext context = (LoggerContext) LogManager.getContext(false); @@ -155,6 +164,7 @@ public void test_loggerConfiguration() { assertNotNull("Logger should be configured", loggerConfig); } + @Test public void test_parseProjectProperties_withEmptyPath() { // Given CustomSystemHelper helper = new CustomSystemHelper(); @@ -167,6 +177,7 @@ public void test_parseProjectProperties_withEmptyPath() { assertEquals("true", System.getProperty("fess.webapp.plugin")); } + @Test public void test_parseProjectProperties_propertyPersistence() { // Given CustomSystemHelper helper1 = new CustomSystemHelper(); @@ -185,6 +196,7 @@ public void test_parseProjectProperties_propertyPersistence() { assertEquals("Property should remain consistent", propertyAfterFirst, propertyAfterSecond); } + @Test public void test_parseProjectProperties_threadSafety() throws InterruptedException { // Given final CustomSystemHelper helper = new CustomSystemHelper(); @@ -212,6 +224,7 @@ public void test_parseProjectProperties_threadSafety() throws InterruptedExcepti } } + @Test public void test_constructor_initialization() { // Given & When CustomSystemHelper helper = new CustomSystemHelper(); @@ -222,6 +235,7 @@ public void test_constructor_initialization() { assertTrue("Helper should be instance of CustomSystemHelper", helper instanceof CustomSystemHelper); } + @Test public void test_parseProjectProperties_overwritesExistingProperty() { // Given CustomSystemHelper helper = new CustomSystemHelper(); @@ -235,6 +249,7 @@ public void test_parseProjectProperties_overwritesExistingProperty() { assertEquals("Property should be overwritten to true", "true", System.getProperty("fess.webapp.plugin")); } + @Test public void test_parseProjectProperties_withAbsolutePath() { // Given CustomSystemHelper helper = new CustomSystemHelper(); @@ -247,6 +262,7 @@ public void test_parseProjectProperties_withAbsolutePath() { assertEquals("true", System.getProperty("fess.webapp.plugin")); } + @Test public void test_parseProjectProperties_withRelativePath() { // Given CustomSystemHelper helper = new CustomSystemHelper(); @@ -259,6 +275,7 @@ public void test_parseProjectProperties_withRelativePath() { assertEquals("true", System.getProperty("fess.webapp.plugin")); } + @Test public void test_parseProjectProperties_withSpecialCharactersInPath() { // Given CustomSystemHelper helper = new CustomSystemHelper(); @@ -277,6 +294,7 @@ public void test_parseProjectProperties_withSpecialCharactersInPath() { assertEquals("true", resultAfterUnicode); } + @Test public void test_multipleInstances_independence() { // Given CustomSystemHelper helper1 = new CustomSystemHelper(); @@ -294,6 +312,7 @@ public void test_multipleInstances_independence() { assertNotSame("Instances should be different objects", helper2, helper3); } + @Test public void test_parseProjectProperties_consistencyAcrossInstances() { // Given System.clearProperty("fess.webapp.plugin"); @@ -313,6 +332,7 @@ public void test_parseProjectProperties_consistencyAcrossInstances() { assertEquals("Values should be consistent", valueAfterHelper1, valueAfterHelper2); } + @Test public void test_parseProjectProperties_withDifferentPathTypes() { // Given CustomSystemHelper helper = new CustomSystemHelper(); @@ -327,6 +347,7 @@ public void test_parseProjectProperties_withDifferentPathTypes() { } } + @Test public void test_parseProjectProperties_propertyValueIsExactlyTrue() { // Given CustomSystemHelper helper = new CustomSystemHelper(); @@ -344,6 +365,7 @@ public void test_parseProjectProperties_propertyValueIsExactlyTrue() { assertFalse("Property value should not be empty", propertyValue.isEmpty()); } + @Test public void test_parseProjectProperties_idempotency() { // Given CustomSystemHelper helper = new CustomSystemHelper(); @@ -367,6 +389,7 @@ public void test_parseProjectProperties_idempotency() { assertEquals("Multiple calls should produce same result (idempotent)", secondValue, thirdValue); } + @Test public void test_parseProjectProperties_doesNotThrowException() { // Given CustomSystemHelper helper = new CustomSystemHelper(); @@ -385,6 +408,7 @@ public void test_parseProjectProperties_doesNotThrowException() { } } + @Test public void test_parseProjectProperties_stressTest() { // Given CustomSystemHelper helper = new CustomSystemHelper();