Skip to content

[fj-doc-base-kotlin] migrate junit4 to junit5 #323 #327

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 17, 2025
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
7 changes: 0 additions & 7 deletions fj-doc-base-kotlin/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -91,16 +91,9 @@
<version>${kotlin.version}</version>
</dependency>

<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<scope>test</scope>
</dependency>

<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-api</artifactId>
<version>${junit-jupiter-api-version}</version>
<scope>test</scope>
</dependency>
<dependency>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
package test.org.fugerit.java.doc.base.kotlin.model

import junit.framework.TestCase
import org.fugerit.java.core.cfg.ConfigRuntimeException
import org.fugerit.java.doc.base.config.DocInput
import org.fugerit.java.doc.base.config.DocOutput
import org.fugerit.java.doc.base.kotlin.dsl.*
import org.fugerit.java.doc.base.typehandler.markdown.SimpleMarkdownExtTypeHandlerUTF8
import org.junit.jupiter.api.Assertions
import org.junit.jupiter.api.Test
import org.slf4j.Logger
import org.slf4j.LoggerFactory
import java.io.ByteArrayOutputStream
Expand All @@ -18,7 +18,7 @@ import javax.script.ScriptEngineManager
/**
* DocDsl testing.
*/
class DocAltTest : TestCase() {
class DocAltTest {

private val log: Logger = LoggerFactory.getLogger(this.javaClass)

Expand Down Expand Up @@ -58,6 +58,7 @@ class DocAltTest : TestCase() {
/**
* testScriptCoverage
*/
@Test
fun testScriptCoverage() = arrayListOf<String>(
"src/test/resources/doc-dsl-sample/sample-2-coverage-a.kts",
"src/test/resources/doc-dsl-sample/sample-2-coverage-b.kts",
Expand All @@ -79,6 +80,7 @@ class DocAltTest : TestCase() {
/**
* testScript
*/
@Test
fun testScript() =
Assertions.assertEquals( "http://javacoredoc.fugerit.org",
testScriptWorker( "src/test/resources/doc-dsl-sample/sample-2.kts" ).attributes["xmlns"]
Expand All @@ -95,6 +97,7 @@ class DocAltTest : TestCase() {
/**
* testScriptParams
*/
@Test
fun testScriptParams() =
Assertions.assertEquals( "http://javacoredoc.fugerit.org",
testScriptWorkerBind( "src/test/resources/doc-dsl-sample/sample-2-params.kts", true, params ).attributes["xmlns"]
Expand All @@ -112,6 +115,7 @@ class DocAltTest : TestCase() {
/**
* testFail
*/
@Test
fun testFail() {
val helper = HelperDSL()
val textTag = HelperDSL.TextElement( "text" )
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@
import org.fugerit.java.doc.base.typehandler.markdown.SimpleMarkdownExtTypeHandler;
import org.fugerit.java.script.helper.EvalScript;
import org.fugerit.java.script.helper.EvalScriptWithDataModel;
import org.junit.Assert;
import org.junit.Test;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

Expand All @@ -24,13 +24,13 @@
import java.util.HashMap;
import java.util.Map;

public class TestKotlinParser {
class TestKotlinParser {

public static final boolean VALID = true;
public static final boolean NOT_VALID = false;
static final boolean VALID = true;
static final boolean NOT_VALID = false;

public static final boolean NO_EXCEPTION = false;
public static final boolean EXCEPTION = true;
static final boolean NO_EXCEPTION = false;
static final boolean EXCEPTION = true;

private static final Logger logger = LoggerFactory.getLogger( TestKotlinParser.class );

Expand All @@ -48,7 +48,7 @@ private boolean validateWorker( String path, boolean valid, boolean exception, b
for ( String error : result.getInfoList() ) {
logger.info( "Validation info {}", error );
}
Assert.assertEquals( "Validation result" , valid, result.isResultOk() );
Assertions.assertEquals( valid, result.isResultOk() );
return result.isResultOk();
}
} );
Expand All @@ -71,37 +71,37 @@ private boolean parseWorker( String path ) {
}

@Test
public void testValidate() {
Assert.assertTrue( this.validateWorker( "sample-2", true, false, false ) );
Assert.assertTrue( this.validateWorker( "sample-2", true, false, true ) );
void testValidate() {
Assertions.assertTrue( this.validateWorker( "sample-2", true, false, false ) );
Assertions.assertTrue( this.validateWorker( "sample-2", true, false, true ) );
}

@Test
public void testParse() {
Assert.assertTrue( this.parseWorker( "sample-2" ) );
Assert.assertTrue( this.parseWorker( "sample-2-coverage" ) );
void testParse() {
Assertions.assertTrue( this.parseWorker( "sample-2" ) );
Assertions.assertTrue( this.parseWorker( "sample-2-coverage" ) );
}

@Test
public void testDslDocToXml() throws IOException {
void testDslDocToXml() throws IOException {
Map<String, Object> dataModel = new HashMap<>();
DocEvalWithDataModel eval = new DocKotlinParser();
try ( InputStreamReader reader = new InputStreamReader( ClassHelper.loadFromDefaultClassLoader( "doc-dsl-sample/sample-2.kts" ) ) ) {
String xml = eval.evalWithDataModel( reader, dataModel );
Assert.assertNotNull( xml );
Assertions.assertNotNull( xml );
}
}

@Test
public void testWithComplexDataModel() throws IOException {
void testWithComplexDataModel() throws IOException {
Map<String, Object> dataModel = new HashMap<>();
dataModel.put( "docTitle", "Complex map conversion example title" );
dataModel.put( "listPeople", Arrays.asList(new People("Luthien", "Tinuviel", "Queen"), new People("Thorin", "Oakshield", "King")));
EvalScript eval = new EvalScriptWithDataModel( "kts" );
try ( InputStreamReader reader = new InputStreamReader( ClassHelper.loadFromDefaultClassLoader( "doc-dsl-sample/sample-map.kts" ) ) ) {
String xml = eval.handle( reader, dataModel ).toString();
logger.info( "xml : \n{}", xml );
Assert.assertNotNull( xml );
Assertions.assertNotNull( xml );
}
}

Expand Down
Loading