Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<artifactId>fess-webapp-example</artifactId>
<packaging>jar</packaging>
<name>Example Webapp Plugin</name>
<version>15.4.0-SNAPSHOT</version>
<version>15.5.0-SNAPSHOT</version>
<scm>
<connection>scm:git:git@github.com:codelibs/fess-webapp-example.git</connection>
<developerConnection>scm:git:git@github.com:codelibs/fess-webapp-example.git</developerConnection>
Expand All @@ -15,7 +15,7 @@
<parent>
<groupId>org.codelibs.fess</groupId>
<artifactId>fess-parent</artifactId>
<version>15.4.0</version>
<version>15.5.0-SNAPSHOT</version>
<relativePath />
</parent>
<build>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -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() {
Expand All @@ -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;

Expand All @@ -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() {
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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) {
Expand Down
109 changes: 109 additions & 0 deletions src/test/java/org/codelibs/fess/webapp/example/UnitWebappTestCase.java
Original file line number Diff line number Diff line change
@@ -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<TestInfo> 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);
}
}