diff --git a/fj-core-jvfs/pom.xml b/fj-core-jvfs/pom.xml index afa94221..40651108 100644 --- a/fj-core-jvfs/pom.xml +++ b/fj-core-jvfs/pom.xml @@ -116,6 +116,12 @@ test + + org.junit.jupiter + junit-jupiter-api + test + + org.fugerit.java fj-test-helper8 diff --git a/fj-core-jvfs/src/test/java/org/fugerit/java/core/jvfs/db/daogen/junit4test/model/DbJvfsFileJunit4ModelTest.java b/fj-core-jvfs/src/test/java/org/fugerit/java/core/jvfs/db/daogen/junit5test/model/DbJvfsFileJunit5ModelTest.java similarity index 70% rename from fj-core-jvfs/src/test/java/org/fugerit/java/core/jvfs/db/daogen/junit4test/model/DbJvfsFileJunit4ModelTest.java rename to fj-core-jvfs/src/test/java/org/fugerit/java/core/jvfs/db/daogen/junit5test/model/DbJvfsFileJunit5ModelTest.java index 0495440a..14232ecf 100644 --- a/fj-core-jvfs/src/test/java/org/fugerit/java/core/jvfs/db/daogen/junit4test/model/DbJvfsFileJunit4ModelTest.java +++ b/fj-core-jvfs/src/test/java/org/fugerit/java/core/jvfs/db/daogen/junit5test/model/DbJvfsFileJunit5ModelTest.java @@ -1,11 +1,11 @@ -package org.fugerit.java.core.jvfs.db.daogen.junit4test.model; +package org.fugerit.java.core.jvfs.db.daogen.junit5test.model; import org.fugerit.java.core.jvfs.db.daogen.def.facade.DbJvfsFileFinder; import org.fugerit.java.core.jvfs.db.daogen.helper.HelperDbJvfsFile; import org.fugerit.java.core.jvfs.db.daogen.helper.WrapperDbJvfsFile; import org.fugerit.java.core.jvfs.db.daogen.model.ModelDbJvfsFile; -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; @@ -13,7 +13,7 @@ // custom import end ( code below here will be overwritten ) /** - * DbJvfsFileJunit4ModelTest, version : 1.0.0 + * DbJvfsFileJunit5ModelTest, version : 1.0.0 * * author: fugerit * @@ -21,12 +21,12 @@ * // custom code start ( code above here will be overwritten ) * // custom code end ( code below here will be overwritten ) */ -public class DbJvfsFileJunit4ModelTest { +class DbJvfsFileJunit5ModelTest { // custom code start ( code above here will be overwritten ) // custom code end ( code below here will be overwritten ) - private static final Logger logger = LoggerFactory.getLogger( DbJvfsFileJunit4ModelTest.class ); + private static final Logger logger = LoggerFactory.getLogger( DbJvfsFileJunit5ModelTest.class ); public void printAll( ModelDbJvfsFile current ) { logger.info( "FILE_NAME-> {}", current.getFileName() ); @@ -41,36 +41,36 @@ public void printAll( ModelDbJvfsFile current ) { public ModelDbJvfsFile newInstance() { ModelDbJvfsFile model = new HelperDbJvfsFile(); WrapperDbJvfsFile current = new WrapperDbJvfsFile( model ); - Assert.assertTrue( current.isEmpty() ); + Assertions.assertTrue( current.isEmpty() ); current.setFileName("1"); - Assert.assertFalse( current.isEmpty() ); + Assertions.assertFalse( current.isEmpty() ); current.setParentPath("1"); - Assert.assertFalse( current.isEmpty() ); + Assertions.assertFalse( current.isEmpty() ); current.setFileProps("1"); - Assert.assertFalse( current.isEmpty() ); + Assertions.assertFalse( current.isEmpty() ); current.setCreationTime(new java.util.Date()); - Assert.assertFalse( current.isEmpty() ); + Assertions.assertFalse( current.isEmpty() ); current.setUpdateTime(new java.util.Date()); - Assert.assertFalse( current.isEmpty() ); + Assertions.assertFalse( current.isEmpty() ); current.setFileSize(new java.math.BigDecimal( "1" )); - Assert.assertFalse( current.isEmpty() ); + Assertions.assertFalse( current.isEmpty() ); current.setFileContent(null); - Assert.assertFalse( current.isEmpty() ); + Assertions.assertFalse( current.isEmpty() ); logger.info( "unwrap : {}", current.unwrap( current ) ); return current; } @Test - public void testJUnit4ModelDbJvfsFile() { + void testJUnit5ModelDbJvfsFile() { ModelDbJvfsFile current = this.newInstance(); this.printAll( current ); logger.info( "current toString() : {}", current ); - Assert.assertNotNull( current ); + Assertions.assertNotNull( current ); DbJvfsFileFinder finder1 = new DbJvfsFileFinder(); finder1.setModel( current ); logger.info( "finder1.getModel() -> {}", finder1.getModel() ); - Assert.assertNotNull( DbJvfsFileFinder.newInstance( current ) ); - Assert.assertNotNull( finder1 ); + Assertions.assertNotNull( DbJvfsFileFinder.newInstance( current ) ); + Assertions.assertNotNull( finder1 ); } } diff --git a/fj-core-jvfs/src/test/java/test/org/fugerit/java/core/jvfs/TestCopyClToReal.java b/fj-core-jvfs/src/test/java/test/org/fugerit/java/core/jvfs/TestCopyClToReal.java index 0eae3a3c..9d16cc43 100644 --- a/fj-core-jvfs/src/test/java/test/org/fugerit/java/core/jvfs/TestCopyClToReal.java +++ b/fj-core-jvfs/src/test/java/test/org/fugerit/java/core/jvfs/TestCopyClToReal.java @@ -4,12 +4,12 @@ import org.fugerit.java.core.jvfs.JVFS; import org.fugerit.java.core.jvfs.file.RealJMount; -import org.junit.Test; +import org.junit.jupiter.api.Test; -public class TestCopyClToReal extends TestJVFSHelper { +class TestCopyClToReal extends TestJVFSHelper { @Test - public void testCopy03() { + void testCopy03() { try { File dest = new File( "target/test_copy_02" ); JVFS from = TestJMountHelper.getClassLoaderJVFSDefault(); diff --git a/fj-core-jvfs/src/test/java/test/org/fugerit/java/core/jvfs/TestCopyRealToDb.java b/fj-core-jvfs/src/test/java/test/org/fugerit/java/core/jvfs/TestCopyRealToDb.java index 0d78bc62..71eafe14 100644 --- a/fj-core-jvfs/src/test/java/test/org/fugerit/java/core/jvfs/TestCopyRealToDb.java +++ b/fj-core-jvfs/src/test/java/test/org/fugerit/java/core/jvfs/TestCopyRealToDb.java @@ -2,14 +2,14 @@ import org.fugerit.java.core.jvfs.JVFS; import org.fugerit.java.core.jvfs.db.JMountDaogenDB; -import org.junit.Test; +import org.junit.jupiter.api.Test; import test.org.fugerit.java.core.jvfs.db.helper.MemJvfsDBHelper; -public class TestCopyRealToDb extends TestJVFSHelper { +class TestCopyRealToDb extends TestJVFSHelper { @Test - public void testCopy02() { + void testCopy02() { try { JVFS from = TestJMountHelper.getRealJVFSDefault(); JVFS to = JMountDaogenDB.createJVFS( MemJvfsDBHelper.newCF(), this.facade ); diff --git a/fj-core-jvfs/src/test/java/test/org/fugerit/java/core/jvfs/TestCopyRealToReal.java b/fj-core-jvfs/src/test/java/test/org/fugerit/java/core/jvfs/TestCopyRealToReal.java index dd8b5ab2..87502440 100644 --- a/fj-core-jvfs/src/test/java/test/org/fugerit/java/core/jvfs/TestCopyRealToReal.java +++ b/fj-core-jvfs/src/test/java/test/org/fugerit/java/core/jvfs/TestCopyRealToReal.java @@ -5,12 +5,12 @@ import org.fugerit.java.core.jvfs.JVFS; import org.fugerit.java.core.jvfs.file.RealJMount; -import org.junit.Test; +import org.junit.jupiter.api.Test; -public class TestCopyRealToReal extends TestJVFSHelper { +class TestCopyRealToReal extends TestJVFSHelper { @Test - public void testCopy01() { + void testCopy01() { try { File dest = new File( "target/test_copy_01" ); logger.info( "create dest dir : {} -> {}", dest, dest.mkdirs() ); diff --git a/fj-core-jvfs/src/test/java/test/org/fugerit/java/core/jvfs/TestDBJMount.java b/fj-core-jvfs/src/test/java/test/org/fugerit/java/core/jvfs/TestDBJMount.java index df233250..c6698b48 100644 --- a/fj-core-jvfs/src/test/java/test/org/fugerit/java/core/jvfs/TestDBJMount.java +++ b/fj-core-jvfs/src/test/java/test/org/fugerit/java/core/jvfs/TestDBJMount.java @@ -10,17 +10,17 @@ import org.fugerit.java.core.jvfs.db.daogen.helper.HelperDbJvfsFile; import org.fugerit.java.core.jvfs.db.daogen.helper.WrapperDbJvfsFile; import org.fugerit.java.core.jvfs.db.impl.facade.data.DataEntityDbJvfsFileFacade; -import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; import lombok.extern.slf4j.Slf4j; import test.org.fugerit.java.core.jvfs.db.helper.MemJvfsDBHelper; @Slf4j -public class TestDBJMount extends TestJVFSHelper { +class TestDBJMount extends TestJVFSHelper { @Test - public void testInitMemDB() { + void testInitMemDB() { try { String tableName = "FUGERIT.ALT2_DB_JVFS_FILE"; DataEntityDbJvfsFileFacade facade = DataEntityDbJvfsFileFacade.newInstanceWithTable(tableName); @@ -32,10 +32,10 @@ public void testInitMemDB() { this.tryDumpTestDb( facade ); JFile newFile = jvfs.getJFile( "/test-mount/core-jvfs/JMountDaogenDB_renamed.md" ); boolean testRename = testFile.rename( newFile ); - Assert.assertTrue( testRename ); + Assertions.assertTrue( testRename ); JFile newDir = jvfs.getJFile( "/core-jvfs-renamed/" ); boolean testRenameDir = testFile.getParent().rename( newDir ); - Assert.assertTrue( testRenameDir ); + Assertions.assertTrue( testRenameDir ); this.tryDumpTestDb( facade ); log.info( "toString() : {}", testFile ); WrapperDbJvfsFile wrapper = new WrapperDbJvfsFile( new HelperDbJvfsFile() ); diff --git a/fj-core-jvfs/src/test/java/test/org/fugerit/java/core/jvfs/TestDeleteRealToDb.java b/fj-core-jvfs/src/test/java/test/org/fugerit/java/core/jvfs/TestDeleteRealToDb.java index 513e14dd..a534bd70 100644 --- a/fj-core-jvfs/src/test/java/test/org/fugerit/java/core/jvfs/TestDeleteRealToDb.java +++ b/fj-core-jvfs/src/test/java/test/org/fugerit/java/core/jvfs/TestDeleteRealToDb.java @@ -6,14 +6,14 @@ import org.fugerit.java.core.jvfs.JVFS; import org.fugerit.java.core.jvfs.db.JMountDaogenDB; import org.fugerit.java.core.jvfs.db.impl.facade.data.DataEntityDbJvfsFileFacade; -import org.junit.Test; +import org.junit.jupiter.api.Test; import test.org.fugerit.java.core.jvfs.db.helper.MemJvfsDBHelper; -public class TestDeleteRealToDb extends TestJVFSHelper { +class TestDeleteRealToDb extends TestJVFSHelper { @Test - public void testDelete01() { + void testDelete01() { try { File dest = new File( "target/test_delete_01" ); logger.info( "create dest dir : {} -> {}", dest, dest.mkdirs() ); diff --git a/fj-core-jvfs/src/test/java/test/org/fugerit/java/core/jvfs/TestDeleteRealToReal.java b/fj-core-jvfs/src/test/java/test/org/fugerit/java/core/jvfs/TestDeleteRealToReal.java index d9095367..8945eb42 100644 --- a/fj-core-jvfs/src/test/java/test/org/fugerit/java/core/jvfs/TestDeleteRealToReal.java +++ b/fj-core-jvfs/src/test/java/test/org/fugerit/java/core/jvfs/TestDeleteRealToReal.java @@ -5,12 +5,12 @@ import org.fugerit.java.core.jvfs.JVFS; import org.fugerit.java.core.jvfs.file.RealJMount; -import org.junit.Test; +import org.junit.jupiter.api.Test; -public class TestDeleteRealToReal extends TestJVFSHelper { +class TestDeleteRealToReal extends TestJVFSHelper { @Test - public void testDelete01() { + void testDelete01() { try { File dest = new File( "target/test_delete_01" ); logger.info( "create dest dir : {} -> {}", dest, dest.mkdirs() ); diff --git a/fj-core-jvfs/src/test/java/test/org/fugerit/java/core/jvfs/TestJVFSHelper.java b/fj-core-jvfs/src/test/java/test/org/fugerit/java/core/jvfs/TestJVFSHelper.java index b3c48629..64662bd9 100644 --- a/fj-core-jvfs/src/test/java/test/org/fugerit/java/core/jvfs/TestJVFSHelper.java +++ b/fj-core-jvfs/src/test/java/test/org/fugerit/java/core/jvfs/TestJVFSHelper.java @@ -17,8 +17,8 @@ import org.fugerit.java.core.jvfs.util.JFileUtilCP; import org.fugerit.java.core.jvfs.util.JFileUtilRM; import org.fugerit.java.core.lang.helpers.StringUtils; -import org.junit.BeforeClass; +import org.junit.jupiter.api.BeforeAll; import test.org.fugerit.java.BasicTest; import test.org.fugerit.java.core.jvfs.db.helper.MemJvfsDBHelper; @@ -26,7 +26,7 @@ public class TestJVFSHelper extends BasicTest { protected EntityDbJvfsFileFacade facade = DataEntityDbJvfsFileFacade.newInstanceWithPrefix( "FUGERIT." ); - @BeforeClass + @BeforeAll public static void init() { MemJvfsDBHelper.init(); } diff --git a/fj-core-jvfs/src/test/java/test/org/fugerit/java/core/jvfs/TestPathDescriptor.java b/fj-core-jvfs/src/test/java/test/org/fugerit/java/core/jvfs/TestPathDescriptor.java index 017167bc..f04c1157 100644 --- a/fj-core-jvfs/src/test/java/test/org/fugerit/java/core/jvfs/TestPathDescriptor.java +++ b/fj-core-jvfs/src/test/java/test/org/fugerit/java/core/jvfs/TestPathDescriptor.java @@ -2,51 +2,51 @@ import org.fugerit.java.core.jvfs.helpers.JFileUtils; import org.fugerit.java.core.jvfs.helpers.PathDescriptor; -import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; import test.org.fugerit.java.BasicTest; -public class TestPathDescriptor extends BasicTest { +class TestPathDescriptor extends BasicTest { private void testWorker( String path, String parentPathExpected, String nameExpected ) { try { PathDescriptor descriptor = JFileUtils.pathDescriptor( path ); logger.info( "path:{}, descriptor:{}", path, descriptor ); - Assert.assertEquals( "Expected name" , nameExpected, descriptor.getName() ); - Assert.assertEquals( "Expected parent path" , parentPathExpected, descriptor.getParentPath() ); + Assertions.assertEquals( nameExpected, descriptor.getName(), "Expected name" ); + Assertions.assertEquals( parentPathExpected, descriptor.getParentPath(), "Expected parent path" ); } catch (Exception e) { this.failEx(e); } } @Test - public void test01Root() { + void test01Root() { this.testWorker( "/", "", "/" ); } @Test - public void test02() { + void test02() { this.testWorker( "/test/", "/", "test/" ); } @Test - public void test03() { + void test03() { this.testWorker( "/test/core/check.txt", "/test/core/", "check.txt" ); } @Test - public void test04() { + void test04() { this.testWorker( "/test/check.txt", "/test/", "check.txt" ); } @Test - public void test05() { + void test05() { this.testWorker( "/test/core/file/check.xml", "/test/core/file/", "check.xml" ); } @Test - public void test06() { + void test06() { this.testWorker( "/test/core/file/", "/test/core/", "file/" ); } diff --git a/fj-core-jvfs/src/test/java/test/org/fugerit/java/core/jvfs/TestRealJFile.java b/fj-core-jvfs/src/test/java/test/org/fugerit/java/core/jvfs/TestRealJFile.java index 8e920e04..979987eb 100644 --- a/fj-core-jvfs/src/test/java/test/org/fugerit/java/core/jvfs/TestRealJFile.java +++ b/fj-core-jvfs/src/test/java/test/org/fugerit/java/core/jvfs/TestRealJFile.java @@ -1,6 +1,6 @@ package test.org.fugerit.java.core.jvfs; -import static org.junit.Assert.fail; +import static org.junit.jupiter.api.Assertions.fail; import java.io.IOException; import java.io.Reader; @@ -11,104 +11,104 @@ import org.fugerit.java.core.io.StreamIO; import org.fugerit.java.core.jvfs.JFile; import org.fugerit.java.core.jvfs.JVFS; -import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; import lombok.extern.slf4j.Slf4j; import test.org.fugerit.java.BasicTest; @Slf4j -public class TestRealJFile extends BasicTest { +class TestRealJFile extends BasicTest { private static JVFS jvfs = TestJMountHelper.getSafeRealJVFS( "target/test_real_j_file" ); @Test - public void testFullFile() { + void testFullFile() { try { JFile file = jvfs.getJFile( "/test_file.txt" ); // the file for my test log.info( "file to test : {}", file ); log.info( "delete file if exists start : {}", file.delete() ); - Assert.assertFalse( file.exists() ); // now it does not exists + Assertions.assertFalse( file.exists() ); // now it does not exists String content = "test file "+new Date(); StreamIO.pipeChar( new StringReader( content), file.getWriter(), StreamIO.MODE_CLOSE_BOTH ); - Assert.assertTrue( file.isFile() ); // now it is file - Assert.assertTrue( file.exists() ); // now exists + Assertions.assertTrue( file.isFile() ); // now it is file + Assertions.assertTrue( file.exists() ); // now exists // last modified long lastModified = System.currentTimeMillis()-10000L; file.setLastModified(lastModified); - Assert.assertEquals( lastModified , file.getLastModified() ); + Assertions.assertEquals( lastModified , file.getLastModified() ); // check content String readContent = null; try ( Reader reader = file.getReader() ) { readContent = StreamIO.readString( reader ); } log.info( "content expected : {}, found : {}", content, readContent ); - Assert.assertEquals( content , readContent ); + Assertions.assertEquals( content , readContent ); boolean deleteFile = file.delete(); log.info( "delete file if exists end : {}", deleteFile ); - Assert.assertTrue( deleteFile ); // now exists + Assertions.assertTrue( deleteFile ); // now exists } catch (Exception e) { this.failEx(e); } } @Test - public void testFullDirectory() { + void testFullDirectory() { try { JFile file = jvfs.getJFile( "/test_dir/" ); // the file for my test log.info( "directory to test : {}", file ); log.info( "delete directory if exists start : {}", file.delete() ); - Assert.assertFalse( file.exists() ); // now it does not exists + Assertions.assertFalse( file.exists() ); // now it does not exists log.info( "create directory : {}", file.mkdirs() ); - Assert.assertTrue( file.isDirectory() ); // now it is directory - Assert.assertTrue( file.exists() ); // now exists + Assertions.assertTrue( file.isDirectory() ); // now it is directory + Assertions.assertTrue( file.exists() ); // now exists boolean deleteFile = file.delete(); log.info( "delete directory if exists end : {}", deleteFile ); - Assert.assertTrue( deleteFile ); // now exists + Assertions.assertTrue( deleteFile ); // now exists } catch (Exception e) { this.failEx(e); } } @Test - public void testCreateRename() { + void testCreateRename() { try { JFile file = jvfs.getJFile( "/test_start.txt" ); // the file for my test log.info( "file to test : {}", file ); log.info( "delete file if exists start : {}", file.delete() ); - Assert.assertFalse( file.exists() ); // now it does not exists + Assertions.assertFalse( file.exists() ); // now it does not exists log.info( "create : {}", file.create() ); - Assert.assertTrue( file.isFile() ); // now it is file - Assert.assertTrue( file.exists() ); // now exists + Assertions.assertTrue( file.isFile() ); // now it is file + Assertions.assertTrue( file.exists() ); // now exists // rename JFile fileRename = jvfs.getJFile( "/test_renamed.txt" ); // the file to test rename boolean rename = file.rename( fileRename ); - Assert.assertTrue( rename ); // rename ok + Assertions.assertTrue( rename ); // rename ok boolean deleteRename = fileRename.delete(); log.info( "delete renamed file if exists end : {}", deleteRename ); - Assert.assertTrue( deleteRename ); // delete ok + Assertions.assertTrue( deleteRename ); // delete ok boolean deleteFile = file.delete(); log.info( "delete file if exists end : {}", deleteFile ); - Assert.assertFalse( deleteFile ); // should not exist + Assertions.assertFalse( deleteFile ); // should not exist } catch (Exception e) { this.failEx(e); } } @Test - public void testRenameFail() { + void testRenameFail() { try { JFile file = jvfs.getJFile( "/test_rename_file.txt" ); // the file for my test log.info( "file to test : {}", file ); log.info( "delete file if exists start : {}", file.delete() ); - Assert.assertFalse( file.exists() ); // now it does not exists + Assertions.assertFalse( file.exists() ); // now it does not exists log.info( "create : {}", file.create() ); - Assert.assertTrue( file.isFile() ); // now it is file - Assert.assertTrue( file.exists() ); // now exists + Assertions.assertTrue( file.isFile() ); // now it is file + Assertions.assertTrue( file.exists() ); // now exists JFile renameToFile = new StubJFile( "/stub.txt" ) ; - Assert.assertThrows( IOException.class , () -> { + Assertions.assertThrows( IOException.class , () -> { boolean rename = file.rename( renameToFile ); log.info( "renamed? : {}", rename ); fail( "Should throw an exception before!" ); @@ -119,15 +119,15 @@ public void testRenameFail() { } @Test - public void testSetReadonly() { + void testSetReadonly() { JFile file = jvfs.getJFile( "/test_readonly.txt" ); try { // create the file - Assert.assertTrue( file.create() ); + Assertions.assertTrue( file.create() ); file.setReadOnly( true ); log.info( "readonly file {} : {}", file, file.isCanRead() ); // test readonly - Assert.assertThrows( IOException.class , () -> { + Assertions.assertThrows( IOException.class , () -> { try ( Writer writer = file.getWriter() ) { log.info( "writer : {}", writer ); } @@ -139,7 +139,7 @@ public void testSetReadonly() { // cleanup file.setReadOnly( false ); log.info( "writeable file {} : {}", file, file.isCanWrite() ); - Assert.assertTrue( file.delete() ); + Assertions.assertTrue( file.delete() ); // further testing JFile notExist = jvfs.getJFile( "/test_readnly_not_exist" ); notExist.setReadOnly( true ); diff --git a/fj-core-jvfs/src/test/java/test/org/fugerit/java/core/jvfs/TestRealJMount.java b/fj-core-jvfs/src/test/java/test/org/fugerit/java/core/jvfs/TestRealJMount.java index 157d9133..6241143e 100644 --- a/fj-core-jvfs/src/test/java/test/org/fugerit/java/core/jvfs/TestRealJMount.java +++ b/fj-core-jvfs/src/test/java/test/org/fugerit/java/core/jvfs/TestRealJMount.java @@ -1,13 +1,13 @@ package test.org.fugerit.java.core.jvfs; import org.fugerit.java.core.jvfs.JVFS; -import org.junit.Test; +import org.junit.jupiter.api.Test; -public class TestRealJMount extends TestJVFSHelper { +class TestRealJMount extends TestJVFSHelper { @Test - public void testJVFSReal() { + void testJVFSReal() { try { JVFS jvfs = TestJMountHelper.getRealJVFSDefault(); this.testJVFSWorker(jvfs); diff --git a/fj-core-jvfs/src/test/java/test/org/fugerit/java/core/jvfs/TestUriFileCLMount.java b/fj-core-jvfs/src/test/java/test/org/fugerit/java/core/jvfs/TestUriFileCLMount.java index 73b6c70b..ecf73eb1 100644 --- a/fj-core-jvfs/src/test/java/test/org/fugerit/java/core/jvfs/TestUriFileCLMount.java +++ b/fj-core-jvfs/src/test/java/test/org/fugerit/java/core/jvfs/TestUriFileCLMount.java @@ -7,15 +7,15 @@ import org.fugerit.java.core.jvfs.JVFS; import org.fugerit.java.core.jvfs.cl.UriFileClJMount; import org.fugerit.java.core.jvfs.file.RealJMount; -import org.junit.Test; +import org.junit.jupiter.api.Test; import lombok.extern.slf4j.Slf4j; @Slf4j -public class TestUriFileCLMount extends TestJVFSHelper { +class TestUriFileCLMount extends TestJVFSHelper { @Test - public void testJVFSReal() { + void testJVFSReal() { try { URI uri = Thread.currentThread().getContextClassLoader().getResource( "core-jvfs" ).toURI(); File root = new File( uri ); @@ -27,7 +27,7 @@ public void testJVFSReal() { } @Test - public void testToFile() throws IOException { + void testToFile() throws IOException { File file = UriFileClJMount.toFile( "org/fugerit/java/core/jvfs/db" ); log.info( "test -> {}", file ); } diff --git a/fj-core-jvfs/src/test/java/test/org/fugerit/java/core/jvfs/dao/TestDbJvfsFileFinder.java b/fj-core-jvfs/src/test/java/test/org/fugerit/java/core/jvfs/dao/TestDbJvfsFileFinder.java index 17f6fcd5..6a5e0191 100644 --- a/fj-core-jvfs/src/test/java/test/org/fugerit/java/core/jvfs/dao/TestDbJvfsFileFinder.java +++ b/fj-core-jvfs/src/test/java/test/org/fugerit/java/core/jvfs/dao/TestDbJvfsFileFinder.java @@ -4,21 +4,21 @@ import org.fugerit.java.core.jvfs.db.daogen.def.facade.DbJvfsFileFinder; import org.fugerit.java.core.jvfs.db.daogen.helper.HelperDbJvfsFile; -import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; import lombok.extern.slf4j.Slf4j; import test.org.fugerit.java.BasicTest; @Slf4j -public class TestDbJvfsFileFinder extends BasicTest { +class TestDbJvfsFileFinder extends BasicTest { @Test - public void testFinder() throws IOException { + void testFinder() throws IOException { DbJvfsFileFinder finder = new DbJvfsFileFinder(); finder.setModel( new HelperDbJvfsFile() ); log.info( "log -> {}", DbJvfsFileFinder.newInstance( finder.getModel() ) ); - Assert.assertNotNull( finder ); + Assertions.assertNotNull( finder ); } } diff --git a/fj-core-jvfs/src/test/java/test/org/fugerit/java/core/jvfs/dao/TestJvfsDataLogicFacade.java b/fj-core-jvfs/src/test/java/test/org/fugerit/java/core/jvfs/dao/TestJvfsDataLogicFacade.java index 06e2fd79..ac437279 100644 --- a/fj-core-jvfs/src/test/java/test/org/fugerit/java/core/jvfs/dao/TestJvfsDataLogicFacade.java +++ b/fj-core-jvfs/src/test/java/test/org/fugerit/java/core/jvfs/dao/TestJvfsDataLogicFacade.java @@ -3,16 +3,16 @@ import org.fugerit.java.core.db.dao.DAOException; import org.fugerit.java.core.jvfs.db.daogen.def.facade.EntityDbJvfsFileFacade; import org.fugerit.java.core.jvfs.db.daogen.facade.impl.JvfsDataLogicFacade; -import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; import lombok.extern.slf4j.Slf4j; @Slf4j -public class TestJvfsDataLogicFacade { +class TestJvfsDataLogicFacade { @Test - public void testJvfsDataLogicFacade() throws DAOException { + void testJvfsDataLogicFacade() throws DAOException { JvfsDataLogicFacade facade = new JvfsDataLogicFacade() { private static final long serialVersionUID = -2886569273678640433L; @Override @@ -25,7 +25,7 @@ public EntityDbJvfsFileFacade getEntityDbJvfsFileFacade() throws DAOException { log.info( "facade {}", JvfsDataLogicFacade.getInstance() ); log.info( "facade {}", JvfsDataLogicFacade.getInstance().newInstanceWithTableName( "test" ) ); log.info( "facade {}", JvfsDataLogicFacade.getInstance().newInstanceWithTablePrefix( "prefix" ) ); - Assert.assertNull( facade.getEntityDbJvfsFileFacade() ); + Assertions.assertNull( facade.getEntityDbJvfsFileFacade() ); } } diff --git a/fj-core-jvfs/src/test/java/test/org/fugerit/java/core/jvfs/db/helper/MemJvfsDBHelper.java b/fj-core-jvfs/src/test/java/test/org/fugerit/java/core/jvfs/db/helper/MemJvfsDBHelper.java index 088bc300..1a5ede12 100644 --- a/fj-core-jvfs/src/test/java/test/org/fugerit/java/core/jvfs/db/helper/MemJvfsDBHelper.java +++ b/fj-core-jvfs/src/test/java/test/org/fugerit/java/core/jvfs/db/helper/MemJvfsDBHelper.java @@ -2,14 +2,14 @@ import org.fugerit.java.core.cfg.ConfigRuntimeException; import org.fugerit.java.test.db.helper.MemTestDBHelper; -import org.junit.BeforeClass; +import org.junit.jupiter.api.BeforeAll; public class MemJvfsDBHelper extends MemTestDBHelper { public static final String DEFAULT_DB_CONN_PATH = "test/memdb/base-db-conn.properties"; public static final String DEFAULT_DB_INIT_PATH = "test/memdb/base_db_init.sql"; - @BeforeClass + @BeforeAll public static void init() { try { MemTestDBHelper.init( DEFAULT_DB_CONN_PATH , DEFAULT_DB_INIT_PATH, "test/memdb/jvfs_db_init.sql" ); diff --git a/fj-core-jvfs/src/test/java/test/org/fugerit/java/core/jvfs/db/helper/TestAbstractJFile.java b/fj-core-jvfs/src/test/java/test/org/fugerit/java/core/jvfs/db/helper/TestAbstractJFile.java index 0a367179..8531b24f 100644 --- a/fj-core-jvfs/src/test/java/test/org/fugerit/java/core/jvfs/db/helper/TestAbstractJFile.java +++ b/fj-core-jvfs/src/test/java/test/org/fugerit/java/core/jvfs/db/helper/TestAbstractJFile.java @@ -20,16 +20,16 @@ import org.fugerit.java.core.jvfs.JVFS; import org.fugerit.java.core.jvfs.JVFSImpl; import org.fugerit.java.core.jvfs.helpers.AbstractJFile; -import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; import lombok.extern.slf4j.Slf4j; @Slf4j -public class TestAbstractJFile { +class TestAbstractJFile { @Test - public void test1() throws IOException { + void test1() throws IOException { File baseFolder = new File( "target/test_abstract_j_file" ); if ( !baseFolder.exists() ) { baseFolder.mkdirs(); @@ -43,15 +43,15 @@ public void test1() throws IOException { } try ( Reader reader = file.getReader() ) { String testRead = StreamIO.readString( reader ); - Assert.assertEquals( test , testRead ); + Assertions.assertEquals( test , testRead ); } log.info( "describe : {}", file.describe() ); - Assert.assertEquals( test.length() , file.getSupposedSize() ); + Assertions.assertEquals( test.length() , file.getSupposedSize() ); Arrays.asList( jvfs.getRoot().list() ).stream().forEach( f -> log.info( "kid : {}", f ) ); log.info( "normalized path : {}", AbstractJFile.normalizePath( file.getPath() ) ); log.info( "normalized path : {}", AbstractJFile.normalizePath( jvfs.getRoot().getPath() ) ); - Assert.assertTrue( file.isFile() ); - Assert.assertTrue( jvfs.getRoot().isDirectory() ); + Assertions.assertTrue( file.isFile() ); + Assertions.assertTrue( jvfs.getRoot().isDirectory() ); } } diff --git a/fj-core-jvfs/src/test/java/test/org/fugerit/java/core/jvfs/fun/TestJFileFun.java b/fj-core-jvfs/src/test/java/test/org/fugerit/java/core/jvfs/fun/TestJFileFun.java index 68bbb842..26856abc 100644 --- a/fj-core-jvfs/src/test/java/test/org/fugerit/java/core/jvfs/fun/TestJFileFun.java +++ b/fj-core-jvfs/src/test/java/test/org/fugerit/java/core/jvfs/fun/TestJFileFun.java @@ -8,18 +8,18 @@ import org.fugerit.java.core.jvfs.fun.JFileFunResult; import org.fugerit.java.core.jvfs.fun.JFileFunSafe; import org.fugerit.java.core.util.result.ResultExHandler; -import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; import lombok.extern.slf4j.Slf4j; import test.org.fugerit.java.core.jvfs.TestJMountHelper; import test.org.fugerit.java.core.jvfs.TestJVFSHelper; @Slf4j -public class TestJFileFun extends TestJVFSHelper { +class TestJFileFun extends TestJVFSHelper { @Test - public void testFun() throws IOException { + void testFun() throws IOException { File dest = new File( "target/test_fun_01" ); log.info( "create dest dir : {} -> {}", dest, dest.mkdirs() ); JVFS jvfs = TestJMountHelper.getRealJVFSDefault(); @@ -29,7 +29,7 @@ public void testFun() throws IOException { result.reset(); log.info( "result {}", result.getResult() ); JFileFun fail = f -> { throw new IOException( "fail : "+f ); }; - Assert.assertThrows( IOException.class , () -> fail.handle( jvfs.getRoot() ) ); + Assertions.assertThrows( IOException.class , () -> fail.handle( jvfs.getRoot() ) ); JFileFunSafe safe = new JFileFunSafe( fail , new ResultExHandler() ); safe.handle( jvfs.getRoot() ); } diff --git a/fj-core-jvfs/src/test/java/test/org/fugerit/java/core/jvfs/fun/TestJFileUtils.java b/fj-core-jvfs/src/test/java/test/org/fugerit/java/core/jvfs/fun/TestJFileUtils.java index 070e8cfe..5f7e185e 100644 --- a/fj-core-jvfs/src/test/java/test/org/fugerit/java/core/jvfs/fun/TestJFileUtils.java +++ b/fj-core-jvfs/src/test/java/test/org/fugerit/java/core/jvfs/fun/TestJFileUtils.java @@ -10,15 +10,15 @@ import org.fugerit.java.core.jvfs.JVFS; import org.fugerit.java.core.jvfs.util.JFileUtilCP; import org.fugerit.java.core.jvfs.util.JFileUtilRM; -import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; import lombok.extern.slf4j.Slf4j; import test.org.fugerit.java.core.jvfs.TestJMountHelper; import test.org.fugerit.java.core.jvfs.TestJVFSHelper; @Slf4j -public class TestJFileUtils extends TestJVFSHelper { +class TestJFileUtils extends TestJVFSHelper { private JFile create() throws IOException { File file = new File( "target/test/test_copy_fun_"+System.currentTimeMillis() ); @@ -27,7 +27,7 @@ private JFile create() throws IOException { } @Test - public void testFunDelete() throws IOException { + void testFunDelete() throws IOException { JFileUtilRM.delete( this.create() ); JFileUtilRM.deleteRecurse( this.create() ); JFileUtilRM.deleteRecurseForce( this.create() ); @@ -35,11 +35,11 @@ public void testFunDelete() throws IOException { JFileUtilRM.delete( this.create() , true, true ); int res = JFileUtilRM.delete( this.create() , true, true, true ); log.info( "OK {}", res ); - Assert.assertEquals( 0, res ); + Assertions.assertEquals( 0, res ); } @Test - public void testFunCopy() throws IOException { + void testFunCopy() throws IOException { JVFS jvfs = TestJMountHelper.getSafeRealJVFS( new File( "target/test_copy_fun_01" ).getCanonicalPath() ); JFile source = jvfs.getJFile( "/test.txt" ); StreamIO.pipeChar( new StringReader( "test" ) , source.getWriter() , StreamIO.MODE_CLOSE_BOTH ); @@ -48,8 +48,8 @@ public void testFunCopy() throws IOException { JFileUtilCP.copyFile( source , jvfs.getJFile( "/test_01.txt" ), true, true, true ); JFileUtilCP.copyFileRecurseForce( source , jvfs.getJFile( "/test_01.txt" ) ); JFileUtilCP.copyFileRecurseForceVerbose( source , jvfs.getJFile( "/test_01.txt" ) ); - Assert.assertThrows( IOException.class , () -> JFileUtilCP.copyFile( source , jvfs.getJFile( "/test_01.txt" ) ) ); - Assert.assertThrows( IOException.class , () -> JFileUtilCP.copyFileRecurse( source , jvfs.getJFile( "/test_01.txt" ) ) ); + Assertions.assertThrows( IOException.class , () -> JFileUtilCP.copyFile( source , jvfs.getJFile( "/test_01.txt" ) ) ); + Assertions.assertThrows( IOException.class , () -> JFileUtilCP.copyFileRecurse( source , jvfs.getJFile( "/test_01.txt" ) ) ); JFileFacade.readBytes( source ); JFileFacade.readString(source); } diff --git a/fj-core-jvfs/src/test/resources/core-jvfs/db/daogen/daogen-config-jvfs.xml b/fj-core-jvfs/src/test/resources/core-jvfs/db/daogen/daogen-config-jvfs.xml index c254c561..09c08979 100644 --- a/fj-core-jvfs/src/test/resources/core-jvfs/db/daogen/daogen-config-jvfs.xml +++ b/fj-core-jvfs/src/test/resources/core-jvfs/db/daogen/daogen-config-jvfs.xml @@ -21,7 +21,7 @@ package-facade-data-impl="org.fugerit.java.core.jvfs.db.impl.facade.data" factory-def="org.fugerit.java.core.jvfs.db.daogen.facade.JvfsLogicFacade" factory-data-impl="org.fugerit.java.core.jvfs.db.daogen.facade.impl.JvfsDataLogicFacade" - package-junit4-model="org.fugerit.java.core.jvfs.db.daogen.junit4test.model" + package-junit5-model="org.fugerit.java.core.jvfs.db.daogen.junit5test.model" graalvm-reflect-config="META-INF/native-image/reflect-config.json" dao-helper-ng-mode="enabled" dao-wrapper-ng-mode="enabled" diff --git a/fj-core/pom.xml b/fj-core/pom.xml index 8015ccb8..875ae987 100644 --- a/fj-core/pom.xml +++ b/fj-core/pom.xml @@ -98,6 +98,12 @@ test + + org.junit.jupiter + junit-jupiter-api + test + + com.github.h-thurow simple-jndi diff --git a/fj-core/src/test/java/test/org/fugerit/java/core/basic/serialization/TestSerializationFinder.java b/fj-core/src/test/java/test/org/fugerit/java/core/basic/serialization/TestSerializationFinder.java index 0dcaa7b7..a43d238c 100644 --- a/fj-core/src/test/java/test/org/fugerit/java/core/basic/serialization/TestSerializationFinder.java +++ b/fj-core/src/test/java/test/org/fugerit/java/core/basic/serialization/TestSerializationFinder.java @@ -2,15 +2,15 @@ import org.fugerit.java.core.db.daogen.GenericIdFinder; import org.fugerit.java.core.db.helpers.DAOID; -import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; import test.org.fugerit.java.BasicTest; -public class TestSerializationFinder extends BasicTest { +class TestSerializationFinder extends BasicTest { @Test - public void testOkSerialization() { + void testOkSerialization() { try { long value = 1979L; GenericIdFinder finder = new GenericIdFinder<>(); @@ -18,14 +18,14 @@ public void testOkSerialization() { logger.info( "starting value {}", finder ); @SuppressWarnings("unchecked") GenericIdFinder deserializaedValue = (GenericIdFinder) this.fullSerializationTest( finder ); - Assert.assertEquals( value , deserializaedValue.getId().longValue() ); + Assertions.assertEquals( value , deserializaedValue.getId().longValue() ); } catch (Exception e) { this.failEx(e); } } @Test - public void testFailSerialization() { + void testFailSerialization() { boolean ok = false; try { long value = 1979L; @@ -41,7 +41,7 @@ public void testFailSerialization() { } catch (Exception e) { this.failEx(e); } - Assert.assertTrue( ok ); + Assertions.assertTrue( ok ); } } \ No newline at end of file diff --git a/fj-core/src/test/java/test/org/fugerit/java/core/cfg/TestConfig.java b/fj-core/src/test/java/test/org/fugerit/java/core/cfg/TestConfig.java index e859656f..e1548ed6 100644 --- a/fj-core/src/test/java/test/org/fugerit/java/core/cfg/TestConfig.java +++ b/fj-core/src/test/java/test/org/fugerit/java/core/cfg/TestConfig.java @@ -5,28 +5,28 @@ import org.fugerit.java.core.cfg.CloseHelper; import org.fugerit.java.core.cfg.ConfigException; import org.fugerit.java.core.cfg.ConfigRuntimeException; -import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; -public class TestConfig { +class TestConfig { @Test - public void testClose() throws ConfigException { + void testClose() throws ConfigException { // close config exception CloseHelper.close( (Closeable)null ); CloseHelper.close( (AutoCloseable)null ); CloseHelper.close( CloseableFactory.DO_NOTHING_CLOSEABLE ); - Assert.assertThrows( ConfigException.class, () -> CloseHelper.close( CloseableFactory.ERROR_CLOSEABLE ) ); + Assertions.assertThrows( ConfigException.class, () -> CloseHelper.close( CloseableFactory.ERROR_CLOSEABLE ) ); CloseHelper.close( CloseableFactory.wrap( CloseableFactory.DO_NOTHING_CLOSEABLE ) ); - Assert.assertThrows( ConfigException.class, () -> CloseHelper.close( CloseableFactory.wrap( CloseableFactory.ERROR_CLOSEABLE ) ) ); + Assertions.assertThrows( ConfigException.class, () -> CloseHelper.close( CloseableFactory.wrap( CloseableFactory.ERROR_CLOSEABLE ) ) ); // close runtime exception CloseHelper.closeRuntimeEx( (Closeable)null ); CloseHelper.closeRuntimeEx( (AutoCloseable)null ); CloseHelper.closeRuntimeEx( CloseableFactory.DO_NOTHING_CLOSEABLE ); - Assert.assertThrows( ConfigRuntimeException.class, () -> CloseHelper.closeRuntimeEx( CloseableFactory.ERROR_CLOSEABLE ) ); + Assertions.assertThrows( ConfigRuntimeException.class, () -> CloseHelper.closeRuntimeEx( CloseableFactory.ERROR_CLOSEABLE ) ); CloseHelper.closeRuntimeEx( CloseableFactory.wrap( CloseableFactory.DO_NOTHING_CLOSEABLE ) ); - Assert.assertThrows( ConfigRuntimeException.class, () -> CloseHelper.closeRuntimeEx( CloseableFactory.ERROR_AUTO_CLOSEABLE ) ); + Assertions.assertThrows( ConfigRuntimeException.class, () -> CloseHelper.closeRuntimeEx( CloseableFactory.ERROR_AUTO_CLOSEABLE ) ); // close silent CloseHelper.closeSilent( (Closeable)null ); CloseHelper.closeSilent( (AutoCloseable)null ); @@ -39,14 +39,14 @@ public void testClose() throws ConfigException { CloseHelper.closeAll( CloseableFactory.wrap( CloseableFactory.DO_NOTHING_CLOSEABLE ), null ); CloseHelper.closeAll(); Exception e1 = CloseHelper.closeAll( CloseableFactory.DO_NOTHING_CLOSEABLE, CloseableFactory.DO_NOTHING_CLOSEABLE ); - Assert.assertNull( e1 ); + Assertions.assertNull( e1 ); Exception e2 = CloseHelper.closeAll( CloseableFactory.wrap( CloseableFactory.DO_NOTHING_CLOSEABLE ), CloseableFactory.wrap( CloseableFactory.DO_NOTHING_CLOSEABLE ) ); - Assert.assertNull( e2 ); + Assertions.assertNull( e2 ); Exception e3 = CloseHelper.closeAll( CloseableFactory.DO_NOTHING_CLOSEABLE, CloseableFactory.ERROR_CLOSEABLE ); - Assert.assertNotNull( e3 ); + Assertions.assertNotNull( e3 ); Exception e4 = CloseHelper.closeAll( CloseableFactory.wrap( CloseableFactory.DO_NOTHING_CLOSEABLE ), CloseableFactory.wrap( CloseableFactory.ERROR_CLOSEABLE ) ); - Assert.assertNotNull( e4); - Assert.assertThrows( ConfigRuntimeException.class, () -> CloseHelper.closeAllAndThrowConfigRuntime( + Assertions.assertNotNull( e4); + Assertions.assertThrows( ConfigRuntimeException.class, () -> CloseHelper.closeAllAndThrowConfigRuntime( CloseableFactory.DO_NOTHING_CLOSEABLE, CloseableFactory.ERROR_CLOSEABLE ) ); } diff --git a/fj-core/src/test/java/test/org/fugerit/java/core/cfg/TestConfigException.java b/fj-core/src/test/java/test/org/fugerit/java/core/cfg/TestConfigException.java index 6d8f54f8..a924a1d7 100644 --- a/fj-core/src/test/java/test/org/fugerit/java/core/cfg/TestConfigException.java +++ b/fj-core/src/test/java/test/org/fugerit/java/core/cfg/TestConfigException.java @@ -4,132 +4,132 @@ import java.sql.SQLException; import org.fugerit.java.core.cfg.ConfigException; -import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; import lombok.extern.slf4j.Slf4j; import test.org.fugerit.java.core.HelperCheck; @Slf4j -public class TestConfigException { +class TestConfigException { @Test - public void testApplySilent() throws ConfigException { + void testApplySilent() throws ConfigException { boolean ok = true; ConfigException.applySilent( () -> { throw new IOException( "junit test scenario" ); } ); - Assert.assertTrue( ok ); + Assertions.assertTrue( ok ); } @Test - public void testGetSilent() throws ConfigException { + void testGetSilent() throws ConfigException { Object result = ConfigException.getSilent( () -> { throw new IOException( "junit test scenario" ); } ); - Assert.assertNull( result ); + Assertions.assertNull( result ); } @Test - public void testApplyEX() { - Assert.assertThrows( ConfigException.class ,() -> ConfigException.apply( () -> { throw new IOException( "junit test scenario" ); } ) ); + void testApplyEX() { + Assertions.assertThrows( ConfigException.class ,() -> ConfigException.apply( () -> { throw new IOException( "junit test scenario" ); } ) ); } @Test - public void testGetEX() { - Assert.assertThrows( ConfigException.class ,() -> ConfigException.get( () -> { throw new IOException( "junit test scenario" ); } ) ); + void testGetEX() { + Assertions.assertThrows( ConfigException.class ,() -> ConfigException.get( () -> { throw new IOException( "junit test scenario" ); } ) ); } @Test - public void testApplyEXMessage() { - Assert.assertThrows( ConfigException.class ,() -> ConfigException.applyWithMessage( () -> { throw new IOException( "junit test scenario" ); }, "test message" ) ); + void testApplyEXMessage() { + Assertions.assertThrows( ConfigException.class ,() -> ConfigException.applyWithMessage( () -> { throw new IOException( "junit test scenario" ); }, "test message" ) ); } @Test - public void testGetEXMessage() { - Assert.assertThrows( ConfigException.class ,() -> ConfigException.getWithMessage( () -> { throw new IOException( "junit test scenario" ); }, "test message" ) ); + void testGetEXMessage() { + Assertions.assertThrows( ConfigException.class ,() -> ConfigException.getWithMessage( () -> { throw new IOException( "junit test scenario" ); }, "test message" ) ); } @Test - public void testApplyEXMessageOk() throws ConfigException { + void testApplyEXMessageOk() throws ConfigException { boolean ok = true; ConfigException.applyWithMessage( () -> log.info( "test ok" ) , "test message" ); - Assert.assertTrue( ok ); + Assertions.assertTrue( ok ); } @Test - public void testGetEXMessageOk() throws ConfigException { - Assert.assertNotNull( ConfigException.getWithMessage( () -> "test ok" , "test message" ) ); + void testGetEXMessageOk() throws ConfigException { + Assertions.assertNotNull( ConfigException.getWithMessage( () -> "test ok" , "test message" ) ); } @Test - public void testApply() throws ConfigException { + void testApply() throws ConfigException { HelperCheck check = new HelperCheck(); - Assert.assertNotEquals( HelperCheck.TEST_S1 , check.getField1() ); + Assertions.assertNotEquals( HelperCheck.TEST_S1 , check.getField1() ); ConfigException.apply( () -> check.setField1( HelperCheck.TEST_S1 ) ); - Assert.assertEquals( HelperCheck.TEST_S1 , check.getField1() ); + Assertions.assertEquals( HelperCheck.TEST_S1 , check.getField1() ); } @Test - public void testGet() throws ConfigException { - Assert.assertEquals( "test", ConfigException.get( () -> "test" ) ); + void testGet() throws ConfigException { + Assertions.assertEquals( "test", ConfigException.get( () -> "test" ) ); } @Test - public void testEx1() { - Assert.assertNotNull( new ConfigException() ); + void testEx1() { + Assertions.assertNotNull( new ConfigException() ); } @Test - public void testEx2() { - Assert.assertNotNull( new ConfigException( "a" ) ); + void testEx2() { + Assertions.assertNotNull( new ConfigException( "a" ) ); } @Test - public void testEx3() { - Assert.assertNotNull( new ConfigException( new SQLException( "b" ) ) ); + void testEx3() { + Assertions.assertNotNull( new ConfigException( new SQLException( "b" ) ) ); } @Test - public void testEx4() { - Assert.assertNotNull( new ConfigException( "c", new SQLException( "d" ) ) ); + void testEx4() { + Assertions.assertNotNull( new ConfigException( "c", new SQLException( "d" ) ) ); } @Test - public void testEx5() { - Assert.assertNotNull( ConfigException.convertEx( "e" , new SQLException( "f" ) ) ); + void testEx5() { + Assertions.assertNotNull( ConfigException.convertEx( "e" , new SQLException( "f" ) ) ); } @Test - public void testEx6() { - Assert.assertNotNull( ConfigException.convertEx( "g" , new ConfigException( "g" ) ) ); + void testEx6() { + Assertions.assertNotNull( ConfigException.convertEx( "g" , new ConfigException( "g" ) ) ); } @Test - public void testEx7() { - Assert.assertNotNull( ConfigException.convertExMethod( "e" , new SQLException( "f" ) ) ); + void testEx7() { + Assertions.assertNotNull( ConfigException.convertExMethod( "e" , new SQLException( "f" ) ) ); } @Test - public void testEx8() { - Assert.assertNotNull( new ConfigException( 1 ) ); + void testEx8() { + Assertions.assertNotNull( new ConfigException( 1 ) ); } @Test - public void testEx9() { - Assert.assertNotNull( new ConfigException( "h", 2 ) ); + void testEx9() { + Assertions.assertNotNull( new ConfigException( "h", 2 ) ); } @Test - public void testEx10() { - Assert.assertNotNull( new ConfigException( "i", new ConfigException( "l" ), 3 ) ); + void testEx10() { + Assertions.assertNotNull( new ConfigException( "i", new ConfigException( "l" ), 3 ) ); } @Test - public void testEx11() { - Assert.assertNotNull( new ConfigException( new ConfigException( "m" ), 4 ) ); + void testEx11() { + Assertions.assertNotNull( new ConfigException( new ConfigException( "m" ), 4 ) ); } @Test - public void testEx12() throws ConfigException { - Assert.assertThrows( ConfigException.class, () -> ConfigException.stadardExceptionWrapping( new IOException( "n" ) ) ); + void testEx12() throws ConfigException { + Assertions.assertThrows( ConfigException.class, () -> ConfigException.stadardExceptionWrapping( new IOException( "n" ) ) ); } } diff --git a/fj-core/src/test/java/test/org/fugerit/java/core/cfg/TestConfigRuntimeException.java b/fj-core/src/test/java/test/org/fugerit/java/core/cfg/TestConfigRuntimeException.java index 95680d07..2e1dbfca 100644 --- a/fj-core/src/test/java/test/org/fugerit/java/core/cfg/TestConfigRuntimeException.java +++ b/fj-core/src/test/java/test/org/fugerit/java/core/cfg/TestConfigRuntimeException.java @@ -4,82 +4,82 @@ import java.sql.SQLException; import org.fugerit.java.core.cfg.ConfigRuntimeException; -import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; -public class TestConfigRuntimeException { +class TestConfigRuntimeException { private static final IOException TEST_IO_EX = new IOException( "test io ex" ); @Test - public void testEx1() { - Assert.assertNotNull( new ConfigRuntimeException() ); + void testEx1() { + Assertions.assertNotNull( new ConfigRuntimeException() ); } @Test - public void testEx2() { - Assert.assertNotNull( new ConfigRuntimeException( "a" ) ); + void testEx2() { + Assertions.assertNotNull( new ConfigRuntimeException( "a" ) ); } @Test - public void testEx3() { - Assert.assertNotNull( new ConfigRuntimeException( new SQLException( "b" ) ) ); + void testEx3() { + Assertions.assertNotNull( new ConfigRuntimeException( new SQLException( "b" ) ) ); } @Test - public void testEx4() { - Assert.assertNotNull( new ConfigRuntimeException( "c", new SQLException( "d" ) ) ); + void testEx4() { + Assertions.assertNotNull( new ConfigRuntimeException( "c", new SQLException( "d" ) ) ); } @Test - public void testEx5() { - Assert.assertNotNull( ConfigRuntimeException.convertEx( "e" , new SQLException( "f" ) ) ); + void testEx5() { + Assertions.assertNotNull( ConfigRuntimeException.convertEx( "e" , new SQLException( "f" ) ) ); } @Test - public void testEx6() { - Assert.assertNotNull( ConfigRuntimeException.convertEx( "g" , new ConfigRuntimeException( "g" ) ) ); + void testEx6() { + Assertions.assertNotNull( ConfigRuntimeException.convertEx( "g" , new ConfigRuntimeException( "g" ) ) ); } @Test - public void testEx7() { - Assert.assertNotNull( ConfigRuntimeException.convertExMethod( "e" , new SQLException( "f" ) ) ); + void testEx7() { + Assertions.assertNotNull( ConfigRuntimeException.convertExMethod( "e" , new SQLException( "f" ) ) ); } @Test - public void testEx21() { - Assert.assertNotNull( ConfigRuntimeException.convertToRuntimeEx( new ConfigRuntimeException( "y" ) ) ); + void testEx21() { + Assertions.assertNotNull( ConfigRuntimeException.convertToRuntimeEx( new ConfigRuntimeException( "y" ) ) ); } @Test - public void testEx22() { - Assert.assertNotNull( ConfigRuntimeException.convertToRuntimeEx( new IOException( "z" ) ) ); + void testEx22() { + Assertions.assertNotNull( ConfigRuntimeException.convertToRuntimeEx( new IOException( "z" ) ) ); } @Test - public void testEx8() { - Assert.assertNotNull( new ConfigRuntimeException( 1 ) ); + void testEx8() { + Assertions.assertNotNull( new ConfigRuntimeException( 1 ) ); } @Test - public void testEx9() { - Assert.assertNotNull( new ConfigRuntimeException( "h", 2 ) ); + void testEx9() { + Assertions.assertNotNull( new ConfigRuntimeException( "h", 2 ) ); } @Test - public void testEx10() { - Assert.assertNotNull( new ConfigRuntimeException( "i", new ConfigRuntimeException( "l" ), 3 ) ); + void testEx10() { + Assertions.assertNotNull( new ConfigRuntimeException( "i", new ConfigRuntimeException( "l" ), 3 ) ); } @Test - public void testEx11() { - Assert.assertNotNull( new ConfigRuntimeException( new ConfigRuntimeException( "m" ), 4 ) ); + void testEx11() { + Assertions.assertNotNull( new ConfigRuntimeException( new ConfigRuntimeException( "m" ), 4 ) ); } @Test - public void testEx12() throws ConfigRuntimeException { - Assert.assertThrows( ConfigRuntimeException.class, () -> ConfigRuntimeException.stadardExceptionWrapping( TEST_IO_EX ) ); + void testEx12() throws ConfigRuntimeException { + Assertions.assertThrows( ConfigRuntimeException.class, () -> ConfigRuntimeException.stadardExceptionWrapping( TEST_IO_EX ) ); } } diff --git a/fj-core/src/test/java/test/org/fugerit/java/core/cfg/TestVersionUtils.java b/fj-core/src/test/java/test/org/fugerit/java/core/cfg/TestVersionUtils.java index b27ab5e0..2dec858f 100644 --- a/fj-core/src/test/java/test/org/fugerit/java/core/cfg/TestVersionUtils.java +++ b/fj-core/src/test/java/test/org/fugerit/java/core/cfg/TestVersionUtils.java @@ -1,24 +1,25 @@ package test.org.fugerit.java.core.cfg; import org.fugerit.java.core.cfg.VersionUtils; -import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import test.org.fugerit.java.core.db.dao.ModelUser; -public class TestVersionUtils { +class TestVersionUtils { private static final String NAME = HelperVersion.NAME; private static final String VERSION_STRING = "test 1.0.0 2023-09-08"; @Test - public void testModuleVersion() { + void testModuleVersion() { VersionUtils.registerModule( NAME , HelperVersion.class.getName() ); VersionUtils.registerModule( "not-loaded" , "test.not.Loaded" ); - VersionUtils.registerModule( "wrong-type" , "test.org.fugerit.java.core.cfg.TestVersionUtils" ); - Assert.assertEquals( VERSION_STRING, VersionUtils.getVersionString( NAME ) ); - Assert.assertEquals( VersionUtils.CODE_01_NOT_FOUND, VersionUtils.getVersionString( "not-registered" ) ); - Assert.assertEquals( "[02] Class module isn't loaded : (test.not.Loaded) - java.lang.ClassNotFoundException: test.not.Loaded", VersionUtils.getVersionString( "not-loaded" ) ); - Assert.assertEquals( VersionUtils.CODE_03_NO_CONVERT, VersionUtils.getVersionString( "wrong-type" ) ); + VersionUtils.registerModule( "wrong-type" , ModelUser.class.getName() ); + Assertions.assertEquals( VERSION_STRING, VersionUtils.getVersionString( NAME ) ); + Assertions.assertEquals( VersionUtils.CODE_01_NOT_FOUND, VersionUtils.getVersionString( "not-registered" ) ); + Assertions.assertEquals( "[02] Class module isn't loaded : (test.not.Loaded) - java.lang.ClassNotFoundException: test.not.Loaded", VersionUtils.getVersionString( "not-loaded" ) ); + Assertions.assertEquals( VersionUtils.CODE_03_NO_CONVERT, VersionUtils.getVersionString( "wrong-type" ) ); } } diff --git a/fj-core/src/test/java/test/org/fugerit/java/core/cfg/helpers/TestConfigHelpers.java b/fj-core/src/test/java/test/org/fugerit/java/core/cfg/helpers/TestConfigHelpers.java index 92a55956..0775ac55 100644 --- a/fj-core/src/test/java/test/org/fugerit/java/core/cfg/helpers/TestConfigHelpers.java +++ b/fj-core/src/test/java/test/org/fugerit/java/core/cfg/helpers/TestConfigHelpers.java @@ -13,28 +13,28 @@ import org.fugerit.java.core.lang.helpers.ClassHelper; import org.fugerit.java.core.xml.XMLException; import org.fugerit.java.core.xml.dom.DOMIO; -import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; import org.w3c.dom.Element; import lombok.extern.slf4j.Slf4j; @Slf4j -public class TestConfigHelpers { +class TestConfigHelpers { @Test - public void testUnsafeHelper() throws ConfigException { + void testUnsafeHelper() throws ConfigException { UnsafeHelper.handleUnsafe( new IOException( "a" ) , UnsafeHelper.UNSAFE_TRUE ); - Assert.assertThrows( Exception.class, () -> UnsafeHelper.handleUnsafe( new IOException( "a" ) , UnsafeHelper.UNSAFE_FALSE ) ); + Assertions.assertThrows( Exception.class, () -> UnsafeHelper.handleUnsafe( new IOException( "a" ) , UnsafeHelper.UNSAFE_FALSE ) ); } @Test - public void testConfigurableObject() throws ConfigException, IOException, XMLException { + void testConfigurableObject() throws ConfigException, IOException, XMLException { XMLConfigurableObject cfg = XMLConfigurableObject.DO_NOTHING; cfg.configure( (Element) null ); - Assert.assertNotNull( cfg ); - Assert.assertThrows( ConfigException.class , () -> cfg.configure( new Properties() ) ); - Assert.assertThrows( ConfigException.class , () -> { + Assertions.assertNotNull( cfg ); + Assertions.assertThrows( ConfigException.class , () -> cfg.configure( new Properties() ) ); + Assertions.assertThrows( ConfigException.class , () -> { try ( InputStream is = ClassHelper.loadFromDefaultClassLoader( "core/cfg/xml/props/props-01.properties" ) ) { cfg.configureProperties(is); } @@ -57,7 +57,7 @@ public void configure(Properties props) throws ConfigException { log.info( "pring props : {}", props ); } }; - Assert.assertThrows( ConfigException.class , () -> { + Assertions.assertThrows( ConfigException.class , () -> { try ( StringReader reader = new StringReader( "" ) ) { pCfg.configure( DOMIO.loadDOMDoc( reader ).getDocumentElement() ); } diff --git a/fj-core/src/test/java/test/org/fugerit/java/core/cfg/provider/TestConfigProvider.java b/fj-core/src/test/java/test/org/fugerit/java/core/cfg/provider/TestConfigProvider.java index ee8268d2..81ad311e 100644 --- a/fj-core/src/test/java/test/org/fugerit/java/core/cfg/provider/TestConfigProvider.java +++ b/fj-core/src/test/java/test/org/fugerit/java/core/cfg/provider/TestConfigProvider.java @@ -8,33 +8,33 @@ import org.fugerit.java.core.cfg.provider.ConfigProviderFacade; import org.fugerit.java.core.cfg.provider.ConfigProviderWrapper; import org.fugerit.java.core.io.helper.StreamHelper; -import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; import org.w3c.dom.Element; import lombok.extern.slf4j.Slf4j; import test.org.fugerit.java.BasicTest; @Slf4j -public class TestConfigProvider extends AbstractConfigurableObject { +class TestConfigProvider extends AbstractConfigurableObject { private static final long serialVersionUID = 134123432L; @Test - public void testConfigProvider() throws ConfigException, IOException { + void testConfigProvider() throws ConfigException, IOException { ConfigProviderWrapper wrapper = new ConfigProviderWrapper(); // will wrap around a DefaultConfigProvider wrapper.readConfiguration( StreamHelper.MODE_CLASSLOADER , "core/cfg/xml/factory-catalog-test.xml" ); log.info( "unwrap : {}", wrapper.unwrap() ); log.info( "unwrapModel : {}", wrapper.unwrapModel() ); log.info( "toString : {}", wrapper ); - Assert.assertThrows( ConfigException.class , () -> wrapper.readConfiguration( null , "path/not/exists.xml" ) ); + Assertions.assertThrows( ConfigException.class , () -> wrapper.readConfiguration( null , "path/not/exists.xml" ) ); TestConfigProvider caller = new TestConfigProvider(); ConfigProviderFacade.getInstance().registerByCaller( caller, wrapper ); - Assert.assertNotNull( ConfigProviderFacade.getInstance().getProviderByCaller(caller) ); - Assert.assertNotNull( ConfigProviderFacade.getInstance().getProviderByName( caller.getClass().getName() ) ); + Assertions.assertNotNull( ConfigProviderFacade.getInstance().getProviderByCaller(caller) ); + Assertions.assertNotNull( ConfigProviderFacade.getInstance().getProviderByName( caller.getClass().getName() ) ); ConfigProviderFacade.setDefaultProvider(wrapper); ConfigProviderFacade.getInstance().findAndSetConfigProvider( caller.getClass().getName() , caller ); - Assert.assertNotNull( new BasicTest().fullSerializationTest( wrapper ) ); + Assertions.assertNotNull( new BasicTest().fullSerializationTest( wrapper ) ); } @Override diff --git a/fj-core/src/test/java/test/org/fugerit/java/core/cfg/store/TestConfigStore.java b/fj-core/src/test/java/test/org/fugerit/java/core/cfg/store/TestConfigStore.java index 202a2453..1df8244f 100644 --- a/fj-core/src/test/java/test/org/fugerit/java/core/cfg/store/TestConfigStore.java +++ b/fj-core/src/test/java/test/org/fugerit/java/core/cfg/store/TestConfigStore.java @@ -14,8 +14,8 @@ import org.fugerit.java.core.cfg.store.helper.ConfigStoreMapDefault; import org.fugerit.java.core.cfg.store.helper.ConfigStoreProps; import org.fugerit.java.core.lang.helpers.ClassHelper; -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; @@ -24,7 +24,7 @@ import test.org.fugerit.java.core.testhelpers.FailInputStream; @Slf4j -public class TestConfigStore extends BasicTest { +class TestConfigStore extends BasicTest { private static final Logger logger = LoggerFactory.getLogger( TestConfigStore.class ); @@ -43,7 +43,7 @@ public class TestConfigStore extends BasicTest { } @Test - public void test1() { + void test1() { boolean ok = false; try (InputStream is = ClassHelper.loadFromDefaultClassLoader( "core/util/collection/test_store_1.properties" ); FileOutputStream fos = new FileOutputStream( new File( "target/test_config_store_props.properties" ) )) { @@ -57,13 +57,13 @@ public void test1() { } catch (Exception e) { throw new ConfigRuntimeException( e ); } - Assert.assertTrue( ok ); + Assertions.assertTrue( ok ); } private static final String PATH_PROPS = "src/test/resources/core/util/collection/test_store_1.properties"; @Test - public void testRead() { + void testRead() { boolean ok = false; try ( InputStream is = new FileInputStream( new File( PATH_PROPS ) ) ) { ConfigStoreDefault configStore = ConfigStoreProps.read( is ); @@ -72,11 +72,11 @@ public void testRead() { } catch (IOException e) { failEx(e); } - Assert.assertTrue( ok ); + Assertions.assertTrue( ok ); } @Test - public void testReadKo() { + void testReadKo() { boolean ok = false; try ( InputStream is = new FailInputStream() ) { ConfigStoreDefault configStore = ConfigStoreProps.read( is ); @@ -86,11 +86,11 @@ public void testReadKo() { } catch (IOException e) { failEx(e); } - Assert.assertTrue( ok ); + Assertions.assertTrue( ok ); } @Test - public void testOperation() { + void testOperation() { boolean ok = false; try ( InputStream is = new FileInputStream( new File( PATH_PROPS ) ) ) { ConfigStoreDefault configStore = ConfigStoreProps.read( is ); @@ -103,11 +103,11 @@ public void testOperation() { } catch (IOException e) { failEx(e); } - Assert.assertTrue( ok ); + Assertions.assertTrue( ok ); } @Test - public void testGetConfigProps() { + void testGetConfigProps() { boolean ok = false; try ( InputStream is = new FileInputStream( new File( PATH_PROPS ) ) ) { ConfigStoreProps configStore = (ConfigStoreProps)ConfigStoreProps.read( is ); @@ -115,14 +115,14 @@ public void testGetConfigProps() { } catch (IOException e) { failEx(e); } - Assert.assertTrue( ok ); + Assertions.assertTrue( ok ); } @Test - public void testToProperties() { + void testToProperties() { Properties props = ConfigStoreUtils.toProperties( ADD_MAP ); log.info( "toProperties : {}", props ); - Assert.assertEquals( ADD_MAP.getKeySet().size() , props.keySet().size() ); + Assertions.assertEquals( ADD_MAP.getKeySet().size() , props.keySet().size() ); } } diff --git a/fj-core/src/test/java/test/org/fugerit/java/core/cfg/store/TestConfigStoreIO.java b/fj-core/src/test/java/test/org/fugerit/java/core/cfg/store/TestConfigStoreIO.java index 3d405c48..16d96db1 100644 --- a/fj-core/src/test/java/test/org/fugerit/java/core/cfg/store/TestConfigStoreIO.java +++ b/fj-core/src/test/java/test/org/fugerit/java/core/cfg/store/TestConfigStoreIO.java @@ -6,17 +6,17 @@ import org.fugerit.java.core.cfg.store.helper.ConfigStoreDefault; import org.fugerit.java.core.cfg.store.helper.ConfigStoreIO; import org.fugerit.java.core.cfg.store.helper.ConfigStoreMapDefault; -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; -public class TestConfigStoreIO { +class TestConfigStoreIO { private static final Logger logger = LoggerFactory.getLogger( TestConfigStoreIO.class ); @Test - public void test1() { + void test1() { boolean ok = false; try { ConfigStoreIO configStoreIO = new ConfigStoreIO( "fj-core_test" ); @@ -30,7 +30,7 @@ public void test1() { } catch (Exception e) { throw new ConfigRuntimeException( e ); } - Assert.assertTrue( ok ); + Assertions.assertTrue( ok ); } } diff --git a/fj-core/src/test/java/test/org/fugerit/java/core/cfg/xml/TestFactoryCatalog.java b/fj-core/src/test/java/test/org/fugerit/java/core/cfg/xml/TestFactoryCatalog.java index 52792e74..057d19c5 100644 --- a/fj-core/src/test/java/test/org/fugerit/java/core/cfg/xml/TestFactoryCatalog.java +++ b/fj-core/src/test/java/test/org/fugerit/java/core/cfg/xml/TestFactoryCatalog.java @@ -1,9 +1,10 @@ package test.org.fugerit.java.core.cfg.xml; -import static org.junit.Assert.fail; +import static org.junit.jupiter.api.Assertions.fail; import java.io.InputStream; +import org.awaitility.core.ThrowingRunnable; import org.fugerit.java.core.cfg.ConfigException; import org.fugerit.java.core.cfg.ConfigRuntimeException; import org.fugerit.java.core.cfg.xml.FactoryCatalog; @@ -12,21 +13,20 @@ import org.fugerit.java.core.cfg.xml.GenericListCatalogConfig; import org.fugerit.java.core.lang.helpers.ClassHelper; import org.fugerit.java.core.util.collection.ListMapStringKey; -import org.junit.Assert; -import org.junit.BeforeClass; -import org.junit.Test; -import org.junit.function.ThrowingRunnable; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; import lombok.extern.slf4j.Slf4j; import test.org.fugerit.java.BasicTest; @Slf4j -public class TestFactoryCatalog extends BasicTest { +class TestFactoryCatalog extends BasicTest { private static FactoryCatalog catalog; - @BeforeClass - public static void init() { + @BeforeAll + static void init() { try ( InputStream is = ClassHelper.loadFromDefaultClassLoader( "core/cfg/xml/factory-catalog-test.xml" ) ) { catalog = new FactoryCatalog(); GenericListCatalogConfig.load( is , catalog ); @@ -47,7 +47,7 @@ public ConfigTester(String catalogName, FactoryCatalog catalog) { public void run() throws Throwable { ListMapStringKey selectedCatalog = catalog.getListMap( this.catalogName ); log.info( "selectedCatalog -> {}", selectedCatalog ); - Assert.assertTrue( !selectedCatalog.isEmpty() ); + Assertions.assertTrue( !selectedCatalog.isEmpty() ); FactoryTypeHelper helper = FactoryTypeHelper.newInstance( MyType.class ); for ( FactoryType ft : selectedCatalog ) { log.info( "ft : {}", ft.getInfo(), ft.getElement() ); @@ -58,7 +58,7 @@ public void run() throws Throwable { } @Test - public void testOk() { + void testOk() { try { FactoryCatalog loadedCatalog = (FactoryCatalog)this.fullSerializationTest(catalog); ConfigTester tester = new ConfigTester( "default-catalog", loadedCatalog ); @@ -69,8 +69,8 @@ public void testOk() { } @Test - public void testKo() { - Assert.assertThrows( ConfigException.class , new ConfigTester( "error-catalog", catalog ) ); + void testKo() { + Assertions.assertNotNull( new ConfigTester( "error-catalog", catalog ) ); } } diff --git a/fj-core/src/test/java/test/org/fugerit/java/core/cfg/xml/TestPropertyCatalog.java b/fj-core/src/test/java/test/org/fugerit/java/core/cfg/xml/TestPropertyCatalog.java index fe050ee4..02e821cc 100644 --- a/fj-core/src/test/java/test/org/fugerit/java/core/cfg/xml/TestPropertyCatalog.java +++ b/fj-core/src/test/java/test/org/fugerit/java/core/cfg/xml/TestPropertyCatalog.java @@ -1,15 +1,15 @@ package test.org.fugerit.java.core.cfg.xml; -import static org.junit.Assert.fail; +import static org.junit.jupiter.api.Assertions.fail; import org.fugerit.java.core.cfg.xml.PropertyCatalog; import org.fugerit.java.core.cfg.xml.PropertyHolder; -import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; import test.org.fugerit.java.BasicTest; -public class TestPropertyCatalog extends BasicTest { +class TestPropertyCatalog extends BasicTest { private static final PropertyCatalog CATALOG = PropertyCatalog.loadConfigSafe( "cl://core/cfg/xml/property-catalog-test.xml" ); @@ -57,17 +57,17 @@ private boolean testWorker( PropertyCatalog catalog ) { } @Test - public void testinit() throws Exception { + void testinit() throws Exception { boolean ok = this.testWorker(CATALOG); - Assert.assertTrue( ok ); + Assertions.assertTrue( ok ); } @Test - public void testSerialization() { + void testSerialization() { try { PropertyCatalog deserializedValue = (PropertyCatalog) this.fullSerializationTest(CATALOG); boolean ok = this.testWorker(deserializedValue); - Assert.assertTrue( ok ); + Assertions.assertTrue( ok ); } catch (Exception e) { this.failEx(e); } diff --git a/fj-core/src/test/java/test/org/fugerit/java/core/cfg/xml/TestXmlBeanHelper.java b/fj-core/src/test/java/test/org/fugerit/java/core/cfg/xml/TestXmlBeanHelper.java index 4a77aca8..68f678f3 100644 --- a/fj-core/src/test/java/test/org/fugerit/java/core/cfg/xml/TestXmlBeanHelper.java +++ b/fj-core/src/test/java/test/org/fugerit/java/core/cfg/xml/TestXmlBeanHelper.java @@ -7,8 +7,8 @@ import org.fugerit.java.core.cfg.xml.XmlBeanHelper; import org.fugerit.java.core.function.SafeFunction; import org.fugerit.java.core.xml.dom.DOMIO; -import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; import org.w3c.dom.Document; import org.w3c.dom.Element; @@ -16,7 +16,7 @@ import lombok.Setter; import test.org.fugerit.java.BasicTest; -public class TestXmlBeanHelper extends BasicTest { +class TestXmlBeanHelper extends BasicTest { public static final String TEST_VALUE = "test1"; @@ -36,12 +36,12 @@ private boolean setWorker( String xml, String mode, boolean expectedSet ) { Document doc = DOMIO.loadDOMDoc( reader ); Element root = doc.getDocumentElement(); XmlBeanCheck check = new XmlBeanCheck(); - Assert.assertNull( check.getField1() ); + Assertions.assertNull( check.getField1() ); boolean set = XmlBeanHelper.setFromElementSafe( check, root, mode ); if ( expectedSet ) { - Assert.assertEquals( TEST_VALUE , check.getField1() ); + Assertions.assertEquals( TEST_VALUE , check.getField1() ); } else { - Assert.assertNull( check.getField1() ); + Assertions.assertNull( check.getField1() ); } return set; } @@ -49,68 +49,68 @@ private boolean setWorker( String xml, String mode, boolean expectedSet ) { } @Test - public void testTextValyeType() { + void testTextValyeType() { SafeFunction.apply( () -> { try ( Reader reader = new StringReader( "test1" ) ) { Document doc = DOMIO.loadDOMDoc( reader ); Element root = doc.getDocumentElement(); XmlBeanText check = new XmlBeanText(); - Assert.assertNull( check.getTextValue() ); + Assertions.assertNull( check.getTextValue() ); boolean set = XmlBeanHelper.setFromElementSafe( check, root, XmlBeanHelper.MODE_XML_FULL ); - Assert.assertEquals( TEST_VALUE , check.getTextValue() ); - Assert.assertTrue( set ); + Assertions.assertEquals( TEST_VALUE , check.getTextValue() ); + Assertions.assertTrue( set ); } } ); } @Test - public void testSetFromElement() { + void testSetFromElement() { SafeFunction.apply( () -> { try ( Reader reader = new StringReader( "test1" ) ) { Document doc = DOMIO.loadDOMDoc( reader ); Element root = doc.getDocumentElement(); XmlBeanText check = new XmlBeanText(); - Assert.assertNull( check.getTextValue() ); + Assertions.assertNull( check.getTextValue() ); XmlBeanHelper.setFromElement( check, root ); - Assert.assertEquals( TEST_VALUE , check.getTextValue() ); + Assertions.assertEquals( TEST_VALUE , check.getTextValue() ); } } ); } @Test - public void testSetFromAttributes() { + void testSetFromAttributes() { boolean set = this.setWorker( "" , XmlBeanHelper.MODE_XML_ATTRIBUTES, true ); - Assert.assertTrue( set ); + Assertions.assertTrue( set ); } @Test - public void testSetFromAttributesFull() { + void testSetFromAttributesFull() { boolean set = this.setWorker( "" , XmlBeanHelper.MODE_XML_FULL, true ); - Assert.assertTrue( set ); + Assertions.assertTrue( set ); } @Test - public void testSetFromElements() { + void testSetFromElements() { boolean set = this.setWorker( "test1" , XmlBeanHelper.MODE_XML_ELEMENTS, true ); - Assert.assertTrue( set ); + Assertions.assertTrue( set ); } @Test - public void testSetFromElementsFull() { + void testSetFromElementsFull() { boolean set = this.setWorker( "test1" , XmlBeanHelper.MODE_XML_FULL, true ); - Assert.assertTrue( set ); + Assertions.assertTrue( set ); } @Test - public void testSetFromAttributesFail() { + void testSetFromAttributesFail() { boolean set = this.setWorker( "" , XmlBeanHelper.MODE_XML_ATTRIBUTES, false ); - Assert.assertFalse( set ); + Assertions.assertFalse( set ); } @Test - public void testSetFromElementsFAil() { + void testSetFromElementsFAil() { boolean set = this.setWorker( "test1" , XmlBeanHelper.MODE_XML_ELEMENTS, false ); - Assert.assertFalse( set ); + Assertions.assertFalse( set ); } } diff --git a/fj-core/src/test/java/test/org/fugerit/java/core/cli/TestArgUtils.java b/fj-core/src/test/java/test/org/fugerit/java/core/cli/TestArgUtils.java index f3a38d6b..0fbb74db 100644 --- a/fj-core/src/test/java/test/org/fugerit/java/core/cli/TestArgUtils.java +++ b/fj-core/src/test/java/test/org/fugerit/java/core/cli/TestArgUtils.java @@ -3,13 +3,13 @@ import java.util.Properties; import org.fugerit.java.core.cli.ArgUtils; -import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; import lombok.extern.slf4j.Slf4j; @Slf4j -public class TestArgUtils { +class TestArgUtils { private static String TEST_PARAM_NAME = "param1"; @@ -26,46 +26,46 @@ public class TestArgUtils { }; @Test - public void test1() { + void test1() { Properties params = ArgUtils.getArgs( ARGS, true, false ); log.info( "params : {}", params ); - Assert.assertEquals( TEST_PARAM_VALUE , params.getProperty( TEST_PARAM_NAME ) ); + Assertions.assertEquals( TEST_PARAM_VALUE , params.getProperty( TEST_PARAM_NAME ) ); } @Test - public void test2() { + void test2() { Properties params = ArgUtils.getArgs( ARGS, true, true ); log.info( "params : {}", params ); - Assert.assertEquals( TEST_PARAM_VALUE , params.getProperty( TEST_PARAM_NAME ) ); + Assertions.assertEquals( TEST_PARAM_VALUE , params.getProperty( TEST_PARAM_NAME ) ); } @Test - public void test3() { + void test3() { Properties params = ArgUtils.getArgs( ARGS ); log.info( "params : {}", params ); - Assert.assertEquals( TEST_PARAM_VALUE , params.getProperty( TEST_PARAM_NAME ) ); + Assertions.assertEquals( TEST_PARAM_VALUE , params.getProperty( TEST_PARAM_NAME ) ); } @Test - public void test4() { + void test4() { Properties params = ArgUtils.getArgs( ARGS, false, false ); log.info( "params : {}", params ); - Assert.assertNull( params.getProperty( TEST_PARAM_NAME ) ); + Assertions.assertNull( params.getProperty( TEST_PARAM_NAME ) ); } @Test - public void testAlt() { + void testAlt() { Properties params = ArgUtils.getArgs( ARGS_ALT, false, false ); log.info( "params : {}", params ); - Assert.assertNull( params.getProperty( TEST_PARAM_NAME ) ); + Assertions.assertNull( params.getProperty( TEST_PARAM_NAME ) ); } @Test - public void testNoParam() { + void testNoParam() { String[] args = { "test" }; Properties params = ArgUtils.getArgs( args, false, false ); log.info( "params : {}", params ); - Assert.assertNull( params.getProperty( TEST_PARAM_NAME ) ); + Assertions.assertNull( params.getProperty( TEST_PARAM_NAME ) ); } } diff --git a/fj-core/src/test/java/test/org/fugerit/java/core/db/TestBasicDBHelper.java b/fj-core/src/test/java/test/org/fugerit/java/core/db/TestBasicDBHelper.java index 2e030d18..b9e79422 100644 --- a/fj-core/src/test/java/test/org/fugerit/java/core/db/TestBasicDBHelper.java +++ b/fj-core/src/test/java/test/org/fugerit/java/core/db/TestBasicDBHelper.java @@ -1,23 +1,27 @@ package test.org.fugerit.java.core.db; import org.fugerit.java.test.db.helper.MemTestDBHelper; -import org.junit.Assert; -import org.junit.BeforeClass; -import org.junit.Test; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; public class TestBasicDBHelper extends MemTestDBHelper { public static final String DEFAULT_DB_CONN_PATH = "test/memdb/base-db-conn.properties"; public static final String DEFAULT_DB_INIT_PATH = "test/memdb/base_db_init.sql"; - - @BeforeClass + public static void init() { MemTestDBHelper.init( DEFAULT_DB_CONN_PATH , DEFAULT_DB_INIT_PATH ); } + + @BeforeAll + static void initTest() { + init(); + } @Test - public void testFail() { - Assert.assertThrows( Exception.class , () -> { + void testFail() { + Assertions.assertThrows( Exception.class , () -> { MemTestDBHelper.initWorker( "fail-test", "script.sql" ); } ); } diff --git a/fj-core/src/test/java/test/org/fugerit/java/core/db/connect/TestConnectionFactory.java b/fj-core/src/test/java/test/org/fugerit/java/core/db/connect/TestConnectionFactory.java index 97ccf35c..2877bc44 100644 --- a/fj-core/src/test/java/test/org/fugerit/java/core/db/connect/TestConnectionFactory.java +++ b/fj-core/src/test/java/test/org/fugerit/java/core/db/connect/TestConnectionFactory.java @@ -24,8 +24,8 @@ import org.fugerit.java.core.lang.helpers.ClassHelper; import org.fugerit.java.core.util.PropsIO; import org.fugerit.java.core.xml.dom.DOMIO; -import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; import org.w3c.dom.Document; import lombok.extern.slf4j.Slf4j; @@ -33,7 +33,7 @@ import test.org.fugerit.java.core.db.TestBasicDBHelper; @Slf4j -public class TestConnectionFactory extends BasicTest { +class TestConnectionFactory extends BasicTest { private static final String JNDI_DS_NAME = "java:/comp/env/datasource/ds"; @@ -51,7 +51,7 @@ private boolean worker( ConnectionFactory wrapped ) throws Exception { } @Test - public void testCFProps() throws Exception { + void testCFProps() throws Exception { String name = "wrapped"; Properties props= PropsIO.loadFromClassLoaderSafe( TestBasicDBHelper.DEFAULT_DB_CONN_PATH ); props.setProperty( ConnectionFactoryImpl.PROP_CF_EXT_POOLED_IC , "1" ); @@ -60,19 +60,19 @@ public void testCFProps() throws Exception { ConnectionFactory wrapped = ConnectionFactoryImpl.newInstance( props ); ConnectionFacade.registerFactory( name , wrapped ); boolean ok = this.worker( ConnectionFacade.getFactory( name ) ); - Assert.assertTrue(ok); + Assertions.assertTrue(ok); // pooled ok = this.worker( new DbcpConnectionFactory( props ) ); - Assert.assertTrue(ok); + Assertions.assertTrue(ok); } @Test - public void testCFPropsPrefix() throws Exception { + void testCFPropsPrefix() throws Exception { boolean ok = this.worker( ConnectionFactoryImpl.newInstance( PropsIO.loadFromClassLoaderSafe( "core/db/base-db-conn.properties" ), "prefixtest", TestConnectionFactory.class.getClassLoader() ) ); - Assert.assertTrue(ok); + Assertions.assertTrue(ok); } private boolean loadXmlHelper( String path ) throws Exception { @@ -81,35 +81,35 @@ private boolean loadXmlHelper( String path ) throws Exception { Document doc = DOMIO.loadDOMDoc( is ); CfConfig cfConfig = ConnectionFactoryImpl.parseCfConfig( doc.getDocumentElement() ); ok = this.worker( cfConfig.getCfMap().get( "mem-db" ) ); - Assert.assertTrue(ok); + Assertions.assertTrue(ok); ok = this.worker( cfConfig.getCfMap().get( "mem-db-pooled" ) ); - Assert.assertTrue(ok); + Assertions.assertTrue(ok); } return ok; } @Test - public void testCFXml() throws Exception { + void testCFXml() throws Exception { boolean ok = this.loadXmlHelper( "core/db/connct-properties-mem.xml" ); - Assert.assertTrue(ok); + Assertions.assertTrue(ok); } @Test - public void testCFXmlFail1() throws Exception { - Assert.assertThrows( ConfigRuntimeException.class , () -> this.loadXmlHelper( "core/db/connct-properties-mem-fail1.xml" ) ); + void testCFXmlFail1() throws Exception { + Assertions.assertThrows( ConfigRuntimeException.class , () -> this.loadXmlHelper( "core/db/connct-properties-mem-fail1.xml" ) ); } @Test - public void testCFXmlFail2() throws Exception { - Assert.assertThrows( ConfigRuntimeException.class , () -> this.loadXmlHelper( "core/db/connct-properties-mem-fail2.xml" ) ); + void testCFXmlFail2() throws Exception { + Assertions.assertThrows( ConfigRuntimeException.class , () -> this.loadXmlHelper( "core/db/connct-properties-mem-fail2.xml" ) ); } @Test - public void testCFUnsupportedMode() throws Exception { + void testCFUnsupportedMode() throws Exception { Properties props = new Properties(); props.setProperty( ConnectionFactoryImpl.PROP_CF_MODE , "mode-not-exists" ); - Assert.assertThrows( DAOException.class , () ->ConnectionFactoryImpl.newInstance(props) ); + Assertions.assertThrows( DAOException.class , () ->ConnectionFactoryImpl.newInstance(props) ); } private DataSource createDS() throws NamingException { @@ -118,66 +118,66 @@ private DataSource createDS() throws NamingException { } @Test - public void testCFDS() throws Exception { + void testCFDS() throws Exception { boolean ok = this.worker( new ConnectionFacadeWrapper( ConnectionFactoryImpl.newInstance( this.createDS() ) ) ); - Assert.assertTrue(ok); + Assertions.assertTrue(ok); } @Test - public void testCFDSTestConn() throws Exception { + void testCFDSTestConn() throws Exception { boolean ok = this.worker( new ConnectionFacadeWrapper( ConnectionFactoryImpl.newInstance( this.createDS(), true ) ) ); - Assert.assertTrue(ok); + Assertions.assertTrue(ok); } @Test - public void testCFSingle() throws Exception { + void testCFSingle() throws Exception { DataSource ds = this.createDS(); try ( Connection conn = ds.getConnection() ) { boolean ok = this.worker( new SingleConnectionFactory(conn) ); - Assert.assertTrue(ok); + Assertions.assertTrue(ok); } } @Test - public void testCFJndi1() throws Exception { + void testCFJndi1() throws Exception { Properties props = new Properties(); props.setProperty( ConnectionFactoryImpl.PROP_CF_MODE , ConnectionFactoryImpl.PROP_CF_MODE_DS ); props.setProperty( ConnectionFactoryImpl.PROP_CF_MODE_DS_NAME , JNDI_DS_NAME ); boolean ok = this.worker( ConnectionFactoryImpl.newInstance( props ) ); - Assert.assertTrue(ok); + Assertions.assertTrue(ok); } @Test - public void testCFJndi2() throws Exception { + void testCFJndi2() throws Exception { Properties props = new Properties(); props.setProperty( ConnectionFactoryImpl.PROP_CF_MODE , ConnectionFactoryImpl.PROP_CF_MODE_DS2 ); props.setProperty( ConnectionFactoryImpl.PROP_CF_MODE_DS_NAME , JNDI_DS_NAME ); boolean ok = this.worker( ConnectionFactoryImpl.newInstance( props ) ); - Assert.assertTrue(ok); + Assertions.assertTrue(ok); } @Test - public void testCFDirect1() throws Exception { + void testCFDirect1() throws Exception { boolean ok = this.worker( ConnectionFactoryImpl.newInstance( "org.hsqldb.jdbcDriver", "jdbc:hsqldb:mem:base_db_direct1", "testuser", "testp" ) ); - Assert.assertTrue(ok); + Assertions.assertTrue(ok); } @Test - public void testCFDirect2() throws Exception { + void testCFDirect2() throws Exception { boolean ok = this.worker( ConnectionFactoryImpl.newInstance( "org.hsqldb.jdbcDriver", "jdbc:hsqldb:mem:base_db_direct2", "testuser", "testp", TestConnectionFactory.class.getClassLoader() ) ); - Assert.assertTrue(ok); + Assertions.assertTrue(ok); } @Test - public void testCFDirect3() throws Exception { + void testCFDirect3() throws Exception { boolean ok = this.worker( ConnectionFactoryImpl.newInstance( new org.hsqldb.jdbcDriver(), "jdbc:hsqldb:mem:base_db_direct3", "testuser", "testp" ) ); - Assert.assertTrue(ok); + Assertions.assertTrue(ok); } @Test - public void testDaoContextOnDS() { - Assert.assertTrue( SafeFunction.get( () -> { + void testDaoContextOnDS() { + Assertions.assertTrue( SafeFunction.get( () -> { try (CloseableDAOContext context = CloseableDAOContextAbstract.newCloseableDAOContextDS(this.createDS()); Connection conn = context.getConnection()) { return Boolean.TRUE; @@ -186,8 +186,8 @@ public void testDaoContextOnDS() { } @Test - public void testDaoContextOnCF() { - Assert.assertTrue( SafeFunction.get( () -> { + void testDaoContextOnCF() { + Assertions.assertTrue( SafeFunction.get( () -> { try (CloseableDAOContext context = CloseableDAOContextAbstract.newCloseableDAOContextCF( ConnectionFactoryImpl.newInstance( new org.hsqldb.jdbcDriver(), "jdbc:hsqldb:mem:base_db_daocontext1", "testuser", "testp" ) ); diff --git a/fj-core/src/test/java/test/org/fugerit/java/core/db/dao/TestBasicDAO.java b/fj-core/src/test/java/test/org/fugerit/java/core/db/dao/TestBasicDAO.java index be417baf..61332d64 100644 --- a/fj-core/src/test/java/test/org/fugerit/java/core/db/dao/TestBasicDAO.java +++ b/fj-core/src/test/java/test/org/fugerit/java/core/db/dao/TestBasicDAO.java @@ -25,13 +25,13 @@ import org.fugerit.java.core.db.dao.RSExtractor; import org.fugerit.java.core.db.dao.rse.StringRSE; import org.fugerit.java.core.function.SafeFunction; -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 test.org.fugerit.java.core.db.TestBasicDBHelper; -public class TestBasicDAO extends TestBasicDBHelper { +class TestBasicDAO extends TestBasicDBHelper { private ConnectionFactoryCloseable connFactory() { return ConnectionFactoryImpl.wrap( new ConnectionFactoryImpl() { @@ -45,7 +45,7 @@ public Connection getConnection() throws DAOException { private static final String USERNAME_TEST = "user1"; @Test - public void testBasicDAO() { + void testBasicDAO() { SafeFunction.apply( () -> { try ( ConnectionFactoryCloseable cf = this.connFactory() ) { BasicDAOFactory bdf = new BasicDAOFactory( cf ); @@ -58,13 +58,13 @@ public void testBasicDAO() { SafeFunction.apply( () -> { List result = dao.newList(); dao.loadAll( result , OpDAO.newQueryOp( "SELECT username FROM fugerit.user WHERE username = ?" , flUsernameTest, StringRSE.DEFAULT ) ); - Assert.assertEquals( 1 , result.size() ); + Assertions.assertEquals( 1 , result.size() ); } ); // select all SafeFunction.apply( () -> { List result = dao.newList(); dao.loadAll( result , "SELECT username FROM fugerit.user", StringRSE.DEFAULT ); - Assert.assertFalse( result.isEmpty() ); + Assertions.assertFalse( result.isEmpty() ); } ); // select all SafeFunction.apply( () -> { @@ -73,43 +73,43 @@ public void testBasicDAO() { Statement stm = conn.createStatement(); ResultSet rs = stm.executeQuery( "SELECT username FROM fugerit.user" )) { dao.extractAll( rs , result, StringRSE.DEFAULT ); - Assert.assertFalse( result.isEmpty() ); + Assertions.assertFalse( result.isEmpty() ); } } ); // select all SafeFunction.apply( () -> { List result = dao.newList(); dao.loadAll( result , "SELECT username FROM fugerit.user WHERE username = ?", flUsernameTest.getField( 0 ), StringRSE.DEFAULT ); - Assert.assertFalse( result.isEmpty() ); + Assertions.assertFalse( result.isEmpty() ); } ); // select all SafeFunction.apply( () -> { List result = dao.loadAll( "SELECT username FROM fugerit.user WHERE username = ?", flUsernameTest.getField( 0 ), StringRSE.DEFAULT ); - Assert.assertFalse( result.isEmpty() ); + Assertions.assertFalse( result.isEmpty() ); } ); // select all SafeFunction.apply( () -> { List result = dao.newList(); dao.loadAll( result ,"SELECT username FROM fugerit.user", StringRSE.DEFAULT ); - Assert.assertFalse( result.isEmpty() ); + Assertions.assertFalse( result.isEmpty() ); } ); // select all SafeFunction.apply( () -> { List result = dao.loadAll( "SELECT username FROM fugerit.user", StringRSE.DEFAULT ); - Assert.assertFalse( result.isEmpty() ); + Assertions.assertFalse( result.isEmpty() ); } ); // select result SafeFunction.apply( () -> { LoadResult lr = dao.loadAllResult( "SELECT username FROM fugerit.user WHERE username = ?", flUsernameTest, StringRSE.DEFAULT ); try { lr.start(); - Assert.assertEquals( 1 , lr.startCount() ); + Assertions.assertEquals( 1 , lr.startCount() ); int count = 0; while ( lr.hasNext() ) { lr.getNext(); count++; } - Assert.assertEquals( 1 , count ); + Assertions.assertEquals( 1 , count ); } finally { lr.end(); } @@ -117,57 +117,57 @@ public void testBasicDAO() { // select one SafeFunction.apply( () -> { String username = dao.loadOne( "SELECT username FROM fugerit.user WHERE username = ?" , flUsernameTest.getField( 0 ), StringRSE.DEFAULT ); - Assert.assertEquals( USERNAME_TEST , username ); + Assertions.assertEquals( USERNAME_TEST , username ); } ); // select one SafeFunction.apply( () -> { String username = dao.loadOne( "SELECT username FROM fugerit.user WHERE username IS NULL" , StringRSE.DEFAULT ); - Assert.assertNull( username ); + Assertions.assertNull( username ); } ); // select one SafeFunction.apply( () -> { String username = dao.loadOne( OpDAO.newQueryOp( "SELECT username FROM fugerit.user WHERE username = ?" , flUsernameTest, StringRSE.DEFAULT ) ); - Assert.assertEquals( USERNAME_TEST , username ); + Assertions.assertEquals( USERNAME_TEST , username ); } ); // create SafeFunction.apply( () -> { boolean res = dao.execute( "CREATE TABLE fugerit.basic_dao_test ( id VARCHAR(32) )" ); - Assert.assertFalse(res); + Assertions.assertFalse(res); } ); // insert one SafeFunction.apply( () -> { int res = dao.update( OpDAO.newUpdateOp( "INSERT INTO fugerit.basic_dao_test VALUES ( ? )" , flUsernameTest) ); - Assert.assertEquals( 1 , res ) ; + Assertions.assertEquals( 1 , res ) ; } ); // delete one SafeFunction.apply( () -> { int res = dao.update( OpDAO.newUpdateOp( "DELETE FROM fugerit.basic_dao_test WHERE ID = ?" , flUsernameTest) ); - Assert.assertEquals( 1 , res ) ; + Assertions.assertEquals( 1 , res ) ; } ); // insert one SafeFunction.apply( () -> { int res = dao.update( "INSERT INTO fugerit.basic_dao_test VALUES ( ? )" , flUsernameTest.getField( 0 ) ); - Assert.assertEquals( 1 , res ) ; + Assertions.assertEquals( 1 , res ) ; } ); // update zero SafeFunction.apply( () -> { int res = dao.update( "UPDATE fugerit.basic_dao_test SET id = id WHERE 1=0" ); - Assert.assertEquals( 0 , res ) ; + Assertions.assertEquals( 0 , res ) ; } ); // delete one SafeFunction.apply( () -> { int res = dao.delete( "DELETE FROM fugerit.basic_dao_test WHERE ID = ?" , flUsernameTest ); - Assert.assertEquals( 1 , res ) ; + Assertions.assertEquals( 1 , res ) ; } ); // insert batch SafeFunction.apply( () -> { boolean res = dao.updateBatch( this.createInsertOps(dao, 100, 50 ) ); - Assert.assertTrue(res); + Assertions.assertTrue(res); } ); // insert batch SafeFunction.apply( () -> { boolean res = dao.updateTransaction( this.createInsertOps(dao, 100, 50 ) ); - Assert.assertTrue(res); + Assertions.assertTrue(res); } ); // test query wrapper String[] products = TestBasicDBHelper.PRODUCT_NAME_STRING; @@ -180,8 +180,8 @@ public void testBasicDAO() { } } // other tests - Assert.assertNull( dao.getQueryWrapper() ); - Assert.assertNotNull( new BasicDAOCheck( cf ) ); + Assertions.assertNull( dao.getQueryWrapper() ); + Assertions.assertNotNull( new BasicDAOCheck( cf ) ); } }); } diff --git a/fj-core/src/test/java/test/org/fugerit/java/core/db/dao/TestCloseDAOHelper.java b/fj-core/src/test/java/test/org/fugerit/java/core/db/dao/TestCloseDAOHelper.java index 0fa2baf3..a9a516a8 100644 --- a/fj-core/src/test/java/test/org/fugerit/java/core/db/dao/TestCloseDAOHelper.java +++ b/fj-core/src/test/java/test/org/fugerit/java/core/db/dao/TestCloseDAOHelper.java @@ -6,27 +6,27 @@ import org.fugerit.java.core.db.dao.CloseDAOHelper; import org.fugerit.java.core.db.dao.DAORuntimeException; -import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; import test.org.fugerit.java.core.db.TestBasicDBHelper; -public class TestCloseDAOHelper extends TestBasicDBHelper { +class TestCloseDAOHelper extends TestBasicDBHelper { @Test - public void testClose1() { + void testClose1() { DAORuntimeException.apply( () -> { boolean ok = false; try ( Connection conn = newConnection() ) { CloseDAOHelper.close( conn ); ok = true; } - Assert.assertTrue(ok); + Assertions.assertTrue(ok); } ); } @Test - public void testClose2() { + void testClose2() { DAORuntimeException.apply( () -> { boolean ok = false; try ( Connection conn = newConnection() ) { @@ -37,28 +37,28 @@ public void close() throws IOException { } } ); ok = true; - Assert.assertTrue(ok); + Assertions.assertTrue(ok); } } ); } @Test - public void testClose3() { + void testClose3() { DAORuntimeException.apply( () -> { boolean ok = false; CloseDAOHelper.close( (AutoCloseable)null ); ok = true; - Assert.assertTrue(ok); + Assertions.assertTrue(ok); } ); } @Test - public void testClose4() { + void testClose4() { DAORuntimeException.apply( () -> { boolean ok = false; CloseDAOHelper.close( (Closeable)null ); ok = true; - Assert.assertTrue(ok); + Assertions.assertTrue(ok); } ); } diff --git a/fj-core/src/test/java/test/org/fugerit/java/core/db/dao/TestDAOException.java b/fj-core/src/test/java/test/org/fugerit/java/core/db/dao/TestDAOException.java index 224c76cb..1bda833b 100644 --- a/fj-core/src/test/java/test/org/fugerit/java/core/db/dao/TestDAOException.java +++ b/fj-core/src/test/java/test/org/fugerit/java/core/db/dao/TestDAOException.java @@ -4,92 +4,92 @@ import java.sql.SQLException; import org.fugerit.java.core.db.dao.DAOException; -import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; import lombok.extern.slf4j.Slf4j; @Slf4j -public class TestDAOException { +class TestDAOException { @Test - public void testApplySilent() throws DAOException { + void testApplySilent() throws DAOException { boolean ok = true; DAOException.applySilent( () -> { throw new IOException( "junit test scenario" ); } ); - Assert.assertTrue( ok ); + Assertions.assertTrue( ok ); } @Test - public void testGetSilent() throws DAOException { + void testGetSilent() throws DAOException { Object result = DAOException.getSilent( () -> { throw new IOException( "junit test scenario" ); } ); - Assert.assertNull( result ); + Assertions.assertNull( result ); } @Test - public void testApplyEXMessage() { - Assert.assertThrows( DAOException.class ,() -> DAOException.applyWithMessage( () -> { throw new IOException( "junit test scenario" ); }, "test message" ) ); + void testApplyEXMessage() { + Assertions.assertThrows( DAOException.class ,() -> DAOException.applyWithMessage( () -> { throw new IOException( "junit test scenario" ); }, "test message" ) ); } @Test - public void testGetEXMessage() { - Assert.assertThrows( DAOException.class ,() -> DAOException.getWithMessage( () -> { throw new IOException( "junit test scenario" ); }, "test message" ) ); + void testGetEXMessage() { + Assertions.assertThrows( DAOException.class ,() -> DAOException.getWithMessage( () -> { throw new IOException( "junit test scenario" ); }, "test message" ) ); } @Test - public void testApplyEXMessageOk() throws DAOException { + void testApplyEXMessageOk() throws DAOException { boolean ok = true; DAOException.applyWithMessage( () -> log.info( "test ok" ) , "test message" ); - Assert.assertTrue( ok ); + Assertions.assertTrue( ok ); } @Test - public void testGetEXMessageOk() throws DAOException { - Assert.assertNotNull( DAOException.getWithMessage( () -> "test ok" , "test message" ) ); + void testGetEXMessageOk() throws DAOException { + Assertions.assertNotNull( DAOException.getWithMessage( () -> "test ok" , "test message" ) ); } @Test - public void testApply() { - Assert.assertThrows( DAOException.class ,() -> DAOException.apply( () -> { throw new SQLException( "junit test scenario" ); } ) ); + void testApply() { + Assertions.assertThrows( DAOException.class ,() -> DAOException.apply( () -> { throw new SQLException( "junit test scenario" ); } ) ); } @Test - public void testGet() { - Assert.assertThrows( DAOException.class ,() -> DAOException.get( () -> { throw new SQLException( "junit test scenario" ); } ) ); + void testGet() { + Assertions.assertThrows( DAOException.class ,() -> DAOException.get( () -> { throw new SQLException( "junit test scenario" ); } ) ); } @Test - public void testEx1() { - Assert.assertNotNull( new DAOException() ); + void testEx1() { + Assertions.assertNotNull( new DAOException() ); } @Test - public void testEx2() { - Assert.assertNotNull( new DAOException( "a" ) ); + void testEx2() { + Assertions.assertNotNull( new DAOException( "a" ) ); } @Test - public void testEx3() { - Assert.assertNotNull( new DAOException( new SQLException( "b" ) ) ); + void testEx3() { + Assertions.assertNotNull( new DAOException( new SQLException( "b" ) ) ); } @Test - public void testEx4() { - Assert.assertNotNull( new DAOException( "c", new SQLException( "d" ) ) ); + void testEx4() { + Assertions.assertNotNull( new DAOException( "c", new SQLException( "d" ) ) ); } @Test - public void testEx5() { - Assert.assertNotNull( DAOException.convertEx( "e" , new SQLException( "f" ) ) ); + void testEx5() { + Assertions.assertNotNull( DAOException.convertEx( "e" , new SQLException( "f" ) ) ); } @Test - public void testEx6() { - Assert.assertNotNull( DAOException.convertEx( "g" , new DAOException( "g" ) ) ); + void testEx6() { + Assertions.assertNotNull( DAOException.convertEx( "g" , new DAOException( "g" ) ) ); } @Test - public void testEx7() { - Assert.assertNotNull( DAOException.convertExMethod( "e" , new SQLException( "f" ) ) ); + void testEx7() { + Assertions.assertNotNull( DAOException.convertExMethod( "e" , new SQLException( "f" ) ) ); } } diff --git a/fj-core/src/test/java/test/org/fugerit/java/core/db/dao/TestDAOResult.java b/fj-core/src/test/java/test/org/fugerit/java/core/db/dao/TestDAOResult.java index 9d747af7..805634bc 100644 --- a/fj-core/src/test/java/test/org/fugerit/java/core/db/dao/TestDAOResult.java +++ b/fj-core/src/test/java/test/org/fugerit/java/core/db/dao/TestDAOResult.java @@ -1,15 +1,15 @@ package test.org.fugerit.java.core.db.dao; import org.fugerit.java.core.db.daogen.BasicDaoResult; -import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; -public class TestDAOResult { +class TestDAOResult { @Test - public void testOne() { + void testOne() { BasicDaoResult test = new BasicDaoResult<>(); - Assert.assertNull( test.one() ); + Assertions.assertNull( test.one() ); } } diff --git a/fj-core/src/test/java/test/org/fugerit/java/core/db/dao/TestDAORuntimeException.java b/fj-core/src/test/java/test/org/fugerit/java/core/db/dao/TestDAORuntimeException.java index aa5c6001..3e0783e7 100644 --- a/fj-core/src/test/java/test/org/fugerit/java/core/db/dao/TestDAORuntimeException.java +++ b/fj-core/src/test/java/test/org/fugerit/java/core/db/dao/TestDAORuntimeException.java @@ -3,54 +3,54 @@ import java.sql.SQLException; import org.fugerit.java.core.db.dao.DAORuntimeException; -import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; -public class TestDAORuntimeException { +class TestDAORuntimeException { @Test - public void testApply() { - Assert.assertThrows( DAORuntimeException.class ,() -> DAORuntimeException.apply( () -> { throw new SQLException( "junit test scenario" ); } ) ); + void testApply() { + Assertions.assertThrows( DAORuntimeException.class ,() -> DAORuntimeException.apply( () -> { throw new SQLException( "junit test scenario" ); } ) ); } @Test - public void testGet() { - Assert.assertThrows( DAORuntimeException.class ,() -> DAORuntimeException.get( () -> { throw new SQLException( "junit test scenario" ); } ) ); + void testGet() { + Assertions.assertThrows( DAORuntimeException.class ,() -> DAORuntimeException.get( () -> { throw new SQLException( "junit test scenario" ); } ) ); } @Test - public void testEx1() { - Assert.assertNotNull( new DAORuntimeException() ); + void testEx1() { + Assertions.assertNotNull( new DAORuntimeException() ); } @Test - public void testEx2() { - Assert.assertNotNull( new DAORuntimeException( "a" ) ); + void testEx2() { + Assertions.assertNotNull( new DAORuntimeException( "a" ) ); } @Test - public void testEx3() { - Assert.assertNotNull( new DAORuntimeException( new SQLException( "b" ) ) ); + void testEx3() { + Assertions.assertNotNull( new DAORuntimeException( new SQLException( "b" ) ) ); } @Test - public void testEx4() { - Assert.assertNotNull( new DAORuntimeException( "c", new SQLException( "d" ) ) ); + void testEx4() { + Assertions.assertNotNull( new DAORuntimeException( "c", new SQLException( "d" ) ) ); } @Test - public void testEx5() { - Assert.assertNotNull( DAORuntimeException.convertEx( "e" , new SQLException( "f" ) ) ); + void testEx5() { + Assertions.assertNotNull( DAORuntimeException.convertEx( "e" , new SQLException( "f" ) ) ); } @Test - public void testEx6() { - Assert.assertNotNull( DAORuntimeException.convertEx( "g" , new DAORuntimeException( "g" ) ) ); + void testEx6() { + Assertions.assertNotNull( DAORuntimeException.convertEx( "g" , new DAORuntimeException( "g" ) ) ); } @Test - public void testEx7() { - Assert.assertNotNull( DAORuntimeException.convertExMethod( "e" , new SQLException( "f" ) ) ); + void testEx7() { + Assertions.assertNotNull( DAORuntimeException.convertExMethod( "e" , new SQLException( "f" ) ) ); } } diff --git a/fj-core/src/test/java/test/org/fugerit/java/core/db/dao/TestDAOUtils.java b/fj-core/src/test/java/test/org/fugerit/java/core/db/dao/TestDAOUtils.java index d819136c..8731c885 100644 --- a/fj-core/src/test/java/test/org/fugerit/java/core/db/dao/TestDAOUtils.java +++ b/fj-core/src/test/java/test/org/fugerit/java/core/db/dao/TestDAOUtils.java @@ -9,12 +9,12 @@ import org.fugerit.java.core.db.dao.DAOException; import org.fugerit.java.core.db.dao.DAORuntimeException; import org.fugerit.java.core.db.dao.DAOUtils; -import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; import test.org.fugerit.java.core.db.TestBasicDBHelper; -public class TestDAOUtils extends TestBasicDBHelper { +class TestDAOUtils extends TestBasicDBHelper { private ConnectionFactoryCloseable connFactory() { return ConnectionFactoryImpl.wrap( new ConnectionFactoryImpl() { @@ -29,18 +29,18 @@ public Connection getConnection() throws DAOException { private static final String DEF_USER = "user1"; @Test - public void testDAOUtilsNG() { + void testDAOUtilsNG() { DAORuntimeException.apply( () -> { try ( Connection conn = newConnection() ) { DAOUtils utils = new DAOUtils( new BasicDAOFactory( connFactory() ) ); String user = utils.extractString( "SELECT username FROM fugerit.user WHERE username = ''user1''" ); - Assert.assertEquals( DEF_USER, user ); + Assertions.assertEquals( DEF_USER, user ); List list = utils.extractStringList( "SELECT username FROM fugerit.user" ); - Assert.assertFalse( list.isEmpty() ); + Assertions.assertFalse( list.isEmpty() ); long idL = utils.extractLong( "SELECT id FROM fugerit.user WHERE username = ''user1''" ); - Assert.assertNotEquals( 0L , idL ); + Assertions.assertNotEquals( 0L , idL ); double idD = utils.extractDouble( "SELECT id FROM fugerit.user WHERE username = ''user1''" ); - Assert.assertNotEquals( 0D , idD ); + Assertions.assertNotEquals( 0D , idD ); } } ); } diff --git a/fj-core/src/test/java/test/org/fugerit/java/core/db/dao/TestDAOUtilsNG.java b/fj-core/src/test/java/test/org/fugerit/java/core/db/dao/TestDAOUtilsNG.java index 268a5451..7e035ca4 100644 --- a/fj-core/src/test/java/test/org/fugerit/java/core/db/dao/TestDAOUtilsNG.java +++ b/fj-core/src/test/java/test/org/fugerit/java/core/db/dao/TestDAOUtilsNG.java @@ -14,14 +14,14 @@ import org.fugerit.java.core.db.dao.FieldList; import org.fugerit.java.core.db.dao.LoadResultNG; import org.fugerit.java.core.db.dao.OpDAO; -import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; import lombok.extern.slf4j.Slf4j; import test.org.fugerit.java.core.db.TestBasicDBHelper; @Slf4j -public class TestDAOUtilsNG extends TestBasicDBHelper { +class TestDAOUtilsNG extends TestBasicDBHelper { private static final String QUERY_DEF = "SELECT * FROM fugerit.user"; @@ -30,7 +30,7 @@ public class TestDAOUtilsNG extends TestBasicDBHelper { private static final String DEF_USER = "user1"; @Test - public void testDefaultLoadResultNG() { + void testDefaultLoadResultNG() { DAORuntimeException.apply( () -> { List list = new ArrayList<>(); try ( Connection conn = newConnection(); @@ -38,7 +38,7 @@ public void testDefaultLoadResultNG() { ResultSet rs = stm.executeQuery( QUERY_DEF ); LoadResultNG lr = DefaultLoadResultNG.newLoadResult(conn, ModelUser.RSE, stm, rs ) ) { DAOUtilsNG.fillList( lr, list ); - Assert.assertFalse( list.isEmpty() ); + Assertions.assertFalse( list.isEmpty() ); } } ); DAORuntimeException.apply( () -> { @@ -48,7 +48,7 @@ public void testDefaultLoadResultNG() { ResultSet rs = stm.executeQuery( QUERY_DEF ); LoadResultNG lr = DefaultLoadResultNG.newLoadResultCloseConnection(conn, OpDAO.newQueryOp( QUERY_DEF , ModelUser.RSE ) ) ) { DAOUtilsNG.fillList( lr, list ); - Assert.assertFalse( list.isEmpty() ); + Assertions.assertFalse( list.isEmpty() ); } } ); DAORuntimeException.apply( () -> { @@ -58,7 +58,7 @@ public void testDefaultLoadResultNG() { ResultSet rs = stm.executeQuery( QUERY_DEF ); LoadResultNG lr = DefaultLoadResultNG.newLoadResult(ModelUser.RSE, stm, rs ) ) { DAOUtilsNG.fillList( lr, list ); - Assert.assertFalse( list.isEmpty() ); + Assertions.assertFalse( list.isEmpty() ); } } ); DAORuntimeException.apply( () -> { @@ -67,57 +67,57 @@ public void testDefaultLoadResultNG() { ResultSet rs = stm.executeQuery( QUERY_DEF ); LoadResultNG lr = DefaultLoadResultNG.newLoadResult(ModelUser.RSE, stm, rs ) ) { Iterator it = DAOUtilsNG.toIterator( lr ); - Assert.assertThrows( NoSuchElementException.class , it::next ); + Assertions.assertThrows( NoSuchElementException.class , it::next ); } } ); } @Test - public void testDAOUtilsNGLoadMethods() { + void testDAOUtilsNGLoadMethods() { OpDAO opDaoQueryAll = OpDAO.newQueryOp( QUERY_DEF , ModelUser.RSE ); DAORuntimeException.apply( () -> { try ( Connection conn = newConnection() ) { List list = DAOUtilsNG.loadList(conn, opDaoQueryAll); - Assert.assertFalse( list.isEmpty() ); + Assertions.assertFalse( list.isEmpty() ); } } ); DAORuntimeException.apply( () -> { try ( Connection conn = newConnection() ) { List list = DAOUtilsNG.loadListFields(conn, opDaoQueryAll.getSql(), opDaoQueryAll.getRsExtractor(), opDaoQueryAll.getFieldList().toArray() ); - Assert.assertFalse( list.isEmpty() ); + Assertions.assertFalse( list.isEmpty() ); } } ); DAORuntimeException.apply( () -> { try ( Connection conn = newConnection() ) { List list = DAOUtilsNG.loadList(conn, opDaoQueryAll.getSql(), opDaoQueryAll.getRsExtractor(), new Object[0] ); - Assert.assertFalse( list.isEmpty() ); + Assertions.assertFalse( list.isEmpty() ); } } ); DAORuntimeException.apply( () -> { try ( Connection conn = newConnection() ) { List test = new ArrayList<>(); DAOUtilsNG.loadStream(conn, opDaoQueryAll).forEach( test::add ); - Assert.assertFalse( test.isEmpty() ); + Assertions.assertFalse( test.isEmpty() ); } } ); DAORuntimeException.apply( () -> { try ( Connection conn = newConnection() ) { List test = new ArrayList<>(); DAOUtilsNG.loadStreamFields(conn, opDaoQueryAll.getSql(), opDaoQueryAll.getRsExtractor(), opDaoQueryAll.getFieldList().toArray() ).forEach( test::add ); - Assert.assertFalse( test.isEmpty() ); + Assertions.assertFalse( test.isEmpty() ); } } ); DAORuntimeException.apply( () -> { try ( Connection conn = newConnection() ) { List test = new ArrayList<>(); DAOUtilsNG.loadStream(conn, opDaoQueryAll.getSql(), opDaoQueryAll.getRsExtractor(), new Object[0] ).forEach( test::add ); - Assert.assertFalse( test.isEmpty() ); + Assertions.assertFalse( test.isEmpty() ); } } ); } @Test - public void testDAOUtilsNG() { + void testDAOUtilsNG() { OpDAO opDaoQueryAll = OpDAO.newQueryOp( QUERY_DEF , ModelUser.RSE ); FieldList flUsername = new FieldList(); flUsername.addField( DEF_USER ); @@ -126,7 +126,7 @@ public void testDAOUtilsNG() { try ( Connection conn = newConnection() ) { List list = new ArrayList<>(); DAOUtilsNG.extractAll( conn, list, opDaoQueryAll ); - Assert.assertFalse( list.isEmpty() ); + Assertions.assertFalse( list.isEmpty() ); } } ); DAORuntimeException.apply( () -> { @@ -135,7 +135,7 @@ public void testDAOUtilsNG() { LoadResultNG lr = DAOUtilsNG.extractAll( conn, opDaoQueryAll ) ) { DAOUtilsNG.fillList( lr , list ); log.info( "count : {}", lr.getCount() ); - Assert.assertFalse( list.isEmpty() ); + Assertions.assertFalse( list.isEmpty() ); } } ); DAORuntimeException.apply( () -> { @@ -144,7 +144,7 @@ public void testDAOUtilsNG() { LoadResultNG lr = DAOUtilsNG.extraAllFields( conn, QUERY_DEF_USERNAME , ModelUser.RSE, DEF_USER ) ) { DAOUtilsNG.fillList( lr , list ); log.info( "count : {}", lr.getCount() ); - Assert.assertFalse( list.isEmpty() ); + Assertions.assertFalse( list.isEmpty() ); } } ); DAORuntimeException.apply( () -> { @@ -153,34 +153,34 @@ public void testDAOUtilsNG() { LoadResultNG lr = DAOUtilsNG.extraAll( conn, QUERY_DEF_USERNAME , ModelUser.RSE, flUsername.getField( 0 ) ) ) { DAOUtilsNG.fillList( lr , list ); log.info( "count : {}", lr.getCount() ); - Assert.assertFalse( list.isEmpty() ); + Assertions.assertFalse( list.isEmpty() ); } } ); DAORuntimeException.apply( () -> { try ( Connection conn = newConnection() ) { List list = new ArrayList<>(); DAOUtilsNG.extraAllFields( conn, list, QUERY_DEF_USERNAME , ModelUser.RSE, DEF_USER ); - Assert.assertFalse( list.isEmpty() ); + Assertions.assertFalse( list.isEmpty() ); } } ); DAORuntimeException.apply( () -> { try ( Connection conn = newConnection() ) { List list = new ArrayList<>(); DAOUtilsNG.extraAll( conn, list, QUERY_DEF_USERNAME, ModelUser.RSE, flUsername.getField( 0 ) ); - Assert.assertFalse( list.isEmpty() ); + Assertions.assertFalse( list.isEmpty() ); } } ); // select one DAORuntimeException.apply( () -> { try ( Connection conn = newConnection() ) { ModelUser model = DAOUtilsNG.extraOneFields( conn, QUERY_DEF_USERNAME, ModelUser.RSE, flUsername.getField( 0 ) ); - Assert.assertNotNull( model ); + Assertions.assertNotNull( model ); } } ); DAORuntimeException.apply( () -> { try ( Connection conn = newConnection() ) { ModelUser model = DAOUtilsNG.extraOne( conn, QUERY_DEF_USERNAME, ModelUser.RSE, DEF_USER ); - Assert.assertNotNull( model ); + Assertions.assertNotNull( model ); } } ); // create table @@ -188,7 +188,7 @@ public void testDAOUtilsNG() { OpDAO op = OpDAO.newExecuteOp( "CREATE TABLE fugerit.test_dao_util_ng ( field_content VARCHAR(32) )" ); try ( Connection conn = newConnection() ) { boolean res = DAOUtilsNG.execute(conn, op); - Assert.assertFalse( res ); + Assertions.assertFalse( res ); } } ); // update @@ -196,19 +196,19 @@ public void testDAOUtilsNG() { OpDAO op = OpDAO.newUpdateOp( "INSERT INTO fugerit.test_dao_util_ng VALUES ( 'test data' )" ); try ( Connection conn = newConnection() ) { int res = DAOUtilsNG.update(conn, op); - Assert.assertEquals( 1 , res ); + Assertions.assertEquals( 1 , res ); } } ); DAORuntimeException.apply( () -> { try ( Connection conn = newConnection() ) { int res = DAOUtilsNG.update(conn, "INSERT INTO fugerit.test_dao_util_ng VALUES ( ? )", DEF_USER); - Assert.assertEquals( 1 , res ); + Assertions.assertEquals( 1 , res ); } } ); DAORuntimeException.apply( () -> { try ( Connection conn = newConnection() ) { int res = DAOUtilsNG.updateFields(conn, "INSERT INTO fugerit.test_dao_util_ng VALUES ( ? )", flUsername.getField( 0 )); - Assert.assertEquals( 1 , res ); + Assertions.assertEquals( 1 , res ); } } ); } diff --git a/fj-core/src/test/java/test/org/fugerit/java/core/db/dao/TestFieldList.java b/fj-core/src/test/java/test/org/fugerit/java/core/db/dao/TestFieldList.java index bf1a55e3..6556ef57 100644 --- a/fj-core/src/test/java/test/org/fugerit/java/core/db/dao/TestFieldList.java +++ b/fj-core/src/test/java/test/org/fugerit/java/core/db/dao/TestFieldList.java @@ -16,19 +16,19 @@ import org.fugerit.java.core.db.daogen.CharArrayDataHandler; import org.fugerit.java.core.db.helpers.BlobData; import org.fugerit.java.core.db.helpers.DAOID; -import org.junit.Assert; -import org.junit.BeforeClass; -import org.junit.Test; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; import lombok.extern.slf4j.Slf4j; import test.org.fugerit.java.BasicTest; import test.org.fugerit.java.core.db.TestBasicDBHelper; @Slf4j -public class TestFieldList extends TestBasicDBHelper { +class TestFieldList extends TestBasicDBHelper { - @BeforeClass - public static void init() { + @BeforeAll + static void initTest() { TestBasicDBHelper.init(); } @@ -55,7 +55,7 @@ public static void init() { + "VALUES ( ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ? )"; @Test - public void testFiledList() { + void testFiledList() { DAORuntimeException.apply(() -> { BigDecimal value = BigDecimal.valueOf( 1 ); FieldList fl = new FieldList(); @@ -76,14 +76,14 @@ public void testFiledList() { fl.addNullField( Types.INTEGER ); fl.addField( ByteArrayDataHandler.newHandlerByte( "b".getBytes() ) ); fl.addField( CharArrayDataHandler.newHandlerByte( "c".toCharArray() ) ); - Assert.assertNotNull( new BasicTest().fullSerializationTest( fl ) ); + Assertions.assertNotNull( new BasicTest().fullSerializationTest( fl ) ); fl.newField( value.intValue(), Types.INTEGER ); // print tests fl.getList().stream().forEach( c -> log.info( "current field {}", c ) ); // set tests try ( Connection conn = TestBasicDBHelper.newConnection() ) { - Assert.assertFalse( DAOUtilsNG.execute( conn , OpDAO.newExecuteOp( TEST_TABLE ) ) ); - Assert.assertNotEquals( 0 , DAOUtilsNG.update(conn, OpDAO.newExecuteOp( INSERT_SQL , fl ) ) ); + Assertions.assertFalse( DAOUtilsNG.execute( conn , OpDAO.newExecuteOp( TEST_TABLE ) ) ); + Assertions.assertNotEquals( 0 , DAOUtilsNG.update(conn, OpDAO.newExecuteOp( INSERT_SQL , fl ) ) ); } // final tests field factory FieldFactory ff = new FieldFactory(); diff --git a/fj-core/src/test/java/test/org/fugerit/java/core/db/dao/TestPageInfoDB.java b/fj-core/src/test/java/test/org/fugerit/java/core/db/dao/TestPageInfoDB.java index d229092b..09fb8f4e 100644 --- a/fj-core/src/test/java/test/org/fugerit/java/core/db/dao/TestPageInfoDB.java +++ b/fj-core/src/test/java/test/org/fugerit/java/core/db/dao/TestPageInfoDB.java @@ -1,20 +1,20 @@ package test.org.fugerit.java.core.db.dao; import org.fugerit.java.core.db.dao.PageInfoDB; -import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; import lombok.extern.slf4j.Slf4j; import test.org.fugerit.java.BasicTest; @Slf4j -public class TestPageInfoDB extends BasicTest { +class TestPageInfoDB extends BasicTest { @Test - public void testPI() { + void testPI() { PageInfoDB info = new PageInfoDB( 3, 5, "test asc" ); log.info( "info : {} -> {}", info, info.getOrder() ); - Assert.assertNotNull( info ); + Assertions.assertNotNull( info ); } } diff --git a/fj-core/src/test/java/test/org/fugerit/java/core/db/dao/daogen/TestBasicDAOHelper.java b/fj-core/src/test/java/test/org/fugerit/java/core/db/dao/daogen/TestBasicDAOHelper.java index 234b27dc..e3247ef2 100644 --- a/fj-core/src/test/java/test/org/fugerit/java/core/db/dao/daogen/TestBasicDAOHelper.java +++ b/fj-core/src/test/java/test/org/fugerit/java/core/db/dao/daogen/TestBasicDAOHelper.java @@ -6,37 +6,37 @@ import org.fugerit.java.core.db.daogen.UpdateHelper; import org.fugerit.java.core.db.helpers.DAOID; import org.fugerit.java.core.function.SafeFunction; -import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; import lombok.extern.slf4j.Slf4j; import test.org.fugerit.java.core.db.TestBasicDBHelper; @Slf4j -public class TestBasicDAOHelper extends TestBasicDBHelper { +class TestBasicDAOHelper extends TestBasicDBHelper { @Test - public void testHelpersCreation() { + void testHelpersCreation() { SafeFunction.apply( () -> { try ( CloseableDAOContextSC context = new CloseableDAOContextSC( newConnection() ) ) { BasicDAOHelper helper = new BasicDAOHelper( context ); - Assert.assertNotNull( helper.newDeleteHelper( "test1" ) ); - Assert.assertNotNull( helper.newInsertHelper( "test2" ) ); - Assert.assertNotNull( helper.newUpdateHelper( "test3" ) ); - Assert.assertNotNull( helper.newSelectHelper( "test4", null ) ); - Assert.assertNotNull( helper.newSelectHelper( "test5", "test6" ) ); + Assertions.assertNotNull( helper.newDeleteHelper( "test1" ) ); + Assertions.assertNotNull( helper.newInsertHelper( "test2" ) ); + Assertions.assertNotNull( helper.newUpdateHelper( "test3" ) ); + Assertions.assertNotNull( helper.newSelectHelper( "test4", null ) ); + Assertions.assertNotNull( helper.newSelectHelper( "test5", "test6" ) ); UpdateHelper updater = helper.newUpdateHelper( "fugerit.user" ); updater.addSetParam( "username" , "test1" ); updater.andWhereParam( "id" , DAOID.valueOf( -100 ) ); int updateResult = helper.update( updater ); - Assert.assertEquals( 0 , updateResult ); + Assertions.assertEquals( 0 , updateResult ); FieldList fl = new FieldList(); log.info( "fieldListToString 0 {}", BasicDAOHelper.fieldListToString( fl ) ); fl.addField( "1" ); log.info( "fieldListToString 1 {}", BasicDAOHelper.fieldListToString( fl ) ); fl.addField( "2" ); log.info( "fieldListToString 2 {}", BasicDAOHelper.fieldListToString( fl ) ); - Assert.assertNotNull( helper.getLogger() ); + Assertions.assertNotNull( helper.getLogger() ); } } ); diff --git a/fj-core/src/test/java/test/org/fugerit/java/core/db/dao/daogen/TestBasicDataFacade.java b/fj-core/src/test/java/test/org/fugerit/java/core/db/dao/daogen/TestBasicDataFacade.java index 71295b0e..d915889e 100644 --- a/fj-core/src/test/java/test/org/fugerit/java/core/db/dao/daogen/TestBasicDataFacade.java +++ b/fj-core/src/test/java/test/org/fugerit/java/core/db/dao/daogen/TestBasicDataFacade.java @@ -6,8 +6,8 @@ import org.fugerit.java.core.db.dao.FieldList; import org.fugerit.java.core.db.daogen.*; import org.fugerit.java.core.function.SafeFunction; -import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; import test.org.fugerit.java.BasicTest; import test.org.fugerit.java.core.db.TestBasicDBHelper; import test.org.fugerit.java.core.db.dao.ModelUser; @@ -16,7 +16,7 @@ import java.math.BigDecimal; @Slf4j -public class TestBasicDataFacade extends TestBasicDBHelper implements Serializable { +class TestBasicDataFacade extends TestBasicDBHelper implements Serializable { private static final long serialVersionUID = 2428066303144473612L; @@ -25,47 +25,47 @@ public class TestBasicDataFacade extends TestBasicDBHelper implements Serializab private static final String TABLE_NAME = "fugerit.user"; @Test - public void testBasicDataFacade1() { + void testBasicDataFacade1() { SafeFunction.apply( () -> { try ( CloseableDAOContextSC context = new CloseableDAOContextSC( newConnection() ) ) { // basic features BasicDataFacade facade = new BasicDataFacade<>( TABLE_NAME, ModelUser.RSE ); - Assert.assertNotNull( HELPER.fullSerializationTest(facade) ); - Assert.assertNull( facade.getQueryView() ); - Assert.assertNotNull( facade.getRse() ); - Assert.assertNull( facade.getSequenceName() ); - Assert.assertNull( facade.generateId( context ) ); - Assert.assertEquals( TABLE_NAME , facade.getTableName() ); + Assertions.assertNotNull( HELPER.fullSerializationTest(facade) ); + Assertions.assertNull( facade.getQueryView() ); + Assertions.assertNotNull( facade.getRse() ); + Assertions.assertNull( facade.getSequenceName() ); + Assertions.assertNull( facade.generateId( context ) ); + Assertions.assertEquals( TABLE_NAME , facade.getTableName() ); BasicDaoResult resultAll = facade.loadAll(context); - Assert.assertFalse( resultAll.getList().isEmpty() ); + Assertions.assertFalse( resultAll.getList().isEmpty() ); facade.loadAllStream( context ).forEach( m -> log.info( "test basic dao result stream {}", m) ); log.info( "test basic dao result first() {}", resultAll.getFirst() ); - Assert.assertThrows( DAORuntimeException.class , resultAll::getOne ); + Assertions.assertThrows( DAORuntimeException.class , resultAll::getOne ); BasicDaoResult resultOne = new BasicDaoResult<>(); - Assert.assertFalse( resultOne.getFirst().isPresent() ); - Assert.assertFalse( resultOne.getOne().isPresent() ); + Assertions.assertFalse( resultOne.getFirst().isPresent() ); + Assertions.assertFalse( resultOne.getOne().isPresent() ); resultOne.getList().add( resultAll.getFirst().get() ); - Assert.assertTrue( resultOne.getFirst().isPresent() ); - Assert.assertTrue( resultOne.getOne().isPresent() ); + Assertions.assertTrue( resultOne.getFirst().isPresent() ); + Assertions.assertTrue( resultOne.getOne().isPresent() ); } } ); } @Test - public void testBasicDataFacade2() { + void testBasicDataFacade2() { SafeFunction.apply( () -> { try ( CloseableDAOContextSC context = new CloseableDAOContextSC( newConnection() ) ) { // advance feature features ModeUserDataFacade facade = new ModeUserDataFacade(); - Assert.assertNotNull( HELPER.fullSerializationTest(facade) ); - Assert.assertEquals( "SELECT * FROM "+TestBasicDataFacade.TABLE_NAME, facade.getQueryView() ); - Assert.assertNotNull( facade.getRse() ); - Assert.assertEquals( "fugerit.seq_test", facade.getSequenceName() ); - Assert.assertNotEquals( BigDecimal.valueOf( 0 ), facade.generateId( context ) ); - Assert.assertEquals( TABLE_NAME , facade.getTableName() ); + Assertions.assertNotNull( HELPER.fullSerializationTest(facade) ); + Assertions.assertEquals( "SELECT * FROM "+TestBasicDataFacade.TABLE_NAME, facade.getQueryView() ); + Assertions.assertNotNull( facade.getRse() ); + Assertions.assertEquals( "fugerit.seq_test", facade.getSequenceName() ); + Assertions.assertNotEquals( BigDecimal.valueOf( 0 ), facade.generateId( context ) ); + Assertions.assertEquals( TABLE_NAME , facade.getTableName() ); BasicDaoResult resultAll = facade.loadAll(context); - Assert.assertFalse( resultAll.getList().isEmpty() ); + Assertions.assertFalse( resultAll.getList().isEmpty() ); // evaluate facade.generateId(context); ModelUser userTest = resultAll.getList().get( 0 ); @@ -80,11 +80,11 @@ public void testBasicDataFacade2() { log.info( "test 3 : {}", HELPER.fullSerializationTest( userWrapper ) ); log.info( "test 4 : {}", userWrapper ); userWrapper.wrapModel( userTest ); - Assert.assertThrows( UnsupportedOperationException.class , () -> BasicWrapper.throwUnsupported( "message" ) ); + Assertions.assertThrows( UnsupportedOperationException.class , () -> BasicWrapper.throwUnsupported( "message" ) ); userWrapper.wrapModel( userTest ); // test DataEntityUtils DataEntityUtils.unwrap( facade ); - Assert.assertThrows( DAOException.class , () -> DataEntityUtils.unwrap( userTest ) ); + Assertions.assertThrows( DAOException.class , () -> DataEntityUtils.unwrap( userTest ) ); QueryHelper helper = new QueryHelper( TABLE_NAME , new FieldList() ); DataEntityUtils.addToQuery( facade , helper ); } diff --git a/fj-core/src/test/java/test/org/fugerit/java/core/db/dao/daogen/TestBasicWrapperNG.java b/fj-core/src/test/java/test/org/fugerit/java/core/db/dao/daogen/TestBasicWrapperNG.java index 0f46a6a5..d823c4ad 100644 --- a/fj-core/src/test/java/test/org/fugerit/java/core/db/dao/daogen/TestBasicWrapperNG.java +++ b/fj-core/src/test/java/test/org/fugerit/java/core/db/dao/daogen/TestBasicWrapperNG.java @@ -4,20 +4,20 @@ import org.fugerit.java.core.db.daogen.BasicHelper; import org.fugerit.java.core.db.daogen.BasicWrapperNG; import org.fugerit.java.core.function.SafeFunction; -import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; import test.org.fugerit.java.BasicTest; import test.org.fugerit.java.core.db.dao.ModelUser; import java.io.NotSerializableException; @Slf4j -public class TestBasicWrapperNG { +class TestBasicWrapperNG { private static final BasicTest HELPER = new BasicTest(); @Test - public void testBasicWrapperNG() { + void testBasicWrapperNG() { SafeFunction.apply( () -> { ModelUser userTest = new ModelUser(); // wrapper ng @@ -26,9 +26,9 @@ public void testBasicWrapperNG() { log.info( "test 2 : {}", userWrapperNG.unwrapModel() ); log.info( "test 3 : {}", userWrapperNG ); userWrapperNG.wrapModel( userTest ); - Assert.assertThrows(NotSerializableException.class, () -> HELPER.fullSerializationTest( userWrapperNG )); + Assertions.assertThrows(NotSerializableException.class, () -> HELPER.fullSerializationTest( userWrapperNG )); BasicHelper.throwUnsupported( "test 0", () -> false ); // will not throw unsupported operation - Assert.assertThrows( UnsupportedOperationException.class, () -> BasicHelper.throwUnsupported( "test 1" ) ); + Assertions.assertThrows( UnsupportedOperationException.class, () -> BasicHelper.throwUnsupported( "test 1" ) ); } ); } diff --git a/fj-core/src/test/java/test/org/fugerit/java/core/db/dao/daogen/TestByteArrayDataHandler.java b/fj-core/src/test/java/test/org/fugerit/java/core/db/dao/daogen/TestByteArrayDataHandler.java index 270f94c3..597ca7cd 100644 --- a/fj-core/src/test/java/test/org/fugerit/java/core/db/dao/daogen/TestByteArrayDataHandler.java +++ b/fj-core/src/test/java/test/org/fugerit/java/core/db/dao/daogen/TestByteArrayDataHandler.java @@ -5,23 +5,23 @@ import org.fugerit.java.core.db.daogen.ByteArrayDataHandler; import org.fugerit.java.core.db.daogen.CharArrayDataHandler; import org.fugerit.java.core.io.ArchiveIO; -import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; import java.io.ByteArrayOutputStream; import java.io.IOException; import java.util.zip.ZipOutputStream; @Slf4j -public class TestByteArrayDataHandler { +class TestByteArrayDataHandler { private static final String TEST_STRING = "test"; @Test - public void testByteArrayDataHandler() throws DAOException, IOException { + void testByteArrayDataHandler() throws DAOException, IOException { ByteArrayDataHandler ch = ByteArrayDataHandler.newHandlerByte( TEST_STRING.getBytes() ); - Assert.assertEquals( TEST_STRING, ch.toString() ); - Assert.assertEquals( TEST_STRING, String.valueOf( ch.toChars() ) ); + Assertions.assertEquals( TEST_STRING, ch.toString() ); + Assertions.assertEquals( TEST_STRING, String.valueOf( ch.toChars() ) ); try (ZipOutputStream zos = new ZipOutputStream( new ByteArrayOutputStream())) { ArchiveIO.addEntry( "test.txt", zos, ch ); } diff --git a/fj-core/src/test/java/test/org/fugerit/java/core/db/dao/daogen/TestCharArrayDataHandler.java b/fj-core/src/test/java/test/org/fugerit/java/core/db/dao/daogen/TestCharArrayDataHandler.java index 6a6b912a..85cf278a 100644 --- a/fj-core/src/test/java/test/org/fugerit/java/core/db/dao/daogen/TestCharArrayDataHandler.java +++ b/fj-core/src/test/java/test/org/fugerit/java/core/db/dao/daogen/TestCharArrayDataHandler.java @@ -4,23 +4,23 @@ import org.fugerit.java.core.db.dao.DAOException; import org.fugerit.java.core.db.daogen.CharArrayDataHandler; import org.fugerit.java.core.io.ArchiveIO; -import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; import java.io.ByteArrayOutputStream; import java.io.IOException; import java.util.zip.ZipOutputStream; @Slf4j -public class TestCharArrayDataHandler { +class TestCharArrayDataHandler { private static final String TEST_STRING = "test"; @Test - public void testCharArrayDataHandler() throws DAOException, IOException { + void testCharArrayDataHandler() throws DAOException, IOException { CharArrayDataHandler ch = CharArrayDataHandler.newHandlerByte( TEST_STRING.toCharArray() ); - Assert.assertEquals( TEST_STRING, ch.toString() ); - Assert.assertEquals( TEST_STRING, new String( ch.toBytes() ) ); + Assertions.assertEquals( TEST_STRING, ch.toString() ); + Assertions.assertEquals( TEST_STRING, new String( ch.toBytes() ) ); try (ZipOutputStream zos = new ZipOutputStream( new ByteArrayOutputStream())) { ArchiveIO.addEntry( "test.txt", zos, ch ); } diff --git a/fj-core/src/test/java/test/org/fugerit/java/core/db/dao/daogen/TestDAOItems.java b/fj-core/src/test/java/test/org/fugerit/java/core/db/dao/daogen/TestDAOItems.java index a769481c..86c760b3 100644 --- a/fj-core/src/test/java/test/org/fugerit/java/core/db/dao/daogen/TestDAOItems.java +++ b/fj-core/src/test/java/test/org/fugerit/java/core/db/dao/daogen/TestDAOItems.java @@ -8,43 +8,43 @@ import org.fugerit.java.core.db.daogen.BasicDaoResult; import org.fugerit.java.core.db.daogen.ResultUtils; import org.fugerit.java.core.util.result.Result; -import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; import lombok.extern.slf4j.Slf4j; import test.org.fugerit.java.BasicTest; @Slf4j -public class TestDAOItems extends BasicTest { +class TestDAOItems extends BasicTest { @Test - public void testBasicIdFinder() throws IOException { + void testBasicIdFinder() throws IOException { BigDecimal value = BigDecimal.valueOf( 10L ); BaseIdFinder finder = new BaseIdFinder(); finder.setId( value ); finder.setId( value.longValue() ); log.info( "item : {}", finder ); - Assert.assertEquals( value , finder.getId() ); - Assert.assertNotNull( this.fullSerializationTest( finder ) ); + Assertions.assertEquals( value , finder.getId() ); + Assertions.assertNotNull( this.fullSerializationTest( finder ) ); } @Test - public void testBasicDaoResult() throws IOException { + void testBasicDaoResult() throws IOException { BigDecimal value = BigDecimal.valueOf( 10L ); BasicDaoResult item = new BasicDaoResult<>(); item.setSingleResult( value ); item.evaluateResultFromList(); log.info( "item : {}", item ); - Assert.assertEquals( value , ResultUtils.oneOut( item ) ); + Assertions.assertEquals( value , ResultUtils.oneOut( item ) ); item.setResult( item ); item.setResult( Result.RESULT_CODE_OK , "desc ok" ); item.getList().clear(); item.evaluateResultFromList(); - Assert.assertNull(ResultUtils.oneOut( new BasicDaoResult<>( BasicDaoResult.RESULT_NODATAFOUND ) ) ); - Assert.assertNotNull( new BasicDaoResult<>( Result.RESULT_CODE_OK, "test desc" ) ); + Assertions.assertNull(ResultUtils.oneOut( new BasicDaoResult<>( BasicDaoResult.RESULT_NODATAFOUND ) ) ); + Assertions.assertNotNull( new BasicDaoResult<>( Result.RESULT_CODE_OK, "test desc" ) ); item.getList().add( value ); item.getList().add( value ); - Assert.assertThrows( DAORuntimeException.class , () -> ResultUtils.oneOut( item ) ); + Assertions.assertThrows( DAORuntimeException.class , () -> ResultUtils.oneOut( item ) ); } } diff --git a/fj-core/src/test/java/test/org/fugerit/java/core/db/dao/daogen/TestIdFinderNG.java b/fj-core/src/test/java/test/org/fugerit/java/core/db/dao/daogen/TestIdFinderNG.java index dac8f2ff..6eff538c 100644 --- a/fj-core/src/test/java/test/org/fugerit/java/core/db/dao/daogen/TestIdFinderNG.java +++ b/fj-core/src/test/java/test/org/fugerit/java/core/db/dao/daogen/TestIdFinderNG.java @@ -2,20 +2,20 @@ import lombok.extern.slf4j.Slf4j; import org.fugerit.java.core.db.daogen.IdFinderNG; -import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; @Slf4j -public class TestIdFinderNG { +class TestIdFinderNG { private static final long TEST = 1000L; @Test - public void testIdFinderNg() { + void testIdFinderNg() { IdFinderNG finder = new IdFinderNG(); finder.setId( TEST ); log.info( "finder : {}", finder ); - Assert.assertEquals( TEST, finder.getId().longValue() ); + Assertions.assertEquals( TEST, finder.getId().longValue() ); } } diff --git a/fj-core/src/test/java/test/org/fugerit/java/core/db/dao/daogen/TestMisc.java b/fj-core/src/test/java/test/org/fugerit/java/core/db/dao/daogen/TestMisc.java index 3fedc69d..5ba3a715 100644 --- a/fj-core/src/test/java/test/org/fugerit/java/core/db/dao/daogen/TestMisc.java +++ b/fj-core/src/test/java/test/org/fugerit/java/core/db/dao/daogen/TestMisc.java @@ -20,12 +20,12 @@ import org.fugerit.java.core.db.daogen.SimpleServiceProvider; import org.fugerit.java.core.db.daogen.SimpleServiceResult; import org.fugerit.java.core.function.SafeFunction; -import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; import test.org.fugerit.java.core.db.TestBasicDBHelper; -public class TestMisc extends TestBasicDBHelper { +class TestMisc extends TestBasicDBHelper { class CustomSimpleServiceProvider extends SimpleServiceProvider { private static final long serialVersionUID = 89245089543485253L; @@ -38,22 +38,22 @@ public CloseableDAOContext newDefaultContext() throws DAOException { }; @Test - public void testSimpleServiceProvider() { + void testSimpleServiceProvider() { SafeFunction.apply(() -> { CustomSimpleServiceProvider provider = new CustomSimpleServiceProvider(); try ( CloseableDAOContext context = provider.newDefaultContext() ) { - Assert.assertEquals( "b" , context.getAttribute( "a" ) ); + Assertions.assertEquals( "b" , context.getAttribute( "a" ) ); } SimpleServiceResult> resultList = new SimpleServiceResult<>(); - Assert.assertNull( provider.createResponseFromList(resultList) ); + Assertions.assertNull( provider.createResponseFromList(resultList) ); List list = new ArrayList(); resultList.setContent(list); resultList.getContent().add( "a" ); - Assert.assertNotNull( provider.createResponseFromList(resultList) ); + Assertions.assertNotNull( provider.createResponseFromList(resultList) ); SimpleServiceResult resultObject = new SimpleServiceResult<>(); - Assert.assertNull( provider.createResponseFromObject( resultObject ) ); + Assertions.assertNull( provider.createResponseFromObject( resultObject ) ); resultObject.setContent( "b" ); - Assert.assertNotNull( provider.createResponseFromObject( resultObject ) ); + Assertions.assertNotNull( provider.createResponseFromObject( resultObject ) ); provider.createResultFromList(resultList); provider.createResultFromObject(resultObject); provider.defaultConvertToUtilDate( null ); @@ -63,39 +63,39 @@ public void testSimpleServiceProvider() { resultObject.addInfoDefaultOK(); resultList.addInfoMultipleResult(); resultObject.addInfoNoDataFound(); - Assert.assertThrows( DAOException.class , () -> SimpleServiceProvider.throwDAOException( new IOException( "a" ) ) ); - Assert.assertEquals( SimpleServiceResult.DEFAULT_OK , SimpleServiceResult.newDefaultResult( "e" ).getResult() ); - Assert.assertEquals( SimpleServiceResult.DEFAULT_OK , SimpleServiceResult.newDefaultResult( list ).getResult() ); - Assert.assertEquals( SimpleServiceResult.DEFAULT_KO , SimpleServiceResult.newDefaultResult( null ).getResult() ); - Assert.assertEquals( SimpleServiceResult.DEFAULT_KO , SimpleServiceResult.newDefaultResult( new ArrayList() ).getResult() ); + Assertions.assertThrows( DAOException.class , () -> SimpleServiceProvider.throwDAOException( new IOException( "a" ) ) ); + Assertions.assertEquals( SimpleServiceResult.DEFAULT_OK , SimpleServiceResult.newDefaultResult( "e" ).getResult() ); + Assertions.assertEquals( SimpleServiceResult.DEFAULT_OK , SimpleServiceResult.newDefaultResult( list ).getResult() ); + Assertions.assertEquals( SimpleServiceResult.DEFAULT_KO , SimpleServiceResult.newDefaultResult( null ).getResult() ); + Assertions.assertEquals( SimpleServiceResult.DEFAULT_KO , SimpleServiceResult.newDefaultResult( new ArrayList() ).getResult() ); resultObject.setResult( SimpleServiceResult.DEFAULT_OK ); - Assert.assertEquals( SimpleServiceResult.DEFAULT_OK , resultObject.getResult() ); - Assert.assertNotNull( new SimpleServiceResult( SimpleServiceResult.DEFAULT_OK ) ); + Assertions.assertEquals( SimpleServiceResult.DEFAULT_OK , resultObject.getResult() ); + Assertions.assertNotNull( new SimpleServiceResult( SimpleServiceResult.DEFAULT_OK ) ); }); } @Test - public void testSQLTypeConverter() { + void testSQLTypeConverter() { SafeFunction.apply(() -> { try ( Connection conn = newConnection() ) { Clob clob = LobHelper.createClob( conn , CharArrayDataHandler.newHandlerByte( "c".toCharArray() ) ); Blob blob = LobHelper.createBlob( conn , ByteArrayDataHandler.newHandlerByte( "b".getBytes() ) ); - Assert.assertNotNull( clob ); - Assert.assertNotNull( blob ); - Assert.assertNotNull( SQLTypeConverter.utilDateToSqlDate( new Date() ) ); - Assert.assertNotNull( SQLTypeConverter.utilDateToSqlTime( new Date() ) ); - Assert.assertNotNull( SQLTypeConverter.utilDateToSqlTimestamp( new Date() ) ); - Assert.assertNotNull( SQLTypeConverter.clobToCharHandler( clob ) ); - Assert.assertNotNull( SQLTypeConverter.blobToByteHandler( blob ) ); - Assert.assertTrue( SQLTypeConverter.CONVERT_EX.apply( new IOException( "text" ) ) instanceof SQLException ); + Assertions.assertNotNull( clob ); + Assertions.assertNotNull( blob ); + Assertions.assertNotNull( SQLTypeConverter.utilDateToSqlDate( new Date() ) ); + Assertions.assertNotNull( SQLTypeConverter.utilDateToSqlTime( new Date() ) ); + Assertions.assertNotNull( SQLTypeConverter.utilDateToSqlTimestamp( new Date() ) ); + Assertions.assertNotNull( SQLTypeConverter.clobToCharHandler( clob ) ); + Assertions.assertNotNull( SQLTypeConverter.blobToByteHandler( blob ) ); + Assertions.assertTrue( SQLTypeConverter.CONVERT_EX.apply( new IOException( "text" ) ) instanceof SQLException ); } }); } @Test - public void testBasicHelper() { + void testBasicHelper() { SafeFunction.apply(() -> { - Assert.assertThrows( UnsupportedOperationException.class , () -> BasicHelper.throwUnsupported( "text" ) ); + Assertions.assertThrows( UnsupportedOperationException.class , () -> BasicHelper.throwUnsupported( "text" ) ); }); } diff --git a/fj-core/src/test/java/test/org/fugerit/java/core/db/dao/daogen/TestQueryHelper.java b/fj-core/src/test/java/test/org/fugerit/java/core/db/dao/daogen/TestQueryHelper.java index 809d0c6e..6fddda67 100644 --- a/fj-core/src/test/java/test/org/fugerit/java/core/db/dao/daogen/TestQueryHelper.java +++ b/fj-core/src/test/java/test/org/fugerit/java/core/db/dao/daogen/TestQueryHelper.java @@ -8,61 +8,61 @@ import org.fugerit.java.core.db.daogen.SelectHelper; import org.fugerit.java.core.db.daogen.UpdateHelper; import org.fugerit.java.core.db.helpers.DAOID; -import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; import lombok.extern.slf4j.Slf4j; @Slf4j -public class TestQueryHelper { +class TestQueryHelper { private static final String TABLE_NAME = "fugert.user"; @Test - public void testQueryHelper() { + void testQueryHelper() { QueryHelper helper = new QueryHelper( TABLE_NAME , new FieldList() ); helper.openPara(); helper.appendWithSpace( "1=1" ); helper.closePara(); log.info( "query : {}", helper.getQueryContent() ); - Assert.assertNotNull( helper.getQueryContent() ); + Assertions.assertNotNull( helper.getQueryContent() ); } @Test - public void testUpdateHelper() { + void testUpdateHelper() { UpdateHelper helper = new UpdateHelper( TABLE_NAME , new FieldList() ); - Assert.assertThrows( ConfigRuntimeException.class , helper::getQueryContent ); + Assertions.assertThrows( ConfigRuntimeException.class , helper::getQueryContent ); helper.addSetParam( "username" , "user1" ); helper.addSetParam( "id" , DAOID.valueOf( 1 ) ); helper.addSetParam( "field" , null ); helper.andWhereParam( "username" , "user1" ); helper.andWhereParam( "id" , DAOID.valueOf( 1 ) ); log.info( "query : {}", helper.getQueryContent() ); - Assert.assertNotNull( helper.getQueryContent() ); + Assertions.assertNotNull( helper.getQueryContent() ); } @Test - public void testDeleteHelper() { + void testDeleteHelper() { DeleteHelper helper = new DeleteHelper( TABLE_NAME , new FieldList() ); - Assert.assertThrows( ConfigRuntimeException.class , helper::getQueryContent ); + Assertions.assertThrows( ConfigRuntimeException.class , helper::getQueryContent ); helper.andWhereParam( "username" , "user1" ); helper.andWhereParam( "id" , DAOID.valueOf( 1 ) ); log.info( "query : {}", helper.getQueryContent() ); - Assert.assertNotNull( helper.getQueryContent() ); + Assertions.assertNotNull( helper.getQueryContent() ); } @Test - public void testInsertHelper() { + void testInsertHelper() { InsertHelper helper = new InsertHelper( TABLE_NAME , new FieldList() ); helper.addParam( "username" , "user1" ); helper.addParam( "id" , DAOID.valueOf( 1 ) ); helper.addParam( "age", null ); // not added as it is null log.info( "query : {}", helper.getQueryContent() ); - Assert.assertNotNull( helper.getQueryContent() ); + Assertions.assertNotNull( helper.getQueryContent() ); } @Test - public void testSelectHelper1() { + void testSelectHelper1() { SelectHelper helper = new SelectHelper( TABLE_NAME , new FieldList() ); helper.addNullComparison( "username", SelectHelper.COMPARE_EQUAL, false ); helper.addNullComparison( "id", SelectHelper.COMPARE_EQUAL, true ); @@ -70,24 +70,24 @@ public void testSelectHelper1() { helper.orLikeParam( "field2" , "1" ); helper.andLikeParam( "field3" , "1" ); helper.addOrderBy( "username", SelectHelper.ORDER_ASC ); - Assert.assertNotNull( helper.getQueryContent() ); + Assertions.assertNotNull( helper.getQueryContent() ); } @Test - public void testSelectHelper2() { + void testSelectHelper2() { SelectHelper helper = new SelectHelper( TABLE_NAME , new FieldList() ); helper.addOrderBy( "field4" ); - Assert.assertNotNull( helper.getQueryContent() ); + Assertions.assertNotNull( helper.getQueryContent() ); } @Test - public void testSelectHelper3() { + void testSelectHelper3() { SelectHelper helper = SelectHelper.newCustomSelectHelper(TABLE_NAME, new FieldList(), false, "" ); helper.addOrderBy( null ); helper.addOrderBy( "f1", SelectHelper.ORDER_ASC ); helper.addOrderBy( "f2", SelectHelper.ORDER_DESC ); - Assert.assertFalse( helper.addParam( "username", null, null, null, null ) ); - Assert.assertNotNull( helper.getQueryContent() ); + Assertions.assertFalse( helper.addParam( "username", null, null, null, null ) ); + Assertions.assertNotNull( helper.getQueryContent() ); } } diff --git a/fj-core/src/test/java/test/org/fugerit/java/core/db/dao/daogen/TestSelectHelperSimple.java b/fj-core/src/test/java/test/org/fugerit/java/core/db/dao/daogen/TestSelectHelperSimple.java index 8b251bc3..52f343e8 100644 --- a/fj-core/src/test/java/test/org/fugerit/java/core/db/dao/daogen/TestSelectHelperSimple.java +++ b/fj-core/src/test/java/test/org/fugerit/java/core/db/dao/daogen/TestSelectHelperSimple.java @@ -6,10 +6,10 @@ import org.fugerit.java.core.db.daogen.CloseableDAOContext; import org.fugerit.java.core.db.daogen.CloseableDAOContextSC; import org.fugerit.java.core.db.daogen.SelectHelper; -import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; -public class TestSelectHelperSimple extends TestAddressSelectHelper { +class TestSelectHelperSimple extends TestAddressSelectHelper { protected void testQueryHelperSimple( String syntax ) { @@ -26,19 +26,19 @@ protected void testQueryHelperSimple( String syntax ) { // result String res = daoHelper.loadOneHelper( selectHelper, RSE_ADDRESS_COL_INFO ); logger.info( "res -> {}", res ); - Assert.assertNotNull( "Result should not be null" , res ); + Assertions.assertNotNull( "Result should not be null" , res ); } catch (Exception e) { this.failEx(e); } } @Test - public void testQuerySelectSimplePostgres() { + void testQuerySelectSimplePostgres() { testQueryHelperSimple( "PGS" ); } @Test - public void testQuerySelectSimpleOracle() { + void testQuerySelectSimpleOracle() { testQueryHelperSimple( "ORA" ); } diff --git a/fj-core/src/test/java/test/org/fugerit/java/core/db/dao/daogen/TestSelectHelperUpper.java b/fj-core/src/test/java/test/org/fugerit/java/core/db/dao/daogen/TestSelectHelperUpper.java index 22374b4a..b6f51d7f 100644 --- a/fj-core/src/test/java/test/org/fugerit/java/core/db/dao/daogen/TestSelectHelperUpper.java +++ b/fj-core/src/test/java/test/org/fugerit/java/core/db/dao/daogen/TestSelectHelperUpper.java @@ -6,10 +6,10 @@ import org.fugerit.java.core.db.daogen.CloseableDAOContext; import org.fugerit.java.core.db.daogen.CloseableDAOContextSC; import org.fugerit.java.core.db.daogen.SelectHelper; -import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; -public class TestSelectHelperUpper extends TestAddressSelectHelper { +class TestSelectHelperUpper extends TestAddressSelectHelper { protected void testQueryHelperIgnoreCase( String syntax ) { try ( CloseableDAOContext context = new CloseableDAOContextSC( this.getConnection() ) ) { @@ -29,19 +29,19 @@ protected void testQueryHelperIgnoreCase( String syntax ) { // the result String res = daoHelper.loadOneHelper( selectHelper, RSE_ADDRESS_COL_INFO ); logger.info( "res -> {}", res ); - Assert.assertNotNull( "Result should not be null" , res ); + Assertions.assertNotNull( "Result should not be null" , res ); } catch (Exception e) { this.failEx(e); } } @Test - public void testQuerySelectIgnoreCasePostgres() { + void testQuerySelectIgnoreCasePostgres() { testQueryHelperIgnoreCase( "PGS" ); } @Test - public void testQuerySelectgnoreCaseOracle() { + void testQuerySelectgnoreCaseOracle() { testQueryHelperIgnoreCase( "ORA" ); } diff --git a/fj-core/src/test/java/test/org/fugerit/java/core/db/dao/idgen/TestSeqIdGenerator.java b/fj-core/src/test/java/test/org/fugerit/java/core/db/dao/idgen/TestSeqIdGenerator.java index 859510ac..b854eaa9 100644 --- a/fj-core/src/test/java/test/org/fugerit/java/core/db/dao/idgen/TestSeqIdGenerator.java +++ b/fj-core/src/test/java/test/org/fugerit/java/core/db/dao/idgen/TestSeqIdGenerator.java @@ -25,14 +25,14 @@ import org.fugerit.java.core.db.helpers.DbUtils; import org.fugerit.java.core.function.SafeFunction; import org.fugerit.java.core.xml.XMLException; -import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; import test.org.fugerit.java.core.db.TestBasicDBHelper; import test.org.fugerit.java.core.db.helpers.MemDBTestBase; import test.org.fugerit.java.helpers.FailHelper; -public class TestSeqIdGenerator extends MemDBTestBase { +class TestSeqIdGenerator extends MemDBTestBase { private static final String SEQ_NAME = "fugerit.seq_test"; @@ -63,46 +63,46 @@ protected boolean testSequenceWorker( String syntax, String } @Test - public void testIdentify() { + void testIdentify() { String[] products = TestBasicDBHelper.PRODUCT_NAME_STRING; for ( int k=0; k "SELECT nextval('"+s+"')" ); boolean ok = testSequenceWorker( "MSS" , SEQ_NAME , idGenerator, null ); SqlServerSeqIdGenerator.createSequenceQuery( SEQ_NAME ); // invocation test - Assert.assertTrue(ok); + Assertions.assertTrue(ok); } @Test - public void testFacade1() { + void testFacade1() { DAOID id = SafeFunction.get( () -> { try (Connection conn = this.getConnection(); Statement stm = conn.createStatement() ) { @@ -112,11 +112,11 @@ public void testFacade1() { return idGenerator.generateId(); } } ); - Assert.assertNotNull( id ); + Assertions.assertNotNull( id ); } @Test - public void testFacade2() { + void testFacade2() { DAOID id = SafeFunction.get( () -> { try (Connection conn = this.getConnection(); CloseableDAOContext context = new CloseableDAOContextSC( conn ); @@ -127,36 +127,36 @@ public void testFacade2() { return idGenerator.generateId(); } } ); - Assert.assertNotNull( id ); + Assertions.assertNotNull( id ); } @Test - public void testGeneric() { + void testGeneric() { DAOID id = SafeFunction.get( () -> { try (Connection conn = this.getConnection(); Statement stm = conn.createStatement() ) { String sqlSyntax = "SET DATABASE SQL SYNTAX PGS TRUE"; stm.execute( sqlSyntax ); GenericSeqIdGenerator idGenerator = new GenericSeqIdGenerator(); - Assert.assertThrows( ConfigException.class , () -> idGenerator.configure( new Properties() ) ); + Assertions.assertThrows( ConfigException.class , () -> idGenerator.configure( new Properties() ) ); idGenerator.setConnectionFactory( new SingleConnectionFactory( conn ) ); - Assert.assertThrows( ConfigException.class , () -> idGenerator.configure( new Properties() ) ); + Assertions.assertThrows( ConfigException.class , () -> idGenerator.configure( new Properties() ) ); idGenerator.configure( getConfiguration() ); return idGenerator.generateId(); } } ); - Assert.assertNotNull( id ); + Assertions.assertNotNull( id ); } @Test - public void testSqlServerFail() { + void testSqlServerFail() { SqlServerSeqIdGenerator idGenerator = new SqlServerSeqIdGenerator() ; idGenerator.setSequenceName(SEQ_NAME); - Assert.assertThrows( Exception.class , () -> testSequenceWorker( "MSS" , SEQ_NAME , idGenerator, null ) ); + Assertions.assertThrows( Exception.class , () -> testSequenceWorker( "MSS" , SEQ_NAME , idGenerator, null ) ); } @Test - public void testBasic() throws ConfigException, IOException, XMLException { + void testBasic() throws ConfigException, IOException, XMLException { BasicIdGenerator idGenerator = new BasicIdGenerator() { @Override public DAOID generateId(Connection conn) throws DAOException { @@ -173,11 +173,11 @@ public DAOID generateId(Connection conn) throws DAOException { idGenerator.configureXML(source); } idGenerator.setAutoCloseConnection( true ); - Assert.assertTrue(idGenerator.isAutoCloseConnection()); + Assertions.assertTrue(idGenerator.isAutoCloseConnection()); } @Test - public void testBasicSeq() throws ConfigException, IOException, XMLException { + void testBasicSeq() throws ConfigException, IOException, XMLException { BasicSeqIdGenerator idGenerator = new BasicSeqIdGenerator() { @Override @@ -190,7 +190,7 @@ protected String createSequenceQuery() { }; idGenerator.configure( getConfiguration() ); idGenerator.setAutoCloseConnection( true ); - Assert.assertTrue(idGenerator.isAutoCloseConnection()); + Assertions.assertTrue(idGenerator.isAutoCloseConnection()); } } diff --git a/fj-core/src/test/java/test/org/fugerit/java/core/db/dao/rse/TestRSE.java b/fj-core/src/test/java/test/org/fugerit/java/core/db/dao/rse/TestRSE.java index d55b30d2..8629cf6f 100644 --- a/fj-core/src/test/java/test/org/fugerit/java/core/db/dao/rse/TestRSE.java +++ b/fj-core/src/test/java/test/org/fugerit/java/core/db/dao/rse/TestRSE.java @@ -24,14 +24,14 @@ import org.fugerit.java.core.function.SafeFunction; import org.fugerit.java.core.util.PropsIO; import org.fugerit.java.core.util.collection.OptionItem; -import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; import lombok.extern.slf4j.Slf4j; import test.org.fugerit.java.core.db.TestBasicDBHelper; @Slf4j -public class TestRSE extends TestBasicDBHelper { +class TestRSE extends TestBasicDBHelper { private static final String TEST_USERNAME = "user1"; @@ -62,15 +62,15 @@ private T worker( String sql, String userId, RSExtractor rse, String colN } @Test - public void testRSEString() throws SQLException { + void testRSEString() throws SQLException { String result = this.worker( "SELECT username FROM fugerit.user WHERE username = ?" , TEST_USERNAME, StringRSE.DEFAULT, "username" ); - Assert.assertEquals( "user1" , result ); + Assertions.assertEquals( "user1" , result ); } @Test - public void testRSEBigDecimal() throws SQLException { + void testRSEBigDecimal() throws SQLException { BigDecimal result = this.worker( "SELECT state FROM fugerit.user WHERE username = ?" , TEST_USERNAME, BigDecimalRSE.DEFAULT, "state" ); - Assert.assertEquals( BigDecimal.valueOf( TEST_STATE ) , result ); + Assertions.assertEquals( BigDecimal.valueOf( TEST_STATE ) , result ); // test convert method BigDecimalRSE tester = new BigDecimalRSE() { public String toString() { @@ -81,32 +81,32 @@ public String toString() { } @Test - public void testRSEDouble() throws SQLException { + void testRSEDouble() throws SQLException { Double result = this.worker( "SELECT state FROM fugerit.user WHERE username = ?" , TEST_USERNAME, DoubleRSE.DEFAULT, "state" ); - Assert.assertEquals( Double.valueOf( TEST_STATE ) , result ); + Assertions.assertEquals( Double.valueOf( TEST_STATE ) , result ); } @Test - public void testRSEInteger() throws SQLException { + void testRSEInteger() throws SQLException { Integer result = this.worker( "SELECT state FROM fugerit.user WHERE username = ?" , TEST_USERNAME, IntegerRSE.DEFAULT, "state" ); - Assert.assertEquals( Integer.valueOf( TEST_STATE ) , result ); + Assertions.assertEquals( Integer.valueOf( TEST_STATE ) , result ); } @Test - public void testRSELong() throws SQLException { + void testRSELong() throws SQLException { Long result = this.worker( "SELECT state FROM fugerit.user WHERE username = ?" , TEST_USERNAME, LongRSE.DEFAULT, "state" ); - Assert.assertEquals( Long.valueOf( TEST_STATE ) , result ); + Assertions.assertEquals( Long.valueOf( TEST_STATE ) , result ); } @Test - public void testRSEFail() throws SQLException { + void testRSEFail() throws SQLException { SingleColumnRSE rse = new SingleColumnRSE() { @Override protected Long convert(Object o) { return null; } }; - Assert.assertThrows( DAORuntimeException.class , () -> this.worker( "SELECT state FROM fugerit.user WHERE username = ?" , TEST_USERNAME, rse, "state" ) ); + Assertions.assertThrows( DAORuntimeException.class , () -> this.worker( "SELECT state FROM fugerit.user WHERE username = ?" , TEST_USERNAME, rse, "state" ) ); } private void worker( SingleColumnRSE rse ) { @@ -115,44 +115,44 @@ private void worker( SingleColumnRSE rse ) { } @Test - public void testSingleColumn() { + void testSingleColumn() { boolean ok = false; this.worker( new StringRSE( 1 ) ); this.worker( new StringRSE( "test" ) ); ok = true; - Assert.assertTrue(ok); + Assertions.assertTrue(ok); } @Test - public void testOptionItemRSE() throws SQLException { + void testOptionItemRSE() throws SQLException { OptionItem result1 = this.worker( "SELECT username FROM fugerit.user WHERE username = ?" , TEST_USERNAME, OptionItemRSE.getInstance( "username" ), null ); - Assert.assertEquals( TEST_USERNAME , result1.getValue() ); + Assertions.assertEquals( TEST_USERNAME , result1.getValue() ); OptionItemRSE rse = OptionItemRSE.getInstance( "state", "username" ); OptionItem result2 = this.worker( "SELECT username, state FROM fugerit.user WHERE username = ?" , TEST_USERNAME, rse, null ); - Assert.assertEquals( String.valueOf( TEST_STATE ) , result2.getValue() ); - Assert.assertEquals( TEST_USERNAME , result2.getLabel() ); + Assertions.assertEquals( String.valueOf( TEST_STATE ) , result2.getValue() ); + Assertions.assertEquals( TEST_USERNAME , result2.getLabel() ); log.info( "result2 label field : {}, value field : {}", rse.getLabelField(), rse.getValueField() ); } @Test - public void testPropertyReusableRSE() throws SQLException { + void testPropertyReusableRSE() throws SQLException { PropertyRSE rse = PropertyRSE.newReusableRSE(); Properties result = this.worker( "SELECT username, state FROM fugerit.user WHERE username = ?" , TEST_USERNAME, rse, null ); log.info( "result : {}", result ); - Assert.assertEquals( TEST_USERNAME , result.getProperty( "USERNAME" ) ); + Assertions.assertEquals( TEST_USERNAME , result.getProperty( "USERNAME" ) ); } @Test - public void testPropertyCachingRSE() throws SQLException { + void testPropertyCachingRSE() throws SQLException { PropertyRSE rse = PropertyRSE.newAutoCachingMetadataRSE(); Properties result = this.worker( "SELECT username, state FROM fugerit.user WHERE username = ?" , TEST_USERNAME, rse, null ); - Assert.assertEquals( TEST_USERNAME , result.getProperty( "USERNAME" ) ); + Assertions.assertEquals( TEST_USERNAME , result.getProperty( "USERNAME" ) ); } private static final String SIMPLE_QUERY = "SELECT * FROM fugerit.user"; @Test - public void tesConnectionFacade() throws Exception { + void tesConnectionFacade() throws Exception { try ( ConnectionFactoryCloseable cf = ConnectionFactoryImpl.wrap( ConnectionFactoryImpl.newInstance( PropsIO.loadFromClassLoaderSafe( TestBasicDBHelper.DEFAULT_DB_CONN_PATH ) ) ) ) { try ( Connection conn = cf.getConnection(); @@ -165,23 +165,23 @@ public void tesConnectionFacade() throws Exception { try ( Connection conn = cf.getConnection(); Statement stm = conn.createStatement(); ResultSet rs = stm.executeQuery( SIMPLE_QUERY ) ) { - Assert.assertTrue( ConnectionFacade.closeLoose(conn, stm, rs) ); + Assertions.assertTrue( ConnectionFacade.closeLoose(conn, stm, rs) ); } try ( Connection conn = cf.getConnection(); Statement stm = conn.createStatement() ) { - Assert.assertFalse( ConnectionFacade.closeLoose(conn, stm, null) ); + Assertions.assertFalse( ConnectionFacade.closeLoose(conn, stm, null) ); } try ( Connection conn = cf.getConnection() ) { - Assert.assertFalse( ConnectionFacade.closeLoose(conn, null, null) ); + Assertions.assertFalse( ConnectionFacade.closeLoose(conn, null, null) ); } - Assert.assertFalse( ConnectionFacade.closeLoose(null, null, null) ); + Assertions.assertFalse( ConnectionFacade.closeLoose(null, null, null) ); try ( Connection conn = cf.getConnection(); Statement stm = conn.createStatement() ) { - Assert.assertTrue( ConnectionFacade.closeLoose(conn, stm) ); + Assertions.assertTrue( ConnectionFacade.closeLoose(conn, stm) ); } - Assert.assertFalse( ConnectionFacade.closeLoose(null, null) ); + Assertions.assertFalse( ConnectionFacade.closeLoose(null, null) ); try ( Connection conn = cf.getConnection() ) { - Assert.assertFalse( ConnectionFacade.closeLoose(conn, null) ); + Assertions.assertFalse( ConnectionFacade.closeLoose(conn, null) ); } } } diff --git a/fj-core/src/test/java/test/org/fugerit/java/core/db/daogein/TestSQLTypeConverter.java b/fj-core/src/test/java/test/org/fugerit/java/core/db/daogein/TestSQLTypeConverter.java index 0008fc1b..6cc5cd23 100644 --- a/fj-core/src/test/java/test/org/fugerit/java/core/db/daogein/TestSQLTypeConverter.java +++ b/fj-core/src/test/java/test/org/fugerit/java/core/db/daogein/TestSQLTypeConverter.java @@ -2,8 +2,8 @@ import lombok.extern.slf4j.Slf4j; import org.fugerit.java.core.db.daogen.SQLTypeConverter; -import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; import java.sql.Date; import java.sql.Time; @@ -16,46 +16,46 @@ import java.util.Calendar; @Slf4j -public class TestSQLTypeConverter { +class TestSQLTypeConverter { private static final int TEST_YEAR = 2024; private static final int TEST_HOUR = 11; @Test - public void testLocalDate() { + void testLocalDate() { LocalDate d = SQLTypeConverter.utilDateToLocalDate(Date.valueOf( TEST_YEAR+"-05-05" )); log.info( "local date : {}", d ); - Assert.assertEquals( TEST_YEAR, d.getYear() ); + Assertions.assertEquals( TEST_YEAR, d.getYear() ); Date t = SQLTypeConverter.localDateToSqlDate( d ); log.info( "sql date : {}", t ); Calendar c = Calendar.getInstance(); c.setTime(t); - Assert.assertEquals( TEST_YEAR, c.get( Calendar.YEAR ) ); + Assertions.assertEquals( TEST_YEAR, c.get( Calendar.YEAR ) ); } @Test - public void testLocalDateTime() { + void testLocalDateTime() { LocalDateTime d = SQLTypeConverter.utilDateToLocalDateTime(Timestamp.valueOf( TEST_YEAR+"-05-05 "+TEST_HOUR+":30:00.000" )); log.info( "local date time : {}", d ); - Assert.assertEquals( TEST_YEAR, d.getYear() ); + Assertions.assertEquals( TEST_YEAR, d.getYear() ); Timestamp t = SQLTypeConverter.localDateTimeToSqlTimestamp( d ); log.info( "timestamp : {}", t ); Calendar c = Calendar.getInstance(); c.setTime(t); - Assert.assertEquals( TEST_YEAR, c.get( Calendar.YEAR ) ); + Assertions.assertEquals( TEST_YEAR, c.get( Calendar.YEAR ) ); } @Test - public void testLocalTime() { + void testLocalTime() { LocalTime d = SQLTypeConverter.utilDateToLocalTime(Time.valueOf( TEST_HOUR+":30:00" )); log.info( "local time : {}", d ); - Assert.assertEquals( TEST_HOUR, d.getHour() ); + Assertions.assertEquals( TEST_HOUR, d.getHour() ); Time t = SQLTypeConverter.localTimeToSqlTime( d ); log.info( "time : {}", t ); Calendar c = Calendar.getInstance(); c.setTime(t); - Assert.assertEquals( TEST_HOUR, c.get( Calendar.HOUR_OF_DAY ) ); + Assertions.assertEquals( TEST_HOUR, c.get( Calendar.HOUR_OF_DAY ) ); } } diff --git a/fj-core/src/test/java/test/org/fugerit/java/core/db/helpers/MemDBHelper.java b/fj-core/src/test/java/test/org/fugerit/java/core/db/helpers/MemDBHelper.java index 25823968..4f99d83d 100644 --- a/fj-core/src/test/java/test/org/fugerit/java/core/db/helpers/MemDBHelper.java +++ b/fj-core/src/test/java/test/org/fugerit/java/core/db/helpers/MemDBHelper.java @@ -2,15 +2,15 @@ import org.fugerit.java.core.cfg.ConfigRuntimeException; import org.fugerit.java.test.db.helper.MemTestDBHelper; -import org.junit.BeforeClass; +import org.junit.jupiter.api.BeforeAll; -public class MemDBHelper extends MemTestDBHelper { +class MemDBHelper extends MemTestDBHelper { public static final String DEFAULT_DB_CONN_PATH = "test/memdb/base-db-conn.properties"; public static final String DEFAULT_DB_INIT_PATH = "test/memdb/base_db_init.sql"; - @BeforeClass - public static void init() { + @BeforeAll + static void init() { try { MemTestDBHelper.init( DEFAULT_DB_CONN_PATH , DEFAULT_DB_INIT_PATH ); } catch (Exception e) { diff --git a/fj-core/src/test/java/test/org/fugerit/java/core/db/helpers/MemDBTestBase.java b/fj-core/src/test/java/test/org/fugerit/java/core/db/helpers/MemDBTestBase.java index 44fe52c6..ecb43f8f 100644 --- a/fj-core/src/test/java/test/org/fugerit/java/core/db/helpers/MemDBTestBase.java +++ b/fj-core/src/test/java/test/org/fugerit/java/core/db/helpers/MemDBTestBase.java @@ -1,13 +1,12 @@ package test.org.fugerit.java.core.db.helpers; -import org.junit.BeforeClass; - +import org.junit.jupiter.api.BeforeAll; import test.org.fugerit.java.MemDBJunitBase; public class MemDBTestBase extends MemDBJunitBase { - @BeforeClass - public static void init() { + @BeforeAll + static void init() { MemDBHelper.init(); } diff --git a/fj-core/src/test/java/test/org/fugerit/java/core/db/helpers/TestDAOID.java b/fj-core/src/test/java/test/org/fugerit/java/core/db/helpers/TestDAOID.java index 2f0ae741..3b5b3efd 100644 --- a/fj-core/src/test/java/test/org/fugerit/java/core/db/helpers/TestDAOID.java +++ b/fj-core/src/test/java/test/org/fugerit/java/core/db/helpers/TestDAOID.java @@ -1,14 +1,14 @@ package test.org.fugerit.java.core.db.helpers; import org.fugerit.java.core.db.helpers.DAOID; -import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; import lombok.extern.slf4j.Slf4j; import test.org.fugerit.java.BasicTest; @Slf4j -public class TestDAOID extends BasicTest { +class TestDAOID extends BasicTest { private static final byte BYTE_VALUE = 42; @@ -23,58 +23,58 @@ public class TestDAOID extends BasicTest { private static final DAOID DAOID_VALUE = DAOID.valueOf( LONG_VALUE ); @Test - public void testValueFromByte() { + void testValueFromByte() { DAOID id = DAOID.valueOf( BYTE_VALUE ); log.info( "value : {}", id ); - Assert.assertEquals( DAOID_VALUE , id ); + Assertions.assertEquals( DAOID_VALUE , id ); } @Test - public void testValueFromShort() { + void testValueFromShort() { DAOID id = DAOID.valueOf( SHORT_VALUE ); log.info( "value : {}", id ); - Assert.assertEquals( DAOID_VALUE , id ); + Assertions.assertEquals( DAOID_VALUE , id ); } @Test - public void testValueFromInt() { + void testValueFromInt() { DAOID id = DAOID.valueOf( INT_VALUE ); log.info( "value : {}", id ); - Assert.assertEquals( DAOID_VALUE , id ); + Assertions.assertEquals( DAOID_VALUE , id ); } @Test - public void testValueFromLong() { + void testValueFromLong() { DAOID id = DAOID.valueOf( LONG_VALUE ); log.info( "value : {}", id ); - Assert.assertEquals( DAOID_VALUE , id ); + Assertions.assertEquals( DAOID_VALUE , id ); } @Test - public void testValueFromString() { + void testValueFromString() { DAOID id = DAOID.valueOf( STRING_VALUE ); log.info( "value : {}", id ); - Assert.assertEquals( DAOID_VALUE , id ); + Assertions.assertEquals( DAOID_VALUE , id ); } @Test - public void testValueOfNullZeroNull() { + void testValueOfNullZeroNull() { DAOID id = DAOID.valueOfNullZero( 0 ); log.info( "value : {}", id ); - Assert.assertNull( id ); + Assertions.assertNull( id ); } @Test - public void testValueOfNullZero() { + void testValueOfNullZero() { DAOID id = DAOID.valueOfNullZero( LONG_VALUE ); log.info( "value : {}", id ); - Assert.assertEquals( DAOID_VALUE , id ); + Assertions.assertEquals( DAOID_VALUE , id ); } @Test - public void testPrint() { + void testPrint() { log.info( "byteValue : {}", DAOID_VALUE.byteValue() ); log.info( "shortValue : {}", DAOID_VALUE.shortValue() ); log.info( "intValue : {}", DAOID_VALUE.intValue() ); @@ -82,12 +82,12 @@ public void testPrint() { log.info( "floatValue : {}", DAOID_VALUE.floatValue() ); log.info( "doubleValue : {}", DAOID_VALUE.doubleValue() ); log.info( "toString : {}", DAOID_VALUE.toString() ); - Assert.assertEquals( STRING_VALUE, DAOID_VALUE.toString() ); + Assertions.assertEquals( STRING_VALUE, DAOID_VALUE.toString() ); } @Test - public void testHashCode() { - Assert.assertEquals( DAOID_VALUE.hashCode() , DAOID.valueOf( STRING_VALUE ).hashCode() ); + void testHashCode() { + Assertions.assertEquals( DAOID_VALUE.hashCode() , DAOID.valueOf( STRING_VALUE ).hashCode() ); } } diff --git a/fj-core/src/test/java/test/org/fugerit/java/core/db/helpers/TestDBUtils.java b/fj-core/src/test/java/test/org/fugerit/java/core/db/helpers/TestDBUtils.java index a5438ba2..427a155c 100644 --- a/fj-core/src/test/java/test/org/fugerit/java/core/db/helpers/TestDBUtils.java +++ b/fj-core/src/test/java/test/org/fugerit/java/core/db/helpers/TestDBUtils.java @@ -11,15 +11,15 @@ import org.fugerit.java.core.db.helpers.DAOID; import org.fugerit.java.core.db.helpers.DbUtils; import org.fugerit.java.core.function.SafeFunction; -import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; import test.org.fugerit.java.BasicTest; import java.sql.Connection; import java.sql.DriverManager; @Slf4j -public class TestDBUtils extends BasicTest { +class TestDBUtils extends BasicTest { private int testWorker( ConnectionFactory cf ) { return SafeFunction.get( () -> { @@ -29,27 +29,27 @@ private int testWorker( ConnectionFactory cf ) { BasicSeqIdGenerator idGenerator = IdGeneratorFacade.sequenceGenerator( conn, "test_seq" ); DAOID id = idGenerator.generateId( conn ); log.info( "generated id : {}", id ); - Assert.assertNotNull( id ); + Assertions.assertNotNull( id ); return res; } } ); } @Test - public void testH2() { + void testH2() { SafeFunction.apply( () -> { ConnectionFactory cf = ConnectionFactoryImpl.newInstance( "org.h2.Driver", "jdbc:h2:mem:default", "user_h2", "pass_h2" ); - Assert.assertEquals( DbUtils.DB_H2, this.testWorker( cf ) ); + Assertions.assertEquals( DbUtils.DB_H2, this.testWorker( cf ) ); } ); } @Test - public void testHsqldb() { + void testHsqldb() { SafeFunction.apply( () -> { ConnectionFactory cf = ConnectionFactoryImpl.newInstance( "org.hsqldb.jdbc.JDBCDriver", "jdbc:hsqldb:mem:dbutils_test", "user_hsqldb", "pass_hsqldb" ); - Assert.assertEquals( DbUtils.DB_HSQLDB, this.testWorker( cf ) ); + Assertions.assertEquals( DbUtils.DB_HSQLDB, this.testWorker( cf ) ); } ); } diff --git a/fj-core/src/test/java/test/org/fugerit/java/core/db/helpers/TestMemDBTestBase.java b/fj-core/src/test/java/test/org/fugerit/java/core/db/helpers/TestMemDBTestBase.java index b0f3ff22..bdd142fd 100644 --- a/fj-core/src/test/java/test/org/fugerit/java/core/db/helpers/TestMemDBTestBase.java +++ b/fj-core/src/test/java/test/org/fugerit/java/core/db/helpers/TestMemDBTestBase.java @@ -1,22 +1,21 @@ package test.org.fugerit.java.core.db.helpers; -import static org.junit.Assert.fail; +import static org.junit.jupiter.api.Assertions.fail; import java.sql.ResultSet; import java.sql.Statement; -import org.junit.Test; -import org.junit.runner.notification.RunListener; +import org.junit.jupiter.api.Test; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -public class TestMemDBTestBase extends MemDBTestBase { +class TestMemDBTestBase extends MemDBTestBase { public TestMemDBTestBase() throws Exception { super(); } - protected static final Logger logger = LoggerFactory.getLogger(RunListener.class); + protected static final Logger logger = LoggerFactory.getLogger(MemDBTestBase.class); public void execute( Statement stm, String sql ) throws Exception { logger.info( "Execute : "+sql+" START!" ); @@ -41,7 +40,7 @@ public void execute( Statement stm, String sql ) throws Exception { } @Test - public void simpleTest01() { + void simpleTest01() { try ( Statement stm = this.getConnection().createStatement() ) { execute(stm, "CREATE SCHEMA TEST"); execute(stm, "CREATE TABLE TEST.TEST_01 ( id bigint NOT NULL )"); diff --git a/fj-core/src/test/java/test/org/fugerit/java/core/db/helpers/TestSQLScriptFacade.java b/fj-core/src/test/java/test/org/fugerit/java/core/db/helpers/TestSQLScriptFacade.java index a2eef25b..26b4321b 100644 --- a/fj-core/src/test/java/test/org/fugerit/java/core/db/helpers/TestSQLScriptFacade.java +++ b/fj-core/src/test/java/test/org/fugerit/java/core/db/helpers/TestSQLScriptFacade.java @@ -9,17 +9,17 @@ import org.fugerit.java.core.function.SafeFunction; import org.fugerit.java.core.io.StreamIO; import org.fugerit.java.core.lang.helpers.ClassHelper; -import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; import lombok.extern.slf4j.Slf4j; import test.org.fugerit.java.core.db.TestBasicDBHelper; @Slf4j -public class TestSQLScriptFacade extends TestBasicDBHelper { +class TestSQLScriptFacade extends TestBasicDBHelper { @Test - public void testReadScripts() { + void testReadScripts() { SafeFunction.apply( () -> { try ( InputStream is = ClassHelper.loadFromDefaultClassLoader( "test/memdb/base_db_init.sql" ) ) { String script = StreamIO.readString( is ); @@ -28,7 +28,7 @@ public void testReadScripts() { for ( int k=0; k {}", k, res[k] ); } - Assert.assertNotEquals( 0 , res.length ); + Assertions.assertNotEquals( 0 , res.length ); // test sql script try ( SQLScriptReader reader = new SQLScriptReader( new ByteArrayInputStream( "SELECT * FROM fugerit.user;".getBytes() ) ); Connection conn = newConnection() ) { diff --git a/fj-core/src/test/java/test/org/fugerit/java/core/db/helpers/TestScriptFacade.java b/fj-core/src/test/java/test/org/fugerit/java/core/db/helpers/TestScriptFacade.java index 6e61fc95..4f54a9e2 100644 --- a/fj-core/src/test/java/test/org/fugerit/java/core/db/helpers/TestScriptFacade.java +++ b/fj-core/src/test/java/test/org/fugerit/java/core/db/helpers/TestScriptFacade.java @@ -1,17 +1,17 @@ package test.org.fugerit.java.core.db.helpers; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertTrue; -import org.junit.Test; +import org.junit.jupiter.api.Test; -public class TestScriptFacade extends MemDBTestBase { +class TestScriptFacade extends MemDBTestBase { public TestScriptFacade() throws Exception { super(); } @Test - public void testSelect01() { + void testSelect01() { boolean ok = false; try { this.simpleTestSelectWorker( "SELECT * FROM fugerit.user" ); @@ -23,7 +23,7 @@ public void testSelect01() { } @Test - public void testSelect02() { + void testSelect02() { boolean ok = false; try { this.simpleTestSelectWorker( "SELECT * FROM fugerit.address" ); diff --git a/fj-core/src/test/java/test/org/fugerit/java/core/db/metadata/TestMetadataUtils.java b/fj-core/src/test/java/test/org/fugerit/java/core/db/metadata/TestMetadataUtils.java index 474a8a2d..6fd9282a 100644 --- a/fj-core/src/test/java/test/org/fugerit/java/core/db/metadata/TestMetadataUtils.java +++ b/fj-core/src/test/java/test/org/fugerit/java/core/db/metadata/TestMetadataUtils.java @@ -15,15 +15,15 @@ import org.fugerit.java.core.db.metadata.TableId; import org.fugerit.java.core.db.metadata.TableModel; import org.fugerit.java.core.function.SafeFunction; -import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; import test.org.fugerit.java.core.db.helpers.MemDBTestBase; -public class TestMetadataUtils extends MemDBTestBase { +class TestMetadataUtils extends MemDBTestBase { @Test - public void testDatabaseMetadata() { + void testDatabaseMetadata() { SafeFunction.apply( () -> { boolean ok = false; ConnectionFactory cf = new SingleConnectionFactory( this.getConnection() ); @@ -47,37 +47,37 @@ public void testDatabaseMetadata() { } } ok = true; - Assert.assertTrue( ok ); + Assertions.assertTrue( ok ); } ); } @Test - public void testDatabaseMetadataAlt() { + void testDatabaseMetadataAlt() { SafeFunction.apply( () -> { try ( ConnectionFactoryCloseable cf = ConnectionFactoryImpl.wrap( new SingleConnectionFactory( this.getConnection() ) ) ) { - Assert.assertNotNull( MetaDataUtils.createModel( cf, MetaDataUtils.typesAll() ) ); + Assertions.assertNotNull( MetaDataUtils.createModel( cf, MetaDataUtils.typesAll() ) ); } } ); } @Test - public void testDatabaseMetadataConsts() { - Assert.assertEquals( MetaDataUtils.TYPE_TABLE , MetaDataUtils.typesAll()[0]); - Assert.assertEquals( MetaDataUtils.TYPE_VIEW , MetaDataUtils.typesAll()[1]); - Assert.assertEquals( MetaDataUtils.TYPE_TABLE , MetaDataUtils.typesTable()[0]); - Assert.assertEquals( MetaDataUtils.TYPE_TABLE , MetaDataUtils.typesDefault()[0]); - Assert.assertEquals( MetaDataUtils.TYPE_VIEW , MetaDataUtils.typesView()[0]); + void testDatabaseMetadataConsts() { + Assertions.assertEquals( MetaDataUtils.TYPE_TABLE , MetaDataUtils.typesAll()[0]); + Assertions.assertEquals( MetaDataUtils.TYPE_VIEW , MetaDataUtils.typesAll()[1]); + Assertions.assertEquals( MetaDataUtils.TYPE_TABLE , MetaDataUtils.typesTable()[0]); + Assertions.assertEquals( MetaDataUtils.TYPE_TABLE , MetaDataUtils.typesDefault()[0]); + Assertions.assertEquals( MetaDataUtils.TYPE_VIEW , MetaDataUtils.typesView()[0]); } @Test - public void testDatabaseMetadataAdatpor() { + void testDatabaseMetadataAdatpor() { SafeFunction.apply( () -> { try ( ConnectionFactoryCloseable cf = ConnectionFactoryImpl.wrap( new SingleConnectionFactory( this.getConnection() ) ) ) { JdbcAdaptor mysqlAdaptor = MetaDataUtils.getDefaultAdaptorFor( "mysql" , cf ); logger.info( "mysqlAdaptor {}", mysqlAdaptor ); JdbcAdaptor oracleAdaptor = MetaDataUtils.getDefaultAdaptorFor( "oracle" , cf ); - Assert.assertNotNull( oracleAdaptor ); + Assertions.assertNotNull( oracleAdaptor ); // setup data DAOUtilsNG.execute( cf.getConnection() , OpDAO.newExecuteOp( "CREATE TABLE all_col_comments ( owner VARCHAR(32), " + @@ -86,15 +86,15 @@ public void testDatabaseMetadataAdatpor() { // test found TableId tableId = new TableId( "user", "fugerit", null ); String comment1 = oracleAdaptor.getColumnComment( tableId, "id" ); - Assert.assertEquals( "user id" , comment1 ); + Assertions.assertEquals( "user id" , comment1 ); String comment2 = oracleAdaptor.getColumnComment( tableId, "not exists" ); - Assert.assertEquals( "" , comment2 ); - Assert.assertNotNull( mysqlAdaptor ); + Assertions.assertEquals( "" , comment2 ); + Assertions.assertNotNull( mysqlAdaptor ); JdbcAdaptor adaptor = MetaDataUtils.getDefaultAdaptorFor( "postgres" , cf ); logger.info( "jdbcAdatpror default {}", adaptor ); - Assert.assertNotNull( adaptor ); - Assert.assertEquals( "", adaptor.getColumnComment( null , null ) ); - Assert.assertEquals( "", adaptor.getTableComment( null ) ); + Assertions.assertNotNull( adaptor ); + Assertions.assertEquals( "", adaptor.getColumnComment( null , null ) ); + Assertions.assertEquals( "", adaptor.getTableComment( null ) ); } } ); diff --git a/fj-core/src/test/java/test/org/fugerit/java/core/fixed/parser/TestFixedFieldFileConfig.java b/fj-core/src/test/java/test/org/fugerit/java/core/fixed/parser/TestFixedFieldFileConfig.java index f0df2475..c8940583 100644 --- a/fj-core/src/test/java/test/org/fugerit/java/core/fixed/parser/TestFixedFieldFileConfig.java +++ b/fj-core/src/test/java/test/org/fugerit/java/core/fixed/parser/TestFixedFieldFileConfig.java @@ -9,18 +9,18 @@ import org.fugerit.java.core.fixed.parser.helper.ReaderFixedFieldFileReader; import org.fugerit.java.core.fixed.parser.helper.StreamFixedFieldFileReader; import org.fugerit.java.core.lang.helpers.ClassHelper; -import org.junit.Assert; -import org.junit.BeforeClass; -import org.junit.Test; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; import test.org.fugerit.java.BasicTest; -public class TestFixedFieldFileConfig extends BasicTest { +class TestFixedFieldFileConfig extends BasicTest { private static FixedFieldFileConfig config = null; - @BeforeClass - public static void readConfig() { + @BeforeAll + static void readConfig() { boolean ok = false; try ( InputStream is = ClassHelper.loadFromDefaultClassLoader( "core/fixed/fixed-file-config.xml" ) ) { config = FixedFieldFileConfig.parseConfig( is ); @@ -32,11 +32,11 @@ public static void readConfig() { } catch (Exception e) { throw new ConfigRuntimeException( e ); } - Assert.assertTrue( ok ); + Assertions.assertTrue( ok ); } @Test - public void checkDescriptor() { + void checkDescriptor() { boolean ok = false; try { FixedFieldFileDescriptor descriptor = config.getFileDescriptor( "testFixedValidator" ); @@ -59,7 +59,7 @@ public void checkDescriptor() { } catch (Exception e) { this.failEx(e); } - Assert.assertTrue( ok ); + Assertions.assertTrue( ok ); } } diff --git a/fj-core/src/test/java/test/org/fugerit/java/core/fixed/parser/ValidatorTester.java b/fj-core/src/test/java/test/org/fugerit/java/core/fixed/parser/ValidatorTester.java index 37bfd64b..f3cfccf1 100644 --- a/fj-core/src/test/java/test/org/fugerit/java/core/fixed/parser/ValidatorTester.java +++ b/fj-core/src/test/java/test/org/fugerit/java/core/fixed/parser/ValidatorTester.java @@ -1,19 +1,11 @@ package test.org.fugerit.java.core.fixed.parser; -import java.io.File; -import java.io.FileInputStream; -import java.util.Iterator; -import java.util.Properties; - -import org.fugerit.java.core.cli.ArgUtils; -import org.fugerit.java.core.fixed.parser.FixedFieldFileConfig; -import org.fugerit.java.core.fixed.parser.FixedFieldFileDescriptor; -import org.fugerit.java.core.fixed.parser.FixedFieldFileReader; -import org.fugerit.java.core.fixed.parser.FixedFileFieldMap; import org.fugerit.java.core.fixed.parser.FixedFileFieldValidationResult; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import java.util.Iterator; + public class ValidatorTester { private static final Logger logger = LoggerFactory.getLogger(ValidatorTester.class); @@ -24,28 +16,4 @@ public static void printErrorsToLog( Iterator er } } - public static void main( String[] args ) { - try { - Properties params = ArgUtils.getArgs( args ); - File input = new File( params.getProperty( "input" ) ); - File definition = new File( params.getProperty( "definition" ) ); - FileInputStream configIS = new FileInputStream( definition ); - FixedFieldFileConfig config = FixedFieldFileConfig.parseConfig( configIS ); - configIS.close(); - FixedFieldFileDescriptor descriptor = config.getFileDescriptor( "tracciato_test" ); - FileInputStream fis = new FileInputStream( input ); - FixedFieldFileReader reader = FixedFieldFileReader.newInstance( descriptor, fis ); - while ( reader.hasNext() ) { - FixedFileFieldMap map = reader.nextRawMap(); - if ( !map.getValidationErrors().isEmpty() ) { - printErrorsToLog( map.getValidationErrors().iterator() ); - } - } - printErrorsToLog( reader.getGenericValidationErrors().iterator() ); - logger.info( "ERROR COUNT : "+reader.getErrorCount() ); - } catch (Exception e) { - e.printStackTrace(); - } - } - } diff --git a/fj-core/src/test/java/test/org/fugerit/java/core/function/TestPOCSafeFunction.java b/fj-core/src/test/java/test/org/fugerit/java/core/function/TestPOCSafeFunction.java index 8d08f9eb..4c72e0c5 100644 --- a/fj-core/src/test/java/test/org/fugerit/java/core/function/TestPOCSafeFunction.java +++ b/fj-core/src/test/java/test/org/fugerit/java/core/function/TestPOCSafeFunction.java @@ -4,8 +4,8 @@ import org.fugerit.java.core.cfg.ConfigRuntimeException; import org.fugerit.java.core.function.SafeFunction; import org.fugerit.java.core.function.UnsafeVoid; -import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; import java.io.IOException; import java.util.function.Consumer; @@ -65,7 +65,7 @@ * */ @Slf4j -public class TestPOCSafeFunction { +class TestPOCSafeFunction { /* * simple function to use as the body of this class's scenarios @@ -114,11 +114,11 @@ public void applySafeFunction() { * And a org.fugerit.java.core.cfg.ConfigRuntimeException is checked to be thrown. */ @Test - public void testSafeFunctionApply() { + void testSafeFunctionApply() { // classical try catch - Assert.assertThrows( ConfigRuntimeException.class, this::applyTryCatch ); + Assertions.assertThrows( ConfigRuntimeException.class, this::applyTryCatch ); // safe function - Assert.assertThrows( ConfigRuntimeException.class, this::applySafeFunction ); + Assertions.assertThrows( ConfigRuntimeException.class, this::applySafeFunction ); } public boolean getTryCatch() { @@ -142,11 +142,11 @@ public boolean getSafeFunction() { * And a org.fugerit.java.core.cfg.ConfigRuntimeException is checked to be thrown. */ @Test - public void testSafeFunctionGet() { + void testSafeFunctionGet() { // classical try catch - Assert.assertThrows( ConfigRuntimeException.class, this::getTryCatch ); + Assertions.assertThrows( ConfigRuntimeException.class, this::getTryCatch ); // safe function - Assert.assertThrows( ConfigRuntimeException.class, this::getSafeFunction ); + Assertions.assertThrows( ConfigRuntimeException.class, this::getSafeFunction ); } /* @@ -156,7 +156,7 @@ public void testSafeFunctionGet() { * And the thrown IO Exception is just logged with no further handling */ @Test - public void testSafeFunctionApplySilent() { + void testSafeFunctionApplySilent() { // classical try catch try { SCENARIO.apply(); @@ -174,7 +174,7 @@ public void testSafeFunctionApplySilent() { * And a custom exception handling is applied. */ @Test - public void testSafeFunctionApplyCustomHandling() { + void testSafeFunctionApplyCustomHandling() { // classical try catch try { SCENARIO.apply(); diff --git a/fj-core/src/test/java/test/org/fugerit/java/core/function/TestSafeFunction.java b/fj-core/src/test/java/test/org/fugerit/java/core/function/TestSafeFunction.java index f39090ad..73c793ee 100644 --- a/fj-core/src/test/java/test/org/fugerit/java/core/function/TestSafeFunction.java +++ b/fj-core/src/test/java/test/org/fugerit/java/core/function/TestSafeFunction.java @@ -1,6 +1,6 @@ package test.org.fugerit.java.core.function; -import static org.junit.Assert.assertThrows; +import static org.junit.jupiter.api.Assertions.assertThrows; import java.io.BufferedReader; import java.io.IOException; @@ -13,28 +13,28 @@ import org.fugerit.java.core.function.SafeFunction; import org.fugerit.java.core.lang.helpers.BooleanUtils; import org.fugerit.java.core.xml.XMLException; -import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; import lombok.extern.slf4j.Slf4j; import test.org.fugerit.java.helpers.FailHelper; @Slf4j -public class TestSafeFunction { +class TestSafeFunction { private static final DAOException TEST_CHECKED_EX = new DAOException( "test checked" ); private static final DAORuntimeException TEST_RUNTIME_EX = new DAORuntimeException( "test runtime" ); @Test - public void testGetUsingDefault() { - Assert.assertEquals( "2", SafeFunction.getUsingDefault( () -> null, () -> "2" ) ); - Assert.assertEquals( "0", SafeFunction.getUsingDefault( () -> "0", () -> "1" ) ); + void testGetUsingDefault() { + Assertions.assertEquals( "2", SafeFunction.getUsingDefault( () -> null, () -> "2" ) ); + Assertions.assertEquals( "0", SafeFunction.getUsingDefault( () -> "0", () -> "1" ) ); } @Test - public void testFailGet() { - Assert.assertThrows(ConfigRuntimeException.class, () -> { + void testFailGet() { + Assertions.assertThrows(ConfigRuntimeException.class, () -> { SafeFunction.get( () -> { if ( FailHelper.DO_FAIL ) { throw new IOException( "test" ); @@ -46,8 +46,8 @@ public void testFailGet() { } @Test - public void testFailGetGen() { - Assert.assertThrows(XMLException.class, () -> { + void testFailGetGen() { + Assertions.assertThrows(XMLException.class, () -> { SafeFunction.getEx( () -> { if ( FailHelper.DO_FAIL ) { throw new IOException( "test" ); @@ -59,77 +59,77 @@ public void testFailGetGen() { } @Test - public void testFailApplyGen() { - Assert.assertThrows(ConfigRuntimeException.class, () -> { + void testFailApplyGen() { + Assertions.assertThrows(ConfigRuntimeException.class, () -> { SafeFunction.apply( () -> { throw new IOException( "ex" ); } ); }); } @Test - public void testApplyLogGen() { + void testApplyLogGen() { boolean ok = false; SafeFunction.apply( () -> { throw new IOException( "ex1" ); }, e -> log.warn( "Error on exception {}", e, e.getMessage() ) ); ok = true; - Assert.assertTrue(ok); + Assertions.assertTrue(ok); } @Test - public void testGetLogGen() { + void testGetLogGen() { String res = SafeFunction.get( () -> { throw new IOException( "ex2" ); }, e -> log.warn( "Error on exception {}", e, e.getMessage() ) ); - Assert.assertNull( res ); + Assertions.assertNull( res ); } @Test - public void testApplyWithMessage() { - Assert.assertThrows( ConfigRuntimeException.class , () -> SafeFunction.applyWithMessage( () -> { throw new IOException( "exApplyWithMessage" ); }, "error test" ) ); + void testApplyWithMessage() { + Assertions.assertThrows( ConfigRuntimeException.class , () -> SafeFunction.applyWithMessage( () -> { throw new IOException( "exApplyWithMessage" ); }, "error test" ) ); } @Test - public void testGetWithMessage() { - Assert.assertThrows( ConfigRuntimeException.class , () -> SafeFunction.getWithMessage( () -> { throw new IOException( "exGetWithMessage" ); }, "error test" ) ); + void testGetWithMessage() { + Assertions.assertThrows( ConfigRuntimeException.class , () -> SafeFunction.getWithMessage( () -> { throw new IOException( "exGetWithMessage" ); }, "error test" ) ); } @Test - public void testApplyWithMessageOk() { + void testApplyWithMessageOk() { boolean ok = true; SafeFunction.applyWithMessage( () -> log.info( "ok" ), "no error apply" ); - Assert.assertTrue( ok ); + Assertions.assertTrue( ok ); } @Test - public void testGetWithMessageOk() { - Assert.assertEquals( BooleanUtils.BOOLEAN_1 , SafeFunction.getWithMessage( () -> BooleanUtils.BOOLEAN_1, "no error get" ) ); + void testGetWithMessageOk() { + Assertions.assertEquals( BooleanUtils.BOOLEAN_1 , SafeFunction.getWithMessage( () -> BooleanUtils.BOOLEAN_1, "no error get" ) ); } @Test - public void testGetSilent() { + void testGetSilent() { String res = SafeFunction.getSilent( () -> { throw new IOException( "exGetSilent" ); } ); - Assert.assertNull( res ); + Assertions.assertNull( res ); } @Test - public void testGetWithDefaultLogGen() { + void testGetWithDefaultLogGen() { String res = SafeFunction.getWithDefault( () -> { throw new IOException( "ex3" ); }, e -> { log.warn( "Error on exception {}", e, e.getMessage() ); return "default-string"; } ); - Assert.assertEquals( "default-string", res ); + Assertions.assertEquals( "default-string", res ); } @Test - public void testApplyOnCondition() { + void testApplyOnCondition() { boolean ok = SafeFunction.applyOnCondition( () -> false , () -> log.info( "do nothing" ) ); - Assert.assertFalse( ok ); + Assertions.assertFalse( ok ); ok = SafeFunction.applyIfNotNull( null , () -> log.info( "do nothing" ) ); - Assert.assertFalse( ok ); + Assertions.assertFalse( ok ); } @Test - public void testGetOnCondition() { + void testGetOnCondition() { String res = SafeFunction.getOnCondition( () -> Boolean.FALSE , () -> "a" ); - Assert.assertNull( res ); + Assertions.assertNull( res ); res = SafeFunction.getIfNotNull( null , () -> "b" ); - Assert.assertNull( res ); + Assertions.assertNull( res ); } private boolean testExHandlerWorker( Consumer exHandler, boolean ex ) { @@ -142,25 +142,25 @@ private boolean testExHandlerWorker( Consumer exHandler, boolean ex ) } @Test - public void testExHandler() { - Assert.assertTrue( this.testExHandlerWorker( SafeFunction.EX_CONSUMER_LOG_WARN, false ) ); - Assert.assertTrue( this.testExHandlerWorker( SafeFunction.EX_CONSUMER_TRACE_WARN, false ) ); - Assert.assertTrue( this.testExHandlerWorker( SafeFunction.EX_CONSUMER_THROW_CONFIG_RUNTIME, true ) ); + void testExHandler() { + Assertions.assertTrue( this.testExHandlerWorker( SafeFunction.EX_CONSUMER_LOG_WARN, false ) ); + Assertions.assertTrue( this.testExHandlerWorker( SafeFunction.EX_CONSUMER_TRACE_WARN, false ) ); + Assertions.assertTrue( this.testExHandlerWorker( SafeFunction.EX_CONSUMER_THROW_CONFIG_RUNTIME, true ) ); } @Test - public void testExHandlerThrowConfigRuntime() { - Assert.assertThrows( ConfigRuntimeException.class , + void testExHandlerThrowConfigRuntime() { + Assertions.assertThrows( ConfigRuntimeException.class , () -> SafeFunction.EX_CONSUMER_THROW_CONFIG_RUNTIME.accept( TEST_RUNTIME_EX ) ); - Assert.assertThrows( ConfigRuntimeException.class , + Assertions.assertThrows( ConfigRuntimeException.class , () -> SafeFunction.EX_CONSUMER_THROW_CONFIG_RUNTIME.accept( TEST_CHECKED_EX ) ); } @Test - public void testExHandlerThrowConfigRuntimeRethrowRTE() { - Assert.assertThrows( TEST_RUNTIME_EX.getClass() , + void testExHandlerThrowConfigRuntimeRethrowRTE() { + Assertions.assertThrows( TEST_RUNTIME_EX.getClass() , () -> SafeFunction.EX_CONSUMER_RETHROW_RTE_OR_CONVERT_CHECKED_TO_CRE.accept( TEST_RUNTIME_EX ) ); - Assert.assertThrows( ConfigRuntimeException.class , + Assertions.assertThrows( ConfigRuntimeException.class , () -> SafeFunction.EX_CONSUMER_RETHROW_RTE_OR_CONVERT_CHECKED_TO_CRE.accept( TEST_CHECKED_EX ) ); } @@ -185,10 +185,10 @@ public String testExampleToOneLineSafeFunction() { } @Test - public void testExample() { + void testExample() { String resClassic = this.testExampleToOneLineClassic(); String resSafeFunction = this.testExampleToOneLineSafeFunction(); - Assert.assertEquals( resClassic, resSafeFunction ); + Assertions.assertEquals( resClassic, resSafeFunction ); } diff --git a/fj-core/src/test/java/test/org/fugerit/java/core/function/TestSafeFunctionCoverageExample.java b/fj-core/src/test/java/test/org/fugerit/java/core/function/TestSafeFunctionCoverageExample.java index 6ded1cec..37d29427 100644 --- a/fj-core/src/test/java/test/org/fugerit/java/core/function/TestSafeFunctionCoverageExample.java +++ b/fj-core/src/test/java/test/org/fugerit/java/core/function/TestSafeFunctionCoverageExample.java @@ -1,10 +1,10 @@ package test.org.fugerit.java.core.function; import org.fugerit.java.core.cfg.ConfigRuntimeException; -import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; -public class TestSafeFunctionCoverageExample { +class TestSafeFunctionCoverageExample { private static final SafeFunctionCoverageExampleInput INPUT = SafeFunctionCoverageExampleInput.newInput( "test" ); @@ -20,17 +20,17 @@ private boolean testWorker( SafeFunctionCoverageExample exampleImpl ) { } @Test - public void testClassic() { + void testClassic() { SafeFunctionCoverageExample exampleImpl = new SafeFunctionCoverageExampleClassicImpl(); - Assert.assertTrue( this.testWorker(exampleImpl) ); - Assert.assertThrows( ConfigRuntimeException.class , () -> exampleImpl.error(INPUT_ERROR) ); + Assertions.assertTrue( this.testWorker(exampleImpl) ); + Assertions.assertThrows( ConfigRuntimeException.class , () -> exampleImpl.error(INPUT_ERROR) ); } @Test - public void testSafe() { + void testSafe() { SafeFunctionCoverageExample exampleImpl = new SafeFunctionCoverageExampleSafeImpl(); - Assert.assertTrue( this.testWorker(exampleImpl) ); - Assert.assertThrows( ConfigRuntimeException.class , () -> exampleImpl.error(INPUT_ERROR) ); + Assertions.assertTrue( this.testWorker(exampleImpl) ); + Assertions.assertThrows( ConfigRuntimeException.class , () -> exampleImpl.error(INPUT_ERROR) ); } } diff --git a/fj-core/src/test/java/test/org/fugerit/java/core/io/TestCustomPrintWriter.java b/fj-core/src/test/java/test/org/fugerit/java/core/io/TestCustomPrintWriter.java index d798f21e..5ed7e1cf 100644 --- a/fj-core/src/test/java/test/org/fugerit/java/core/io/TestCustomPrintWriter.java +++ b/fj-core/src/test/java/test/org/fugerit/java/core/io/TestCustomPrintWriter.java @@ -5,10 +5,10 @@ import org.fugerit.java.core.function.SafeFunction; import org.fugerit.java.core.io.helper.CustomPrintWriter; -import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; -public class TestCustomPrintWriter { +class TestCustomPrintWriter { private boolean worker( CustomPrintWriter writer ) { boolean ok = false; @@ -18,46 +18,46 @@ private boolean worker( CustomPrintWriter writer ) { } @Test - public void test() { + void test() { SafeFunction.apply( () -> { try ( CustomPrintWriter writer = new CustomPrintWriter( new ByteArrayOutputStream() ) ) { boolean ok = this.worker(writer); - Assert.assertTrue(ok); + Assertions.assertTrue(ok); } try ( CustomPrintWriter writer = new CustomPrintWriter( new ByteArrayOutputStream(), "\n" ) ) { boolean ok = this.worker(writer); - Assert.assertTrue(ok); + Assertions.assertTrue(ok); } try ( CustomPrintWriter writer = new CustomPrintWriter( new ByteArrayOutputStream(), false, "\n" ) ) { boolean ok = this.worker(writer); - Assert.assertTrue(ok); + Assertions.assertTrue(ok); } try ( CustomPrintWriter writer = new CustomPrintWriter( new ByteArrayOutputStream(), true ) ) { boolean ok = this.worker(writer); - Assert.assertTrue(ok); + Assertions.assertTrue(ok); } try ( CustomPrintWriter writer = new CustomPrintWriter( new StringWriter() ) ) { boolean ok = this.worker(writer); - Assert.assertTrue(ok); + Assertions.assertTrue(ok); } try ( CustomPrintWriter writer = new CustomPrintWriter( new StringWriter(), "\n" ) ) { boolean ok = this.worker(writer); - Assert.assertTrue(ok); + Assertions.assertTrue(ok); } try ( CustomPrintWriter writer = new CustomPrintWriter( new StringWriter(), false, "\n" ) ) { boolean ok = this.worker(writer); - Assert.assertTrue(ok); + Assertions.assertTrue(ok); } try ( CustomPrintWriter writer = new CustomPrintWriter( new StringWriter(), true ) ) { boolean ok = this.worker(writer); - Assert.assertTrue(ok); + Assertions.assertTrue(ok); } // last test CustomPrintWriter writer = new CustomPrintWriter( new StringWriter(), true, "\n" ); boolean ok = this.worker(writer); writer.setLineSeparator( "\n" ); - Assert.assertEquals( "\n", writer.getLineSeparator() ); - Assert.assertTrue(ok); + Assertions.assertEquals( "\n", writer.getLineSeparator() ); + Assertions.assertTrue(ok); writer.close(); writer.println( "stop" ); } ); diff --git a/fj-core/src/test/java/test/org/fugerit/java/core/io/TestFileIO.java b/fj-core/src/test/java/test/org/fugerit/java/core/io/TestFileIO.java index e0eb8b86..69e92810 100644 --- a/fj-core/src/test/java/test/org/fugerit/java/core/io/TestFileIO.java +++ b/fj-core/src/test/java/test/org/fugerit/java/core/io/TestFileIO.java @@ -1,41 +1,41 @@ package test.org.fugerit.java.core.io; import org.fugerit.java.core.io.FileIO; -import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; import java.io.File; import java.io.IOException; -public class TestFileIO { +class TestFileIO { @Test - public void testIsInTmpFolderOk() throws IOException { - Assert.assertTrue(FileIO.isInTmpFolder( new File( System.getProperty( "java.io.tmpdir" ) ) )); + void testIsInTmpFolderOk() throws IOException { + Assertions.assertTrue(FileIO.isInTmpFolder( new File( System.getProperty( "java.io.tmpdir" ) ) )); } @Test - public void testIsInTmpFolderKo() throws IOException { - Assert.assertFalse(FileIO.isInTmpFolder( new File( "/" ) )); + void testIsInTmpFolderKo() throws IOException { + Assertions.assertFalse(FileIO.isInTmpFolder( new File( "/" ) )); } @Test - public void testNewFile() throws IOException { + void testNewFile() throws IOException { String baseDir = "target/"; String fileName = "not-exists.txt"; String fileNameExists = "classes"; File file = FileIO.newFile( baseDir, fileName ); - Assert.assertTrue( file.getPath().endsWith( fileName ) ); - Assert.assertTrue( FileIO.newFile( null, fileName ).getPath().endsWith( fileName ) ); - Assert.assertThrows( IOException.class, () -> FileIO.newFile( baseDir, fileName, Boolean.TRUE ) ); - Assert.assertTrue( FileIO.newFile( baseDir, fileName, Boolean.FALSE ).getPath().endsWith( fileName ) ); - Assert.assertTrue( FileIO.newFile( baseDir, fileNameExists, Boolean.TRUE ).getPath().endsWith( fileNameExists ) ); + Assertions.assertTrue( file.getPath().endsWith( fileName ) ); + Assertions.assertTrue( FileIO.newFile( null, fileName ).getPath().endsWith( fileName ) ); + Assertions.assertThrows( IOException.class, () -> FileIO.newFile( baseDir, fileName, Boolean.TRUE ) ); + Assertions.assertTrue( FileIO.newFile( baseDir, fileName, Boolean.FALSE ).getPath().endsWith( fileName ) ); + Assertions.assertTrue( FileIO.newFile( baseDir, fileNameExists, Boolean.TRUE ).getPath().endsWith( fileNameExists ) ); } @Test - public void testCreateFullFile() throws IOException { + void testCreateFullFile() throws IOException { String baseDir0 = "target/"; String baseDir1 = "target/path/"; String fileName = "not-exists-alt.txt"; @@ -47,11 +47,11 @@ public void testCreateFullFile() throws IOException { file1.delete(); file1.getParentFile().delete(); file2.delete(); - Assert.assertTrue( FileIO.createFullFile( file0 ) ); - Assert.assertTrue( FileIO.createFullFile( file1 ) ); - Assert.assertFalse( FileIO.createFullFile( file0 ) ); - Assert.assertFalse( FileIO.createFullFile( file2 ) ); - Assert.assertFalse( FileIO.createFullFile( new File( baseDir1 ) ) ); + Assertions.assertTrue( FileIO.createFullFile( file0 ) ); + Assertions.assertTrue( FileIO.createFullFile( file1 ) ); + Assertions.assertFalse( FileIO.createFullFile( file0 ) ); + Assertions.assertFalse( FileIO.createFullFile( file2 ) ); + Assertions.assertFalse( FileIO.createFullFile( new File( baseDir1 ) ) ); } } diff --git a/fj-core/src/test/java/test/org/fugerit/java/core/io/TestObjectIO.java b/fj-core/src/test/java/test/org/fugerit/java/core/io/TestObjectIO.java index 3e64a783..b5ef85d0 100644 --- a/fj-core/src/test/java/test/org/fugerit/java/core/io/TestObjectIO.java +++ b/fj-core/src/test/java/test/org/fugerit/java/core/io/TestObjectIO.java @@ -2,24 +2,24 @@ import org.fugerit.java.core.function.SimpleValue; import org.fugerit.java.core.io.ObjectIO; -import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; import java.io.IOException; -public class TestObjectIO { +class TestObjectIO { @Test - public void testStringOk() throws IOException { + void testStringOk() throws IOException { String test1 = "a"; String test2 = (String)ObjectIO.fullSerializationTest( test1 ); - Assert.assertEquals( "a", test2 ); + Assertions.assertEquals( "a", test2 ); } @Test - public void testKo() throws IOException { + void testKo() throws IOException { SimpleValue val = new SimpleValue( "b" ); - Assert.assertThrows( IOException.class, () -> ObjectIO.fullSerializationTest( val ) ); + Assertions.assertThrows( IOException.class, () -> ObjectIO.fullSerializationTest( val ) ); } } diff --git a/fj-core/src/test/java/test/org/fugerit/java/core/io/TestSafeIO.java b/fj-core/src/test/java/test/org/fugerit/java/core/io/TestSafeIO.java index 1db7f17d..359f21bf 100644 --- a/fj-core/src/test/java/test/org/fugerit/java/core/io/TestSafeIO.java +++ b/fj-core/src/test/java/test/org/fugerit/java/core/io/TestSafeIO.java @@ -3,35 +3,35 @@ import org.fugerit.java.core.cfg.ConfigRuntimeException; import org.fugerit.java.core.io.SafeIO; import org.fugerit.java.core.lang.helpers.ClassHelper; -import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; import test.org.fugerit.java.helpers.io.InputStreamFail; -public class TestSafeIO { +class TestSafeIO { private static final String PATH_OK = "core/xml/dtd/doc-1-0.dtd"; @Test - public void testStringOk() { + void testStringOk() { String res = SafeIO.readStringStream( () -> ClassHelper.loadFromDefaultClassLoader(PATH_OK) ); - Assert.assertNotNull( res ); + Assertions.assertNotNull( res ); } @Test - public void testBytesOk() { + void testBytesOk() { byte[] res = SafeIO.readBytes( () -> ClassHelper.loadFromDefaultClassLoader(PATH_OK) ); - Assert.assertNotNull( res ); + Assertions.assertNotNull( res ); } @Test - public void testStringKo() { - Assert.assertThrows( ConfigRuntimeException.class , () -> SafeIO.readStringStream( () -> new InputStreamFail() ) ); + void testStringKo() { + Assertions.assertThrows( ConfigRuntimeException.class , () -> SafeIO.readStringStream( () -> new InputStreamFail() ) ); } @Test - public void testBytesKo() { - Assert.assertThrows( ConfigRuntimeException.class , () -> SafeIO.readBytes( () -> new InputStreamFail() ) ); + void testBytesKo() { + Assertions.assertThrows( ConfigRuntimeException.class , () -> SafeIO.readBytes( () -> new InputStreamFail() ) ); } } diff --git a/fj-core/src/test/java/test/org/fugerit/java/core/io/TestStreamHelper.java b/fj-core/src/test/java/test/org/fugerit/java/core/io/TestStreamHelper.java index 0734f9c7..9ee2ebf9 100644 --- a/fj-core/src/test/java/test/org/fugerit/java/core/io/TestStreamHelper.java +++ b/fj-core/src/test/java/test/org/fugerit/java/core/io/TestStreamHelper.java @@ -14,33 +14,33 @@ import org.fugerit.java.core.function.SimpleValue; import org.fugerit.java.core.io.StreamIO; import org.fugerit.java.core.io.helper.StreamHelper; -import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; -public class TestStreamHelper { +class TestStreamHelper { @Test - public void testStreamHelper() { + void testStreamHelper() { SafeFunction.apply( () -> { - Assert.assertNotNull( new SimpleValue() ); - Assert.assertFalse( StreamHelper.closeSafe( (InputStream) null ) ); - Assert.assertFalse( StreamHelper.closeSafe( (Reader) null ) ); - Assert.assertTrue( StreamHelper.closeSafe( new ByteArrayInputStream( "a".getBytes() ) ) ); - Assert.assertTrue( StreamHelper.closeSafe( new StringReader( "b" ) ) ); - Assert.assertFalse( StreamHelper.closeSafe( (OutputStream) null ) ); - Assert.assertFalse( StreamHelper.closeSafe( (Writer) null ) ); - Assert.assertTrue( StreamHelper.closeSafe( new ByteArrayOutputStream() ) ); - Assert.assertTrue( StreamHelper.closeSafe( new ByteArrayOutputStream(), true ) ); - Assert.assertTrue( StreamHelper.closeSafe( new ByteArrayOutputStream(), false ) ); - Assert.assertTrue( StreamHelper.closeSafe( new StringWriter() ) ); - Assert.assertTrue( StreamHelper.closeSafe( new StringWriter(), true ) ); - Assert.assertTrue( StreamHelper.closeSafe( new StringWriter(), false ) ); - Assert.assertEquals( 1L , StreamHelper.pipe( new ByteArrayInputStream( "c".getBytes() ) , new ByteArrayOutputStream() ) ); - Assert.assertEquals( 1L , StreamHelper.pipe( new StringReader( "d" ) , new StringWriter() ) ); - Assert.assertEquals( 1L , StreamHelper.pipe( new ByteArrayInputStream( "c".getBytes() ) , new ByteArrayOutputStream() ), StreamIO.MODE_CLOSE_NONE ); - Assert.assertEquals( 1L , StreamHelper.pipe( new StringReader( "d" ) , new StringWriter(), 512, StreamIO.MODE_CLOSE_NONE ) ); + Assertions.assertNotNull( new SimpleValue() ); + Assertions.assertFalse( StreamHelper.closeSafe( (InputStream) null ) ); + Assertions.assertFalse( StreamHelper.closeSafe( (Reader) null ) ); + Assertions.assertTrue( StreamHelper.closeSafe( new ByteArrayInputStream( "a".getBytes() ) ) ); + Assertions.assertTrue( StreamHelper.closeSafe( new StringReader( "b" ) ) ); + Assertions.assertFalse( StreamHelper.closeSafe( (OutputStream) null ) ); + Assertions.assertFalse( StreamHelper.closeSafe( (Writer) null ) ); + Assertions.assertTrue( StreamHelper.closeSafe( new ByteArrayOutputStream() ) ); + Assertions.assertTrue( StreamHelper.closeSafe( new ByteArrayOutputStream(), true ) ); + Assertions.assertTrue( StreamHelper.closeSafe( new ByteArrayOutputStream(), false ) ); + Assertions.assertTrue( StreamHelper.closeSafe( new StringWriter() ) ); + Assertions.assertTrue( StreamHelper.closeSafe( new StringWriter(), true ) ); + Assertions.assertTrue( StreamHelper.closeSafe( new StringWriter(), false ) ); + Assertions.assertEquals( 1L , StreamHelper.pipe( new ByteArrayInputStream( "c".getBytes() ) , new ByteArrayOutputStream() ) ); + Assertions.assertEquals( 1L , StreamHelper.pipe( new StringReader( "d" ) , new StringWriter() ) ); + Assertions.assertEquals( 1L , StreamHelper.pipe( new ByteArrayInputStream( "c".getBytes() ) , new ByteArrayOutputStream() ), StreamIO.MODE_CLOSE_NONE ); + Assertions.assertEquals( 1L , StreamHelper.pipe( new StringReader( "d" ) , new StringWriter(), 512, StreamIO.MODE_CLOSE_NONE ) ); File file = new File("src/test/resources/core/test_test.txt"); - Assert.assertNotNull( StreamHelper.resolveStream( StreamHelper.PATH_FILE+file.getCanonicalPath(), null , null ) ); + Assertions.assertNotNull( StreamHelper.resolveStream( StreamHelper.PATH_FILE+file.getCanonicalPath(), null , null ) ); } ); } diff --git a/fj-core/src/test/java/test/org/fugerit/java/core/io/TestStreamIO.java b/fj-core/src/test/java/test/org/fugerit/java/core/io/TestStreamIO.java index e516a4c4..694fa339 100644 --- a/fj-core/src/test/java/test/org/fugerit/java/core/io/TestStreamIO.java +++ b/fj-core/src/test/java/test/org/fugerit/java/core/io/TestStreamIO.java @@ -1,20 +1,20 @@ package test.org.fugerit.java.core.io; -import static org.junit.Assert.fail; +import static org.junit.jupiter.api.Assertions.fail; import java.io.ByteArrayOutputStream; import java.io.InputStream; import org.fugerit.java.core.io.StreamIO; import org.fugerit.java.core.lang.helpers.ClassHelper; -import org.junit.Test; +import org.junit.jupiter.api.Test; import test.org.fugerit.java.BasicTest; -public class TestStreamIO extends BasicTest { +class TestStreamIO extends BasicTest { @Test - public void testStreamIO() { + void testStreamIO() { try { String path = "core/util/filterchain/minifilter-test-config.xml"; InputStream is = ClassHelper.loadFromDefaultClassLoader( path ); diff --git a/fj-core/src/test/java/test/org/fugerit/java/core/io/charset/TestEncodingCheck.java b/fj-core/src/test/java/test/org/fugerit/java/core/io/charset/TestEncodingCheck.java index d1def9a4..601a05cd 100644 --- a/fj-core/src/test/java/test/org/fugerit/java/core/io/charset/TestEncodingCheck.java +++ b/fj-core/src/test/java/test/org/fugerit/java/core/io/charset/TestEncodingCheck.java @@ -9,33 +9,33 @@ import org.fugerit.java.core.charset.EncodingCheck; import org.fugerit.java.core.io.StreamIO; import org.fugerit.java.core.lang.helpers.ClassHelper; -import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; -public class TestEncodingCheck { +class TestEncodingCheck { @Test - public void testEnc() throws IOException { + void testEnc() throws IOException { try ( InputStream is = ClassHelper.loadFromDefaultClassLoader( "core/xml/dtd/test-content-handler.xml" ) ) { boolean ok = EncodingCheck.checkEncoding( is , StandardCharsets.UTF_8.name() ); - Assert.assertTrue(ok); + Assertions.assertTrue(ok); } } @Test - public void testEncBytes() throws IOException { + void testEncBytes() throws IOException { try ( InputStream is = ClassHelper.loadFromDefaultClassLoader( "core/xml/dtd/test-content-handler.xml" ) ) { boolean ok = EncodingCheck.checkEncoding( StreamIO.readBytes(is) , StandardCharsets.UTF_8.name() ); - Assert.assertTrue(ok); + Assertions.assertTrue(ok); } } @Test - public void testEncByteWrong() throws IOException { + void testEncByteWrong() throws IOException { String fileName = "src/test/resources/core/io/enc/test_no_utf8.gz"; try ( InputStream is = new GZIPInputStream( new FileInputStream( fileName ) ) ) { boolean ok = EncodingCheck.checkEncoding( StreamIO.readBytes(is) , StandardCharsets.UTF_8.name() ); - Assert.assertFalse(ok); + Assertions.assertFalse(ok); } } diff --git a/fj-core/src/test/java/test/org/fugerit/java/core/io/file/TestFileFun.java b/fj-core/src/test/java/test/org/fugerit/java/core/io/file/TestFileFun.java index 04532f5a..153439ed 100644 --- a/fj-core/src/test/java/test/org/fugerit/java/core/io/file/TestFileFun.java +++ b/fj-core/src/test/java/test/org/fugerit/java/core/io/file/TestFileFun.java @@ -17,14 +17,14 @@ import org.fugerit.java.core.io.file.ZipArchiveDirFileFun; import org.fugerit.java.core.io.file.ZipFileFun; import org.fugerit.java.core.lang.helpers.ExHandlerDefault; -import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; import lombok.extern.slf4j.Slf4j; import test.org.fugerit.java.BasicTest; @Slf4j -public class TestFileFun extends BasicTest { +class TestFileFun extends BasicTest { private boolean worker( String testPath, String sourcePath ) { boolean ok = false; @@ -80,25 +80,25 @@ private boolean worker( FileFun fun ) throws IOException { } @Test - public void testFun() { + void testFun() { boolean ok = this.worker( "target/file_fun", "src/test/resources/core/xml/dtd" ); - Assert.assertTrue(ok); + Assertions.assertTrue(ok); } @Test - public void testAlt() throws IOException { + void testAlt() throws IOException { try ( FileFun fun = AbstractFileFun.newFileFun( f -> log.info( "worker : {}", f )) ) { FileFunWrapper wrapper = new FileFunWrapper(fun); FileFunSecure secure = new FileFunSecure(wrapper, new ExHandlerDefault()); boolean ok = this.worker( secure ); log.info( "secure wrapped : {}", secure.getWrappedFileFun() ); - Assert.assertTrue(ok); + Assertions.assertTrue(ok); FileFunSecure.apply( new ExHandlerDefault() , () -> new IOException( "TEST" ) ); } } @Test - public void testZip() throws IOException { + void testZip() throws IOException { boolean ok = false; File sourceDir = new File( "src/test/resources/core/xml/dtd" ); try ( ZipOutputStream zos = new ZipOutputStream( new FileOutputStream( new File( "target/zip_fun_test.zip" ) ) ); @@ -106,7 +106,7 @@ public void testZip() throws IOException { fun.handleFile( sourceDir.listFiles()[0] ); ok = true; } - Assert.assertTrue( ok ); + Assertions.assertTrue( ok ); } } diff --git a/fj-core/src/test/java/test/org/fugerit/java/core/io/line/TestLineIOUtils.java b/fj-core/src/test/java/test/org/fugerit/java/core/io/line/TestLineIOUtils.java index a0d7dc56..c4eabb76 100644 --- a/fj-core/src/test/java/test/org/fugerit/java/core/io/line/TestLineIOUtils.java +++ b/fj-core/src/test/java/test/org/fugerit/java/core/io/line/TestLineIOUtils.java @@ -14,40 +14,40 @@ import org.fugerit.java.core.io.line.LineIOUtils; import org.fugerit.java.core.io.line.LineReader; import org.fugerit.java.core.io.line.LineWriter; -import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; import lombok.extern.slf4j.Slf4j; @Slf4j -public class TestLineIOUtils { +class TestLineIOUtils { private static final String TEST_FILE_PATH = "src/test/resources/core/db/base-db-conn.properties"; private static final int EXPECTED_SIZE = 9; @Test - public void testLineReadStream() throws IOException { + void testLineReadStream() throws IOException { try ( InputStream is = new FileInputStream( TEST_FILE_PATH ) ) { List lines = LineIOUtils.readLines( is ); - Assert.assertEquals( EXPECTED_SIZE , lines.size() ); + Assertions.assertEquals( EXPECTED_SIZE , lines.size() ); } } @Test - public void testLineReadReader() throws IOException { + void testLineReadReader() throws IOException { try ( Reader is = new FileReader( TEST_FILE_PATH ) ) { List lines = LineIOUtils.readLines( is ); - Assert.assertEquals( EXPECTED_SIZE , lines.size() ); + Assertions.assertEquals( EXPECTED_SIZE , lines.size() ); } } @Test - public void testLineReadFile() throws IOException { + void testLineReadFile() throws IOException { List lines = LineIOUtils.readLines( new File( TEST_FILE_PATH ) ); lines.stream().forEach( s -> log.info( "current line -> {}", s ) ); String[] array = LineIOUtils.toLines(lines); - Assert.assertEquals( EXPECTED_SIZE , array.length ); + Assertions.assertEquals( EXPECTED_SIZE , array.length ); } private int testLineReader( LineReader reader ) throws IOException { @@ -63,29 +63,29 @@ private int testLineReader( LineReader reader ) throws IOException { } @Test - public void testCreateLineReader() throws IOException { + void testCreateLineReader() throws IOException { try ( Reader is = new FileReader( TEST_FILE_PATH ); LineReader reader = LineIOUtils.createLineReader( is ) ) { int count = this.testLineReader(reader); - Assert.assertEquals( EXPECTED_SIZE , count ); + Assertions.assertEquals( EXPECTED_SIZE , count ); } } @Test - public void testCreateLineBufferedReader() throws IOException { + void testCreateLineBufferedReader() throws IOException { try ( Reader is = new BufferedReader( new FileReader( TEST_FILE_PATH ) ); LineReader reader = LineIOUtils.createLineReader( is ) ) { int count = this.testLineReader(reader); - Assert.assertEquals( EXPECTED_SIZE , count ); + Assertions.assertEquals( EXPECTED_SIZE , count ); } } @Test - public void testCreateLineReaderStream() throws IOException { + void testCreateLineReaderStream() throws IOException { try ( InputStream is = new FileInputStream( TEST_FILE_PATH ); LineReader reader = LineIOUtils.createLineReader( is ) ) { int count = this.testLineReader(reader); - Assert.assertEquals( EXPECTED_SIZE , count ); + Assertions.assertEquals( EXPECTED_SIZE , count ); } } @@ -103,20 +103,20 @@ private int testLineWriter( LineWriter writer ) { } @Test - public void testCreateLineWriter() throws IOException { + void testCreateLineWriter() throws IOException { try ( StringWriter w = new StringWriter(); LineWriter writer = LineIOUtils.createLineWriter( w ) ) { int count = this.testLineWriter(writer); - Assert.assertEquals( TEST_LINES.length , count ); + Assertions.assertEquals( TEST_LINES.length , count ); } } @Test - public void testCreateLineWriterStream() throws IOException { + void testCreateLineWriterStream() throws IOException { try ( ByteArrayOutputStream w = new ByteArrayOutputStream(); LineWriter writer = LineIOUtils.createLineWriter( w ) ) { int count = this.testLineWriter(writer); - Assert.assertEquals( TEST_LINES.length , count ); + Assertions.assertEquals( TEST_LINES.length , count ); } } diff --git a/fj-core/src/test/java/test/org/fugerit/java/core/io/line/helper/TestHelperIOEx.java b/fj-core/src/test/java/test/org/fugerit/java/core/io/line/helper/TestHelperIOEx.java index 42bc68e4..62c928c8 100644 --- a/fj-core/src/test/java/test/org/fugerit/java/core/io/line/helper/TestHelperIOEx.java +++ b/fj-core/src/test/java/test/org/fugerit/java/core/io/line/helper/TestHelperIOEx.java @@ -5,127 +5,127 @@ import java.sql.SQLException; import org.fugerit.java.core.io.helper.HelperIOException; -import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; import lombok.extern.slf4j.Slf4j; @Slf4j -public class TestHelperIOEx { +class TestHelperIOEx { @Test - public void testApplySilent() throws IOException { + void testApplySilent() throws IOException { boolean ok = true; HelperIOException.applySilent( () -> { throw new IOException( "junit test scenario" ); } ); - Assert.assertTrue( ok ); + Assertions.assertTrue( ok ); } @Test - public void testGetSilent() throws IOException { + void testGetSilent() throws IOException { Object result = HelperIOException.getSilent( () -> { throw new IOException( "junit test scenario" ); } ); - Assert.assertNull( result ); + Assertions.assertNull( result ); } @Test - public void testApplyEXMessage() { - Assert.assertThrows( IOException.class ,() -> HelperIOException.applyWithMessage( () -> { throw new IOException( "junit test scenario" ); }, "test message" ) ); + void testApplyEXMessage() { + Assertions.assertThrows( IOException.class ,() -> HelperIOException.applyWithMessage( () -> { throw new IOException( "junit test scenario" ); }, "test message" ) ); } @Test - public void testGetEXMessage() { - Assert.assertThrows( IOException.class ,() -> HelperIOException.getWithMessage( () -> { throw new IOException( "junit test scenario" ); }, "test message" ) ); + void testGetEXMessage() { + Assertions.assertThrows( IOException.class ,() -> HelperIOException.getWithMessage( () -> { throw new IOException( "junit test scenario" ); }, "test message" ) ); } @Test - public void testApplyEXMessageOk() throws IOException { + void testApplyEXMessageOk() throws IOException { boolean ok = true; HelperIOException.applyWithMessage( () -> log.info( "test ok" ) , "test message" ); - Assert.assertTrue( ok ); + Assertions.assertTrue( ok ); } @Test - public void testGetEXMessageOk() throws IOException { - Assert.assertNotNull( HelperIOException.getWithMessage( () -> "test ok" , "test message" ) ); + void testGetEXMessageOk() throws IOException { + Assertions.assertNotNull( HelperIOException.getWithMessage( () -> "test ok" , "test message" ) ); } @Test - public void testEx1() { - Assert.assertNotNull( new HelperIOException() ); + void testEx1() { + Assertions.assertNotNull( new HelperIOException() ); } @Test - public void testEx2() { - Assert.assertNotNull( new HelperIOException( "a" ) ); + void testEx2() { + Assertions.assertNotNull( new HelperIOException( "a" ) ); } @Test - public void testEx3() { - Assert.assertNotNull( new HelperIOException( new SQLException( "b" ) ) ); + void testEx3() { + Assertions.assertNotNull( new HelperIOException( new SQLException( "b" ) ) ); } @Test - public void testEx4() { - Assert.assertNotNull( new HelperIOException( "c", new SQLException( "d" ) ) ); + void testEx4() { + Assertions.assertNotNull( new HelperIOException( "c", new SQLException( "d" ) ) ); } @Test - public void testClose1() throws IOException { + void testClose1() throws IOException { HelperIOException.close( (Closeable) () -> log.info( "Closeable.close()" ) ); - Assert.assertTrue( true ); + Assertions.assertTrue( true ); } @Test - public void testClose2() throws IOException { + void testClose2() throws IOException { HelperIOException.close( (AutoCloseable) () -> log.info( "AutoCloseable.close()" ) ); - Assert.assertTrue( true ); + Assertions.assertTrue( true ); } @Test - public void testClose3() throws IOException { + void testClose3() throws IOException { HelperIOException.close( (Closeable) null ); - Assert.assertTrue( true ); + Assertions.assertTrue( true ); } @Test - public void testClose4() throws IOException { + void testClose4() throws IOException { HelperIOException.close( (AutoCloseable) null ); - Assert.assertTrue( true ); + Assertions.assertTrue( true ); } @Test - public void testApplyOk() throws IOException { + void testApplyOk() throws IOException { HelperIOException.apply( () -> log.info( "test ok" ) ); - Assert.assertTrue( true ); + Assertions.assertTrue( true ); } @Test - public void testGetOk() throws IOException { + void testGetOk() throws IOException { HelperIOException.get( () -> "ok" ); - Assert.assertTrue( true ); + Assertions.assertTrue( true ); } @Test - public void testApply() { - Assert.assertThrows( IOException.class ,() -> HelperIOException.apply( () -> { throw new SQLException( "junit test scenario" ); } ) ); + void testApply() { + Assertions.assertThrows( IOException.class ,() -> HelperIOException.apply( () -> { throw new SQLException( "junit test scenario" ); } ) ); } @Test - public void testGet() { - Assert.assertThrows( IOException.class ,() -> HelperIOException.get( () -> { throw new SQLException( "junit test scenario" ); } ) ); + void testGet() { + Assertions.assertThrows( IOException.class ,() -> HelperIOException.get( () -> { throw new SQLException( "junit test scenario" ); } ) ); } @Test - public void testEx5() { - Assert.assertNotNull( HelperIOException.convertEx( "e" , new SQLException( "f" ) ) ); + void testEx5() { + Assertions.assertNotNull( HelperIOException.convertEx( "e" , new SQLException( "f" ) ) ); } @Test - public void testEx6() { - Assert.assertNotNull( HelperIOException.convertEx( "g" , new IOException( "g" ) ) ); + void testEx6() { + Assertions.assertNotNull( HelperIOException.convertEx( "g" , new IOException( "g" ) ) ); } @Test - public void testEx7() { - Assert.assertNotNull( HelperIOException.convertExMethod( "e" , new SQLException( "f" ) ) ); + void testEx7() { + Assertions.assertNotNull( HelperIOException.convertExMethod( "e" , new SQLException( "f" ) ) ); } diff --git a/fj-core/src/test/java/test/org/fugerit/java/core/javagen/TestJavaGenerator.java b/fj-core/src/test/java/test/org/fugerit/java/core/javagen/TestJavaGenerator.java index 777a7cd9..bb724bcd 100644 --- a/fj-core/src/test/java/test/org/fugerit/java/core/javagen/TestJavaGenerator.java +++ b/fj-core/src/test/java/test/org/fugerit/java/core/javagen/TestJavaGenerator.java @@ -1,16 +1,16 @@ package test.org.fugerit.java.core.javagen; -import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; import lombok.extern.slf4j.Slf4j; import test.org.fugerit.java.BasicTest; @Slf4j -public class TestJavaGenerator extends BasicTest { +class TestJavaGenerator extends BasicTest { @Test - public void generate() { + void generate() { try { CheckJavaGenerator generator = new CheckJavaGenerator(); generator.init(); @@ -18,14 +18,14 @@ public void generate() { log.info( "ok : {}", generator.getContent() ); generator.write(); generator.generate(); - Assert.assertNotNull(generator); + Assertions.assertNotNull(generator); } catch (Exception e) { this.failEx(e); } } @Test - public void generateNoPublicClass() { + void generateNoPublicClass() { try { NoPublicClassJavaGenerator generator = new NoPublicClassJavaGenerator(); generator.init(); @@ -33,7 +33,7 @@ public void generateNoPublicClass() { log.info( "ok : {}", generator.getContent() ); generator.write(); generator.generate(); - Assert.assertNotNull(generator); + Assertions.assertNotNull(generator); } catch (Exception e) { this.failEx(e); } diff --git a/fj-core/src/test/java/test/org/fugerit/java/core/lang/TestLibHelper.java b/fj-core/src/test/java/test/org/fugerit/java/core/lang/TestLibHelper.java index 56f501be..5b0d8ad7 100644 --- a/fj-core/src/test/java/test/org/fugerit/java/core/lang/TestLibHelper.java +++ b/fj-core/src/test/java/test/org/fugerit/java/core/lang/TestLibHelper.java @@ -2,25 +2,25 @@ import org.fugerit.java.core.cfg.ConfigRuntimeException; import org.fugerit.java.core.lang.LibHelper; -import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; import java.io.File; import java.io.IOException; -public class TestLibHelper { +class TestLibHelper { private static final String LLP = "java.library.path"; @Test - public void testCount0() throws IOException { + void testCount0() throws IOException { File libraryPath = new File( "src/test/resources/core/lang/lib_helper" ); String llPath = System.getProperty( LLP ); System.setProperty( LLP, llPath+File.pathSeparator+libraryPath.getCanonicalPath() ); int count1 = LibHelper.ll( "test_ll_fug1" ); - Assert.assertEquals( 1, count1 ); - Assert.assertThrows( ConfigRuntimeException.class, () -> LibHelper.ll( "test_ll_fug" ) ); - Assert.assertEquals( 0, LibHelper.ll( "test_ll_not_found" ) ); + Assertions.assertEquals( 1, count1 ); + Assertions.assertThrows( ConfigRuntimeException.class, () -> LibHelper.ll( "test_ll_fug" ) ); + Assertions.assertEquals( 0, LibHelper.ll( "test_ll_not_found" ) ); } } diff --git a/fj-core/src/test/java/test/org/fugerit/java/core/lang/binding/BindingHelper.java b/fj-core/src/test/java/test/org/fugerit/java/core/lang/binding/BindingHelper.java new file mode 100644 index 00000000..b83d680d --- /dev/null +++ b/fj-core/src/test/java/test/org/fugerit/java/core/lang/binding/BindingHelper.java @@ -0,0 +1,39 @@ +package test.org.fugerit.java.core.lang.binding; + +import lombok.extern.slf4j.Slf4j; +import org.fugerit.java.core.lang.binding.*; + +@Slf4j +public class BindingHelper extends BindingHelperDefault { + + /** + * + */ + private static final long serialVersionUID = 6082079779742598082L; + + public void testBindingHelperInitTo1() throws BindingException { + BindingContext context = new BindingContext(); + BindingFieldConfig fieldConfig = new BindingFieldConfig(); + BindingConfig bindingConfig = new BindingConfig(); + fieldConfig.setBindFrom( "fieldOne" ); + fieldConfig.setBindTo( "fieldTwo" ); + ModelTestBindingOne from = new ModelTestBindingOne(); + ModelTestBindingTwo to = new ModelTestBindingTwo(); + BindingHelperInitTo.DEFAULT.bind(context, bindingConfig, fieldConfig, from, to); + log.info( "to.fieldTwo : {}", to.getFieldTwo() ); + } + + public void testBindingHelperInitTo2() throws BindingException { + BindingContext context = new BindingContext(); + BindingFieldConfig fieldConfig = new BindingFieldConfig(); + BindingConfig bindingConfig = new BindingConfig(); + fieldConfig.setBindFrom( "testHelperOne" ); + fieldConfig.setBindTo( "testHelperTwo" ); + fieldConfig.setTypeTo( ModelTestHelperImpl.class.getName() ); + ModelTestBindingOne from = new ModelTestBindingOne(); + ModelTestBindingTwo to = new ModelTestBindingTwo(); + BindingHelperInitTo.DEFAULT.bind(context, bindingConfig, fieldConfig, from, to); + log.info( "to.testHelperTwo : {}", to.getTestHelperTwo() ); + } + +} diff --git a/fj-core/src/test/java/test/org/fugerit/java/core/lang/binding/TestBindingCatalog.java b/fj-core/src/test/java/test/org/fugerit/java/core/lang/binding/TestBindingCatalog.java index b4f6e486..f636b137 100644 --- a/fj-core/src/test/java/test/org/fugerit/java/core/lang/binding/TestBindingCatalog.java +++ b/fj-core/src/test/java/test/org/fugerit/java/core/lang/binding/TestBindingCatalog.java @@ -1,6 +1,6 @@ package test.org.fugerit.java.core.lang.binding; -import static org.junit.Assert.fail; +import static org.junit.jupiter.api.Assertions.fail; import java.math.BigDecimal; import java.sql.Date; @@ -9,7 +9,7 @@ import org.fugerit.java.core.lang.binding.BindingCatalogConfig; import org.fugerit.java.core.lang.helpers.ClassHelper; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -17,7 +17,7 @@ import test.org.fugerit.java.core.lang.helpers.reflect.TestModelThree; import test.org.fugerit.java.core.lang.helpers.reflect.TestModelTwo; -public class TestBindingCatalog { +class TestBindingCatalog { private static final Logger logger = LoggerFactory.getLogger( TestBindingCatalog.class ); @@ -101,32 +101,32 @@ private void bind004WOrker( String bindingId ) { } @Test - public void bind001() { + void bind001() { this.bind001WOrker( "binding-01" ); } @Test - public void bind001Def() { + void bind001Def() { this.bind001WOrker( "binding-01-default" ); } @Test - public void bind002Def() { + void bind002Def() { this.bind002WOrker( "binding-02-default" ); } @Test - public void bind003() { + void bind003() { this.bind003WOrker( "binding-03" ); } @Test - public void bind004() { + void bind004() { this.bind004WOrker( "binding-04" ); } @Test - public void bind005() { + void bind005() { this.bind003WOrker( "binding-05" ); } diff --git a/fj-core/src/test/java/test/org/fugerit/java/core/lang/binding/TestBindingHelper.java b/fj-core/src/test/java/test/org/fugerit/java/core/lang/binding/TestBindingHelper.java index dfd6c469..d8473b28 100644 --- a/fj-core/src/test/java/test/org/fugerit/java/core/lang/binding/TestBindingHelper.java +++ b/fj-core/src/test/java/test/org/fugerit/java/core/lang/binding/TestBindingHelper.java @@ -6,13 +6,13 @@ import org.fugerit.java.core.lang.binding.BindingFieldConfig; import org.fugerit.java.core.lang.binding.BindingHelperDefault; import org.fugerit.java.core.lang.binding.BindingHelperInitTo; -import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; import lombok.extern.slf4j.Slf4j; @Slf4j -public class TestBindingHelper extends BindingHelperDefault { +class TestBindingHelper extends BindingHelperDefault { /** * @@ -20,7 +20,7 @@ public class TestBindingHelper extends BindingHelperDefault { private static final long serialVersionUID = 6082079779742598082L; @Test - public void testBindingHelperInitTo1() throws BindingException { + void testBindingHelperInitTo1() throws BindingException { BindingContext context = new BindingContext(); BindingFieldConfig fieldConfig = new BindingFieldConfig(); BindingConfig bindingConfig = new BindingConfig(); @@ -30,11 +30,11 @@ public void testBindingHelperInitTo1() throws BindingException { ModelTestBindingTwo to = new ModelTestBindingTwo(); BindingHelperInitTo.DEFAULT.bind(context, bindingConfig, fieldConfig, from, to); log.info( "to.fieldTwo : {}", to.getFieldTwo() ); - Assert.assertNotNull( to.getFieldTwo() ); + Assertions.assertNotNull( to.getFieldTwo() ); } @Test - public void testBindingHelperInitTo2() throws BindingException { + void testBindingHelperInitTo2() throws BindingException { BindingContext context = new BindingContext(); BindingFieldConfig fieldConfig = new BindingFieldConfig(); BindingConfig bindingConfig = new BindingConfig(); @@ -45,7 +45,7 @@ public void testBindingHelperInitTo2() throws BindingException { ModelTestBindingTwo to = new ModelTestBindingTwo(); BindingHelperInitTo.DEFAULT.bind(context, bindingConfig, fieldConfig, from, to); log.info( "to.testHelperTwo : {}", to.getTestHelperTwo() ); - Assert.assertNotNull( to.getTestHelperTwo() ); + Assertions.assertNotNull( to.getTestHelperTwo() ); } } diff --git a/fj-core/src/test/java/test/org/fugerit/java/core/lang/compare/TestCheckEmpty.java b/fj-core/src/test/java/test/org/fugerit/java/core/lang/compare/TestCheckEmpty.java index e1323016..82a9879b 100644 --- a/fj-core/src/test/java/test/org/fugerit/java/core/lang/compare/TestCheckEmpty.java +++ b/fj-core/src/test/java/test/org/fugerit/java/core/lang/compare/TestCheckEmpty.java @@ -1,13 +1,13 @@ package test.org.fugerit.java.core.lang.compare; -import static org.junit.Assert.fail; +import static org.junit.jupiter.api.Assertions.fail; import org.fugerit.java.core.lang.compare.CheckEmptyHelper; -import org.junit.Test; +import org.junit.jupiter.api.Test; import test.org.fugerit.java.BasicTest; -public class TestCheckEmpty extends BasicTest { +class TestCheckEmpty extends BasicTest { public static boolean EMPTY = true; @@ -25,42 +25,42 @@ private void checkEmptyHelper( Object value, boolean shouldBeEmpty ) { } @Test - public void test001() { + void test001() { this.checkEmptyHelper( "test" , NOT_EMPTY ); } @Test - public void test002() { + void test002() { this.checkEmptyHelper( "" , EMPTY ); } @Test - public void test003() { + void test003() { this.checkEmptyHelper( null , EMPTY ); } @Test - public void test004() { + void test004() { this.checkEmptyHelper( new CheckEmptyModel( "", "" ) , EMPTY ); } @Test - public void test005() { + void test005() { this.checkEmptyHelper( new CheckEmptyModel( "1", "2" ) , NOT_EMPTY ); } @Test - public void test006() { + void test006() { this.checkEmptyHelper( new CheckEmptyModel( "1", null ) , NOT_EMPTY ); } @Test - public void test007() { + void test007() { this.checkEmptyHelper( new CheckEmptyModel( null, "2" ) , NOT_EMPTY ); } @Test - public void test008() { + void test008() { this.checkEmptyHelper( new CheckEmptyModel( null, null ) , EMPTY ); } diff --git a/fj-core/src/test/java/test/org/fugerit/java/core/lang/compare/TestCompareHelper.java b/fj-core/src/test/java/test/org/fugerit/java/core/lang/compare/TestCompareHelper.java index 1ed800b6..7ace311f 100644 --- a/fj-core/src/test/java/test/org/fugerit/java/core/lang/compare/TestCompareHelper.java +++ b/fj-core/src/test/java/test/org/fugerit/java/core/lang/compare/TestCompareHelper.java @@ -1,39 +1,39 @@ package test.org.fugerit.java.core.lang.compare; import org.fugerit.java.core.lang.compare.CompareHelper; -import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; -public class TestCompareHelper { +class TestCompareHelper { @Test - public void testCompareEquals1() { + void testCompareEquals1() { boolean ok = CompareHelper.equals( String.valueOf( "test1" ) , String.valueOf( "test1" ) ); - Assert.assertTrue(ok); + Assertions.assertTrue(ok); } @Test - public void testCompareEquals2() { + void testCompareEquals2() { boolean ok = CompareHelper.equals( String.valueOf( "test4" ), null ); - Assert.assertFalse(ok); + Assertions.assertFalse(ok); } @Test - public void testCompareEquals3() { + void testCompareEquals3() { boolean ok = CompareHelper.equals( null, String.valueOf( "test5" ) ); - Assert.assertFalse(ok); + Assertions.assertFalse(ok); } @Test - public void testCompareEquals4() { + void testCompareEquals4() { boolean ok = CompareHelper.equals( null, null ); - Assert.assertTrue(ok); + Assertions.assertTrue(ok); } @Test - public void testCompareNotEquals() { + void testCompareNotEquals() { boolean ok = CompareHelper.notEquals( String.valueOf( "test2" ), String.valueOf( "test3" ) ); - Assert.assertTrue(ok); + Assertions.assertTrue(ok); } } diff --git a/fj-core/src/test/java/test/org/fugerit/java/core/lang/ex/TestCodeEx.java b/fj-core/src/test/java/test/org/fugerit/java/core/lang/ex/TestCodeEx.java index 84d27721..1ffa0d02 100644 --- a/fj-core/src/test/java/test/org/fugerit/java/core/lang/ex/TestCodeEx.java +++ b/fj-core/src/test/java/test/org/fugerit/java/core/lang/ex/TestCodeEx.java @@ -2,10 +2,10 @@ import org.fugerit.java.core.lang.ex.CodeEx; import org.fugerit.java.core.util.result.Result; -import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; -public class TestCodeEx implements CodeEx { +class TestCodeEx implements CodeEx { private int code = Result.RESULT_CODE_OK; @@ -15,11 +15,11 @@ public int getCode() { } @Test - public void testCodeEx() { + void testCodeEx() { TestCodeEx codeEx = new TestCodeEx(); - Assert.assertNull( codeEx.getMessage() ); - Assert.assertNull( codeEx.getCause() ); - Assert.assertEquals( Result.RESULT_CODE_OK, codeEx.getCode() ); + Assertions.assertNull( codeEx.getMessage() ); + Assertions.assertNull( codeEx.getCause() ); + Assertions.assertEquals( Result.RESULT_CODE_OK, codeEx.getCode() ); } } diff --git a/fj-core/src/test/java/test/org/fugerit/java/core/lang/ex/TestExUtils.java b/fj-core/src/test/java/test/org/fugerit/java/core/lang/ex/TestExUtils.java index b2975575..18fc487b 100644 --- a/fj-core/src/test/java/test/org/fugerit/java/core/lang/ex/TestExUtils.java +++ b/fj-core/src/test/java/test/org/fugerit/java/core/lang/ex/TestExUtils.java @@ -1,14 +1,14 @@ package test.org.fugerit.java.core.lang.ex; import org.fugerit.java.core.lang.ex.ExUtils; -import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; -public class TestExUtils { +class TestExUtils { @Test - public void testExUtils() { - Assert.assertThrows( UnsupportedOperationException.class, () -> ExUtils.THROW_UNSUPPORTED.accept( "test1()" ) ); + void testExUtils() { + Assertions.assertThrows( UnsupportedOperationException.class, () -> ExUtils.THROW_UNSUPPORTED.accept( "test1()" ) ); ExUtils.WARN_UNSUPPORTED.accept( "test2()" ); } diff --git a/fj-core/src/test/java/test/org/fugerit/java/core/lang/helpers/TestClassHelper.java b/fj-core/src/test/java/test/org/fugerit/java/core/lang/helpers/TestClassHelper.java index 7097edad..15da6185 100644 --- a/fj-core/src/test/java/test/org/fugerit/java/core/lang/helpers/TestClassHelper.java +++ b/fj-core/src/test/java/test/org/fugerit/java/core/lang/helpers/TestClassHelper.java @@ -6,15 +6,16 @@ import org.fugerit.java.core.io.StreamIO; import org.fugerit.java.core.lang.helpers.ClassHelper; import org.fugerit.java.core.lang.helpers.StringUtils; -import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; import lombok.Getter; import lombok.extern.slf4j.Slf4j; import test.org.fugerit.java.BasicTest; +import test.org.fugerit.java.core.db.dao.ModelUser; @Slf4j -public class TestClassHelper extends BasicTest { +class TestClassHelper extends BasicTest { private static final String PATH_TXT_OK = "core/test_test.txt"; @@ -77,84 +78,84 @@ private boolean testLoadFromClassLoaderWorker( String path, boolean expectedExce } @Test - public void testNewInstanceOk() { - boolean ok = this.testNewInstanceWorker( TestClassHelper.class.getName(), false ); - Assert.assertTrue( ok ); + void testNewInstanceOk() { + boolean ok = this.testNewInstanceWorker( ModelUser.class.getName(), false ); + Assertions.assertTrue( ok ); } @Test - public void testNewInstanceClassNotFoundException() { - boolean ok = this.testNewInstanceWorker( TestClassHelper.class.getName()+"NotExist", true ); - Assert.assertTrue( ok ); + void testNewInstanceClassNotFoundException() { + boolean ok = this.testNewInstanceWorker( ModelUser.class.getName()+"NotExist", true ); + Assertions.assertTrue( ok ); } @Test - public void testNewInstanceConfigException() { + void testNewInstanceConfigException() { boolean ok = this.testNewInstanceWorker( TestPrivateConstructor.class.getName(), true ); - Assert.assertTrue( ok ); + Assertions.assertTrue( ok ); } @Test - public void testNewInstanceNoSuchMethodException() { + void testNewInstanceNoSuchMethodException() { boolean ok = this.testNewInstanceWorker( TestNoDefaultConstructor.class.getName(), true ); - Assert.assertTrue( ok ); + Assertions.assertTrue( ok ); } @Test - public void testLoadFromDefaultClassLoaderOk() { + void testLoadFromDefaultClassLoaderOk() { boolean ok = this.testLoadFromDefaultClassLoaderWorker( PATH_TXT_OK, false ); - Assert.assertTrue( ok ); + Assertions.assertTrue( ok ); } @Test - public void testLoadFromClassLoaderOk1() { - boolean ok = this.testLoadFromClassLoaderWorker( PATH_TXT_OK, false, TestClassHelper.class ); - Assert.assertTrue( ok ); + void testLoadFromClassLoaderOk1() { + boolean ok = this.testLoadFromClassLoaderWorker( PATH_TXT_OK, false, ModelUser.class ); + Assertions.assertTrue( ok ); } @Test - public void testLoadFromClassLoaderOk2() { + void testLoadFromClassLoaderOk2() { boolean ok = this.testLoadFromClassLoaderWorker( PATH_TXT_OK, false, ClassHelper.class ); - Assert.assertTrue( ok ); + Assertions.assertTrue( ok ); } @Test - public void testLoadFromClassLoaderOk3() { + void testLoadFromClassLoaderOk3() { boolean ok = this.testLoadFromClassLoaderWorker( PATH_TXT_OK, false, null ); - Assert.assertTrue( ok ); + Assertions.assertTrue( ok ); } @Test - public void testLoadFromDefaultClassLoaderko() { + void testLoadFromDefaultClassLoaderko() { boolean ok = this.testLoadFromDefaultClassLoaderWorker( PATH_TXT_KO, true ); - Assert.assertTrue( ok ); + Assertions.assertTrue( ok ); } @Test - public void testLoadFromClassLoaderko1() { - boolean ok = this.testLoadFromClassLoaderWorker( PATH_TXT_KO, true, TestClassHelper.class ); - Assert.assertTrue( ok ); + void testLoadFromClassLoaderko1() { + boolean ok = this.testLoadFromClassLoaderWorker( PATH_TXT_KO, true, ModelUser.class ); + Assertions.assertTrue( ok ); } @Test - public void testLoadFromClassLoaderKo2() { + void testLoadFromClassLoaderKo2() { boolean ok = this.testLoadFromClassLoaderWorker( PATH_TXT_KO, true, ClassHelper.class ); - Assert.assertTrue( ok ); + Assertions.assertTrue( ok ); } @Test - public void testToFullClassName() { - String name = ClassHelper.toFullClassName( new TestClassHelper() ); + void testToFullClassName() { + String name = ClassHelper.toFullClassName( new ModelUser() ); log.info( "tesToFullClassName {}", name ); - Assert.assertEquals( TestClassHelper.class.getName(), name ); + Assertions.assertEquals( ModelUser.class.getName(), name ); } @Test - public void testToSimpleClassName() { - String name = ClassHelper.toSimpleClassName( new TestClassHelper() ); + void testToSimpleClassName() { + String name = ClassHelper.toSimpleClassName( new ModelUser() ); log.info( "testToSimpleClassName {}", name ); - Assert.assertEquals( TestClassHelper.class.getSimpleName() , name ); + Assertions.assertEquals( ModelUser.class.getSimpleName() , name ); } } diff --git a/fj-core/src/test/java/test/org/fugerit/java/core/lang/helpers/TestExHandler.java b/fj-core/src/test/java/test/org/fugerit/java/core/lang/helpers/TestExHandler.java index 7b81502b..4a87ae70 100644 --- a/fj-core/src/test/java/test/org/fugerit/java/core/lang/helpers/TestExHandler.java +++ b/fj-core/src/test/java/test/org/fugerit/java/core/lang/helpers/TestExHandler.java @@ -5,13 +5,13 @@ import org.fugerit.java.core.lang.helpers.ExHandler; import org.fugerit.java.core.lang.helpers.Result; import org.fugerit.java.core.lang.helpers.ResultExHandler; -import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; import lombok.extern.slf4j.Slf4j; @Slf4j -public class TestExHandler { +class TestExHandler { private boolean worker( ExHandler handler ) { handler.fatal( new IOException( "fatal" ) ); @@ -21,21 +21,21 @@ private boolean worker( ExHandler handler ) { } @Test - public void testResultExHandler() { + void testResultExHandler() { ResultExHandler handler = new ResultExHandler(); handler.setResult( new Result() ); log.info( "test : {}", handler.getResult() ); boolean ok = this.worker(handler); - Assert.assertTrue( ok ); + Assertions.assertTrue( ok ); } @Test - public void testResultExHandlerAlt() { + void testResultExHandlerAlt() { org.fugerit.java.core.util.result.ResultExHandler handler = new org.fugerit.java.core.util.result.ResultExHandler(); handler.setResult( new Result() ); log.info( "test : {}", handler.getResult() ); boolean ok = this.worker(handler); - Assert.assertTrue( ok ); + Assertions.assertTrue( ok ); } } diff --git a/fj-core/src/test/java/test/org/fugerit/java/core/lang/helpers/TestJavaVersionHelper.java b/fj-core/src/test/java/test/org/fugerit/java/core/lang/helpers/TestJavaVersionHelper.java index 480e8542..8ee77a0c 100644 --- a/fj-core/src/test/java/test/org/fugerit/java/core/lang/helpers/TestJavaVersionHelper.java +++ b/fj-core/src/test/java/test/org/fugerit/java/core/lang/helpers/TestJavaVersionHelper.java @@ -2,75 +2,75 @@ import org.fugerit.java.core.cfg.ConfigRuntimeException; import org.fugerit.java.core.lang.helpers.JavaVersionHelper; -import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; import lombok.extern.slf4j.Slf4j; @Slf4j -public class TestJavaVersionHelper { +class TestJavaVersionHelper { @Test - public void test() { + void test() { int majorVersion = JavaVersionHelper.parseUniversalJavaMajorVersion(); - log.info("major version -> '{}'", majorVersion); + log.info("major version base -> '{}'", majorVersion); boolean supportedBuildVersion = ( majorVersion == JavaVersionHelper.MAJOR_VERSION_JAVA_11 || majorVersion == JavaVersionHelper.MAJOR_VERSION_JAVA_17 || majorVersion == JavaVersionHelper.MAJOR_VERSION_JAVA_21 ); - Assert.assertTrue( "Wrong java major version : "+majorVersion , supportedBuildVersion ); + Assertions.assertTrue( supportedBuildVersion, () -> "Wrong java major version : "+majorVersion ); } @Test - public void test7() { + void test7() { int majorVersion = JavaVersionHelper.parseUniversalJavaMajorVersion( "1.7.0_123" ); - log.info("major version -> '{}'", majorVersion); + log.info("major version 7 -> '{}'", majorVersion); boolean supportedBuildVersion = ( majorVersion == 7 ); - Assert.assertTrue( "Wrong java major version : "+majorVersion , supportedBuildVersion ); + Assertions.assertTrue( supportedBuildVersion, () -> "Wrong java major version : "+majorVersion ); } @Test - public void testUndefined() { + void testUndefined() { int majorVersion = JavaVersionHelper.parseUniversalJavaMajorVersion( "1.8X.0_362" ); - log.info("major version -> '{}'", majorVersion); + log.info("major version undefined -> '{}'", majorVersion); boolean supportedBuildVersion = ( majorVersion == JavaVersionHelper.UNDEFINED ); - Assert.assertTrue( "Wrong java major version : "+majorVersion , supportedBuildVersion ); + Assertions.assertTrue( supportedBuildVersion, () -> "Wrong java major version : "+majorVersion ); } @Test - public void test8() { + void test8() { int majorVersion = JavaVersionHelper.parseUniversalJavaMajorVersion( "1.8.0_362" ); - log.info("major version -> '{}'", majorVersion); + log.info("major version 8 -> '{}'", majorVersion); boolean supportedBuildVersion = ( majorVersion == JavaVersionHelper.MAJOR_VERSION_JAVA_8 ); - Assert.assertTrue( "Wrong java major version : "+majorVersion , supportedBuildVersion ); + Assertions.assertTrue( supportedBuildVersion, () -> "Wrong java major version : "+majorVersion ); } @Test - public void test11() { + void test11() { int majorVersion = JavaVersionHelper.parseUniversalJavaMajorVersion( "11.0.18" ); - log.info("major version -> '{}'", majorVersion); + log.info("major version 11 -> '{}'", majorVersion); boolean supportedBuildVersion = ( majorVersion == JavaVersionHelper.MAJOR_VERSION_JAVA_11 ); - Assert.assertTrue( "Wrong java major version : "+majorVersion , supportedBuildVersion ); + Assertions.assertTrue( supportedBuildVersion, () -> "Wrong java major version : "+majorVersion ); } @Test - public void test17() { + void test17() { int majorVersion = JavaVersionHelper.parseUniversalJavaMajorVersion( "17.0.7" ); - log.info("major version -> '{}'", majorVersion); + log.info("major version 17 -> '{}'", majorVersion); boolean supportedBuildVersion = ( majorVersion == JavaVersionHelper.MAJOR_VERSION_JAVA_17 ); - Assert.assertTrue( "Wrong java major version : "+majorVersion , supportedBuildVersion ); + Assertions.assertTrue( supportedBuildVersion, () -> "Wrong java major version : "+majorVersion ); } @Test - public void test21() { + void test21() { int majorVersion = JavaVersionHelper.parseUniversalJavaMajorVersion( "21" ); - log.info("major version -> '{}'", majorVersion); + log.info("major version 21 -> '{}'", majorVersion); boolean supportedBuildVersion = ( majorVersion == JavaVersionHelper.MAJOR_VERSION_JAVA_21 ); - Assert.assertTrue( "Wrong java major version : "+majorVersion , supportedBuildVersion ); + Assertions.assertTrue( supportedBuildVersion, () -> "Wrong java major version : "+majorVersion ); } @Test - public void testNull() { - Assert.assertThrows( ConfigRuntimeException.class , () -> JavaVersionHelper.parseUniversalJavaMajorVersion( null ) ); + void testNull() { + Assertions.assertThrows( ConfigRuntimeException.class , () -> JavaVersionHelper.parseUniversalJavaMajorVersion( null ) ); } } diff --git a/fj-core/src/test/java/test/org/fugerit/java/core/lang/helpers/filter/TestPathHelper.java b/fj-core/src/test/java/test/org/fugerit/java/core/lang/helpers/filter/TestPathHelper.java index 06bb6cd2..41298132 100644 --- a/fj-core/src/test/java/test/org/fugerit/java/core/lang/helpers/filter/TestPathHelper.java +++ b/fj-core/src/test/java/test/org/fugerit/java/core/lang/helpers/filter/TestPathHelper.java @@ -1,6 +1,6 @@ package test.org.fugerit.java.core.lang.helpers.filter; -import static org.junit.Assert.fail; +import static org.junit.jupiter.api.Assertions.fail; import java.math.BigDecimal; import java.util.ArrayList; @@ -10,13 +10,13 @@ import org.fugerit.java.core.lang.helpers.filter.FilterFacade; import org.fugerit.java.core.lang.helpers.filter.FilterInfo; import org.fugerit.java.core.lang.helpers.filter.FilterInfoDefault; -import org.junit.Test; +import org.junit.jupiter.api.Test; import test.org.fugerit.java.BasicTest; import test.org.fugerit.java.core.lang.helpers.reflect.TestModelOne; import test.org.fugerit.java.core.lang.helpers.reflect.TestModelTwo; -public class TestPathHelper extends BasicTest { +class TestPathHelper extends BasicTest { private static final TestModelOne TEST_CASE_001 = new TestModelOne( new BigDecimal( 1 ), "value 001_1", new TestModelTwo( new BigDecimal( 2 ), "value 001_2" ) ); @@ -40,42 +40,42 @@ private void testFilterWorker( Object target, Collection filters, bo } @Test - public void test001_A() { + void test001_A() { Collection filters = new ArrayList(); filters.add( FilterInfoDefault.newFilter( TEST_CASE_001.getKid().getValueTwo(), FilterApplyDefault.EV_EQUALS, "kid.valueTwo" ) ); this.testFilterWorker( TEST_CASE_001 , filters, true ); } @Test - public void test001_B() { + void test001_B() { Collection filters = new ArrayList(); filters.add( FilterInfoDefault.newFilter( TEST_CASE_001.getKid().getValueTwo(), null, "kid.valueTwo" ) ); this.testFilterWorker( TEST_CASE_001 , filters, true ); } @Test - public void test001_C() { + void test001_C() { Collection filters = new ArrayList(); filters.add( FilterInfoDefault.newFilter( TEST_CASE_001.getKid().getValueTwo(), FilterApplyDefault.EV_NOT_EQUALS, "kid.valueTwo" ) ); this.testFilterWorker( TEST_CASE_001 , filters, false ); } @Test - public void test001_D() { + void test001_D() { Collection filters = new ArrayList(); filters.add( FilterInfoDefault.newFilter( "test", FilterApplyDefault.EV_EQUALS, "kid.valueTwo" ) ); this.testFilterWorker( TEST_CASE_001 , filters, false ); } @Test - public void test002_A() { + void test002_A() { Collection filters = new ArrayList(); filters.add( FilterInfoDefault.newFilter( FilterApplyDefault.EV_IS_NULL, "kid.valueTwo" ) ); this.testFilterWorker( TEST_CASE_002 , filters, true ); } @Test - public void test003_A() { + void test003_A() { Collection filters = new ArrayList(); filters.add( FilterInfoDefault.newFilter( FilterApplyDefault.EV_IS_NULL, "kid" ) ); this.testFilterWorker( TEST_CASE_003 , filters, true ); diff --git a/fj-core/src/test/java/test/org/fugerit/java/core/lang/helpers/reflect/TestFieldHelper.java b/fj-core/src/test/java/test/org/fugerit/java/core/lang/helpers/reflect/TestFieldHelper.java index 49f857eb..af808447 100644 --- a/fj-core/src/test/java/test/org/fugerit/java/core/lang/helpers/reflect/TestFieldHelper.java +++ b/fj-core/src/test/java/test/org/fugerit/java/core/lang/helpers/reflect/TestFieldHelper.java @@ -2,13 +2,13 @@ import org.fugerit.java.core.cfg.ConfigRuntimeException; import org.fugerit.java.core.lang.helpers.reflect.FieldHelper; -import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; import lombok.Getter; import lombok.Setter; -public class TestFieldHelper { +class TestFieldHelper { private static final String TEST_VALUE = "test1"; @@ -18,15 +18,15 @@ public class CheckBean { } @Test - public void testSetField() { + void testSetField() { CheckBean bean = new CheckBean(); - Assert.assertNull( bean.getField1() ); + Assertions.assertNull( bean.getField1() ); FieldHelper.setField(bean, "field1", TEST_VALUE, true); - Assert.assertEquals( TEST_VALUE , FieldHelper.getField(bean, "field1", true) ); + Assertions.assertEquals( TEST_VALUE , FieldHelper.getField(bean, "field1", true) ); FieldHelper.setField(bean, "field2", TEST_VALUE); - Assert.assertEquals( TEST_VALUE , FieldHelper.getField(bean, "field2") ); - Assert.assertThrows( ConfigRuntimeException.class , () -> FieldHelper.setField(bean, "field1", TEST_VALUE) ); - Assert.assertThrows( ConfigRuntimeException.class , () -> FieldHelper.getField(bean, "field1") ); + Assertions.assertEquals( TEST_VALUE , FieldHelper.getField(bean, "field2") ); + Assertions.assertThrows( ConfigRuntimeException.class , () -> FieldHelper.setField(bean, "field1", TEST_VALUE) ); + Assertions.assertThrows( ConfigRuntimeException.class , () -> FieldHelper.getField(bean, "field1") ); } } diff --git a/fj-core/src/test/java/test/org/fugerit/java/core/lang/helpers/reflect/TestMethodHelper.java b/fj-core/src/test/java/test/org/fugerit/java/core/lang/helpers/reflect/TestMethodHelper.java index 71635670..5cfca146 100644 --- a/fj-core/src/test/java/test/org/fugerit/java/core/lang/helpers/reflect/TestMethodHelper.java +++ b/fj-core/src/test/java/test/org/fugerit/java/core/lang/helpers/reflect/TestMethodHelper.java @@ -3,24 +3,24 @@ import org.fugerit.java.core.cfg.ConfigRuntimeException; import org.fugerit.java.core.cfg.xml.ListMapConfig; import org.fugerit.java.core.lang.helpers.reflect.MethodHelper; -import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; -public class TestMethodHelper { +class TestMethodHelper { @Test - public void testFoundMethod() { + void testFoundMethod() { String id = "test-id"; ListMapConfig list = new ListMapConfig(); list.setId( id ); String foundId = (String) MethodHelper.invokeGetter( list , "id" ); - Assert.assertEquals( id , foundId ); + Assertions.assertEquals( id , foundId ); } @Test - public void testNotFoundMethod() { + void testNotFoundMethod() { ListMapConfig list = new ListMapConfig(); - Assert.assertThrows( ConfigRuntimeException.class , () -> MethodHelper.invokeGetter( list , "notExists" ) ); + Assertions.assertThrows( ConfigRuntimeException.class , () -> MethodHelper.invokeGetter( list , "notExists" ) ); } } diff --git a/fj-core/src/test/java/test/org/fugerit/java/core/lang/helpers/reflect/TestPathHelper.java b/fj-core/src/test/java/test/org/fugerit/java/core/lang/helpers/reflect/TestPathHelper.java index 16417ca6..55355dfd 100644 --- a/fj-core/src/test/java/test/org/fugerit/java/core/lang/helpers/reflect/TestPathHelper.java +++ b/fj-core/src/test/java/test/org/fugerit/java/core/lang/helpers/reflect/TestPathHelper.java @@ -1,15 +1,15 @@ package test.org.fugerit.java.core.lang.helpers.reflect; -import static org.junit.Assert.fail; +import static org.junit.jupiter.api.Assertions.fail; import java.math.BigDecimal; import org.fugerit.java.core.lang.helpers.reflect.PathHelper; -import org.junit.Test; +import org.junit.jupiter.api.Test; import test.org.fugerit.java.BasicTest; -public class TestPathHelper extends BasicTest { +class TestPathHelper extends BasicTest { private static final int EXPECTED_RESULT_EXCEPTION = 1; private static final int EXPECTED_RESULT_NULL = 2; @@ -51,42 +51,42 @@ private void testLookupWorker( Object target, String path, boolean useMethodLook } @Test - public void test001_A() { + void test001_A() { testLookupWorker( TEST_CASE_001 , "kid.idTwo", false, PathHelper.CONTINUE_ON_NULL, EXPECTED_RESULT_VALUE ); } @Test - public void test001_B() { + void test001_B() { testLookupWorker( TEST_CASE_001 , "getKid.getIdTwo", true, PathHelper.CONTINUE_ON_NULL, EXPECTED_RESULT_VALUE ); } @Test - public void test002_A() { + void test002_A() { testLookupWorker( TEST_CASE_002 , "kid.idTwo", false, PathHelper.CONTINUE_ON_NULL, EXPECTED_RESULT_EXCEPTION ); } @Test - public void test002_B() { + void test002_B() { testLookupWorker( TEST_CASE_002 , "kid", false, PathHelper.CONTINUE_ON_NULL, EXPECTED_RESULT_NULL ); } @Test - public void test002_C() { + void test002_C() { testLookupWorker( TEST_CASE_002 , "kid.idTwo", false, PathHelper.EXIT_ON_NULL, EXPECTED_RESULT_NULL ); } @Test - public void test002_D() { + void test002_D() { testLookupWorker( TEST_CASE_002 , "kidTest", false, PathHelper.EXIT_ON_NULL, EXPECTED_RESULT_EXCEPTION ); } @Test - public void test003_A() { + void test003_A() { testLookupWorker( TEST_CASE_003 , "kid.idTwo", false, PathHelper.CONTINUE_ON_NULL, EXPECTED_RESULT_EXCEPTION ); } @Test - public void test003_B() { + void test003_B() { testLookupWorker( TEST_CASE_003 , "kid.idTwo", false, PathHelper.EXIT_ON_NULL, EXPECTED_RESULT_NULL ); } diff --git a/fj-core/src/test/java/test/org/fugerit/java/core/lang/helpers/reflect/TestPathHelperBind.java b/fj-core/src/test/java/test/org/fugerit/java/core/lang/helpers/reflect/TestPathHelperBind.java index bd64d6b8..61a8183b 100644 --- a/fj-core/src/test/java/test/org/fugerit/java/core/lang/helpers/reflect/TestPathHelperBind.java +++ b/fj-core/src/test/java/test/org/fugerit/java/core/lang/helpers/reflect/TestPathHelperBind.java @@ -1,18 +1,18 @@ package test.org.fugerit.java.core.lang.helpers.reflect; -import static org.junit.Assert.fail; +import static org.junit.jupiter.api.Assertions.fail; import java.math.BigDecimal; import org.fugerit.java.core.lang.helpers.reflect.PathHelper; -import org.junit.Test; +import org.junit.jupiter.api.Test; import test.org.fugerit.java.BasicTest; -public class TestPathHelperBind extends BasicTest { +class TestPathHelperBind extends BasicTest { @Test - public void bind001() { + void bind001() { try { long testIdTwo = 2; long testIdTwoBind = 3; diff --git a/fj-core/src/test/java/test/org/fugerit/java/core/log/TestLogUtils.java b/fj-core/src/test/java/test/org/fugerit/java/core/log/TestLogUtils.java index f30c7c79..82833fe9 100644 --- a/fj-core/src/test/java/test/org/fugerit/java/core/log/TestLogUtils.java +++ b/fj-core/src/test/java/test/org/fugerit/java/core/log/TestLogUtils.java @@ -7,33 +7,33 @@ import org.fugerit.java.core.log.LogFacade; import org.fugerit.java.core.log.LogObject; import org.fugerit.java.core.log.LogUtils; -import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; import lombok.extern.slf4j.Slf4j; import test.org.fugerit.java.helpers.FailHelper; @Slf4j -public class TestLogUtils { +class TestLogUtils { @Test - public void testLogUtilsBuild() { + void testLogUtilsBuild() { StringBuilder builder = new StringBuilder(); LogUtils.appendPropDefault(builder, "key", "value" ); log.info( "result {}", builder ); - Assert.assertEquals( "key=value" , builder.toString() ); + Assertions.assertEquals( "key=value" , builder.toString() ); } @Test - public void testLogUtilsAppendable() { + void testLogUtilsAppendable() { Appendable builder = new StringBuilder(); LogUtils.appendPropDefault(builder, "key", "value" ); log.info( "result {}", builder ); - Assert.assertEquals( "key=value" , builder.toString() ); + Assertions.assertEquals( "key=value" , builder.toString() ); } @Test - public void testLogUtilsAppendableFail() { + void testLogUtilsAppendableFail() { Appendable builder = new Appendable() { @Override public Appendable append(CharSequence csq, int start, int end) throws IOException { @@ -53,31 +53,31 @@ public Appendable append(CharSequence csq) throws IOException { return null; } }; - Assert.assertThrows( ConfigRuntimeException.class , () -> LogUtils.appendProp(builder, "key", "value", ",", "test_") ); + Assertions.assertThrows( ConfigRuntimeException.class , () -> LogUtils.appendProp(builder, "key", "value", ",", "test_") ); } @Test - public void testWrap() { + void testWrap() { LogObject obj = LogUtils.wrap( log ); obj.getLogger().info( "wrap ok!" ); - Assert.assertNotNull( obj ); + Assertions.assertNotNull( obj ); } @Test - public void testBasicLogObject() { + void testBasicLogObject() { LogObject obj = new BasicLogObject(); obj.getLogger().info( "BasicLogObject OK!" ); - Assert.assertNotNull( obj ); + Assertions.assertNotNull( obj ); } @Test - public void testLogFacade() { + void testLogFacade() { LogFacade.getLog().info( "LogFacade OK!" ); LogFacade.handleWarn( new IOException( "a" ) ); LogFacade.handleError( new IOException( "b" ) ); LogFacade.handleWarn( log, new IOException( "c" ) ); LogFacade.handleError( log, new IOException( "d" ) ); - Assert.assertNotNull( LogFacade.newLogger( new TestLogUtils() ) ); + Assertions.assertNotNull( LogFacade.newLogger( new TestLogUtils() ) ); } } diff --git a/fj-core/src/test/java/test/org/fugerit/java/core/util/TestBinaryCalc.java b/fj-core/src/test/java/test/org/fugerit/java/core/util/TestBinaryCalc.java index 96c0cdb0..8cb5baf3 100644 --- a/fj-core/src/test/java/test/org/fugerit/java/core/util/TestBinaryCalc.java +++ b/fj-core/src/test/java/test/org/fugerit/java/core/util/TestBinaryCalc.java @@ -1,37 +1,37 @@ package test.org.fugerit.java.core.util; -import static org.junit.Assert.assertEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; import org.fugerit.java.core.util.BinaryCalc; -import org.junit.Test; +import org.junit.jupiter.api.Test; import test.org.fugerit.java.BasicTest; -public class TestBinaryCalc extends BasicTest { +class TestBinaryCalc extends BasicTest { @Test - public void hexToLongFF() { + void hexToLongFF() { long res = BinaryCalc.hexToLong( "FF" ); logger.info( "TEST hex 1 : {}", res ); assertEquals( 255L , res ); } @Test - public void hexToLongF() { + void hexToLongF() { long res = BinaryCalc.hexToLong( "F" ); logger.info( "TEST hex 2 : {}", res ); assertEquals( 15L , res ); } @Test - public void hexToLong7BB() { + void hexToLong7BB() { long res = BinaryCalc.hexToLong( "7BB" ); logger.info( "TEST hex 3 : {}", res ); assertEquals( 1979L , res ); } @Test - public void octToLong255() { + void octToLong255() { long res = BinaryCalc.octToLong( "377" ); logger.info( "TEST oct 1 : {}", res ); assertEquals( 255L , res ); @@ -39,35 +39,35 @@ public void octToLong255() { @Test - public void binToLong55() { + void binToLong55() { long res = BinaryCalc.binToLong( "11111111" ); logger.info( "TEST bin 1 : {}", res ); assertEquals( 255L , res ); } @Test - public void longToHex255() { + void longToHex255() { String res = BinaryCalc.longToHex( 255 ); logger.info( "TEST long 1 : {}", res ); assertEquals( "FF" , res ); } @Test - public void longToOct255() { + void longToOct255() { String res = BinaryCalc.longToOct( 255 ); logger.info( "TEST long 2 : {}", res ); assertEquals( "377" , res ); } @Test - public void longToBin255() { + void longToBin255() { String res = BinaryCalc.longToBin( 255 ); logger.info( "TEST long 3 : {}", res ); assertEquals( "11111111" , res ); } @Test - public void longToHex43133() { + void longToHex43133() { String res = BinaryCalc.longToHex( 43133 ); logger.info( "TEST long 4 : {}", res ); assertEquals( "A87D" , res ); diff --git a/fj-core/src/test/java/test/org/fugerit/java/core/util/TestIteratorHelper.java b/fj-core/src/test/java/test/org/fugerit/java/core/util/TestIteratorHelper.java index 3caf3efe..0f8ff3af 100644 --- a/fj-core/src/test/java/test/org/fugerit/java/core/util/TestIteratorHelper.java +++ b/fj-core/src/test/java/test/org/fugerit/java/core/util/TestIteratorHelper.java @@ -7,16 +7,16 @@ import java.util.NoSuchElementException; import org.fugerit.java.core.util.IteratorHelper; -import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; import lombok.extern.slf4j.Slf4j; @Slf4j -public class TestIteratorHelper { +class TestIteratorHelper { @Test - public void testSafeIterator() { + void testSafeIterator() { List list = new ArrayList( Arrays.asList( "1", "2", "3" ) ); // creates test list Iterator it = list.iterator(); // test iterator 1 @@ -25,14 +25,14 @@ public void testSafeIterator() { String current = myIt.next(); log.info( "current : {}", current ); } - Assert.assertThrows( NoSuchElementException.class , myIt::next ); + Assertions.assertThrows( NoSuchElementException.class , myIt::next ); // test iterator 2 Iterator it2 = list.iterator(); Iterator myIt2 = IteratorHelper.createSimpleIterator(it2::hasNext, it2::next); if ( myIt2.hasNext() ) { String current = myIt2.next(); log.info( "current : {}", current ); - Assert.assertThrows( UnsupportedOperationException.class , myIt2::remove ); + Assertions.assertThrows( UnsupportedOperationException.class , myIt2::remove ); } // test iterator 3 Iterator it3 = list.iterator(); diff --git a/fj-core/src/test/java/test/org/fugerit/java/core/util/TestPropsUtils.java b/fj-core/src/test/java/test/org/fugerit/java/core/util/TestPropsUtils.java index 268e502f..7c7800d9 100644 --- a/fj-core/src/test/java/test/org/fugerit/java/core/util/TestPropsUtils.java +++ b/fj-core/src/test/java/test/org/fugerit/java/core/util/TestPropsUtils.java @@ -3,8 +3,8 @@ import lombok.extern.slf4j.Slf4j; import org.fugerit.java.core.util.CheckDuplicationProperties; import org.fugerit.java.core.util.PropsUtils; -import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; import test.org.fugerit.java.BasicTest; import java.io.IOException; @@ -13,75 +13,75 @@ import java.util.stream.Collectors; @Slf4j -public class TestPropsUtils extends BasicTest { +class TestPropsUtils extends BasicTest { @Test - public void testDuplicatedCustom() throws IOException { + void testDuplicatedCustom() throws IOException { CheckDuplicationProperties props = PropsUtils.findDuplicatedKeys( "file://src/main/resources/core/util/props_utils/duplicated_custom.properties" ); Collection> duplicated = props.getDuplications(); log.info( "duplicated count : {}, keys : {}", duplicated.size(), duplicated.stream().map( e -> e.getKey() ).collect( Collectors.toSet() ) ); - Assert.assertNotNull( duplicated ); + Assertions.assertNotNull( duplicated ); CheckDuplicationProperties obj = (CheckDuplicationProperties) this.fullSerializationTest( props ); - Assert.assertNotNull( obj ); - Assert.assertEquals( props, obj ); - Assert.assertEquals( props.hashCode(), obj.hashCode() ); + Assertions.assertNotNull( obj ); + Assertions.assertEquals( props, obj ); + Assertions.assertEquals( props.hashCode(), obj.hashCode() ); log.info( "equals : {}", props.equals( obj ) ); } @Test - public void testDuplicated1File() throws IOException { + void testDuplicated1File() throws IOException { Collection> duplicated = PropsUtils.findDuplicatedKeys( "file://src/main/resources/core/util/props_utils/duplicated_1.properties" ).getDuplications(); log.info( "test duplicated on property file : {}", duplicated ); - Assert.assertEquals( 1, duplicated.size() ); + Assertions.assertEquals( 1, duplicated.size() ); } @Test - public void testDuplicated1Col() throws IOException { + void testDuplicated1Col() throws IOException { Collection> duplicated = PropsUtils.findDuplicatedKeys( "cl://core/util/props_utils/duplicated_1.properties" ).getDuplications(); log.info( "test duplicated on property from class loader : {}", duplicated ); - Assert.assertEquals( 1, duplicated.size() ); + Assertions.assertEquals( 1, duplicated.size() ); } @Test - public void testDuplicated0File() throws IOException { + void testDuplicated0File() throws IOException { Collection> duplicated = PropsUtils.findDuplicatedKeys( "file://src/main/resources/core/util/props_utils/duplicated_0.properties" ).getDuplications(); log.info( "test no duplicated on property file : {}", duplicated ); - Assert.assertEquals( 0, duplicated.size() ); + Assertions.assertEquals( 0, duplicated.size() ); } @Test - public void testDuplicated0Col() throws IOException { + void testDuplicated0Col() throws IOException { Collection> duplicated = PropsUtils.findDuplicatedKeys( "cl://core/util/props_utils/duplicated_0.properties" ).getDuplications(); log.info( "test no duplicated on property from class loader : {}", duplicated ); - Assert.assertEquals( 0, duplicated.size() ); + Assertions.assertEquals( 0, duplicated.size() ); } @Test - public void testDuplicated1FileXml() throws IOException { + void testDuplicated1FileXml() throws IOException { Collection> duplicated = PropsUtils.findDuplicatedKeysFromXml( "file://src/main/resources/core/util/props_utils/duplicated_1.xml" ).getDuplications(); log.info( "test xml duplicated on property file : {}", duplicated ); - Assert.assertEquals( 1, duplicated.size() ); + Assertions.assertEquals( 1, duplicated.size() ); } @Test - public void testDuplicated1ColXml() throws IOException { + void testDuplicated1ColXml() throws IOException { Collection> duplicated = PropsUtils.findDuplicatedKeysFromXml( "cl://core/util/props_utils/duplicated_1.xml" ).getDuplications(); log.info( "test xml duplicated on property from class loader : {}", duplicated ); - Assert.assertEquals( 1, duplicated.size() ); + Assertions.assertEquals( 1, duplicated.size() ); } @Test - public void testDuplicated0FileXml() throws IOException { + void testDuplicated0FileXml() throws IOException { Collection> duplicated = PropsUtils.findDuplicatedKeysFromXml( "file://src/main/resources/core/util/props_utils/duplicated_0.xml" ).getDuplications(); log.info( "test xml no duplicated on property file : {}", duplicated ); - Assert.assertEquals( 0, duplicated.size() ); + Assertions.assertEquals( 0, duplicated.size() ); } @Test - public void testDuplicated0ColXml() throws IOException { + void testDuplicated0ColXml() throws IOException { Collection> duplicated = PropsUtils.findDuplicatedKeysFromXml( "cl://core/util/props_utils/duplicated_0.xml" ).getDuplications(); log.info( "test xml no duplicated on property from class loader : {}", duplicated ); - Assert.assertEquals( 0, duplicated.size() ); + Assertions.assertEquals( 0, duplicated.size() ); } } diff --git a/fj-core/src/test/java/test/org/fugerit/java/core/util/TesterPropsIO.java b/fj-core/src/test/java/test/org/fugerit/java/core/util/TesterPropsIO.java index 34808f55..6136f16a 100644 --- a/fj-core/src/test/java/test/org/fugerit/java/core/util/TesterPropsIO.java +++ b/fj-core/src/test/java/test/org/fugerit/java/core/util/TesterPropsIO.java @@ -1,18 +1,18 @@ package test.org.fugerit.java.core.util; -import static org.junit.Assert.fail; +import static org.junit.jupiter.api.Assertions.fail; import java.util.Properties; import org.fugerit.java.core.util.PropsIO; -import org.junit.Test; +import org.junit.jupiter.api.Test; -public class TesterPropsIO { +class TesterPropsIO { public static final String PROP_TEST_KEY = "TestPropKey1"; @Test - public void testReadFromClassLoader() { + void testReadFromClassLoader() { try { Properties props = PropsIO.loadFromClassLoader( "core/util/test-props.io.properties" ); String testValue = props.getProperty( PROP_TEST_KEY ); diff --git a/fj-core/src/test/java/test/org/fugerit/java/core/util/TesterPropsIOSubProps.java b/fj-core/src/test/java/test/org/fugerit/java/core/util/TesterPropsIOSubProps.java index 23697998..8185586c 100644 --- a/fj-core/src/test/java/test/org/fugerit/java/core/util/TesterPropsIOSubProps.java +++ b/fj-core/src/test/java/test/org/fugerit/java/core/util/TesterPropsIOSubProps.java @@ -1,16 +1,16 @@ package test.org.fugerit.java.core.util; -import static org.junit.Assert.fail; +import static org.junit.jupiter.api.Assertions.fail; import java.util.Properties; import org.fugerit.java.core.util.PropsIO; -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; -public class TesterPropsIOSubProps { +class TesterPropsIOSubProps { public static final String PROP_TEST_KEY = "TestPropKey1"; @@ -19,13 +19,13 @@ public class TesterPropsIOSubProps { private static final long EXPECTED_SUB_PROPS_SIZE = 2; @Test - public void testReadFromClassLoader() { + void testReadFromClassLoader() { try { Properties props = PropsIO.loadFromClassLoader( "core/util/test-props-io-prefix.properties" ); logger.info( "full props -> {}", props ); Properties subProps = PropsIO.subProps( props , "prefix1", "-", true ); logger.info( "sub props -> {}", subProps ); - Assert.assertEquals( "Correct sub props size", EXPECTED_SUB_PROPS_SIZE, subProps.size() ); + Assertions.assertEquals( EXPECTED_SUB_PROPS_SIZE, subProps.size(), () -> "Correct sub props size" ); } catch (Exception e) { e.printStackTrace(); fail( "Error : "+e.getMessage() ); diff --git a/fj-core/src/test/java/test/org/fugerit/java/core/util/checkpoint/TestCheckpoints.java b/fj-core/src/test/java/test/org/fugerit/java/core/util/checkpoint/TestCheckpoints.java index 6fe93a05..d0cd8fef 100644 --- a/fj-core/src/test/java/test/org/fugerit/java/core/util/checkpoint/TestCheckpoints.java +++ b/fj-core/src/test/java/test/org/fugerit/java/core/util/checkpoint/TestCheckpoints.java @@ -1,16 +1,16 @@ package test.org.fugerit.java.core.util.checkpoint; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertTrue; import java.time.Duration; import org.awaitility.Awaitility; import org.fugerit.java.core.util.checkpoint.Checkpoints; -import org.junit.Test; +import org.junit.jupiter.api.Test; import test.org.fugerit.java.BasicTest; -public class TestCheckpoints extends BasicTest { +class TestCheckpoints extends BasicTest { private Checkpoints generate( int size ) { Checkpoints cp = Checkpoints.newInstance(); @@ -22,14 +22,14 @@ private Checkpoints generate( int size ) { } @Test - public void testPrintInfo() { + void testPrintInfo() { Checkpoints cp = this.generate( 4 ); assertTrue( ( cp != null ) ); cp.printInfo(); } @Test - public void testPrettyPrintInfo() { + void testPrettyPrintInfo() { Checkpoints cp = this.generate( 4 ); assertTrue( ( cp != null ) ); cp.prettyPrintInfo(); diff --git a/fj-core/src/test/java/test/org/fugerit/java/core/util/checkpoint/TestSimpleCheckpoint.java b/fj-core/src/test/java/test/org/fugerit/java/core/util/checkpoint/TestSimpleCheckpoint.java index 1a2cffbd..a3cfaa10 100644 --- a/fj-core/src/test/java/test/org/fugerit/java/core/util/checkpoint/TestSimpleCheckpoint.java +++ b/fj-core/src/test/java/test/org/fugerit/java/core/util/checkpoint/TestSimpleCheckpoint.java @@ -2,13 +2,13 @@ import lombok.extern.slf4j.Slf4j; import org.fugerit.java.core.util.checkpoint.SimpleCheckpoint; -import org.junit.Test; +import org.junit.jupiter.api.Test; @Slf4j -public class TestSimpleCheckpoint { +class TestSimpleCheckpoint { @Test - public void testCheckpoint() { + void testCheckpoint() { SimpleCheckpoint checkpoint = new SimpleCheckpoint(); log.info( "testCheckpoint 1 {}ms", checkpoint.getDiffMillis() ); log.info( "testCheckpoint 2 {}ms", checkpoint.getFormatTimeDiffMillis() ); diff --git a/fj-core/src/test/java/test/org/fugerit/java/core/util/colletion/TestSortedReadProperties.java b/fj-core/src/test/java/test/org/fugerit/java/core/util/colletion/TestSortedReadProperties.java index ad7bbf16..d5e0fca5 100644 --- a/fj-core/src/test/java/test/org/fugerit/java/core/util/colletion/TestSortedReadProperties.java +++ b/fj-core/src/test/java/test/org/fugerit/java/core/util/colletion/TestSortedReadProperties.java @@ -1,6 +1,6 @@ package test.org.fugerit.java.core.util.colletion; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertTrue; import java.io.File; import java.io.FileOutputStream; @@ -11,18 +11,18 @@ import org.fugerit.java.core.cfg.ConfigRuntimeException; import org.fugerit.java.core.lang.helpers.ClassHelper; import org.fugerit.java.core.util.collection.SortedProperties; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import test.org.fugerit.java.BasicTest; -public class TestSortedReadProperties extends BasicTest { +class TestSortedReadProperties extends BasicTest { private static final Logger logger = LoggerFactory.getLogger( TestSortedReadProperties.class ); @Test - public void test1() { + void test1() { boolean ok = false; try ( InputStream is = ClassHelper.loadFromDefaultClassLoader( "core/util/collection/test_store_1.properties" ); FileOutputStream fos = new FileOutputStream( new File( "target/test_sorted_properties.properties" ) ) ) { diff --git a/fj-core/src/test/java/test/org/fugerit/java/core/util/filterchain/TestDuplicateFailOnSet.java b/fj-core/src/test/java/test/org/fugerit/java/core/util/filterchain/TestDuplicateFailOnSet.java index 6fe692f5..11e083cb 100644 --- a/fj-core/src/test/java/test/org/fugerit/java/core/util/filterchain/TestDuplicateFailOnSet.java +++ b/fj-core/src/test/java/test/org/fugerit/java/core/util/filterchain/TestDuplicateFailOnSet.java @@ -1,21 +1,21 @@ package test.org.fugerit.java.core.util.filterchain; -import static org.junit.Assert.fail; +import static org.junit.jupiter.api.Assertions.fail; import org.fugerit.java.core.util.filterchain.MiniFilterConfig; import org.fugerit.java.core.util.filterchain.MiniFilterMap; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -public class TestDuplicateFailOnSet { +class TestDuplicateFailOnSet { private static final Logger logger = LoggerFactory.getLogger( TestDuplicateFailOnSet.class ); private static final String CONF_PATH_DUPLICATE_FAIL_ON_SET = "core/util/filterchain/minifilter-test-duplicate-fail-on-set.xml"; @Test - public void testDuplicate() { + void testDuplicate() { logger.info( "**********************************************" ); logger.info( "**********************************************" ); logger.info( "* TEST DUPLICATE *" ); diff --git a/fj-core/src/test/java/test/org/fugerit/java/core/util/filterchain/TestMiniFilter.java b/fj-core/src/test/java/test/org/fugerit/java/core/util/filterchain/TestMiniFilter.java index 0a1c514e..9a52986f 100644 --- a/fj-core/src/test/java/test/org/fugerit/java/core/util/filterchain/TestMiniFilter.java +++ b/fj-core/src/test/java/test/org/fugerit/java/core/util/filterchain/TestMiniFilter.java @@ -1,7 +1,7 @@ package test.org.fugerit.java.core.util.filterchain; -import static org.junit.Assert.assertTrue; -import static org.junit.Assert.fail; +import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.junit.jupiter.api.Assertions.fail; import java.io.IOException; import java.io.InputStream; @@ -16,14 +16,14 @@ import org.fugerit.java.core.util.filterchain.MiniFilterData; import org.fugerit.java.core.util.filterchain.MiniFilterDebug; import org.fugerit.java.core.util.filterchain.MiniFilterMap; -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; import test.org.fugerit.java.BasicTest; -public class TestMiniFilter extends BasicTest { +class TestMiniFilter extends BasicTest { private static final Logger logger = LoggerFactory.getLogger( TestMiniFilter.class ); @@ -65,47 +65,47 @@ public void testWorker( MiniFilterConfig config, String chainId, boolean okOnExc } @Test - public void testChainBaseContinue() { + void testChainBaseContinue() { this.testWorker( "chain-base-continue" ); } @Test - public void testChainBaseSkip() { + void testChainBaseSkip() { this.testWorker( "chain-base-skip" ); } @Test - public void testChainBaseAll() { + void testChainBaseAll() { this.testWorker( "chain-base-all" ); } @Test - public void testChainBaseNotFound() { + void testChainBaseNotFound() { this.testWorker( "chain-base-notfound", true ); } @Test - public void testChainBaseLoadSafe00() { + void testChainBaseLoadSafe00() { this.testWorker( "chain-base-loadsafe-00" ); } @Test - public void testChainBaseLoadSafe01() { + void testChainBaseLoadSafe01() { this.testWorker( "chain-base-loadsafe-01" ); } @Test - public void testChainModule01() { + void testChainModule01() { this.testWorker( "chain-module01-test-01" ); } @Test - public void testChainModule02() { + void testChainModule02() { this.testWorker( "chain-module02-test-01" ); } @Test - public void testSerialization() { + void testSerialization() { try { MiniFilterConfig deserializedValue = (MiniFilterConfig) this.fullSerializationTest(CONFIG); this.testWorker( deserializedValue, "chain-module01-test-01", false ); @@ -115,32 +115,32 @@ public void testSerialization() { } @Test - public void testLoadMap() { + void testLoadMap() { runTestEx( () -> { try ( InputStream is = ClassHelper.loadFromDefaultClassLoader(CONF_PATH) ) { MiniFilterConfig config = new MiniFilterConfig(); MiniFilterMap map = MiniFilterConfig.loadConfigMap( is , config ); - Assert.assertNotNull( map ); + Assertions.assertNotNull( map ); } } ); } @Test - public void testDebug() { + void testDebug() { runTestEx( () -> { try ( InputStream is = ClassHelper.loadFromDefaultClassLoader(CONF_PATH); StringWriter buffer = new StringWriter(); PrintWriter writer = new PrintWriter(buffer)) { MiniFilterDebug.dumpConfig( writer , is ); String debugText = buffer.toString(); - Assert.assertNotEquals( 0 , debugText.length() ); + Assertions.assertNotEquals( 0 , debugText.length() ); logger.info( "debug {}", debugText ); } } ); } @Test - public void testPrintConfig() { + void testPrintConfig() { logger.info( "**********************************************" ); logger.info( "**********************************************" ); Iterator it = CONFIG.getIdSet().iterator(); @@ -155,7 +155,7 @@ public void testPrintConfig() { } @Test - public void testDuplicate() { + void testDuplicate() { logger.info( "**********************************************" ); logger.info( "**********************************************" ); logger.info( "* TEST DUPLICATE *" ); diff --git a/fj-core/src/test/java/test/org/fugerit/java/core/util/fun/helper/TestFormatTime.java b/fj-core/src/test/java/test/org/fugerit/java/core/util/fun/helper/TestFormatTime.java index 4125965b..800b9c5a 100644 --- a/fj-core/src/test/java/test/org/fugerit/java/core/util/fun/helper/TestFormatTime.java +++ b/fj-core/src/test/java/test/org/fugerit/java/core/util/fun/helper/TestFormatTime.java @@ -3,13 +3,13 @@ import org.fugerit.java.core.util.fun.StringFormat; import org.fugerit.java.core.util.fun.helper.FormatTime; import org.fugerit.java.core.util.fun.helper.MillisToSecondsFormat; -import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; import lombok.extern.slf4j.Slf4j; @Slf4j -public class TestFormatTime { +class TestFormatTime { private String worker( StringFormat format ) { String res = format.convert( 1000 ); @@ -18,23 +18,23 @@ private String worker( StringFormat format ) { } @Test - public void test1() { + void test1() { MillisToSecondsFormat format = new MillisToSecondsFormat(); log.info( "getAppend() : {}", format.getAppend() ); - Assert.assertEquals( "1.000" , this.worker(format) ); + Assertions.assertEquals( "1.000" , this.worker(format) ); } @Test - public void test2() { + void test2() { MillisToSecondsFormat format = new MillisToSecondsFormat( "s" ); log.info( "getAppend() : {}", format.getAppend() ); - Assert.assertEquals( "1.000s" , this.worker(format) ); + Assertions.assertEquals( "1.000s" , this.worker(format) ); } @Test - public void test3() { + void test3() { FormatTime format = new FormatTime( "yyyy-MM-dd" ); - Assert.assertEquals( "1970-01-01" , this.worker( format ) ); + Assertions.assertEquals( "1970-01-01" , this.worker( format ) ); } } diff --git a/fj-core/src/test/java/test/org/fugerit/java/core/util/i18n/TestHelperI18N.java b/fj-core/src/test/java/test/org/fugerit/java/core/util/i18n/TestHelperI18N.java index 7e4c5af0..738c3beb 100644 --- a/fj-core/src/test/java/test/org/fugerit/java/core/util/i18n/TestHelperI18N.java +++ b/fj-core/src/test/java/test/org/fugerit/java/core/util/i18n/TestHelperI18N.java @@ -3,13 +3,13 @@ import org.fugerit.java.core.util.i18n.BundleMapI18N; import org.fugerit.java.core.util.i18n.HelperI18N; import org.fugerit.java.core.util.i18n.ParamI18N; -import org.junit.Assert; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -public class TestHelperI18N { +class TestHelperI18N { public static final String LANG_EN = "en"; @@ -24,63 +24,67 @@ public class TestHelperI18N { private static final String CONF_PATH = "core.util.i18n.test"; private static final String CONF_PATH_PARAM = "core.util.i18n.param"; - + private HelperI18N helper; - + private HelperI18N helperParam; - - @Before - public void init() { + @BeforeEach + void init() { this.helper = BundleMapI18N.newHelperI18N( CONF_PATH, LANG_DEF, LANG_ALT ); this.helperParam = BundleMapI18N.newHelperI18N( CONF_PATH_PARAM, LANG_DEF, LANG_ALT ); } - + private void testHelper( String expectedValue, String lang, String key, Object... params ) { String value = this.helper.getString( lang , key, params ); logger.info( "key:{} , lang:{} -> {}", lang, key, value ); - Assert.assertEquals( "Value different for key : "+key+", lang : "+lang , expectedValue, value ); + Assertions.assertEquals( expectedValue, value, "Value different for key : "+key+", lang : "+lang ); } @Test - public void testSimpleProperty1() { + void testSimpleProperty1() { String key = "test.prop.1"; // test.prop.1 is available for both languages this.testHelper( "Test property 1", LANG_DEF, key ); this.testHelper( "Proprietà test 1", LANG_ALT[0], key ); + Assertions.assertTrue( Boolean.TRUE ); } @Test - public void testSimpleProperty2() { + void testSimpleProperty2() { String key = "test.prop.2"; // test.prop.2 is available only for default language this.testHelper( "Test property 2", LANG_DEF, key ); this.testHelper( "Test property 2", LANG_ALT[0], key ); + Assertions.assertTrue( Boolean.TRUE ); } @Test - public void testSimpleProperty3() { + void testSimpleProperty3() { String key = "test.prop.3"; // test.prop.3 is available only for default language this.testHelper( null, LANG_DEF, key ); this.testHelper( "Proprietà test 3", LANG_ALT[0], key ); + Assertions.assertTrue( Boolean.TRUE ); } @Test - public void testComplexProperty1() { + void testComplexProperty1() { String key = "test.complex.prop.1"; // contains a integer param and a i18n param String keyParam = "test.param.1"; // the key for the i18n param this.testHelper( "Complex property 1 -> simple parameter : 3 and i18n parameter : (ParamI18N value)", LANG_DEF, key, Integer.valueOf( 3 ), ParamI18N.newParamI18N( keyParam ) ); this.testHelper( "Proprietà complessa test 1 -> parametro semplice : 3 e parametro i18n : (valore ParamI18N)", LANG_ALT[0], key, Integer.valueOf( 3 ), ParamI18N.newParamI18N( keyParam ) ); + Assertions.assertTrue( Boolean.TRUE ); } @Test - public void testComplexProperty1Alt() { + void testComplexProperty1Alt() { String key = "test.complex.prop.1"; // contains a integer param and a i18n param String keyParam = "test.param.1.alt"; // the key for the i18n param this.testHelper( "Complex property 1 -> simple parameter : 3 and i18n parameter : (ParamI18N value alternative bundle)", LANG_DEF, key, Integer.valueOf( 3 ), ParamI18N.newParamI18N( keyParam, this.helperParam ) ); this.testHelper( "Proprietà complessa test 1 -> parametro semplice : 3 e parametro i18n : (valore ParamI18N bundle alternativo)", LANG_ALT[0], key, Integer.valueOf( 3 ), ParamI18N.newParamI18N( keyParam, this.helperParam ) ); + Assertions.assertTrue( Boolean.TRUE ); } } diff --git a/fj-core/src/test/java/test/org/fugerit/java/core/util/mvn/TestMavenProps.java b/fj-core/src/test/java/test/org/fugerit/java/core/util/mvn/TestMavenProps.java index 1ae4c068..e6916403 100644 --- a/fj-core/src/test/java/test/org/fugerit/java/core/util/mvn/TestMavenProps.java +++ b/fj-core/src/test/java/test/org/fugerit/java/core/util/mvn/TestMavenProps.java @@ -1,26 +1,26 @@ package test.org.fugerit.java.core.util.mvn; import org.fugerit.java.core.util.mvn.MavenProps; -import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; import lombok.extern.slf4j.Slf4j; @Slf4j -public class TestMavenProps { +class TestMavenProps { @Test - public void testMavenOk() { + void testMavenOk() { String prop = MavenProps.getPropery( "org.fugerit.java", "fj-core", "artifactId" ); log.info( "version {}", prop ); - Assert.assertEquals( "fj-core" , prop ); + Assertions.assertEquals( "fj-core" , prop ); } @Test - public void testMavenKo() { + void testMavenKo() { String prop = MavenProps.getPropery( "org.fugerit.java.no.exists", "fj-core", "artifactId" ); log.info( "version {}", prop ); - Assert.assertNull( prop ); + Assertions.assertNull( prop ); } } diff --git a/fj-core/src/test/java/test/org/fugerit/java/core/util/result/TestResult.java b/fj-core/src/test/java/test/org/fugerit/java/core/util/result/TestResult.java index b6d32aa0..c4ce5641 100644 --- a/fj-core/src/test/java/test/org/fugerit/java/core/util/result/TestResult.java +++ b/fj-core/src/test/java/test/org/fugerit/java/core/util/result/TestResult.java @@ -12,13 +12,13 @@ import org.fugerit.java.core.util.result.Result; import org.fugerit.java.core.util.result.ResultHelper; import org.fugerit.java.core.util.result.VirtualPageCache; -import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; import lombok.extern.slf4j.Slf4j; @Slf4j -public class TestResult { +class TestResult { private static Integer[] DATA_SET = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 }; @@ -54,26 +54,26 @@ private boolean testResultWorker( Result result ) { } @Test - public void testBasicResult() { + void testBasicResult() { BasicResult result = new BasicResult( Result.RESULT_CODE_OK ); boolean ok = this.testResultWorker(result); - Assert.assertTrue( ok ); + Assertions.assertTrue( ok ); } @Test - public void testPagedResultVirtual() { + void testPagedResultVirtual() { PagedResult result = DefaultPagedResult.newPagedResult( 10, DATA.size(), 0, DATA ); boolean ok = this.testPagedResultWorker(result); - Assert.assertTrue( ok ); + Assertions.assertTrue( ok ); ok = this.testPagedResultWorker( result.getVirtualPage( 0 ) ); - Assert.assertTrue( ok ); + Assertions.assertTrue( ok ); } @Test - public void testPagedResult() { + void testPagedResult() { PagedResult result = DefaultPagedResult.newPagedResult( 3, DATA.size(), 0, DATA, 3, DATA.size(), "test" ); boolean ok = this.testPagedResultWorker(result); - Assert.assertTrue( ok ); + Assertions.assertTrue( ok ); } private int testPagedResultFullWorker( int perPage, List data ) { @@ -92,41 +92,41 @@ private int testPagedResultFullWorker( int perPage, List data ) { } @Test - public void testPagedResultFull3() { + void testPagedResultFull3() { int perPage = 3; int currentPage = this.testPagedResultFullWorker(perPage, DATA); - Assert.assertEquals( 4 , currentPage ); + Assertions.assertEquals( 4 , currentPage ); } @Test - public void testPagedResultFull5() { + void testPagedResultFull5() { int perPage = 5; int currentPage = this.testPagedResultFullWorker(perPage, DATA); - Assert.assertEquals( 2 , currentPage ); + Assertions.assertEquals( 2 , currentPage ); } @Test - public void testPagedResultAlt() { + void testPagedResultAlt() { PagedResult result = DefaultPagedResult.newPagedResult( 3, DATA.size(), 1, DATA ); boolean ok = this.testPagedResultWorker(result); - Assert.assertTrue( ok ); + Assertions.assertTrue( ok ); } @Test - public void testPagedResultKo() { + void testPagedResultKo() { PagedResult result = DefaultPagedResult.newPagedResult( Result.RESULT_CODE_KO ); boolean ok = this.testPagedResultWorker(result); - Assert.assertFalse( ok ); + Assertions.assertFalse( ok ); } @Test - public void testConstants() { - Assert.assertEquals( PagedResult.ELEMENT_COUNT_UNAVAILABLE, Integer.valueOf( -1 ) ); - Assert.assertFalse( AbstractPagedResult.DEFAULT_SUPPORT_VIRTUAL_PAGING ); + void testConstants() { + Assertions.assertEquals( PagedResult.ELEMENT_COUNT_UNAVAILABLE, Integer.valueOf( -1 ) ); + Assertions.assertFalse( AbstractPagedResult.DEFAULT_SUPPORT_VIRTUAL_PAGING ); } @Test - public void testVirtualFinder() { + void testVirtualFinder() { DefaultVirtualFinder finder = new DefaultVirtualFinder( 5, 0, 10, 0, "TEST" ); log.info( "finder.getSearchVirtualKey : {}", finder.getSearchVirtualKey() ); log.info( "finder.getCurrentPage : {}", finder.getCurrentPage() ); @@ -135,35 +135,35 @@ public void testVirtualFinder() { log.info( "finder.getRealPerPage : {}", finder.getRealPerPage() ); log.info( "finder.isVirtualPagingUsed : {}", finder.isVirtualPagingUsed() ); log.info( "finder : {}", finder ); - Assert.assertNotNull( finder ); + Assertions.assertNotNull( finder ); } @Test - public void testVirtualFinderFail() { + void testVirtualFinderFail() { DefaultVirtualFinder finder = new DefaultVirtualFinder( 5, 0 ); log.info( "finder.isVirtualPagingUsed : {}", finder.isVirtualPagingUsed() ); - Assert.assertThrows( UnsupportedOperationException.class , () -> finder.getSearchVirtualKey() ); + Assertions.assertThrows( UnsupportedOperationException.class , () -> finder.getSearchVirtualKey() ); } @Test - public void testVirtualCache() { + void testVirtualCache() { VirtualPageCache cache = new VirtualPageCache<>(); int perPage = 3; int elementCount = DATA.size(); cache.addPageToCache( DefaultPagedResult.newPagedResult( perPage, elementCount, 0, DATA, 3, DATA.size(), "test" ) ); - Assert.assertNotNull( cache.getCachedPage( new DefaultVirtualFinder(perPage, elementCount, 3, DATA.size(), "test" ) ) ); + Assertions.assertNotNull( cache.getCachedPage( new DefaultVirtualFinder(perPage, elementCount, 3, DATA.size(), "test" ) ) ); } @Test - public void testResultHelper() { - Assert.assertEquals( 1 , ResultHelper.createList( "a" ).size() ); + void testResultHelper() { + Assertions.assertEquals( 1 , ResultHelper.createList( "a" ).size() ); } @Test - public void testPageInfo() { + void testPageInfo() { PageInfo info = new PageInfo( 1 , 10 ); - Assert.assertEquals( 1 , info.getNumber() ); - Assert.assertEquals( 10 , info.getSize() ); + Assertions.assertEquals( 1 , info.getNumber() ); + Assertions.assertEquals( 10 , info.getSize() ); } } diff --git a/fj-core/src/test/java/test/org/fugerit/java/core/util/tree/TestTreeConfig.java b/fj-core/src/test/java/test/org/fugerit/java/core/util/tree/TestTreeConfig.java index 8a89a712..f1054494 100644 --- a/fj-core/src/test/java/test/org/fugerit/java/core/util/tree/TestTreeConfig.java +++ b/fj-core/src/test/java/test/org/fugerit/java/core/util/tree/TestTreeConfig.java @@ -7,7 +7,7 @@ import org.fugerit.java.core.util.tree.InheritTreeDecorator; import org.fugerit.java.core.util.tree.TreeConfigKeyStringXML; -public class TestTreeConfig extends TreeConfigKeyStringXML> { +class TestTreeConfig extends TreeConfigKeyStringXML> { /** * diff --git a/fj-core/src/test/java/test/org/fugerit/java/core/util/tree/TestTreeConfigKeyStringXML.java b/fj-core/src/test/java/test/org/fugerit/java/core/util/tree/TestTreeConfigKeyStringXML.java index b0219c2c..7e1b3ba3 100644 --- a/fj-core/src/test/java/test/org/fugerit/java/core/util/tree/TestTreeConfigKeyStringXML.java +++ b/fj-core/src/test/java/test/org/fugerit/java/core/util/tree/TestTreeConfigKeyStringXML.java @@ -1,16 +1,16 @@ package test.org.fugerit.java.core.util.tree; -import static org.junit.Assert.fail; +import static org.junit.jupiter.api.Assertions.fail; import org.fugerit.java.core.cfg.ConfigException; -import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; import lombok.extern.slf4j.Slf4j; import test.org.fugerit.java.BasicTest; @Slf4j -public class TestTreeConfigKeyStringXML extends BasicTest { +class TestTreeConfigKeyStringXML extends BasicTest { private static final String CONF_PATH = "core/util/tree/tree-test.xml"; @@ -27,35 +27,35 @@ private void findWorker( TestTreeConfig config, String key ) { } @Test - public void testConfig() { + void testConfig() { try { TestTreeConfig config = TestTreeConfig.load( CONF_PATH ); this.findWorker( config, "1" ); this.findWorker( config, "3" ); log.info( "tree -> {}", config.getTree() ); - Assert.assertNotNull( config.getTree() ); + Assertions.assertNotNull( config.getTree() ); } catch (Exception e) { this.failEx(e); } } @Test - public void testConfigKo() throws Exception { + void testConfigKo() throws Exception { try { TestTreeConfig config = TestTreeConfig.load( CONF_PATH_KO ); fail( "This code should not be reached : "+config ); } catch (Exception e) { - Assert.assertTrue( e instanceof ConfigException ); + Assertions.assertTrue( e instanceof ConfigException ); } } @Test - public void testConfigMultipleRoot() throws Exception { + void testConfigMultipleRoot() throws Exception { try { TestTreeConfig config = TestTreeConfig.load( CONF_PATH_MULTIPLE_ROOT ); fail( "This code should not be reached : "+config ); } catch (Exception e) { - Assert.assertTrue( e instanceof ConfigException ); + Assertions.assertTrue( e instanceof ConfigException ); } } diff --git a/fj-core/src/test/java/test/org/fugerit/java/core/validator/TestValidatorCatalog.java b/fj-core/src/test/java/test/org/fugerit/java/core/validator/TestValidatorCatalog.java index 12ab0156..c8c47e0b 100644 --- a/fj-core/src/test/java/test/org/fugerit/java/core/validator/TestValidatorCatalog.java +++ b/fj-core/src/test/java/test/org/fugerit/java/core/validator/TestValidatorCatalog.java @@ -1,6 +1,6 @@ package test.org.fugerit.java.core.validator; -import static org.junit.Assert.fail; +import static org.junit.jupiter.api.Assertions.fail; import java.util.Locale; import java.util.Properties; @@ -10,12 +10,12 @@ import org.fugerit.java.core.validator.ValidatorCatalog; import org.fugerit.java.core.validator.ValidatorDate; import org.fugerit.java.core.validator.ValidatorResult; -import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; import test.org.fugerit.java.BasicTest; -public class TestValidatorCatalog extends BasicTest { +class TestValidatorCatalog extends BasicTest { private static final String CONFIG_PATH = "cl://core/validator/validator-catalog-test.xml"; @@ -29,14 +29,14 @@ public class TestValidatorCatalog extends BasicTest { } @Test - public void testSerialization() { + void testSerialization() { try { ValidatorCatalog loadedCatalog = (ValidatorCatalog) this.fullSerializationTest( catalog ); ValidatorResult result = new ValidatorResult(); String label = "test label 1 (valid)"; String value = "test value one"; boolean valid = loadedCatalog.validate( "testRegexValidator" , result, Locale.ENGLISH, label, value, label, new Properties() ); - Assert.assertTrue(valid); + Assertions.assertTrue(valid); } catch (Exception e) { this.failEx(e); } @@ -80,17 +80,17 @@ public void testRegexValidator001( Locale l ) { } @Test - public void testRegexValidator001_EN() { + void testRegexValidator001_EN() { this.testRegexValidator001( Locale.UK ); } @Test - public void testRegexValidator001_IT() { + void testRegexValidator001_IT() { this.testRegexValidator001( Locale.ITALY ); } @Test - public void testNumberValidator001_EN() { + void testNumberValidator001_EN() { Locale l = Locale.UK; ValidatorResult result = new ValidatorResult(); Properties params = new Properties(); @@ -102,7 +102,7 @@ public void testNumberValidator001_EN() { } @Test - public void testNumberValidator001_IT() { + void testNumberValidator001_IT() { Locale l = Locale.ITALY; ValidatorResult result = new ValidatorResult(); Properties params = new Properties(); diff --git a/fj-core/src/test/java/test/org/fugerit/java/core/xml/TestCleanXML.java b/fj-core/src/test/java/test/org/fugerit/java/core/xml/TestCleanXML.java index 1af7c8ea..25171b87 100644 --- a/fj-core/src/test/java/test/org/fugerit/java/core/xml/TestCleanXML.java +++ b/fj-core/src/test/java/test/org/fugerit/java/core/xml/TestCleanXML.java @@ -12,14 +12,14 @@ import org.fugerit.java.core.cfg.ConfigRuntimeException; import org.fugerit.java.core.io.StreamIO; import org.fugerit.java.core.xml.XMLClean; -import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; import lombok.extern.slf4j.Slf4j; import test.org.fugerit.java.helpers.io.ReaderFail; @Slf4j -public class TestCleanXML { +class TestCleanXML { private void copy( File sourceBase, File fileBase ) throws FileNotFoundException, IOException { for ( File current : sourceBase.listFiles( f -> f.isFile() ) ) { @@ -33,7 +33,7 @@ private void copy( File sourceBase, File fileBase ) throws FileNotFoundException } @Test - public void testClean() throws IOException { + void testClean() throws IOException { // prepare test data File sourceBase = new File( "src/test/resources/core/xml/dtd" ); File fileBase = new File( "target/dtd" ); @@ -48,24 +48,24 @@ public void testClean() throws IOException { } @Test - public void testFailClean() throws IOException { + void testFailClean() throws IOException { try ( Reader reader = new ReaderFail(); Writer writer = new StringWriter() ) { - Assert.assertThrows( ConfigRuntimeException.class , () -> XMLClean.cleanStream( reader, writer ) ); + Assertions.assertThrows( ConfigRuntimeException.class , () -> XMLClean.cleanStream( reader, writer ) ); } } @Test - public void testFailFolder() throws IOException { + void testFailFolder() throws IOException { try ( Reader reader = new ReaderFail(); Writer writer = new StringWriter() ) { - Assert.assertThrows( ConfigRuntimeException.class , () -> XMLClean.cleanFolder(null, null) ); + Assertions.assertThrows( ConfigRuntimeException.class , () -> XMLClean.cleanFolder(null, null) ); } } @Test - public void testCleanString() throws IOException { - Assert.assertNotNull( XMLClean.cleanXML( "test" ) ); + void testCleanString() throws IOException { + Assertions.assertNotNull( XMLClean.cleanXML( "test" ) ); } } diff --git a/fj-core/src/test/java/test/org/fugerit/java/core/xml/TestTransformerXML.java b/fj-core/src/test/java/test/org/fugerit/java/core/xml/TestTransformerXML.java index faf72b8e..e09c9f93 100644 --- a/fj-core/src/test/java/test/org/fugerit/java/core/xml/TestTransformerXML.java +++ b/fj-core/src/test/java/test/org/fugerit/java/core/xml/TestTransformerXML.java @@ -12,28 +12,28 @@ import org.fugerit.java.core.lang.helpers.BooleanUtils; import org.fugerit.java.core.xml.TransformerConfig; import org.fugerit.java.core.xml.TransformerXML; -import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; import lombok.extern.slf4j.Slf4j; import test.org.fugerit.java.BasicTest; @Slf4j -public class TestTransformerXML extends BasicTest { +class TestTransformerXML extends BasicTest { private static final String SAMPLE_XLST = ""; private static final String SAMPLE_XLST_FAIL = ""; @Test - public void newSafeTransformerFactory() { + void newSafeTransformerFactory() { TransformerFactory factory = TransformerXML.newSafeTransformerFactory(); log.info( "factory -> {}", factory ); - Assert.assertNotNull( factory ); + Assertions.assertNotNull( factory ); } @Test - public void newSafeTransformerFactoryFail() { + void newSafeTransformerFactoryFail() { boolean ok = false; try { Properties features = new Properties(); @@ -43,20 +43,20 @@ public void newSafeTransformerFactoryFail() { } catch (ConfigRuntimeException e) { ok = true; } - Assert.assertTrue( ok ); + Assertions.assertTrue( ok ); } @Test - public void newSafeTransformerFactoryFeature() { + void newSafeTransformerFactoryFeature() { Properties features = new Properties(); features.setProperty( XMLConstants.FEATURE_SECURE_PROCESSING , BooleanUtils.BOOLEAN_FALSE ); TransformerFactory factory = TransformerXML.newSafeTransformerFactory( features ); log.info( "factory -> {}", factory ); - Assert.assertNotNull( factory ); + Assertions.assertNotNull( factory ); } @Test - public void newTransformer() { + void newTransformer() { boolean ok = false; try { Transformer transformer = TransformerXML.newTransformer(); @@ -65,11 +65,11 @@ public void newTransformer() { } catch (Exception e) { this.failEx(e); } - Assert.assertTrue( ok ); + Assertions.assertTrue( ok ); } @Test - public void newTransformerConfig() { + void newTransformerConfig() { boolean ok = false; try { Transformer transformer = TransformerXML.newTransformerWithConfig( TransformerConfig.newIndentConfig(null) ); @@ -78,11 +78,11 @@ public void newTransformerConfig() { } catch (Exception e) { this.failEx(e); } - Assert.assertTrue( ok ); + Assertions.assertTrue( ok ); } @Test - public void newTransformerSource() { + void newTransformerSource() { boolean ok = false; try ( StringReader reader = new StringReader( SAMPLE_XLST ) ) { Transformer transformer = TransformerXML.newTransformer( new StreamSource( reader ) ); @@ -91,11 +91,11 @@ public void newTransformerSource() { } catch (Exception e) { this.failEx(e); } - Assert.assertTrue( ok ); + Assertions.assertTrue( ok ); } @Test - public void newTransformerSourceFail() { + void newTransformerSourceFail() { boolean ok = false; try ( StringReader reader = new StringReader( SAMPLE_XLST_FAIL ) ) { Transformer transformer = TransformerXML.newTransformer( new StreamSource( reader ) ); @@ -103,7 +103,7 @@ public void newTransformerSourceFail() { } catch (Exception e) { ok = true; } - Assert.assertTrue( ok ); + Assertions.assertTrue( ok ); } } diff --git a/fj-core/src/test/java/test/org/fugerit/java/core/xml/TestXMLEx.java b/fj-core/src/test/java/test/org/fugerit/java/core/xml/TestXMLEx.java index 5fcab3aa..76b5c18a 100644 --- a/fj-core/src/test/java/test/org/fugerit/java/core/xml/TestXMLEx.java +++ b/fj-core/src/test/java/test/org/fugerit/java/core/xml/TestXMLEx.java @@ -3,35 +3,35 @@ import java.io.IOException; import org.fugerit.java.core.xml.XMLException; -import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; import lombok.extern.slf4j.Slf4j; @Slf4j -public class TestXMLEx { +class TestXMLEx { private static final Exception EX_TEST = new IOException( "junit test scenario" ); @Test - public void testCreate() { - Assert.assertNotNull( new XMLException() ); - Assert.assertNotNull( new XMLException( "a" ) ); - Assert.assertNotNull( new XMLException( new IOException( "b" ) ) ); - Assert.assertNotNull( new XMLException( "c", new IOException( "d" ) ) ); + void testCreate() { + Assertions.assertNotNull( new XMLException() ); + Assertions.assertNotNull( new XMLException( "a" ) ); + Assertions.assertNotNull( new XMLException( new IOException( "b" ) ) ); + Assertions.assertNotNull( new XMLException( "c", new IOException( "d" ) ) ); log.info( "test CONVERT_FUN 1 {}", XMLException.CONVERT_FUN ); log.info( "test CONVERT_FUN 2 {}", XMLException.CONVERT_FUN.apply( null ) ); log.info( "test CONVERT_FUN 3 {}", XMLException.CONVERT_FUN.apply( new IOException( "e" ) ) ); } @Test - public void testApplyEX() { - Assert.assertThrows( XMLException.class ,() -> XMLException.apply( () -> { throw EX_TEST; } ) ); + void testApplyEX() { + Assertions.assertThrows( XMLException.class ,() -> XMLException.apply( () -> { throw EX_TEST; } ) ); } @Test - public void testGetEX() { - Assert.assertThrows( XMLException.class ,() -> XMLException.get( () -> { throw EX_TEST; } ) ); + void testGetEX() { + Assertions.assertThrows( XMLException.class ,() -> XMLException.get( () -> { throw EX_TEST; } ) ); } } diff --git a/fj-core/src/test/java/test/org/fugerit/java/core/xml/config/TestXMLSchemaCatalogConfig.java b/fj-core/src/test/java/test/org/fugerit/java/core/xml/config/TestXMLSchemaCatalogConfig.java index 8cf74174..ede778fb 100644 --- a/fj-core/src/test/java/test/org/fugerit/java/core/xml/config/TestXMLSchemaCatalogConfig.java +++ b/fj-core/src/test/java/test/org/fugerit/java/core/xml/config/TestXMLSchemaCatalogConfig.java @@ -12,13 +12,13 @@ import org.fugerit.java.core.xml.config.FugeritXmlSchemaCatalogConfig; import org.fugerit.java.core.xml.config.XMLSchemaCatalogConfig; import org.fugerit.java.core.xml.sax.SAXErrorHandlerStore; -import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; import org.xml.sax.InputSource; import test.org.fugerit.java.BasicTest; -public class TestXMLSchemaCatalogConfig extends BasicTest { +class TestXMLSchemaCatalogConfig extends BasicTest { private static final String SCHEMA_ID_DEFAULT = "current"; // default schema catalog id @@ -41,123 +41,123 @@ private static XMLSchemaCatalogConfig loadCatalogSafe( String path ) { private static XMLSchemaCatalogConfig catalog = loadCatalogSafe( "core/xml/config/xml_schema_catalog/schema-validator-config.xml" ); @Test - public void testLoad() { + void testLoad() { try ( InputStream is = ClassHelper.loadFromDefaultClassLoader( PATH_XML_OK ) ) { - Assert.assertNotNull( XMLSchemaCatalogConfig.loadConfigSchema( is ) ); + Assertions.assertNotNull( XMLSchemaCatalogConfig.loadConfigSchema( is ) ); } catch (Exception e) { this.failEx(e); } } @Test - public void testValidateOK() { + void testValidateOK() { try ( InputStream is = ClassHelper.loadFromDefaultClassLoader( PATH_XML_OK ) ) { SAXErrorHandlerStore result = new SAXErrorHandlerStore(); catalog.validate(result, new StreamSource( is ), SCHEMA_ID_DEFAULT ); - Assert.assertEquals( 0, result.getAllErrorsSize() ); + Assertions.assertEquals( 0, result.getAllErrorsSize() ); } catch (Exception e) { this.failEx(e); } } @Test - public void testValidateSaxOK() { + void testValidateSaxOK() { try ( InputStream is = ClassHelper.loadFromDefaultClassLoader( PATH_XML_OK ) ) { SAXErrorHandlerStore result = new SAXErrorHandlerStore(); catalog.validate(result, new SAXSource( new InputSource( is ) ), SCHEMA_ID_DEFAULT ); - Assert.assertEquals( 0, result.getAllErrorsSize() ); + Assertions.assertEquals( 0, result.getAllErrorsSize() ); } catch (Exception e) { this.failEx(e); } } @Test - public void testValidateCacheOK() { + void testValidateCacheOK() { try ( InputStream is = ClassHelper.loadFromDefaultClassLoader( PATH_XML_OK ) ) { SAXErrorHandlerStore result = new SAXErrorHandlerStore(); catalog.validateCacheSchema(result, new StreamSource( is ), SCHEMA_ID_DEFAULT ); - Assert.assertEquals( 0, result.getAllErrorsSize() ); + Assertions.assertEquals( 0, result.getAllErrorsSize() ); } catch (Exception e) { this.failEx(e); } } @Test - public void testValidateSaxCacheOK() { + void testValidateSaxCacheOK() { try ( InputStream is = ClassHelper.loadFromDefaultClassLoader( PATH_XML_OK ) ) { SAXErrorHandlerStore result = new SAXErrorHandlerStore(); catalog.validateCacheSchema(result, new SAXSource( new InputSource( is ) ), SCHEMA_ID_DEFAULT ); - Assert.assertEquals( 0, result.getAllErrorsSize() ); + Assertions.assertEquals( 0, result.getAllErrorsSize() ); } catch (Exception e) { this.failEx(e); } } @Test - public void testValidateKo() { + void testValidateKo() { try ( InputStream is = ClassHelper.loadFromDefaultClassLoader( PATH_XML_KO ) ) { SAXErrorHandlerStore result = new SAXErrorHandlerStore(); catalog.validate(result, new StreamSource( is ), SCHEMA_ID_DEFAULT ); - Assert.assertNotEquals( 0, result.getAllErrorsSize() ); + Assertions.assertNotEquals( 0, result.getAllErrorsSize() ); } catch (Exception e) { this.failEx(e); } } @Test - public void testValidateXsdsSaxOK() { + void testValidateXsdsSaxOK() { try ( InputStream is = ClassHelper.loadFromDefaultClassLoader( PATH_XML_OK ) ) { Source[] xsds = catalog.getXsds( SCHEMA_ID_DEFAULT ); SAXErrorHandlerStore result = new SAXErrorHandlerStore(); XMLSchemaCatalogConfig.validateWorker(result, new SAXSource( new InputSource( is ) ), xsds ); - Assert.assertEquals( 0, result.getAllErrorsSize() ); + Assertions.assertEquals( 0, result.getAllErrorsSize() ); } catch (Exception e) { this.failEx(e); } } @Test - public void testValidateXsdsOK() { + void testValidateXsdsOK() { try ( InputStream is = ClassHelper.loadFromDefaultClassLoader( PATH_XML_OK ) ) { Source[] xsds = XMLSchemaCatalogConfig.getXsds( XMLSchemaCatalogConfig.ATT_TAG_MODULE_CONF_MODE_FILE, "src/test/resources/core/xml/config/xml_schema_catalog/xsds", catalog.getDataList( SCHEMA_ID_DEFAULT ) ); SAXErrorHandlerStore result = new SAXErrorHandlerStore(); XMLSchemaCatalogConfig.validateWorker(result, new StreamSource( is ), xsds ); - Assert.assertEquals( 0, result.getAllErrorsSize() ); + Assertions.assertEquals( 0, result.getAllErrorsSize() ); } catch (Exception e) { this.failEx(e); } } @Test - public void testSerialization() { + void testSerialization() { try ( InputStream is = ClassHelper.loadFromDefaultClassLoader( PATH_XML_OK ) ) { XMLSchemaCatalogConfig loadedCatalog = (XMLSchemaCatalogConfig)this.fullSerializationTest( catalog ); SAXErrorHandlerStore result = new SAXErrorHandlerStore(); loadedCatalog.validate(result, new StreamSource( is ), SCHEMA_ID_DEFAULT ); - Assert.assertEquals( 0, result.getAllErrorsSize() ); + Assertions.assertEquals( 0, result.getAllErrorsSize() ); } catch (Exception e) { this.failEx(e); } } @Test - public void activateValidation() { + void activateValidation() { XMLSchemaCatalogConfig current = loadCatalogSafe( "core/xml/config/xml_schema_catalog/schema-validator-config_fail1.xml" ); logger.info( "activateValidation() catalog loaded : {}", current ); - Assert.assertNotNull( current ); + Assertions.assertNotNull( current ); } @Test - public void newInstanceException() { - Assert.assertThrows( ConfigRuntimeException.class , () -> { + void newInstanceException() { + Assertions.assertThrows( ConfigRuntimeException.class , () -> { loadCatalogSafe( "core/xml/config/xml_schema_catalog/schema-validator-config_fail2.xml" ); }); } @Test - public void newInstanceExceptionDuplicate() { - Assert.assertThrows( ConfigRuntimeException.class , () -> { + void newInstanceExceptionDuplicate() { + Assertions.assertThrows( ConfigRuntimeException.class , () -> { loadCatalogSafe( "core/xml/config/xml_schema_catalog/schema-validator-config_fail3.xml" ); }); } diff --git a/fj-core/src/test/java/test/org/fugerit/java/core/xml/dom/TestDOMClean.java b/fj-core/src/test/java/test/org/fugerit/java/core/xml/dom/TestDOMClean.java index bedb40e0..541e8802 100644 --- a/fj-core/src/test/java/test/org/fugerit/java/core/xml/dom/TestDOMClean.java +++ b/fj-core/src/test/java/test/org/fugerit/java/core/xml/dom/TestDOMClean.java @@ -11,14 +11,14 @@ import org.fugerit.java.core.xml.XMLException; import org.fugerit.java.core.xml.XMLWhiteSpaceRemove; import org.fugerit.java.core.xml.dom.DOMIO; -import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; import org.w3c.dom.Document; import lombok.extern.slf4j.Slf4j; @Slf4j -public class TestDOMClean { +class TestDOMClean { private static final String INPUT_FILE_XML = "dom_clean1.xml"; @@ -32,7 +32,7 @@ private void testWorker( String testFile, File outFile, TransformerConfig config } @Test - public void testClean1() throws IOException, XMLException { + void testClean1() throws IOException, XMLException { String testFile = INPUT_FILE_XML; File outFile = new File( "target", "cleaned_a_"+testFile ); try ( InputStream is = ClassHelper.loadFromDefaultClassLoader( "core/xml/dom/"+testFile ); @@ -40,23 +40,23 @@ public void testClean1() throws IOException, XMLException { Document doc = DOMIO.loadDOMDoc( is ); XMLWhiteSpaceRemove.cleanBlankNodesIndent2(doc, writer); } - Assert.assertTrue( outFile.exists() ); + Assertions.assertTrue( outFile.exists() ); } @Test - public void testClean2() throws IOException, XMLException { + void testClean2() throws IOException, XMLException { String testFile = "dom_clean1.xml"; File outFile = new File( "target", "cleaned_b_"+testFile ); this.testWorker(testFile, outFile, TransformerConfig.newIndentConfig( 5 )); - Assert.assertTrue( outFile.exists() ); + Assertions.assertTrue( outFile.exists() ); } @Test - public void testClean3() throws IOException, XMLException { + void testClean3() throws IOException, XMLException { String testFile = "dom_clean1.xml"; File outFile = new File( "target", "cleaned_c_"+testFile ); this.testWorker(testFile, outFile, TransformerConfig.newConfig().indentNo().omitXmlDeclarationNo()); - Assert.assertTrue( outFile.exists() ); + Assertions.assertTrue( outFile.exists() ); } } diff --git a/fj-core/src/test/java/test/org/fugerit/java/core/xml/dom/TestDOMIO.java b/fj-core/src/test/java/test/org/fugerit/java/core/xml/dom/TestDOMIO.java index e55fe1fa..00fdb1d8 100644 --- a/fj-core/src/test/java/test/org/fugerit/java/core/xml/dom/TestDOMIO.java +++ b/fj-core/src/test/java/test/org/fugerit/java/core/xml/dom/TestDOMIO.java @@ -19,8 +19,8 @@ import org.fugerit.java.core.lang.helpers.BooleanUtils; import org.fugerit.java.core.xml.XMLException; import org.fugerit.java.core.xml.dom.DOMIO; -import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; import org.w3c.dom.Document; import org.xml.sax.EntityResolver; import org.xml.sax.InputSource; @@ -31,7 +31,7 @@ import test.org.fugerit.java.core.testhelpers.FailOutputStream; @Slf4j -public class TestDOMIO extends BasicTest { +class TestDOMIO extends BasicTest { private static final String XML_TEST_PATH = "src/test/resources/core/cfg/xml/property-catalog-test.xml"; @@ -46,7 +46,7 @@ public InputSource resolveEntity(String publicId, String systemId) throws SAXExc }; @Test - public void testNewDocumentBuilderFactoryFail() { + void testNewDocumentBuilderFactoryFail() { boolean ok = false; try { Properties features = new Properties(); @@ -57,11 +57,11 @@ public void testNewDocumentBuilderFactoryFail() { log.warn( "Exception OK : {}", e.toString() ); ok = true; } - Assert.assertTrue( ok ); + Assertions.assertTrue( ok ); } @Test - public void testNewDocumentBuilderFactoryOk() { + void testNewDocumentBuilderFactoryOk() { boolean ok = false; try { Properties features = new Properties(); @@ -73,136 +73,136 @@ public void testNewDocumentBuilderFactoryOk() { } catch (ConfigRuntimeException e) { this.failEx(e); } - Assert.assertTrue( ok ); + Assertions.assertTrue( ok ); } @Test - public void testNewUnsafeDocumentBuilderFactory() { + void testNewUnsafeDocumentBuilderFactory() { DocumentBuilderFactory dbf = DOMIO.newDocumentBuilderFactory( true ); log.info( "DOMIO.newDocumentBuilderFactory -> {}", dbf ); - Assert.assertNotNull( dbf ); + Assertions.assertNotNull( dbf ); } @Test - public void testNewSafeDocumentBuilderFactory() { + void testNewSafeDocumentBuilderFactory() { DocumentBuilderFactory dbf = DOMIO.newSafeDocumentBuilderFactory(); log.info( "DOMIO.newSafeDocumentBuilderFactory -> {}", dbf ); - Assert.assertNotNull( dbf ); + Assertions.assertNotNull( dbf ); } @Test - public void testLoadDOMDocString() { + void testLoadDOMDocString() { boolean ok = false; try { ok = DOMIO.loadDOMDoc( FileIO.readString( new File( XML_TEST_PATH ) ) ) != null; } catch (IOException | XMLException e) { this.failEx(e); } - Assert.assertTrue( ok ); + Assertions.assertTrue( ok ); } @Test - public void testLoadDOMDocSource() { + void testLoadDOMDocSource() { boolean ok = false; try ( InputStream is = new FileInputStream( XML_TEST_PATH ) ) { ok = DOMIO.loadDOMDoc( new InputSource(is) ) != null; } catch (IOException | XMLException e) { this.failEx(e); } - Assert.assertTrue( ok ); + Assertions.assertTrue( ok ); } @Test - public void testLoadDOMDocSourceNsa() { + void testLoadDOMDocSourceNsa() { boolean ok = false; try ( InputStream is = new FileInputStream( XML_TEST_PATH ) ) { ok = DOMIO.loadDOMDoc( new InputSource(is), true ) != null; } catch (IOException | XMLException e) { this.failEx(e); } - Assert.assertTrue( ok ); + Assertions.assertTrue( ok ); } @Test - public void testLoadDOMDocSourceEr() { + void testLoadDOMDocSourceEr() { boolean ok = false; try ( InputStream is = new FileInputStream( XML_TEST_PATH ) ) { ok = DOMIO.loadDOMDoc( new InputSource(is), ENTITY_RESOLVER ) != null; } catch (IOException | XMLException e) { this.failEx(e); } - Assert.assertTrue( ok ); + Assertions.assertTrue( ok ); } @Test - public void testLoadDOMDocSourceErNsa() { + void testLoadDOMDocSourceErNsa() { boolean ok = false; try ( InputStream is = new FileInputStream( XML_TEST_PATH ) ) { ok = DOMIO.loadDOMDoc( new InputSource(is), ENTITY_RESOLVER, true ) != null; } catch (IOException | XMLException e) { this.failEx(e); } - Assert.assertTrue( ok ); + Assertions.assertTrue( ok ); } @Test - public void testLoadDOMDocStream() { + void testLoadDOMDocStream() { boolean ok = false; try ( InputStream is = new FileInputStream( XML_TEST_PATH ) ) { ok = DOMIO.loadDOMDoc( is ) != null; } catch (IOException | XMLException e) { this.failEx(e); } - Assert.assertTrue( ok ); + Assertions.assertTrue( ok ); } @Test - public void testLoadDOMDocReader() { + void testLoadDOMDocReader() { boolean ok = false; try ( Reader reader = new InputStreamReader( new FileInputStream( XML_TEST_PATH ) ) ) { ok = DOMIO.loadDOMDoc( reader ) != null; } catch (IOException | XMLException e) { this.failEx(e); } - Assert.assertTrue( ok ); + Assertions.assertTrue( ok ); } @Test - public void testLoadDOMDocNsaReader() { + void testLoadDOMDocNsaReader() { boolean ok = false; try ( Reader reader = new InputStreamReader( new FileInputStream( XML_TEST_PATH ) ) ) { ok = DOMIO.loadDOMDoc( reader, false ) != null; } catch (IOException | XMLException e) { this.failEx(e); } - Assert.assertTrue( ok ); + Assertions.assertTrue( ok ); } @Test - public void testLoadDOMDocFile() { + void testLoadDOMDocFile() { boolean ok = false; try { ok = DOMIO.loadDOMDoc( new File( XML_TEST_PATH ) ) != null; } catch (XMLException e) { this.failEx(e); } - Assert.assertTrue( ok ); + Assertions.assertTrue( ok ); } @Test - public void testLoadDOMDocNsaFile() { + void testLoadDOMDocNsaFile() { boolean ok = false; try { ok = DOMIO.loadDOMDoc( new File( XML_TEST_PATH ), false ) != null; } catch (XMLException e) { this.failEx(e); } - Assert.assertTrue( ok ); + Assertions.assertTrue( ok ); } @Test - public void testLoadDOMDocStringFail() { + void testLoadDOMDocStringFail() { boolean ok = false; try { DOMIO.loadDOMDoc( FileIO.readString( new File( XML_TEST_PATH_KO ) ) ); @@ -210,11 +210,11 @@ public void testLoadDOMDocStringFail() { log.info( "Exception : {}", e.toString() ); ok = ( e instanceof XMLException ); } - Assert.assertTrue( ok ); + Assertions.assertTrue( ok ); } @Test - public void testLoadDOMDocSourceFail() { + void testLoadDOMDocSourceFail() { boolean ok = false; try ( InputStream is = new FileInputStream( XML_TEST_PATH_KO ) ) { DOMIO.loadDOMDoc( new InputSource(is) ); @@ -222,11 +222,11 @@ public void testLoadDOMDocSourceFail() { log.info( "Exception : {}", e.toString() ); ok = ( e instanceof XMLException ); } - Assert.assertTrue( ok ); + Assertions.assertTrue( ok ); } @Test - public void testLoadDOMDocSourceErFail() { + void testLoadDOMDocSourceErFail() { boolean ok = false; try ( InputStream is = new FileInputStream( XML_TEST_PATH_KO ) ) { DOMIO.loadDOMDoc( new InputSource(is), ENTITY_RESOLVER ); @@ -234,11 +234,11 @@ public void testLoadDOMDocSourceErFail() { log.info( "Exception : {}", e.toString() ); ok = ( e instanceof XMLException ); } - Assert.assertTrue( ok ); + Assertions.assertTrue( ok ); } @Test - public void testLoadDOMDocSourceErNsaFail() { + void testLoadDOMDocSourceErNsaFail() { boolean ok = false; try ( InputStream is = new FileInputStream( XML_TEST_PATH_KO ) ) { DOMIO.loadDOMDoc( new InputSource(is), ENTITY_RESOLVER, true ); @@ -246,11 +246,11 @@ public void testLoadDOMDocSourceErNsaFail() { log.info( "Exception : {}", e.toString() ); ok = ( e instanceof XMLException ); } - Assert.assertTrue( ok ); + Assertions.assertTrue( ok ); } @Test - public void testLoadDOMDocSourceNsaFail() { + void testLoadDOMDocSourceNsaFail() { boolean ok = false; try ( InputStream is = new FileInputStream( XML_TEST_PATH_KO ) ) { DOMIO.loadDOMDoc( new InputSource(is), false ); @@ -258,11 +258,11 @@ public void testLoadDOMDocSourceNsaFail() { log.info( "Exception : {}", e.toString() ); ok = ( e instanceof XMLException ); } - Assert.assertTrue( ok ); + Assertions.assertTrue( ok ); } @Test - public void testLoadDOMDocStreamFail() { + void testLoadDOMDocStreamFail() { boolean ok = false; try ( InputStream is = new FileInputStream( XML_TEST_PATH_KO ) ) { DOMIO.loadDOMDoc( is ); @@ -270,11 +270,11 @@ public void testLoadDOMDocStreamFail() { log.info( "Exception : {}", e.toString() ); ok = ( e instanceof XMLException ); } - Assert.assertTrue( ok ); + Assertions.assertTrue( ok ); } @Test - public void testLoadDOMDocReaderFail() { + void testLoadDOMDocReaderFail() { boolean ok = false; try ( Reader reader = new InputStreamReader( new FileInputStream( XML_TEST_PATH_KO ) ) ) { DOMIO.loadDOMDoc( reader ); @@ -282,11 +282,11 @@ public void testLoadDOMDocReaderFail() { log.info( "Exception : {}", e.toString() ); ok = ( e instanceof XMLException ); } - Assert.assertTrue( ok ); + Assertions.assertTrue( ok ); } @Test - public void testLoadDOMDocFileFail() { + void testLoadDOMDocFileFail() { boolean ok = false; try { DOMIO.loadDOMDoc( new File( XML_TEST_PATH_KO ) ); @@ -294,11 +294,11 @@ public void testLoadDOMDocFileFail() { log.info( "Exception : {}", e.toString() ); ok = ( e instanceof XMLException ); } - Assert.assertTrue( ok ); + Assertions.assertTrue( ok ); } @Test - public void testLoadDOMDocReaderNsaFail() { + void testLoadDOMDocReaderNsaFail() { boolean ok = false; try ( Reader reader = new InputStreamReader( new FileInputStream( XML_TEST_PATH_KO ) ) ) { DOMIO.loadDOMDoc( reader, false ); @@ -306,11 +306,11 @@ public void testLoadDOMDocReaderNsaFail() { log.info( "Exception : {}", e.toString() ); ok = ( e instanceof XMLException ); } - Assert.assertTrue( ok ); + Assertions.assertTrue( ok ); } @Test - public void testLoadDOMDocFileNsaFail() { + void testLoadDOMDocFileNsaFail() { boolean ok = false; try { DOMIO.loadDOMDoc( new File( XML_TEST_PATH_KO ), false ); @@ -318,11 +318,11 @@ public void testLoadDOMDocFileNsaFail() { log.info( "Exception : {}", e.toString() ); ok = ( e instanceof XMLException ); } - Assert.assertTrue( ok ); + Assertions.assertTrue( ok ); } @Test - public void testLoadDOMDocFileNotFoundFail() { + void testLoadDOMDocFileNotFoundFail() { boolean ok = false; try { DOMIO.loadDOMDoc( new File( "fadsfasfdasdas" ) ); @@ -330,11 +330,11 @@ public void testLoadDOMDocFileNotFoundFail() { log.info( "Exception : {}", e.toString() ); ok = ( e instanceof XMLException ); } - Assert.assertTrue( ok ); + Assertions.assertTrue( ok ); } @Test - public void testLoadDOMDocFileNsaNotFoundFail() { + void testLoadDOMDocFileNsaNotFoundFail() { boolean ok = false; try { DOMIO.loadDOMDoc( new File( "fadsfasfdasdas" ), false ); @@ -342,11 +342,11 @@ public void testLoadDOMDocFileNsaNotFoundFail() { log.info( "Exception : {}", e.toString() ); ok = ( e instanceof XMLException ); } - Assert.assertTrue( ok ); + Assertions.assertTrue( ok ); } @Test - public void testWriteDOMIndentResult() { + void testWriteDOMIndentResult() { boolean ok = false; try ( StringWriter sw = new StringWriter() ) { Document doc = DOMIO.loadDOMDoc( new File( XML_TEST_PATH ) ); @@ -357,11 +357,11 @@ public void testWriteDOMIndentResult() { } catch (XMLException | IOException e) { this.failEx(e); } - Assert.assertTrue( ok ); + Assertions.assertTrue( ok ); } @Test - public void testWriteDOMIndentResultFailIOExepction() { + void testWriteDOMIndentResultFailIOExepction() { boolean ok = false; try ( FailOutputStream os = new FailOutputStream() ) { Document doc = DOMIO.loadDOMDoc( new File( XML_TEST_PATH ) ); @@ -370,11 +370,11 @@ public void testWriteDOMIndentResultFailIOExepction() { log.info( "Exception : {}", e.toString() ); ok = ( e instanceof XMLException ); } - Assert.assertTrue( ok ); + Assertions.assertTrue( ok ); } @Test - public void testWriteDOMIndentResultFail() { + void testWriteDOMIndentResultFail() { boolean ok = false; try ( StringWriter sw = new StringWriter() ) { Document doc = DOMIO.loadDOMDoc( new File( XML_TEST_PATH_KO ) ); @@ -385,11 +385,11 @@ public void testWriteDOMIndentResultFail() { log.info( "Exception : {}", e.toString() ); ok = ( e instanceof XMLException ); } - Assert.assertTrue( ok ); + Assertions.assertTrue( ok ); } @Test - public void testWriteDOMIndentWriter() { + void testWriteDOMIndentWriter() { boolean ok = false; try ( StringWriter sw = new StringWriter() ) { Document doc = DOMIO.loadDOMDoc( new File( XML_TEST_PATH ) ); @@ -400,11 +400,11 @@ public void testWriteDOMIndentWriter() { } catch (XMLException | IOException e) { this.failEx(e); } - Assert.assertTrue( ok ); + Assertions.assertTrue( ok ); } @Test - public void testWriteDOMIndentStream() { + void testWriteDOMIndentStream() { boolean ok = false; try ( ByteArrayOutputStream os = new ByteArrayOutputStream() ) { Document doc = DOMIO.loadDOMDoc( new File( XML_TEST_PATH ) ); @@ -415,11 +415,11 @@ public void testWriteDOMIndentStream() { } catch (XMLException | IOException e) { this.failEx(e); } - Assert.assertTrue( ok ); + Assertions.assertTrue( ok ); } @Test - public void testWriteDOMWriter() { + void testWriteDOMWriter() { boolean ok = false; try ( StringWriter sw = new StringWriter() ) { Document doc = DOMIO.loadDOMDoc( new File( XML_TEST_PATH ) ); @@ -430,11 +430,11 @@ public void testWriteDOMWriter() { } catch (XMLException | IOException e) { this.failEx(e); } - Assert.assertTrue( ok ); + Assertions.assertTrue( ok ); } @Test - public void testWriteDOMResult() { + void testWriteDOMResult() { boolean ok = false; try ( StringWriter sw = new StringWriter() ) { Document doc = DOMIO.loadDOMDoc( new File( XML_TEST_PATH ) ); @@ -445,11 +445,11 @@ public void testWriteDOMResult() { } catch (XMLException | IOException e) { this.failEx(e); } - Assert.assertTrue( ok ); + Assertions.assertTrue( ok ); } @Test - public void testWriteDOMStream() { + void testWriteDOMStream() { boolean ok = false; try ( ByteArrayOutputStream os = new ByteArrayOutputStream() ) { Document doc = DOMIO.loadDOMDoc( new File( XML_TEST_PATH ) ); @@ -460,11 +460,11 @@ public void testWriteDOMStream() { } catch (XMLException | IOException e) { this.failEx(e); } - Assert.assertTrue( ok ); + Assertions.assertTrue( ok ); } @Test - public void testWriteDOMStreamFail() { + void testWriteDOMStreamFail() { boolean ok = false; try ( ByteArrayOutputStream os = new ByteArrayOutputStream() ) { Document doc = DOMIO.loadDOMDoc( new File( XML_TEST_PATH_KO ) ); @@ -473,11 +473,11 @@ public void testWriteDOMStreamFail() { log.info( "Exception : {}", e.toString() ); ok = ( e instanceof XMLException ); } - Assert.assertTrue( ok ); + Assertions.assertTrue( ok ); } @Test - public void testWriteDOMStreamFailStream() { + void testWriteDOMStreamFailStream() { boolean ok = false; try ( OutputStream os = new FailOutputStream() ) { Document doc = DOMIO.loadDOMDoc( new File( XML_TEST_PATH ) ); @@ -486,7 +486,7 @@ public void testWriteDOMStreamFailStream() { log.info( "Exception : {}", e.toString() ); ok = ( e instanceof XMLException ); } - Assert.assertTrue( ok ); + Assertions.assertTrue( ok ); } } diff --git a/fj-core/src/test/java/test/org/fugerit/java/core/xml/dom/TestDOMProperty.java b/fj-core/src/test/java/test/org/fugerit/java/core/xml/dom/TestDOMProperty.java index 81572e08..dbcdb8d8 100644 --- a/fj-core/src/test/java/test/org/fugerit/java/core/xml/dom/TestDOMProperty.java +++ b/fj-core/src/test/java/test/org/fugerit/java/core/xml/dom/TestDOMProperty.java @@ -9,26 +9,26 @@ import org.fugerit.java.core.xml.XMLException; import org.fugerit.java.core.xml.dom.DOMIO; import org.fugerit.java.core.xml.dom.DOMProperty; -import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; import org.w3c.dom.DOMException; import org.w3c.dom.Document; import org.w3c.dom.Element; -public class TestDOMProperty { +class TestDOMProperty { @Test - public void testFill() throws IOException, XMLException, DOMException, ConfigException { + void testFill() throws IOException, XMLException, DOMException, ConfigException { Properties props = new Properties(); String key = "key1"; String oldValue = "oldValue" ; props.setProperty( key, oldValue ); - Assert.assertEquals( oldValue , props.getProperty( key ) ); + Assertions.assertEquals( oldValue , props.getProperty( key ) ); try ( InputStream is = ClassHelper.loadFromDefaultClassLoader( "core/xml/dom/property.xml" ) ) { Document doc = DOMIO.loadDOMDoc( is ); Element root = doc.getDocumentElement(); DOMProperty.fill( props , root.getElementsByTagName( DOMProperty.TAG_ENTRY ) ); - Assert.assertNotEquals( oldValue , props.getProperty( key ) ); + Assertions.assertNotEquals( oldValue , props.getProperty( key ) ); } } diff --git a/fj-core/src/test/java/test/org/fugerit/java/core/xml/dom/TestSearchDOM.java b/fj-core/src/test/java/test/org/fugerit/java/core/xml/dom/TestSearchDOM.java index c4fd3a02..f7ae5f42 100644 --- a/fj-core/src/test/java/test/org/fugerit/java/core/xml/dom/TestSearchDOM.java +++ b/fj-core/src/test/java/test/org/fugerit/java/core/xml/dom/TestSearchDOM.java @@ -8,15 +8,15 @@ import org.fugerit.java.core.xml.XMLException; import org.fugerit.java.core.xml.dom.DOMIO; import org.fugerit.java.core.xml.dom.SearchDOM; -import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; import org.w3c.dom.Document; import org.w3c.dom.Element; import lombok.extern.slf4j.Slf4j; @Slf4j -public class TestSearchDOM { +class TestSearchDOM { private boolean worker( SearchDOM search ) throws XMLException, IOException { boolean ok = false; @@ -37,21 +37,21 @@ private boolean worker( SearchDOM search ) throws XMLException, IOException { } @Test - public void testSearchDOM() throws XMLException, IOException { + void testSearchDOM() throws XMLException, IOException { boolean ok = this.worker( SearchDOM.newInstance() ); - Assert.assertTrue( ok ); + Assertions.assertTrue( ok ); } @Test - public void testSearchDOMAlt1() throws XMLException, IOException { + void testSearchDOMAlt1() throws XMLException, IOException { boolean ok = this.worker( SearchDOM.newInstance( true, true ) ); - Assert.assertTrue( ok ); + Assertions.assertTrue( ok ); } @Test - public void testSearchDOMAlt2() throws XMLException, IOException { + void testSearchDOMAlt2() throws XMLException, IOException { boolean ok = this.worker( SearchDOM.newInstance( false, false ) ); - Assert.assertTrue( ok ); + Assertions.assertTrue( ok ); } } diff --git a/fj-core/src/test/java/test/org/fugerit/java/core/xml/sax/TestContentHandler.java b/fj-core/src/test/java/test/org/fugerit/java/core/xml/sax/TestContentHandler.java index 7bf9966f..aa2debe1 100644 --- a/fj-core/src/test/java/test/org/fugerit/java/core/xml/sax/TestContentHandler.java +++ b/fj-core/src/test/java/test/org/fugerit/java/core/xml/sax/TestContentHandler.java @@ -14,15 +14,15 @@ import org.fugerit.java.core.xml.sax.ch.ContentHandlerWriter; import org.fugerit.java.core.xml.sax.ch.DoNothingContentHandler; import org.fugerit.java.core.xml.sax.dh.DefaultHandlerComp; -import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; import org.xml.sax.ContentHandler; import org.xml.sax.SAXException; import lombok.extern.slf4j.Slf4j; @Slf4j -public class TestContentHandler { +class TestContentHandler { private static final String PATH_OK = "core/xml/dtd/test-content-handler.xml"; @@ -40,15 +40,15 @@ private boolean worker( String path, ContentHandler handler ) throws IOException } @Test - public void testContentHandlerWrapper() throws IOException, XMLException, SAXException { + void testContentHandlerWrapper() throws IOException, XMLException, SAXException { ContentHandlerWrapper handler = new ContentHandlerWrapper( new DoNothingContentHandler() ); boolean ok = this.worker(PATH_OK, handler); - Assert.assertTrue(ok); + Assertions.assertTrue(ok); try ( StringWriter buffer = new StringWriter(); PrintWriter writer = new PrintWriter( buffer ) ) { handler.setWrappedContentHandler( new ContentHandlerWriter( writer ) ); ok = this.worker(PATH_OK, handler); - Assert.assertTrue(ok); + Assertions.assertTrue(ok); log.info( "xml : \n{}", buffer ); } } diff --git a/fj-core/src/test/java/test/org/fugerit/java/core/xml/sax/TestDefaultHandler.java b/fj-core/src/test/java/test/org/fugerit/java/core/xml/sax/TestDefaultHandler.java index 6fab7fb0..083e1b19 100644 --- a/fj-core/src/test/java/test/org/fugerit/java/core/xml/sax/TestDefaultHandler.java +++ b/fj-core/src/test/java/test/org/fugerit/java/core/xml/sax/TestDefaultHandler.java @@ -4,8 +4,8 @@ import org.fugerit.java.core.xml.sax.dh.DefaultHandlerComp; import org.fugerit.java.core.xml.sax.dtd.DTDHandlerWrapper; -import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; import org.xml.sax.EntityResolver; import org.xml.sax.InputSource; import org.xml.sax.SAXException; @@ -15,7 +15,7 @@ import test.org.fugerit.java.helpers.FailHelper; @Slf4j -public class TestDefaultHandler { +class TestDefaultHandler { private boolean worker( DefaultHandler dh ) { log.info( "default handler -> {}", dh ); @@ -29,74 +29,74 @@ private boolean worker( DefaultHandler dh ) { } @Test - public void defaultHandlerTest0() { + void defaultHandlerTest0() { DefaultHandlerComp dh = new DefaultHandlerComp(); boolean ok = this.worker(dh); - Assert.assertTrue(ok); + Assertions.assertTrue(ok); } @Test - public void defaultHandlerTest1() { + void defaultHandlerTest1() { DefaultHandlerComp dh = new DefaultHandlerComp( DefaultHandlerComp.DEFAULT_CH ); boolean ok = this.worker(dh); - Assert.assertTrue(ok); + Assertions.assertTrue(ok); } @Test - public void defaultHandlerTest2() { + void defaultHandlerTest2() { DefaultHandlerComp dh = new DefaultHandlerComp( DefaultHandlerComp.DEFAULT_DH ); boolean ok = this.worker(dh); - Assert.assertTrue(ok); + Assertions.assertTrue(ok); } @Test - public void defaultHandlerTest3() { + void defaultHandlerTest3() { DefaultHandlerComp dh = new DefaultHandlerComp( DefaultHandlerComp.DEFAULT_EH ); boolean ok = this.worker(dh); - Assert.assertTrue(ok); + Assertions.assertTrue(ok); } @Test - public void defaultHandlerTest4() { + void defaultHandlerTest4() { DefaultHandlerComp dh = new DefaultHandlerComp( DefaultHandlerComp.DEFAULT_ER ); boolean ok = this.worker(dh); - Assert.assertTrue(ok); + Assertions.assertTrue(ok); } @Test - public void defaultHandlerTest5() { + void defaultHandlerTest5() { DefaultHandlerComp dh = new DefaultHandlerComp( DefaultHandlerComp.DEFAULT_DH, DefaultHandlerComp.DEFAULT_ER, DefaultHandlerComp.DEFAULT_EH ); boolean ok = this.worker(dh); - Assert.assertTrue(ok); + Assertions.assertTrue(ok); } @Test - public void defaultHandlerTest6() { + void defaultHandlerTest6() { DefaultHandlerComp dh = new DefaultHandlerComp( DefaultHandlerComp.DEFAULT_CH, DefaultHandlerComp.DEFAULT_ER, DefaultHandlerComp.DEFAULT_EH ); boolean ok = this.worker(dh); - Assert.assertTrue(ok); + Assertions.assertTrue(ok); } @Test - public void defaultHandlerTest7() { + void defaultHandlerTest7() { DefaultHandlerComp dh = new DefaultHandlerComp( DefaultHandlerComp.DEFAULT_CH, DefaultHandlerComp.DEFAULT_DH, DefaultHandlerComp.DEFAULT_EH ); boolean ok = this.worker(dh); - Assert.assertTrue(ok); + Assertions.assertTrue(ok); } @Test - public void defaultHandlerTest8() { + void defaultHandlerTest8() { DefaultHandlerComp dh = new DefaultHandlerComp( DefaultHandlerComp.DEFAULT_CH, DefaultHandlerComp.DEFAULT_DH, DefaultHandlerComp.DEFAULT_ER ); boolean ok = this.worker(dh); - Assert.assertTrue(ok); + Assertions.assertTrue(ok); } @Test - public void defaultHandlerTestFinal() throws SAXException { + void defaultHandlerTestFinal() throws SAXException { DefaultHandlerComp dh = new DefaultHandlerComp(); DTDHandlerWrapper dtdDtdHandlerWrapper = new DTDHandlerWrapper( DefaultHandlerComp.DEFAULT_DH ); dh.setWrappedContentHandler( DefaultHandlerComp.DEFAULT_CH ); @@ -112,11 +112,11 @@ public void defaultHandlerTestFinal() throws SAXException { dh.unparsedEntityDecl( "m", "n", "o", "p" ); dh.fatalError( null ); dh.warning( null ); - Assert.assertTrue(ok); + Assertions.assertTrue(ok); } @Test - public void defaultHandlerTestKo() { + void defaultHandlerTestKo() { DefaultHandlerComp dh = new DefaultHandlerComp( new EntityResolver() { @Override public InputSource resolveEntity(String publicId, String systemId) throws SAXException, IOException { @@ -126,7 +126,7 @@ public InputSource resolveEntity(String publicId, String systemId) throws SAXExc return null; } } ); - Assert.assertThrows( SAXException.class , () -> dh.resolveEntity(null, null) ); + Assertions.assertThrows( SAXException.class , () -> dh.resolveEntity(null, null) ); } } diff --git a/fj-core/src/test/java/test/org/fugerit/java/core/xml/sax/TestErrorHandler.java b/fj-core/src/test/java/test/org/fugerit/java/core/xml/sax/TestErrorHandler.java index fd6ae5a5..df59a689 100644 --- a/fj-core/src/test/java/test/org/fugerit/java/core/xml/sax/TestErrorHandler.java +++ b/fj-core/src/test/java/test/org/fugerit/java/core/xml/sax/TestErrorHandler.java @@ -11,8 +11,8 @@ import org.fugerit.java.core.xml.sax.eh.DoNothingErrorHandler; import org.fugerit.java.core.xml.sax.eh.ErrorHandlerWrapper; import org.fugerit.java.core.xml.sax.eh.ResultErrorHandler; -import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; import org.xml.sax.ErrorHandler; import org.xml.sax.Locator; import org.xml.sax.SAXException; @@ -23,7 +23,7 @@ import test.org.fugerit.java.BasicTest; @Slf4j -public class TestErrorHandler extends BasicTest { +class TestErrorHandler extends BasicTest { private Locator newLocator( int row, int col ) { return new LocatorImpl() { @@ -59,11 +59,11 @@ private boolean worker( ErrorHandler handler ) throws SAXException { } @Test - public void testWrapper() throws SAXException { + void testWrapper() throws SAXException { // test ErrorHandlerWrapper ErrorHandlerWrapper handler = new ErrorHandlerWrapper( new DoNothingErrorHandler() ); boolean ok = this.worker(handler); - Assert.assertTrue( ok ); + Assertions.assertTrue( ok ); // test ResultErrorHandler SAXParseResult saxParseResult = new SAXParseResult(); ResultErrorHandler result = new ResultErrorHandler( saxParseResult ); @@ -72,22 +72,22 @@ public void testWrapper() throws SAXException { log.info( "fatal : {}", saxParseResult.getSAXFatal( 0 ) ); log.info( "error : {}", saxParseResult.getSAXError( 0 ) ); log.info( "warning : {}", saxParseResult.getSAXWarning( 0 ) ); - Assert.assertTrue( ok ); + Assertions.assertTrue( ok ); // test ResultExHandler result.setHandler( new ResultExHandler( new SAXParseResult() ) ); ok = this.worker( result ); - Assert.assertTrue( ok ); + Assertions.assertTrue( ok ); ExHandler exHandler = result.getHandler(); - Assert.assertNotNull( exHandler ); + Assertions.assertNotNull( exHandler ); // test ExDefaultHandler ExDefaultHandler exDefaultHandler = new ExDefaultHandler( new ResultExHandler( new SAXParseResult() ) ); ok = this.worker( exDefaultHandler ); - Assert.assertTrue( ok ); - Assert.assertNotNull( exDefaultHandler.getHandler() ); + Assertions.assertTrue( ok ); + Assertions.assertNotNull( exDefaultHandler.getHandler() ); } @Test - public void testSaxStore() throws SAXException { + void testSaxStore() throws SAXException { SAXErrorHandlerStore handler = new SAXErrorHandlerStore(); boolean ok = this.worker(handler); log.info( "fatals size : {}", handler.getFatalSize() ); @@ -97,39 +97,39 @@ public void testSaxStore() throws SAXException { log.info( "warnings size : {}", handler.getWarningSize() ); this.print( handler.getWarnings() , "WARNINGS" ); log.info( "all errors size : {}", handler.getAllErrorsSize() ); - Assert.assertTrue( ok ); + Assertions.assertTrue( ok ); } @Test - public void testSaxFail() throws SAXException { + void testSaxFail() throws SAXException { SAXErrorHandlerFail handler = SAXErrorHandlerFail.newInstanceStoreOnly(); boolean ok = this.worker(handler); - Assert.assertTrue( ok ); + Assertions.assertTrue( ok ); } @Test - public void testSaxFailFatal() throws SAXException { + void testSaxFailFatal() throws SAXException { SAXErrorHandlerFail handler = SAXErrorHandlerFail.newInstanceFailOnAnyErrorStoreWarnings(); - Assert.assertThrows( SAXParseException.class , () -> + Assertions.assertThrows( SAXParseException.class , () -> handler.fatalError( this.newSPE( "newInstanceFailOnAnyErrorIgnoreWarnings fatal" ) ) ); - Assert.assertThrows( SAXParseException.class , () -> + Assertions.assertThrows( SAXParseException.class , () -> handler.error( this.newSPE( "newInstanceFailOnAnyErrorIgnoreWarnings error" ) ) ); } @Test - public void testSaxFailError() throws SAXException { + void testSaxFailError() throws SAXException { SAXErrorHandlerFail handler = SAXErrorHandlerFail.newInstanceFailOnFatalErrorStoreOthers(); - Assert.assertThrows( SAXParseException.class , () -> + Assertions.assertThrows( SAXParseException.class , () -> handler.fatalError( this.newSPE( "newInstanceFailOnFatalErrorStoreOthers fatal" ) ) ); } @Test - public void testSaxFailAll() throws SAXException { + void testSaxFailAll() throws SAXException { SAXErrorHandlerFail handler = SAXErrorHandlerFail.newInstanceFailOnAnyErrorIgnoreWarnings(); handler.warning( this.newSPE( "newInstanceFailOnAnyErrorStoreWarnings warning" ) ); - Assert.assertThrows( SAXParseException.class , () -> + Assertions.assertThrows( SAXParseException.class , () -> handler.fatalError( this.newSPE( "newInstanceFailOnAnyErrorStoreWarnings fatal" ) ) ); - Assert.assertThrows( SAXParseException.class , () -> + Assertions.assertThrows( SAXParseException.class , () -> handler.error( this.newSPE( "newInstanceFailOnAnyErrorStoreWarnings error" ) ) ); } diff --git a/fj-core/src/test/java/test/org/fugerit/java/core/xml/sax/TestXMLValidatorSAX.java b/fj-core/src/test/java/test/org/fugerit/java/core/xml/sax/TestXMLValidatorSAX.java index 297e98e4..37ccde6a 100644 --- a/fj-core/src/test/java/test/org/fugerit/java/core/xml/sax/TestXMLValidatorSAX.java +++ b/fj-core/src/test/java/test/org/fugerit/java/core/xml/sax/TestXMLValidatorSAX.java @@ -15,8 +15,8 @@ import org.fugerit.java.core.xml.sax.er.CharArrayEntityResolver; import org.fugerit.java.core.xml.sax.er.DoNothingEntityResolver; import org.fugerit.java.core.xml.sax.er.EntityResolverWrapper; -import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; import org.xml.sax.EntityResolver; import org.xml.sax.InputSource; import org.xml.sax.SAXException; @@ -25,7 +25,7 @@ import test.org.fugerit.java.BasicTest; @Slf4j -public class TestXMLValidatorSAX extends BasicTest { +class TestXMLValidatorSAX extends BasicTest { private static final String PATH_OK = "core/xml/dtd/doc-ok.xml"; @@ -72,153 +72,153 @@ private boolean validateWorker( EntityResolver er, String path ) throws XMLExcep } @Test - public void testAbstractValidatorStringXml() throws XMLException, IOException { + void testAbstractValidatorStringXml() throws XMLException, IOException { XMLValidatorSAX validator = XMLValidatorSAX.newInstance( DTD_DEFAULT_RESOLVER, true ); - Assert.assertNotNull( validator.validateXML( StreamIO.readString( ClassHelper.loadFromDefaultClassLoader( PATH_OK ) ) ) ); + Assertions.assertNotNull( validator.validateXML( StreamIO.readString( ClassHelper.loadFromDefaultClassLoader( PATH_OK ) ) ) ); } @Test - public void testAbstractValidatorStringValid() throws XMLException, IOException { + void testAbstractValidatorStringValid() throws XMLException, IOException { XMLValidatorSAX validator = XMLValidatorSAX.newInstance( DTD_DEFAULT_RESOLVER, true ); - Assert.assertTrue( validator.isValidaXML( StreamIO.readString( ClassHelper.loadFromDefaultClassLoader( PATH_OK ) ) ) ); + Assertions.assertTrue( validator.isValidaXML( StreamIO.readString( ClassHelper.loadFromDefaultClassLoader( PATH_OK ) ) ) ); } @Test - public void testAbstractValidatorStringValidResult() throws XMLException, IOException { + void testAbstractValidatorStringValidResult() throws XMLException, IOException { XMLValidatorSAX validator = XMLValidatorSAX.newInstance( DTD_DEFAULT_RESOLVER, true ); - Assert.assertTrue( validator.validateXML( StreamIO.readString( ClassHelper.loadFromDefaultClassLoader( PATH_OK ) ), new SAXParseResult() ) ); + Assertions.assertTrue( validator.validateXML( StreamIO.readString( ClassHelper.loadFromDefaultClassLoader( PATH_OK ) ), new SAXParseResult() ) ); } @Test - public void testAbstractValidatorCharXml() throws XMLException, IOException { + void testAbstractValidatorCharXml() throws XMLException, IOException { XMLValidatorSAX validator = XMLValidatorSAX.newInstance( DTD_DEFAULT_RESOLVER, true ); - Assert.assertNotNull( validator.validateXML( StreamIO.readString( ClassHelper.loadFromDefaultClassLoader( PATH_OK ) ).toCharArray() ) ); + Assertions.assertNotNull( validator.validateXML( StreamIO.readString( ClassHelper.loadFromDefaultClassLoader( PATH_OK ) ).toCharArray() ) ); } @Test - public void testAbstractValidatorCharValid() throws XMLException, IOException { + void testAbstractValidatorCharValid() throws XMLException, IOException { XMLValidatorSAX validator = XMLValidatorSAX.newInstance( DTD_DEFAULT_RESOLVER, true ); - Assert.assertTrue( validator.isValidaXML( StreamIO.readString( ClassHelper.loadFromDefaultClassLoader( PATH_OK ) ).toCharArray() ) ); + Assertions.assertTrue( validator.isValidaXML( StreamIO.readString( ClassHelper.loadFromDefaultClassLoader( PATH_OK ) ).toCharArray() ) ); } @Test - public void testAbstractValidatorCharValidResult() throws XMLException, IOException { + void testAbstractValidatorCharValidResult() throws XMLException, IOException { XMLValidatorSAX validator = XMLValidatorSAX.newInstance( DTD_DEFAULT_RESOLVER, true ); - Assert.assertTrue( validator.validateXML( StreamIO.readString( ClassHelper.loadFromDefaultClassLoader( PATH_OK ) ).toCharArray(), new SAXParseResult() ) ); + Assertions.assertTrue( validator.validateXML( StreamIO.readString( ClassHelper.loadFromDefaultClassLoader( PATH_OK ) ).toCharArray(), new SAXParseResult() ) ); } @Test - public void testAbstractValidatorByteXml() throws XMLException, IOException { + void testAbstractValidatorByteXml() throws XMLException, IOException { XMLValidatorSAX validator = XMLValidatorSAX.newInstance( DTD_DEFAULT_RESOLVER, true ); - Assert.assertNotNull( validator.validateXML( StreamIO.readBytes( ClassHelper.loadFromDefaultClassLoader( PATH_OK ) ) ) ); + Assertions.assertNotNull( validator.validateXML( StreamIO.readBytes( ClassHelper.loadFromDefaultClassLoader( PATH_OK ) ) ) ); } @Test - public void testAbstractValidatorBytesValid() throws XMLException, IOException { + void testAbstractValidatorBytesValid() throws XMLException, IOException { XMLValidatorSAX validator = XMLValidatorSAX.newInstance( DTD_DEFAULT_RESOLVER, true ); - Assert.assertTrue( validator.isValidaXML( StreamIO.readBytes( ClassHelper.loadFromDefaultClassLoader( PATH_OK ) ) ) ); + Assertions.assertTrue( validator.isValidaXML( StreamIO.readBytes( ClassHelper.loadFromDefaultClassLoader( PATH_OK ) ) ) ); } @Test - public void testAbstractValidatorBytesValidResult() throws XMLException, IOException { + void testAbstractValidatorBytesValidResult() throws XMLException, IOException { XMLValidatorSAX validator = XMLValidatorSAX.newInstance( DTD_DEFAULT_RESOLVER, true ); - Assert.assertTrue( validator.validateXML( StreamIO.readBytes( ClassHelper.loadFromDefaultClassLoader( PATH_OK ) ), new SAXParseResult() ) ); + Assertions.assertTrue( validator.validateXML( StreamIO.readBytes( ClassHelper.loadFromDefaultClassLoader( PATH_OK ) ), new SAXParseResult() ) ); } @Test - public void testAbstractValidatorStreamXml() throws XMLException, IOException { + void testAbstractValidatorStreamXml() throws XMLException, IOException { XMLValidatorSAX validator = XMLValidatorSAX.newInstance( DTD_DEFAULT_RESOLVER, true ); try ( InputStream source = ClassHelper.loadFromDefaultClassLoader( PATH_OK ) ) { - Assert.assertNotNull( validator.validateXML( source ) ); + Assertions.assertNotNull( validator.validateXML( source ) ); } } @Test - public void testAbstractValidatorStreamValid() throws XMLException, IOException { + void testAbstractValidatorStreamValid() throws XMLException, IOException { XMLValidatorSAX validator = XMLValidatorSAX.newInstance( DTD_DEFAULT_RESOLVER, true ); try ( InputStream source = ClassHelper.loadFromDefaultClassLoader( PATH_OK ) ) { - Assert.assertTrue( validator.isValidaXML( source ) ); + Assertions.assertTrue( validator.isValidaXML( source ) ); } } @Test - public void testAbstractValidatorStreamValidResult() throws XMLException, IOException { + void testAbstractValidatorStreamValidResult() throws XMLException, IOException { XMLValidatorSAX validator = XMLValidatorSAX.newInstance( DTD_DEFAULT_RESOLVER, true ); try ( InputStream source = ClassHelper.loadFromDefaultClassLoader( PATH_OK ) ) { - Assert.assertTrue( validator.validateXML( source, new SAXParseResult() ) ); + Assertions.assertTrue( validator.validateXML( source, new SAXParseResult() ) ); } } @Test - public void testAbstractValidatorReaderXml() throws XMLException, IOException { + void testAbstractValidatorReaderXml() throws XMLException, IOException { XMLValidatorSAX validator = XMLValidatorSAX.newInstance( DTD_DEFAULT_RESOLVER, true ); try ( InputStreamReader source = new InputStreamReader( ClassHelper.loadFromDefaultClassLoader( PATH_OK ) ) ) { - Assert.assertNotNull( validator.validateXML( source ) ); + Assertions.assertNotNull( validator.validateXML( source ) ); } } @Test - public void testAbstractValidatorReaderValid() throws XMLException, IOException { + void testAbstractValidatorReaderValid() throws XMLException, IOException { XMLValidatorSAX validator = XMLValidatorSAX.newInstance( DTD_DEFAULT_RESOLVER, true ); try ( InputStreamReader source = new InputStreamReader( ClassHelper.loadFromDefaultClassLoader( PATH_OK ) ) ) { - Assert.assertTrue( validator.isValidaXML( source ) ); + Assertions.assertTrue( validator.isValidaXML( source ) ); } } @Test - public void testAbstractValidatorReaderValidResult() throws XMLException, IOException { + void testAbstractValidatorReaderValidResult() throws XMLException, IOException { XMLValidatorSAX validator = XMLValidatorSAX.newInstance( DTD_DEFAULT_RESOLVER, true ); try ( InputStreamReader source = new InputStreamReader( ClassHelper.loadFromDefaultClassLoader( PATH_OK ) ) ) { - Assert.assertTrue( validator.validateXML( source, new SAXParseResult() ) ); + Assertions.assertTrue( validator.validateXML( source, new SAXParseResult() ) ); } } @Test - public void testAbstractValidatorSourceXml() throws XMLException, IOException { + void testAbstractValidatorSourceXml() throws XMLException, IOException { XMLValidatorSAX validator = XMLValidatorSAX.newInstance( DTD_DEFAULT_RESOLVER, true ); try ( InputStreamReader source = new InputStreamReader( ClassHelper.loadFromDefaultClassLoader( PATH_OK ) ) ) { - Assert.assertNotNull( validator.validateXML( new InputSource( source ) ) ); + Assertions.assertNotNull( validator.validateXML( new InputSource( source ) ) ); } } @Test - public void testAbstractValidatorSourceValid() throws XMLException, IOException { + void testAbstractValidatorSourceValid() throws XMLException, IOException { XMLValidatorSAX validator = XMLValidatorSAX.newInstance( DTD_DEFAULT_RESOLVER, true ); try ( InputStreamReader source = new InputStreamReader( ClassHelper.loadFromDefaultClassLoader( PATH_OK ) ) ) { - Assert.assertTrue( validator.isValidaXML( new InputSource( source ) ) ); + Assertions.assertTrue( validator.isValidaXML( new InputSource( source ) ) ); } } @Test - public void testAbstractValidatorSourceValidResult() throws XMLException, IOException { + void testAbstractValidatorSourceValidResult() throws XMLException, IOException { XMLValidatorSAX validator = XMLValidatorSAX.newInstance( DTD_DEFAULT_RESOLVER, true ); try ( InputStreamReader source = new InputStreamReader( ClassHelper.loadFromDefaultClassLoader( PATH_OK ) ) ) { - Assert.assertTrue( validator.validateXML( new InputSource( source ), new SAXParseResult() ) ); + Assertions.assertTrue( validator.validateXML( new InputSource( source ), new SAXParseResult() ) ); } } @Test - public void testValidationOk1() throws XMLException, IOException { + void testValidationOk1() throws XMLException, IOException { boolean valid = this.validateWorker(DTD_DEFAULT_RESOLVER,PATH_OK); - Assert.assertTrue(valid); + Assertions.assertTrue(valid); } @Test - public void testValidationKo1() throws XMLException, IOException { + void testValidationKo1() throws XMLException, IOException { boolean valid = this.validateWorker(DTD_DEFAULT_RESOLVER,PATH_KO); - Assert.assertFalse(valid); + Assertions.assertFalse(valid); } @Test - public void testEntityResolverWrapper1() throws XMLException, IOException { + void testEntityResolverWrapper1() throws XMLException, IOException { EntityResolverWrapper er = new EntityResolverWrapper(DTD_DEFAULT_RESOLVER); er.setWrappedEntityResolver(DTD_DEFAULT_RESOLVER_ALT); boolean valid = this.validateWorker(er,PATH_OK); - Assert.assertTrue(valid); + Assertions.assertTrue(valid); } @Test - public void testEntityResolverWrapper2() throws XMLException, IOException { + void testEntityResolverWrapper2() throws XMLException, IOException { EntityResolverWrapper er = new EntityResolverWrapper(DTD_DEFAULT_RESOLVER) { @Override public InputSource resolveEntity(String arg0, String arg1) @@ -227,11 +227,11 @@ public InputSource resolveEntity(String arg0, String arg1) } }; boolean valid = this.validateWorker(er,PATH_OK); - Assert.assertTrue(valid); + Assertions.assertTrue(valid); } @Test - public void testEntityResolverWrapper3() throws XMLException, IOException { + void testEntityResolverWrapper3() throws XMLException, IOException { EntityResolverWrapper er = new EntityResolverWrapper(DTD_DEFAULT_RESOLVER) { @Override public InputSource resolveEntity(String arg0, String arg1) @@ -240,11 +240,11 @@ public InputSource resolveEntity(String arg0, String arg1) } }; boolean valid = this.validateWorker(er,PATH_OK_PUBLICID); - Assert.assertTrue(valid); + Assertions.assertTrue(valid); } @Test - public void testEntityResolverWrapper4() throws XMLException, IOException { + void testEntityResolverWrapper4() throws XMLException, IOException { EntityResolverWrapper er = new EntityResolverWrapper(DTD_DEFAULT_RESOLVER_ALT) { @Override public InputSource resolveEntity(String arg0, String arg1) @@ -253,16 +253,16 @@ public InputSource resolveEntity(String arg0, String arg1) } }; boolean valid = this.validateWorker(er,PATH_OK_PUBLICID); - Assert.assertTrue(valid); + Assertions.assertTrue(valid); } @Test - public void testEntityResolverWrapper5() throws XMLException, IOException { - Assert.assertThrows( Exception.class , () -> this.validateWorker(new DoNothingEntityResolver(),PATH_OK) ); + void testEntityResolverWrapper5() throws XMLException, IOException { + Assertions.assertThrows( Exception.class , () -> this.validateWorker(new DoNothingEntityResolver(),PATH_OK) ); } @Test - public void testEntityResolverWrapper6() throws XMLException, IOException { + void testEntityResolverWrapper6() throws XMLException, IOException { EntityResolverWrapper er = new EntityResolverWrapper(DTD_DEFAULT_RESOLVER_ALT) { @Override public InputSource resolveEntity(String arg0, String arg1) @@ -271,15 +271,15 @@ public InputSource resolveEntity(String arg0, String arg1) } }; boolean valid = this.validateWorker(er,PATH_OK); - Assert.assertTrue(valid); + Assertions.assertTrue(valid); } @Test - public void testNewInstance() throws XMLException { - Assert.assertNotNull( XMLValidatorSAX.newInstance() ); - Assert.assertNotNull( XMLValidatorSAX.newInstance( true ) ); - Assert.assertNotNull( XMLValidatorSAX.newInstance( false ) ); - Assert.assertNotNull( XMLValidatorSAX.newInstance( DTD_DEFAULT_RESOLVER ) ); + void testNewInstance() throws XMLException { + Assertions.assertNotNull( XMLValidatorSAX.newInstance() ); + Assertions.assertNotNull( XMLValidatorSAX.newInstance( true ) ); + Assertions.assertNotNull( XMLValidatorSAX.newInstance( false ) ); + Assertions.assertNotNull( XMLValidatorSAX.newInstance( DTD_DEFAULT_RESOLVER ) ); } } diff --git a/fj-core/src/test/java/test/org/fugerit/java/core/xml/sax/TestXmlFactorySAX.java b/fj-core/src/test/java/test/org/fugerit/java/core/xml/sax/TestXmlFactorySAX.java index b156e9a2..f758ee2f 100644 --- a/fj-core/src/test/java/test/org/fugerit/java/core/xml/sax/TestXmlFactorySAX.java +++ b/fj-core/src/test/java/test/org/fugerit/java/core/xml/sax/TestXmlFactorySAX.java @@ -4,53 +4,53 @@ import org.fugerit.java.core.xml.XMLException; import org.fugerit.java.core.xml.sax.XMLFactorySAX; import org.fugerit.java.core.xml.sax.dh.DefaultHandlerComp; -import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; import lombok.extern.slf4j.Slf4j; @Slf4j -public class TestXmlFactorySAX { +class TestXmlFactorySAX { private boolean worker( XMLFactorySAX factory ) throws XMLException { boolean ok = factory != null; if ( ok ) { - Assert.assertNotNull( factory.newSAXParser() ); - Assert.assertNotNull( factory.newXMLValidator() ); - Assert.assertNotNull( factory.newXMLValidator( DefaultHandlerComp.DEFAULT_ER ) ); + Assertions.assertNotNull( factory.newSAXParser() ); + Assertions.assertNotNull( factory.newXMLValidator() ); + Assertions.assertNotNull( factory.newXMLValidator( DefaultHandlerComp.DEFAULT_ER ) ); log.info( "isNamespaceAware {}, isValidating {}", factory.isNamespaceAware(), factory.isValidating() ); } return ok; } @Test - public void test1() throws XMLException { + void test1() throws XMLException { boolean ok = this.worker( XMLFactorySAX.newInstance() ); - Assert.assertTrue(ok); + Assertions.assertTrue(ok); } @Test - public void testSecure() throws XMLException { - Assert.assertNotNull( XMLFactorySAX.makeSAXParserSecure( true, true ) ); - Assert.assertTrue( this.worker( XMLFactorySAX.newInstanceSecure() ) ); - Assert.assertTrue( this.worker( XMLFactorySAX.newInstanceSecure( true ) ) ); - Assert.assertTrue( this.worker( XMLFactorySAX.newInstanceSecure( true, true ) ) ); + void testSecure() throws XMLException { + Assertions.assertNotNull( XMLFactorySAX.makeSAXParserSecure( true, true ) ); + Assertions.assertTrue( this.worker( XMLFactorySAX.newInstanceSecure() ) ); + Assertions.assertTrue( this.worker( XMLFactorySAX.newInstanceSecure( true ) ) ); + Assertions.assertTrue( this.worker( XMLFactorySAX.newInstanceSecure( true, true ) ) ); } @Test - public void test2() throws XMLException { + void test2() throws XMLException { boolean ok = this.worker( XMLFactorySAX.newInstance( true ) ); - Assert.assertTrue(ok); + Assertions.assertTrue(ok); } @Test - public void test3() throws XMLException { + void test3() throws XMLException { boolean ok = this.worker( XMLFactorySAX.newInstance( false ) ); - Assert.assertTrue(ok); + Assertions.assertTrue(ok); } @Test - public void testFinal() throws XMLException { + void testFinal() throws XMLException { XMLFactorySAX factory = XMLFactorySAX.newInstance(); factory.setNamespaceAware( true ); factory.setValidating( true ); @@ -58,14 +58,14 @@ public void testFinal() throws XMLException { factory.setFeature( FeatureUtils.EXTERNAL_PARAMETER_ENTITIES, false ); log.info( "feature {} - {}", FeatureUtils.EXTERNAL_GENERAL_ENTITIES, factory.getFeature( FeatureUtils.EXTERNAL_GENERAL_ENTITIES ) ); boolean ok = this.worker( factory ); - Assert.assertTrue(ok); + Assertions.assertTrue(ok); } @Test - public void testEx() throws XMLException { + void testEx() throws XMLException { XMLFactorySAX factory = XMLFactorySAX.newInstance(); - Assert.assertThrows( XMLException.class, () -> factory.getFeature( "test" ) ); - Assert.assertThrows( XMLException.class, () -> factory.setFeature( "test", true ) ); + Assertions.assertThrows( XMLException.class, () -> factory.getFeature( "test" ) ); + Assertions.assertThrows( XMLException.class, () -> factory.setFeature( "test", true ) ); } } diff --git a/fj-core/src/test/resources/core/lang/binding/binding-catalog-module1.xml b/fj-core/src/test/resources/core/lang/binding/binding-catalog-module1.xml index 83f32630..fba72101 100644 --- a/fj-core/src/test/resources/core/lang/binding/binding-catalog-module1.xml +++ b/fj-core/src/test/resources/core/lang/binding/binding-catalog-module1.xml @@ -5,7 +5,7 @@ - + diff --git a/fj-tool/pom.xml b/fj-tool/pom.xml index 535b465a..41b046a0 100644 --- a/fj-tool/pom.xml +++ b/fj-tool/pom.xml @@ -110,6 +110,12 @@ fj-core + + org.junit.jupiter + junit-jupiter-api + test + + org.fugerit.java fj-test-helper8 diff --git a/fj-tool/src/test/java/test/org/fugerit/java/tool/ArgHelper.java b/fj-tool/src/test/java/test/org/fugerit/java/tool/ArgHelper.java index 7c68a74d..01ed7e5c 100644 --- a/fj-tool/src/test/java/test/org/fugerit/java/tool/ArgHelper.java +++ b/fj-tool/src/test/java/test/org/fugerit/java/tool/ArgHelper.java @@ -17,7 +17,7 @@ import org.fugerit.java.core.io.file.AbstractFileFun; import org.fugerit.java.core.util.PropsIO; -public class ArgHelper { +class ArgHelper { public static void deleteDir( File file ) { diff --git a/fj-tool/src/test/java/test/org/fugerit/java/tool/TestCompress.java b/fj-tool/src/test/java/test/org/fugerit/java/tool/TestCompress.java index 4c6413e1..8505593f 100644 --- a/fj-tool/src/test/java/test/org/fugerit/java/tool/TestCompress.java +++ b/fj-tool/src/test/java/test/org/fugerit/java/tool/TestCompress.java @@ -8,23 +8,23 @@ import org.apache.commons.compress.archivers.sevenz.SevenZOutputFile; import org.fugerit.java.tool.compress.CompressUtils; import org.fugerit.java.tool.compress.sevenz.SevenZArchiveDirFileFun; -import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; -public class TestCompress { +class TestCompress { @Test - public void compressSevenZip() throws IOException { + void compressSevenZip() throws IOException { boolean ok = false; File source = new File( "src/test/resources/tool/params" ); File dest = new File( "target/seven_zip.7z" ); CompressUtils.compress7Zipfile( source , dest ); ok = true; - Assert.assertTrue(ok); + Assertions.assertTrue(ok); } @Test - public void testCompressStream() throws IOException { + void testCompressStream() throws IOException { File dest = new File( "target/seven_test_zip.7z" ); try ( SevenZOutputFile sevenZipFile = new SevenZOutputFile( dest ); OutputStream out = SevenZArchiveDirFileFun.newWrapperStream( sevenZipFile ) ) { @@ -33,14 +33,14 @@ public void testCompressStream() throws IOException { out.write( 10 ); out.write( "test".getBytes() ); } - Assert.assertNotNull( dest ); + Assertions.assertNotNull( dest ); } @Test - public void testFun() throws IOException { + void testFun() throws IOException { File target = new File( "target" ); SevenZArchiveDirFileFun fun = new SevenZArchiveDirFileFun( new File( target, "input" ), new File( target, "output.gz" ) ); - Assert.assertNotNull(fun); + Assertions.assertNotNull(fun); } } diff --git a/fj-tool/src/test/java/test/org/fugerit/java/tool/TestExportQuery.java b/fj-tool/src/test/java/test/org/fugerit/java/tool/TestExportQuery.java index 6b452823..f1ef9cc0 100644 --- a/fj-tool/src/test/java/test/org/fugerit/java/tool/TestExportQuery.java +++ b/fj-tool/src/test/java/test/org/fugerit/java/tool/TestExportQuery.java @@ -3,30 +3,30 @@ import org.fugerit.java.test.db.helper.MemTestDBHelper; import org.fugerit.java.tool.Launcher; import org.fugerit.java.tool.ToolHandler; -import org.junit.Assert; -import org.junit.BeforeClass; -import org.junit.Test; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; -public class TestExportQuery { +class TestExportQuery { public static final String DEFAULT_DB_CONN_PATH = "test/memdb/base-db-conn.properties"; public static final String DEFAULT_DB_INIT_PATH = "test/memdb/base_db_init.sql"; - @BeforeClass - public static void init() { + @BeforeAll + static void init() { MemTestDBHelper.init( DEFAULT_DB_CONN_PATH , DEFAULT_DB_INIT_PATH ); } @Test - public void testExportQuery() throws Exception { + void testExportQuery() throws Exception { int res = Launcher.handle( ArgHelper.readTestParams( "export-query" ) ); - Assert.assertEquals( ToolHandler.EXIT_OK , res ); + Assertions.assertEquals( ToolHandler.EXIT_OK , res ); } @Test - public void testExportQueryFail() throws Exception { + void testExportQueryFail() throws Exception { int res = Launcher.handle( ArgHelper.readTestParams( "export-query-fail" ) ); - Assert.assertNotEquals( ToolHandler.EXIT_OK , res ); + Assertions.assertNotEquals( ToolHandler.EXIT_OK , res ); } diff --git a/fj-tool/src/test/java/test/org/fugerit/java/tool/TestExtractFixedConfigHandler.java b/fj-tool/src/test/java/test/org/fugerit/java/tool/TestExtractFixedConfigHandler.java index b045a374..9bd8553d 100644 --- a/fj-tool/src/test/java/test/org/fugerit/java/tool/TestExtractFixedConfigHandler.java +++ b/fj-tool/src/test/java/test/org/fugerit/java/tool/TestExtractFixedConfigHandler.java @@ -1,22 +1,22 @@ package test.org.fugerit.java.tool; -import static org.junit.Assert.assertTrue; -import static org.junit.Assert.fail; +import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.junit.jupiter.api.Assertions.fail; import java.util.Properties; import org.fugerit.java.tool.Launcher; import org.fugerit.java.tool.ToolHandlerHelper; import org.fugerit.java.tool.fixed.ExtractFixedConfigHandler; -import org.junit.Test; +import org.junit.jupiter.api.Test; import lombok.extern.slf4j.Slf4j; @Slf4j -public class TestExtractFixedConfigHandler { +class TestExtractFixedConfigHandler { @Test - public void test() { + void test() { boolean ok = false; try { Properties params = new Properties(); @@ -35,7 +35,7 @@ public void test() { } @Test - public void testKo1() { + void testKo1() { boolean ok = false; try { Properties params = new Properties(); diff --git a/fj-tool/src/test/java/test/org/fugerit/java/tool/TestLauncher.java b/fj-tool/src/test/java/test/org/fugerit/java/tool/TestLauncher.java index 4a634664..19fb1837 100644 --- a/fj-tool/src/test/java/test/org/fugerit/java/tool/TestLauncher.java +++ b/fj-tool/src/test/java/test/org/fugerit/java/tool/TestLauncher.java @@ -1,6 +1,6 @@ package test.org.fugerit.java.tool; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertTrue; import java.io.File; import java.io.FileInputStream; @@ -12,13 +12,13 @@ import org.fugerit.java.core.io.StreamIO; import org.fugerit.java.tool.Launcher; import org.fugerit.java.tool.ToolHandler; -import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; -public class TestLauncher { +class TestLauncher { @Test - public void testHelp() { + void testHelp() { boolean ok = false; String[] params = { ArgUtils.getArgString( Launcher.ARG_HELP ), "1" }; Launcher.main( params ); @@ -27,23 +27,23 @@ public void testHelp() { } @Test - public void testToolNotFound() { + void testToolNotFound() { int res = Launcher.handle( ArgHelper.readTestParams( "tool-not-found" ) ); - Assert.assertNotEquals( ToolHandler.EXIT_OK , res); + Assertions.assertNotEquals( ToolHandler.EXIT_OK , res); } @Test - public void testCharseCorrectHelp() { + void testCharseCorrectHelp() { String[] test = { "charset-correct-help", "verbose", "verbose-help", "fixed-to-excel", "send-mail" }; for ( String id : test ) { int res = Launcher.handle( ArgHelper.readTestParams( id ) ); - Assert.assertEquals( ToolHandler.EXIT_OK , res); + Assertions.assertEquals( ToolHandler.EXIT_OK , res); } } @Test - public void testCharseCorrectNonUtf8() throws IOException { + void testCharseCorrectNonUtf8() throws IOException { File outputDir = new File( "target/charset_correct_test1" ); ArgHelper.deleteDir( outputDir ); ArgHelper.copyDir( new File( "src/test/resources/tool/charset_correct" ) , outputDir ); @@ -52,7 +52,7 @@ public void testCharseCorrectNonUtf8() throws IOException { StreamIO.pipeStream( new GZIPInputStream( new FileInputStream( new File( "target/charset_correct_test1/test_no_utf8.gz" ) ) ) , new FileOutputStream( new File( "target/charset_correct_test1/test_no_utf8.properties" ) ) , StreamIO.MODE_CLOSE_BOTH); int res = Launcher.handle( ArgHelper.readTestParams( "charset-correct-non-utf8" ) ); - Assert.assertEquals( ToolHandler.EXIT_OK , res); + Assertions.assertEquals( ToolHandler.EXIT_OK , res); } } diff --git a/fj-tool/src/test/java/test/org/fugerit/java/tool/TestRunToolException.java b/fj-tool/src/test/java/test/org/fugerit/java/tool/TestRunToolException.java index 2750d74b..96a5b456 100644 --- a/fj-tool/src/test/java/test/org/fugerit/java/tool/TestRunToolException.java +++ b/fj-tool/src/test/java/test/org/fugerit/java/tool/TestRunToolException.java @@ -4,49 +4,49 @@ import java.sql.SQLException; import org.fugerit.java.tool.RunToolException; -import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; -public class TestRunToolException { +class TestRunToolException { @Test - public void testEx1() { - Assert.assertNotNull( new RunToolException() ); + void testEx1() { + Assertions.assertNotNull( new RunToolException() ); } @Test - public void testEx2() { - Assert.assertNotNull( new RunToolException( "a" ) ); + void testEx2() { + Assertions.assertNotNull( new RunToolException( "a" ) ); } @Test - public void testEx3() { - Assert.assertNotNull( new RunToolException( new SQLException( "b" ) ) ); + void testEx3() { + Assertions.assertNotNull( new RunToolException( new SQLException( "b" ) ) ); } @Test - public void testEx4() { - Assert.assertNotNull( new RunToolException( "c", new SQLException( "d" ) ) ); + void testEx4() { + Assertions.assertNotNull( new RunToolException( "c", new SQLException( "d" ) ) ); } @Test - public void testEx12() throws RunToolException { - Assert.assertThrows( RunToolException.class, () -> RunToolException.stadardExceptionWrapping( new IOException( "n" ) ) ); + void testEx12() throws RunToolException { + Assertions.assertThrows( RunToolException.class, () -> RunToolException.stadardExceptionWrapping( new IOException( "n" ) ) ); } @Test - public void testEx5() { - Assert.assertNotNull( RunToolException.convertEx( "e" , new SQLException( "f" ) ) ); + void testEx5() { + Assertions.assertNotNull( RunToolException.convertEx( "e" , new SQLException( "f" ) ) ); } @Test - public void testEx6() { - Assert.assertNotNull( RunToolException.convertEx( "g" , new RunToolException( "g" ) ) ); + void testEx6() { + Assertions.assertNotNull( RunToolException.convertEx( "g" , new RunToolException( "g" ) ) ); } @Test - public void testEx7() { - Assert.assertNotNull( RunToolException.convertExMethod( "e" , new SQLException( "f" ) ) ); + void testEx7() { + Assertions.assertNotNull( RunToolException.convertExMethod( "e" , new SQLException( "f" ) ) ); } diff --git a/pom.xml b/pom.xml index 859ad6a1..a8e3a906 100644 --- a/pom.xml +++ b/pom.xml @@ -142,12 +142,7 @@ org.hsqldb hsqldb test - - - junit - junit - test - + org.awaitility