You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hop.apache.org by ha...@apache.org on 2026/03/07 08:18:59 UTC
(hop) branch main updated: Migrate unit tests from JUnit 4 to JUnit 5(Jupiter) (#6724)
This is an automated email from the ASF dual-hosted git repository.
hansva pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/hop.git
The following commit(s) were added to refs/heads/main by this push:
new 1ba76231be Migrate unit tests from JUnit 4 to JUnit 5(Jupiter) (#6724)
1ba76231be is described below
commit 1ba76231be367a4172107950c046f201d8f2cff2
Author: lance <le...@gmail.com>
AuthorDate: Sat Mar 7 16:18:54 2026 +0800
Migrate unit tests from JUnit 4 to JUnit 5(Jupiter) (#6724)
Signed-off-by: lance <le...@gmail.com>
---
.../java/org/apache/hop/core/QueueRowSetTest.java | 23 +-
.../test/java/org/apache/hop/core/RowSetTest.java | 69 ++--
.../java/org/apache/hop/core/TimedRowTest.java | 16 +-
.../extension/ExtensionPointIntegrationTest.java | 46 ++-
.../fileinput/NonAccessibleFileObjectTest.java | 46 +--
.../apache/hop/core/logging/HopLogLayoutTest.java | 12 +-
.../logging/LogChannelFileWriterBufferTest.java | 9 +-
.../apache/hop/core/logging/LogChannelTest.java | 54 ++--
.../apache/hop/core/logging/LoggingBufferTest.java | 25 +-
.../apache/hop/core/logging/LoggingObjectTest.java | 12 +-
.../hop/core/logging/LoggingPluginTypeTest.java | 20 +-
...Test.java => LoggingRegistrySingletonTest.java} | 21 +-
.../hop/core/logging/LoggingRegistryTest.java | 19 +-
.../hop/core/logging/MetricsRegistryTest.java | 35 ++-
.../hop/core/metrics/MetricsDurationTest.java | 23 +-
.../parameters/DuplicateParamExceptionTest.java | 17 +-
.../core/parameters/NamedParamsDefaultTest.java | 27 +-
.../core/parameters/NamedParamsExceptionTest.java | 12 +-
.../core/parameters/UnknownParamExceptionTest.java | 12 +-
.../hop/core/plugins/PluginRegistryUnitTest.java | 60 ++--
.../org/apache/hop/core/plugins/PluginTest.java | 13 +-
.../org/apache/hop/core/row/ValueDataUtilTest.java | 328 ++++++++++---------
.../org/apache/hop/core/row/ValueMetaTest.java | 209 +++++++------
.../hop/core/row/value/ValueMetaFactoryTest.java | 346 +++++++++++----------
.../value/timestamp/SimpleTimestampFormatTest.java | 114 +++----
.../apache/hop/core/spreadsheet/KCellTypeTest.java | 9 +-
.../java/org/apache/hop/core/svg/SvgImageTest.java | 14 +-
.../org/apache/hop/core/svg/SvgSupportTest.java | 45 ++-
.../org/apache/hop/core/util/DateDetectorTest.java | 52 ++--
.../org/apache/hop/core/util/JsonUtilTest.java | 49 ++-
.../apache/hop/core/util/StringEvaluatorTest.java | 159 +++++-----
.../org/apache/hop/core/util/StringUtilTest.java | 49 +--
.../java/org/apache/hop/core/util/UtilsTest.java | 78 ++---
.../hop/core/variables/VariableRegistryTest.java | 22 +-
.../apache/hop/core/variables/VariablesTest.java | 35 +--
.../java/org/apache/hop/core/vfs/HopVfsTest.java | 20 +-
.../org/apache/hop/core/xml/XmlFormatterTest.java | 51 +--
.../apache/hop/core/xml/XmlHandlerUnitTest.java | 171 +++++-----
.../java/org/apache/hop/core/xml/XmlUtilsTest.java | 15 +-
.../org/apache/hop/i18n/GlobalMessageUtilTest.java | 74 ++---
.../org/apache/hop/i18n/GlobalMessagesTest.java | 13 +-
.../json/JsonMetadataSerializerTest.java | 28 +-
.../serializer/xml/XmlMetadataUtilTest.java | 10 +-
.../java/org/apache/hop/server/HttpUtilTest.java | 40 +--
.../hop/server/ServerConnectionManagerTest.java | 24 +-
.../java/org/apache/hop/base/AbstractMetaTest.java | 78 +++--
.../ActiveSubPipelineConcurrencyTest.java | 8 +-
.../hop/concurrency/BaseRowSetConcurrentTest.java | 15 +-
.../concurrency/BaseTransformConcurrencyTest.java | 32 +-
.../hop/concurrency/RowMetaConcurrencyTest.java | 28 +-
.../concurrency/WorkflowMapConcurrencyTest.java | 15 +-
.../WorkflowTrackerConcurrencyTest.java | 73 ++---
.../hop/core/ConcurrentMapPropertiesTest.java | 32 +-
.../java/org/apache/hop/core/NotePadMetaTest.java | 8 +-
.../hop/core/attributes/AttributesUtilTest.java | 43 ++-
.../core/auth/core/AuthenticationManagerTest.java | 43 ++-
.../DefaultAuthenticationConsumerFactoryTest.java | 42 ++-
.../core/compress/CompressionInputStreamTest.java | 53 ++--
.../core/compress/CompressionOutputStreamTest.java | 49 +--
.../core/compress/CompressionPluginTypeTest.java | 24 +-
.../compress/CompressionProviderFactoryTest.java | 42 +--
.../core/compress/NoneCompressionProviderTest.java | 45 ++-
.../gzip/GzipCompressionInputStreamTest.java | 48 +--
.../gzip/GzipCompressionOutputStreamTest.java | 40 +--
.../compress/gzip/GzipCompressionProviderTest.java | 39 ++-
.../snappy/SnappyCompressionInputStreamTest.java | 40 +--
.../snappy/SnappyCompressionOutputStreamTest.java | 40 +--
.../snappy/SnappyCompressionProviderTest.java | 41 ++-
.../zip/ZipCompressionInputStreamTest.java | 43 +--
.../zip/ZipCompressionOutputStreamTest.java | 62 ++--
.../compress/zip/ZipCompressionProviderTest.java | 43 ++-
.../apache/hop/core/gui/WorkflowTrackerTest.java | 36 +--
.../injection/MetaAnnotationInjectionTest.java | 141 ++++-----
.../hop/core/injection/MetaPropInjectionTest.java | 106 ++++---
.../hop/core/logging/LogChannelFileWriterTest.java | 25 +-
.../apache/hop/core/logging/LogMessageTest.java | 40 ++-
.../metadata/SerializableMetadataProviderTest.java | 16 +-
.../core/reflection/StringSearchResultTest.java | 11 +-
.../core/util/ConfigurableStreamLoggerTest.java | 31 +-
.../apache/hop/core/util/JavaScriptUtilsTest.java | 160 ++++++----
.../apache/hop/execution/ExecutionDataTest.java | 16 +-
.../org/apache/hop/history/AuditManagerTest.java | 67 ++--
.../apache/hop/pipeline/DatabaseImpactTest.java | 23 +-
.../apache/hop/pipeline/ModPartitionerTest.java | 18 +-
.../hop/pipeline/PDI_11948_PipelineTest.java | 11 +-
.../org/apache/hop/pipeline/PipelineMetaTest.java | 214 ++++++-------
.../java/org/apache/hop/pipeline/PipelineTest.java | 131 +++-----
.../org/apache/hop/pipeline/RowProducerTest.java | 28 +-
.../hop/pipeline/TransformWithMappingMetaTest.java | 75 +++--
.../transform/BaseTransformMetaCloningTest.java | 22 +-
.../hop/pipeline/transform/BaseTransformTest.java | 155 ++++-----
.../pipeline/transform/TransformErrorMetaTest.java | 14 +-
.../hop/pipeline/transform/TransformMetaTest.java | 20 +-
.../pipeline/transform/TransformOptionTest.java | 40 +--
.../pipeline/transform/TransformStatusTest.java | 8 +-
.../java/org/apache/hop/server/HopServerTest.java | 74 ++---
.../java/org/apache/hop/utils/FileUtilsTest.java | 39 +--
.../org/apache/hop/workflow/WorkflowMetaTest.java | 57 ++--
.../java/org/apache/hop/workflow/WorkflowTest.java | 71 +----
.../apache/hop/www/BaseHopServerPluginTest.java | 28 +-
.../hop/www/GetPipelineStatusServletTest.java | 16 +-
.../org/apache/hop/www/GetRootServletTest.java | 7 +-
.../org/apache/hop/www/GetStatusServletTest.java | 21 +-
.../hop/www/GetWorkflowStatusServletTest.java | 19 +-
.../org/apache/hop/www/HopServerConfigTest.java | 111 ++++---
.../hop/www/HopServerPipelineStatusTest.java | 56 ++--
.../java/org/apache/hop/www/HopServerTest.java | 40 ++-
.../hop/www/HopServerWorkflowStatusTest.java | 54 ++--
.../apache/hop/www/PausePipelineServletTest.java | 17 +-
.../www/PrepareExecutionPipelineServletTest.java | 18 +-
.../apache/hop/www/RemovePipelineServletTest.java | 16 +-
.../apache/hop/www/RemoveWorkflowServletTest.java | 16 +-
.../apache/hop/www/SniffTransformServletTest.java | 16 +-
.../hop/www/StartExecutionPipelineServletTest.java | 16 +-
.../apache/hop/www/StartPipelineServletTest.java | 17 +-
.../apache/hop/www/StartWorkflowServletTest.java | 17 +-
.../apache/hop/www/StopWorkflowServletTest.java | 18 +-
.../java/org/apache/hop/www/WebResultTest.java | 20 +-
.../java/org/apache/hop/www/WebServerTest.java | 49 ++-
.../test/util/SingleThreadedExecutionGuarder.java | 31 +-
.../hop/ui/core/bus/HopGuiEventsHandlerTest.java | 47 ++-
.../EditRowsDialog_EmptyStringVsNull_Test.java | 21 +-
.../hop/ui/core/widget/text/TextFormatterTest.java | 22 +-
.../hopgui/terminal/HopGuiTerminalPanelTest.java | 101 +++---
.../hopgui/terminal/TerminalShellDetectorTest.java | 36 +--
.../CsvInputAwareImportProgressDialogTest.java | 39 ++-
.../apache/hop/ui/util/EngineMetaUtilsTest.java | 10 +-
.../apache/hop/ui/util/EnvironmentUtilsTest.java | 45 ++-
128 files changed, 3016 insertions(+), 3109 deletions(-)
diff --git a/core/src/test/java/org/apache/hop/core/QueueRowSetTest.java b/core/src/test/java/org/apache/hop/core/QueueRowSetTest.java
index 699a4bc613..c95e72d788 100644
--- a/core/src/test/java/org/apache/hop/core/QueueRowSetTest.java
+++ b/core/src/test/java/org/apache/hop/core/QueueRowSetTest.java
@@ -16,44 +16,45 @@
*/
package org.apache.hop.core;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertSame;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertSame;
import java.util.concurrent.TimeUnit;
import org.apache.hop.core.row.RowMeta;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
-public class QueueRowSetTest {
+/** Unit test for {@link QueueRowSet} */
+class QueueRowSetTest {
Object[] row;
QueueRowSet rowSet;
- @Before
- public void setup() {
+ @BeforeEach
+ void setup() {
rowSet = new QueueRowSet();
row = new Object[] {};
}
@Test
- public void testPutRow() {
+ void testPutRow() {
rowSet.putRow(new RowMeta(), row);
assertSame(row, rowSet.getRow());
}
@Test
- public void testPutRowWait() {
+ void testPutRowWait() {
rowSet.putRowWait(new RowMeta(), row, 1, TimeUnit.SECONDS);
assertSame(row, rowSet.getRowWait(1, TimeUnit.SECONDS));
}
@Test
- public void testGetRowImmediate() {
+ void testGetRowImmediate() {
rowSet.putRow(new RowMeta(), row);
assertSame(row, rowSet.getRowImmediate());
}
@Test
- public void testSize() {
+ void testSize() {
assertEquals(0, rowSet.size());
rowSet.putRow(new RowMeta(), row);
assertEquals(1, rowSet.size());
diff --git a/core/src/test/java/org/apache/hop/core/RowSetTest.java b/core/src/test/java/org/apache/hop/core/RowSetTest.java
index 561230452e..5cdb0a122b 100644
--- a/core/src/test/java/org/apache/hop/core/RowSetTest.java
+++ b/core/src/test/java/org/apache/hop/core/RowSetTest.java
@@ -17,22 +17,22 @@
package org.apache.hop.core;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
import org.apache.hop.core.row.IRowMeta;
import org.apache.hop.core.row.IValueMeta;
import org.apache.hop.core.row.RowMeta;
import org.apache.hop.core.row.value.ValueMetaInteger;
-import org.apache.hop.junit.rules.RestoreHopEnvironment;
-import org.junit.ClassRule;
-import org.junit.Test;
+import org.apache.hop.junit.rules.RestoreHopEnvironmentExtension;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.ExtendWith;
/** Test class for the basic functionality of IRowSet. */
-public class RowSetTest {
- @ClassRule public static RestoreHopEnvironment env = new RestoreHopEnvironment();
+@ExtendWith(RestoreHopEnvironmentExtension.class)
+class RowSetTest {
- public IRowMeta createRowMetaInterface() {
+ IRowMeta createRowMetaInterface() {
IRowMeta rm = new RowMeta();
IValueMeta[] valuesMeta = {
@@ -48,18 +48,16 @@ public class RowSetTest {
/** The basic stuff. */
@Test
- public void testBasicCreation() {
+ void testBasicCreation() {
IRowSet set = new BlockingRowSet(10);
- assertTrue(!set.isDone());
- // TODO assertTrue(set.isEmpty());
- // TODO assertTrue(!set.isFull());
+ assertFalse(set.isDone());
assertEquals(0, set.size());
}
/** Functionality test. */
@Test
- public void testFuntionality1() {
+ void testFunctionality1() {
IRowSet set = new BlockingRowSet(3);
IRowMeta rm = createRowMetaInterface();
@@ -70,97 +68,76 @@ public class RowSetTest {
Object[] r4 = new Object[] {4L};
Object[] r5 = new Object[] {5L};
- // TODO assertTrue(set.isEmpty());
assertEquals(0, set.size());
// Add first row. State 1
set.putRow(rm, r1);
- // TODO assertTrue(!set.isEmpty());
- // TODO assertTrue(!set.isFull());
+
assertEquals(1, set.size());
// Add another row. State: 1 2
set.putRow(rm, r2);
- // TODO assertTrue(!set.isEmpty());
- // TODO assertTrue(!set.isFull());
+
assertEquals(2, set.size());
// Pop off row. State: 2
Object[] r = set.getRow();
int i = rm.indexOfValue("ROWNR");
assertEquals(1L, ((Long) r[i]).longValue());
- // TODO assertTrue(!set.isEmpty());
- // TODO assertTrue(!set.isFull());
+
assertEquals(1, set.size());
// Add another row. State: 2 3
set.putRow(rm, r3);
- // TODO assertTrue(!set.isEmpty());
- // TODO assertTrue(!set.isFull());
+
assertEquals(2, set.size());
// Add another row. State: 2 3 4
set.putRow(rm, r4);
- // TODO assertTrue(!set.isEmpty());
- // TODO assertTrue(set.isFull());
+
assertEquals(3, set.size());
- /*********************************************************************
+ /*
* This was made in more restrict in older version v2.5.0 with a new IRowSet implementation. After older version v2.5.0 you may not try to put
* more rows in a rowset then it can hold (this functionality was also never used in Apache Hop anyway).
- *
- * // Add another row. State: 2 3 4 5 // Note that we can still add rows after the set is full. set.putRow(r5);
- * assertTrue(!set.isEmpty()); assertTrue(set.isFull()); assertEquals(4, set.size());
- *********************************************************************/
+ */
// Pop off row. State: 3 4
r = set.getRow();
i = rm.indexOfValue("ROWNR");
assertEquals(2L, ((Long) r[i]).longValue());
- // TODO assertTrue(!set.isEmpty());
- // TODO assertTrue(!set.isFull());
+
assertEquals(2, set.size());
// Add another row. State: 3 4 5
set.putRow(rm, r5);
- // TODO assertTrue(!set.isEmpty());
- // TODO assertTrue(set.isFull());
assertEquals(3, set.size());
// Pop off row. State: 4 5
r = set.getRow();
i = rm.indexOfValue("ROWNR");
assertEquals(3L, ((Long) r[i]).longValue());
- // TODO assertTrue(!set.isEmpty());
- // TODO assertTrue(!set.isFull());
+
assertEquals(2, set.size());
// Pop off row. State: 5
r = set.getRow();
i = rm.indexOfValue("ROWNR");
assertEquals(4L, ((Long) r[i]).longValue());
- // TODO assertTrue(!set.isEmpty());
- // TODO assertTrue(!set.isFull());
+
assertEquals(1, set.size());
// Pop off row. State:
r = set.getRow();
i = rm.indexOfValue("ROWNR");
assertEquals(5L, ((Long) r[i]).longValue());
- // TODO assertTrue(set.isEmpty());
- // TODO assertTrue(!set.isFull());
- assertEquals(0, set.size());
- /*********************************************************************
- * This was changed v2.5.0 with a new IRowSet // Pop off row. State: try { r = set.getRow();
- * fail("expected NoSuchElementException"); } catch ( IndexOutOfBoundsException ex ) { } assertTrue(set.isEmpty());
- * assertTrue(!set.isFull()); assertEquals(0, set.size());
- **********************************************************************/
+ assertEquals(0, set.size());
}
/** Names test. Just for completeness. */
@Test
- public void testNames() {
+ void testNames() {
IRowSet set = new BlockingRowSet(3);
set.setThreadNameFromToCopy("from", 2, "to", 3);
diff --git a/core/src/test/java/org/apache/hop/core/TimedRowTest.java b/core/src/test/java/org/apache/hop/core/TimedRowTest.java
index 2d2df98424..03a5d65f08 100644
--- a/core/src/test/java/org/apache/hop/core/TimedRowTest.java
+++ b/core/src/test/java/org/apache/hop/core/TimedRowTest.java
@@ -16,17 +16,19 @@
*/
package org.apache.hop.core;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotSame;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertSame;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotSame;
+import static org.junit.jupiter.api.Assertions.assertNull;
+import static org.junit.jupiter.api.Assertions.assertSame;
import java.util.Date;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
+
+/** Unit test for {@link TimedRow} */
+class TimedRowTest {
-public class TimedRowTest {
@Test
- public void testClass() {
+ void testClass() {
final long time = 1447691729119L;
final Date date = new Date(time);
final Object[] data = new Object[] {"value1", "value2", null};
diff --git a/core/src/test/java/org/apache/hop/core/extension/ExtensionPointIntegrationTest.java b/core/src/test/java/org/apache/hop/core/extension/ExtensionPointIntegrationTest.java
index c248eca2ab..0ad736e78f 100644
--- a/core/src/test/java/org/apache/hop/core/extension/ExtensionPointIntegrationTest.java
+++ b/core/src/test/java/org/apache/hop/core/extension/ExtensionPointIntegrationTest.java
@@ -16,11 +16,11 @@
*/
package org.apache.hop.core.extension;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNotSame;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertNotSame;
+import static org.junit.jupiter.api.Assertions.assertNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.mockito.Mockito.mock;
import java.util.ArrayList;
@@ -44,20 +44,20 @@ import org.apache.hop.core.exception.HopPluginException;
import org.apache.hop.core.logging.ILogChannel;
import org.apache.hop.core.plugins.IPlugin;
import org.apache.hop.core.plugins.PluginRegistry;
-import org.apache.hop.junit.rules.RestoreHopEnvironment;
-import org.junit.BeforeClass;
-import org.junit.ClassRule;
-import org.junit.Test;
+import org.apache.hop.junit.rules.RestoreHopEnvironmentExtension;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.ExtendWith;
-public class ExtensionPointIntegrationTest {
- @ClassRule public static RestoreHopEnvironment env = new RestoreHopEnvironment();
+@ExtendWith(RestoreHopEnvironmentExtension.class)
+class ExtensionPointIntegrationTest {
public static final String EXECUTED_FIELD_NAME = "executed";
private static final int TOTAL_THREADS_TO_RUN = 2000;
private static final int MAX_TIMEOUT_SECONDS = 60;
private static ClassPool pool;
- @BeforeClass
- public static void setupBeforeClass() throws Exception {
+ @BeforeAll
+ static void setupBeforeClass() throws Exception {
pool = ClassPool.getDefault();
pool.insertClassPath(new ClassClassPath(ExtensionPointIntegrationTest.class));
for (HopExtensionPoint ep : HopExtensionPoint.values()) {
@@ -70,7 +70,7 @@ public class ExtensionPointIntegrationTest {
}
@Test
- public void test() throws Exception {
+ void test() throws Exception {
// check that all extension points are added to the map
assertEquals(
HopExtensionPoint.values().length, ExtensionPointMap.getInstance().getNumberOfRows());
@@ -115,7 +115,7 @@ public class ExtensionPointIntegrationTest {
HopExtensionPoint.values().length - 1, ExtensionPointMap.getInstance().getNumberOfRows());
}
- private static Class createClassRuntime(HopExtensionPoint ep)
+ private static Class<?> createClassRuntime(HopExtensionPoint ep)
throws NotFoundException, CannotCompileException {
return createClassRuntime(ep, "");
}
@@ -126,10 +126,8 @@ public class ExtensionPointIntegrationTest {
* @param ep extension point id
* @param addition addition to class name to avoid duplicate classes
* @return class
- * @throws NotFoundException
- * @throws CannotCompileException
*/
- private static Class createClassRuntime(HopExtensionPoint ep, String addition)
+ private static Class<?> createClassRuntime(HopExtensionPoint ep, String addition)
throws NotFoundException, CannotCompileException {
final CtClass ctClass = pool.makeClass("Plugin" + ep.id + addition);
ctClass.addInterface(pool.get(IExtensionPoint.class.getCanonicalName()));
@@ -145,7 +143,7 @@ public class ExtensionPointIntegrationTest {
}
@Test
- public void testExtensionPointMapConcurrency() throws InterruptedException {
+ void testExtensionPointMapConcurrency() throws InterruptedException {
final ILogChannel log = mock(ILogChannel.class);
List<Runnable> parallelTasksList = new ArrayList<>(TOTAL_THREADS_TO_RUN);
@@ -215,17 +213,17 @@ public class ExtensionPointIntegrationTest {
}
// wait until all threads are ready
assertTrue(
- "Timeout initializing threads! Perform long lasting initializations before passing runnables to assertConcurrent",
- allExecutorThreadsReady.await(10L * runnables.size(), TimeUnit.MILLISECONDS));
+ allExecutorThreadsReady.await(10L * runnables.size(), TimeUnit.MILLISECONDS),
+ "Timeout initializing threads! Perform long lasting initializations before passing runnables to assertConcurrent");
// start all test runners
afterInitBlocker.countDown();
assertTrue(
- String.format("Timeout! Run took more than %s seconds", MAX_TIMEOUT_SECONDS),
- allDone.await(MAX_TIMEOUT_SECONDS, TimeUnit.SECONDS));
+ allDone.await(MAX_TIMEOUT_SECONDS, TimeUnit.SECONDS),
+ String.format("Timeout! Run took more than %s seconds", MAX_TIMEOUT_SECONDS));
} finally {
threadPool.shutdownNow();
}
assertTrue(
- String.format(" Run failed with exception(s): %s", exceptions), exceptions.isEmpty());
+ exceptions.isEmpty(), String.format(" Run failed with exception(s): %s", exceptions));
}
}
diff --git a/core/src/test/java/org/apache/hop/core/fileinput/NonAccessibleFileObjectTest.java b/core/src/test/java/org/apache/hop/core/fileinput/NonAccessibleFileObjectTest.java
index df18913c78..69f1497955 100644
--- a/core/src/test/java/org/apache/hop/core/fileinput/NonAccessibleFileObjectTest.java
+++ b/core/src/test/java/org/apache/hop/core/fileinput/NonAccessibleFileObjectTest.java
@@ -16,89 +16,95 @@
*/
package org.apache.hop.core.fileinput;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertNull;
+import static org.junit.jupiter.api.Assertions.assertThrows;
import org.apache.commons.vfs2.FileSystemException;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
-public class NonAccessibleFileObjectTest {
+/** Unit test for {@link NonAccessibleFileObject} */
+class NonAccessibleFileObjectTest {
@Test
- public void testGetPublicURIString() {
+ void testGetPublicURIString() {
NonAccessibleFileObject obj = new NonAccessibleFileObject("s3:///mybucket/mykey");
assertEquals("s3:///mybucket/mykey", obj.getPublicURIString());
}
@Test
- public void testGetPublicURIStringWithNullPath() {
+ void testGetPublicURIStringWithNullPath() {
NonAccessibleFileObject obj = new NonAccessibleFileObject(null);
- assertEquals(null, obj.getPublicURIString());
+ assertNull(obj.getPublicURIString());
}
@Test
- public void testExists() throws FileSystemException {
+ void testExists() throws FileSystemException {
NonAccessibleFileObject obj = new NonAccessibleFileObject("s3:///mybucket");
assertFalse(obj.exists());
}
@Test
- public void testIsReadable() throws FileSystemException {
+ void testIsReadable() throws FileSystemException {
NonAccessibleFileObject obj = new NonAccessibleFileObject("s3:///mybucket");
assertFalse(obj.isReadable());
}
@Test
- public void testIsWriteable() throws FileSystemException {
+ void testIsWriteable() throws FileSystemException {
NonAccessibleFileObject obj = new NonAccessibleFileObject("s3:///mybucket");
assertFalse(obj.isWriteable());
}
@Test
- public void testCanRenameTo() {
+ void testCanRenameTo() {
NonAccessibleFileObject obj = new NonAccessibleFileObject("s3:///mybucket");
assertFalse(obj.canRenameTo(null));
}
@Test
- public void testGetURL() throws FileSystemException {
+ void testGetURL() throws FileSystemException {
NonAccessibleFileObject obj = new NonAccessibleFileObject("http://example.com/file");
assertEquals("http://example.com/file", obj.getURL().toString());
}
- @Test(expected = FileSystemException.class)
- public void testGetURLWithInvalidURL() throws FileSystemException {
+ @Test
+ void testGetURLWithInvalidURL() {
NonAccessibleFileObject obj = new NonAccessibleFileObject("not a valid url");
- obj.getURL();
+ assertThrows(FileSystemException.class, obj::getURL);
}
@Test
- public void testIsAttached() {
+ void testIsAttached() {
NonAccessibleFileObject obj = new NonAccessibleFileObject("s3:///mybucket");
assertFalse(obj.isAttached());
}
@Test
- public void testIsContentOpen() {
+ void testIsContentOpen() {
NonAccessibleFileObject obj = new NonAccessibleFileObject("s3:///mybucket");
assertFalse(obj.isContentOpen());
}
@Test
- public void testIsHidden() throws FileSystemException {
+ void testIsHidden() throws FileSystemException {
NonAccessibleFileObject obj = new NonAccessibleFileObject("s3:///mybucket");
assertFalse(obj.isHidden());
}
@Test
- public void testCloseDoesNotThrow() throws FileSystemException {
+ void testCloseDoesNotThrow() throws FileSystemException {
NonAccessibleFileObject obj = new NonAccessibleFileObject("s3:///mybucket");
+ assertNotNull(obj);
obj.close();
}
@Test
- public void testRefreshDoesNotThrow() throws FileSystemException {
+ void testRefreshDoesNotThrow() throws FileSystemException {
NonAccessibleFileObject obj = new NonAccessibleFileObject("s3:///mybucket");
+ assertNotNull(obj);
obj.refresh();
}
}
diff --git a/core/src/test/java/org/apache/hop/core/logging/HopLogLayoutTest.java b/core/src/test/java/org/apache/hop/core/logging/HopLogLayoutTest.java
index 158910ae2c..ff7fdf0397 100644
--- a/core/src/test/java/org/apache/hop/core/logging/HopLogLayoutTest.java
+++ b/core/src/test/java/org/apache/hop/core/logging/HopLogLayoutTest.java
@@ -16,15 +16,15 @@
*/
package org.apache.hop.core.logging;
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
/** Test for {@link HopLogLayout}. */
-public class HopLogLayoutTest {
+class HopLogLayoutTest {
@Test
- public void testFormat() {
+ void testFormat() {
LogMessage mcg =
new LogMessage("Log message for {0}", "Channel 01", new String[] {"Test"}, LogLevel.DEBUG);
@@ -34,8 +34,8 @@ public class HopLogLayoutTest {
final String formattedMsg = layout.format(event);
assertEquals(
- "The log message must be formatted and not contain placeholders.",
"Log message for Test",
- formattedMsg.substring(formattedMsg.indexOf('-') + 2));
+ formattedMsg.substring(formattedMsg.indexOf('-') + 2),
+ "The log message must be formatted and not contain placeholders.");
}
}
diff --git a/core/src/test/java/org/apache/hop/core/logging/LogChannelFileWriterBufferTest.java b/core/src/test/java/org/apache/hop/core/logging/LogChannelFileWriterBufferTest.java
index ff5b0df269..ec80c733cd 100644
--- a/core/src/test/java/org/apache/hop/core/logging/LogChannelFileWriterBufferTest.java
+++ b/core/src/test/java/org/apache/hop/core/logging/LogChannelFileWriterBufferTest.java
@@ -17,14 +17,15 @@
package org.apache.hop.core.logging;
-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 LogChannelFileWriterBufferTest {
+/** Unit test for {@link LogChannelFileWriterBuffer} */
+class LogChannelFileWriterBufferTest {
@Test
- public void test() {
+ void test() {
String id = "1";
String logMessage = "Log message";
diff --git a/core/src/test/java/org/apache/hop/core/logging/LogChannelTest.java b/core/src/test/java/org/apache/hop/core/logging/LogChannelTest.java
index d19337d49d..49095a3dc3 100644
--- a/core/src/test/java/org/apache/hop/core/logging/LogChannelTest.java
+++ b/core/src/test/java/org/apache/hop/core/logging/LogChannelTest.java
@@ -25,63 +25,50 @@ import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
import org.apache.hop.core.util.Utils;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Ignore;
-import org.junit.Test;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
import org.mockito.MockedStatic;
import org.mockito.Mockito;
-@Ignore("This test needs to be reviewed")
-public class LogChannelTest {
-
+class LogChannelTest {
private MockedStatic<Utils> mockedUtils;
-
private MockedStatic<HopLogStore> mockedHopLogStore;
-
private MockedStatic<LoggingRegistry> mockedLoggingRegistry;
-
private MockedStatic<DefaultLogLevel> mockedDefaultLogLevel;
private LogChannel logChannel;
- private final String logChannelSubject = "pdi";
- private final String channelId = "1234-5678-abcd-efgh";
private LogLevel logLevel;
private ILogMessage logMsgInterface;
private LogChannelFileWriterBuffer logChFileWriterBuffer;
- @Before
- public void setUp() {
- LogLevel logLevelStatic = Mockito.mock(LogLevel.class);
- mockedDefaultLogLevel.when(DefaultLogLevel::getLogLevel).thenReturn(LogLevel.BASIC);
+ @BeforeEach
+ void setUp() {
+ mockedUtils = Mockito.mockStatic(Utils.class);
+ mockedHopLogStore = Mockito.mockStatic(HopLogStore.class);
+ mockedLoggingRegistry = Mockito.mockStatic(LoggingRegistry.class);
+ mockedDefaultLogLevel = Mockito.mockStatic(DefaultLogLevel.class);
logChFileWriterBuffer = mock(LogChannelFileWriterBuffer.class);
LoggingRegistry regInstance = mock(LoggingRegistry.class);
- Mockito.when(regInstance.registerLoggingSource(logChannelSubject)).thenReturn(channelId);
- Mockito.when(regInstance.getLogChannelFileWriterBuffer(channelId))
- .thenReturn(logChFileWriterBuffer);
+ String logChannelSubject = "pdi";
+ String channelId = "1234-5678-abcd-efgh";
+ when(regInstance.registerLoggingSource(logChannelSubject)).thenReturn(channelId);
+ when(regInstance.getLogChannelFileWriterBuffer(channelId)).thenReturn(logChFileWriterBuffer);
mockedLoggingRegistry.when(LoggingRegistry::getInstance).thenReturn(regInstance);
logLevel = Mockito.mock(LogLevel.class);
logMsgInterface = mock(ILogMessage.class);
- Mockito.when(logMsgInterface.getLevel()).thenReturn(logLevel);
+ when(logMsgInterface.getLevel()).thenReturn(logLevel);
logChannel = new LogChannel(logChannelSubject);
}
- @Before
- public void setUpStaticMocks() {
- mockedUtils = Mockito.mockStatic(Utils.class);
- mockedHopLogStore = Mockito.mockStatic(HopLogStore.class);
- mockedLoggingRegistry = Mockito.mockStatic(LoggingRegistry.class);
- mockedDefaultLogLevel = Mockito.mockStatic(DefaultLogLevel.class);
- }
-
- @After
- public void tearDownStaticMocks() {
+ @AfterEach
+ void tearDownStaticMocks() {
mockedDefaultLogLevel.closeOnDemand();
mockedLoggingRegistry.closeOnDemand();
mockedHopLogStore.closeOnDemand();
@@ -89,8 +76,9 @@ public class LogChannelTest {
}
@Test
- public void testPrintlnWithNullLogChannelFileWriterBuffer() {
+ void testPrintlnWithNullLogChannelFileWriterBuffer() {
when(logLevel.isVisible(any(LogLevel.class))).thenReturn(true);
+ logChannel.setFilter("");
LoggingBuffer loggingBuffer = mock(LoggingBuffer.class);
mockedHopLogStore.when(HopLogStore::getAppender).thenReturn(loggingBuffer);
@@ -101,14 +89,14 @@ public class LogChannelTest {
}
@Test
- public void testPrintlnLogNotVisible() {
+ void testPrintlnLogNotVisible() {
when(logLevel.isVisible(any(LogLevel.class))).thenReturn(false);
logChannel.println(logMsgInterface, LogLevel.BASIC);
verify(logChFileWriterBuffer, times(0)).addEvent(any(HopLoggingEvent.class));
}
@Test
- public void testPrintMessageFiltered() {
+ void testPrintMessageFiltered() {
LogLevel logLevelFil = Mockito.mock(LogLevel.class);
when(logLevelFil.isError()).thenReturn(false);
diff --git a/core/src/test/java/org/apache/hop/core/logging/LoggingBufferTest.java b/core/src/test/java/org/apache/hop/core/logging/LoggingBufferTest.java
index 16d378a5d3..bcb65ef9f5 100644
--- a/core/src/test/java/org/apache/hop/core/logging/LoggingBufferTest.java
+++ b/core/src/test/java/org/apache/hop/core/logging/LoggingBufferTest.java
@@ -17,20 +17,20 @@
package org.apache.hop.core.logging;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.atomic.AtomicBoolean;
-import org.junit.Assert;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
-public class LoggingBufferTest {
+/** Unit test for {@link LoggingBuffer} */
+class LoggingBufferTest {
@Test
- public void testRaceCondition() throws Exception {
-
+ void testRaceCondition() throws Exception {
final int eventCount = 100;
-
final LoggingBuffer buf = new LoggingBuffer(200);
-
final AtomicBoolean done = new AtomicBoolean(false);
final IHopLoggingEventListener lsnr =
@@ -39,7 +39,6 @@ public class LoggingBufferTest {
};
final HopLoggingEvent event = new HopLoggingEvent();
-
final CountDownLatch latch = new CountDownLatch(1);
Thread.UncaughtExceptionHandler errorHandler = (t, e) -> e.printStackTrace();
@@ -83,11 +82,11 @@ public class LoggingBufferTest {
latch.await();
// check
- Assert.assertEquals("Failed", true, done.get());
+ assertTrue(done.get(), "Failed");
}
@Test
- public void testRemoveBufferLinesBefore() {
+ void testRemoveBufferLinesBefore() {
LoggingBuffer loggingBuffer = new LoggingBuffer(100);
for (int i = 0; i < 40; i++) {
HopLoggingEvent event = new HopLoggingEvent();
@@ -96,11 +95,11 @@ public class LoggingBufferTest {
loggingBuffer.addLogggingEvent(event);
}
loggingBuffer.removeBufferLinesBefore(20);
- Assert.assertEquals(20, loggingBuffer.size());
+ assertEquals(20, loggingBuffer.size());
}
@Test
- public void testRemoveChannelFromBuffer() {
+ void testRemoveChannelFromBuffer() {
String logChannelId = "1";
String otherLogChannelId = "2";
LoggingBuffer loggingBuffer = new LoggingBuffer(20);
@@ -124,6 +123,6 @@ public class LoggingBufferTest {
loggingBuffer.addLogggingEvent(event);
}
loggingBuffer.removeChannelFromBuffer(logChannelId);
- Assert.assertEquals(10, loggingBuffer.size());
+ assertEquals(10, loggingBuffer.size());
}
}
diff --git a/core/src/test/java/org/apache/hop/core/logging/LoggingObjectTest.java b/core/src/test/java/org/apache/hop/core/logging/LoggingObjectTest.java
index 2206bb8347..d204089acc 100644
--- a/core/src/test/java/org/apache/hop/core/logging/LoggingObjectTest.java
+++ b/core/src/test/java/org/apache/hop/core/logging/LoggingObjectTest.java
@@ -17,13 +17,15 @@
package org.apache.hop.core.logging;
-import junit.framework.Assert;
-import org.junit.Test;
+import static org.junit.jupiter.api.Assertions.assertNotEquals;
-public class LoggingObjectTest {
+import org.junit.jupiter.api.Test;
+
+/** Unit test for {@link LoggingObject} */
+class LoggingObjectTest {
@Test
- public void testEquals() {
+ void testEquals() {
ILoggingObject parent =
new LoggingObject(new SimpleLoggingObject("parent", LoggingObjectType.WORKFLOW, null));
@@ -37,6 +39,6 @@ public class LoggingObjectTest {
loggingObject2.setParent(parent);
loggingObject2.setObjectName("job2");
- Assert.assertFalse(loggingObject1.equals(loggingObject2));
+ assertNotEquals(loggingObject1, loggingObject2);
}
}
diff --git a/core/src/test/java/org/apache/hop/core/logging/LoggingPluginTypeTest.java b/core/src/test/java/org/apache/hop/core/logging/LoggingPluginTypeTest.java
index 5705e76a43..1dd2b137ee 100644
--- a/core/src/test/java/org/apache/hop/core/logging/LoggingPluginTypeTest.java
+++ b/core/src/test/java/org/apache/hop/core/logging/LoggingPluginTypeTest.java
@@ -17,36 +17,36 @@
package org.apache.hop.core.logging;
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
-import org.junit.Before;
-import org.junit.Test;
-
-public class LoggingPluginTypeTest {
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+/** Unit test for {@link LoggingPluginType} */
+class LoggingPluginTypeTest {
private LoggingPlugin annotation;
- @Before
- public void setUp() {
+ @BeforeEach
+ void setUp() {
annotation = mock(LoggingPlugin.class);
when(annotation.id()).thenReturn("id");
}
@Test
- public void pickUpsId() {
+ void pickUpsId() {
assertEquals("id", LoggingPluginType.getInstance().extractID(annotation));
}
@Test
- public void pickUpName_NameIsSpecified() {
+ void pickUpName_NameIsSpecified() {
when(annotation.name()).thenReturn("name");
assertEquals("name", LoggingPluginType.getInstance().extractName(annotation));
}
@Test
- public void pickUpName_NameIsNotSpecified() {
+ void pickUpName_NameIsNotSpecified() {
assertEquals("id", LoggingPluginType.getInstance().extractName(annotation));
}
}
diff --git a/core/src/test/java/org/apache/hop/core/logging/LoggingRegistrySingltonTest.java b/core/src/test/java/org/apache/hop/core/logging/LoggingRegistrySingletonTest.java
similarity index 86%
rename from core/src/test/java/org/apache/hop/core/logging/LoggingRegistrySingltonTest.java
rename to core/src/test/java/org/apache/hop/core/logging/LoggingRegistrySingletonTest.java
index 508a2969a6..e27eb930d9 100644
--- a/core/src/test/java/org/apache/hop/core/logging/LoggingRegistrySingltonTest.java
+++ b/core/src/test/java/org/apache/hop/core/logging/LoggingRegistrySingletonTest.java
@@ -17,6 +17,8 @@
package org.apache.hop.core.logging;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+
import java.util.HashSet;
import java.util.Set;
import java.util.concurrent.Callable;
@@ -28,24 +30,20 @@ import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.Future;
import java.util.concurrent.TimeUnit;
-import junit.framework.Assert;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
/**
* Note, this test must be run on separate JAVA instance, to be sure LoggingRegistry was not already
* initialized when using differed initialization or do initialize immediate in static way.
*/
-public class LoggingRegistrySingltonTest {
+class LoggingRegistrySingletonTest {
/**
* Test that LoggingRegistry is concurrent-sage initialized over multiple calls. Creating more
* than 1000 threads can cause significant performance impact.
- *
- * @throws InterruptedException
- * @throws ExecutionException
*/
- @Test(timeout = 30000)
- public void testLoggingRegistryConcurrentInitialization()
+ @Test
+ void testLoggingRegistryConcurrentInitialization()
throws InterruptedException, ExecutionException {
CountDownLatch start = new CountDownLatch(1);
@@ -63,7 +61,8 @@ public class LoggingRegistrySingltonTest {
distinct.add(instance);
i++;
}
- Assert.assertEquals("Only one singlton instance ;)", 1, distinct.size());
+
+ assertEquals(1, distinct.size(), "Only one singleton instance ;)");
}
CompletionService<LoggingRegistry> registerHounds(int count, CountDownLatch start) {
@@ -77,10 +76,10 @@ public class LoggingRegistrySingltonTest {
return completionService;
}
- class LogRegistryKicker implements Callable<LoggingRegistry> {
+ static class LogRegistryKicker implements Callable<LoggingRegistry> {
CountDownLatch start;
- LogRegistryKicker(CountDownLatch start) {
+ public LogRegistryKicker(CountDownLatch start) {
this.start = start;
}
diff --git a/core/src/test/java/org/apache/hop/core/logging/LoggingRegistryTest.java b/core/src/test/java/org/apache/hop/core/logging/LoggingRegistryTest.java
index 8f5e61a569..7849850921 100644
--- a/core/src/test/java/org/apache/hop/core/logging/LoggingRegistryTest.java
+++ b/core/src/test/java/org/apache/hop/core/logging/LoggingRegistryTest.java
@@ -17,19 +17,20 @@
package org.apache.hop.core.logging;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNull;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertNull;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
-public class LoggingRegistryTest {
+/** Unit test for {@link LoggingRegistry} */
+class LoggingRegistryTest {
public static final String LOG_CHANEL_ID_PARENT = "parent-chanel-id";
public static final String LOG_CHANEL_ID_CHILD = "child-chanel-id";
public static final String STRING_DEFAULT = "<def>";
@Test
- public void correctLogIdReturned_WhenLogObjectRegisteredAlready() {
+ void correctLogIdReturned_WhenLogObjectRegisteredAlready() {
LoggingRegistry loggingRegistry = LoggingRegistry.getInstance();
LoggingObject parent =
@@ -48,7 +49,7 @@ public class LoggingRegistryTest {
}
@Test
- public void testRegisterFileWriter() {
+ void testRegisterFileWriter() {
String id = "1";
LoggingRegistry loggingRegistry = LoggingRegistry.getInstance();
@@ -60,7 +61,7 @@ public class LoggingRegistryTest {
}
@Test
- public void testFileWritersIds() {
+ void testFileWritersIds() {
String id = "1";
LoggingRegistry loggingRegistry = LoggingRegistry.getInstance();
@@ -72,7 +73,7 @@ public class LoggingRegistryTest {
}
@Test
- public void testRemoveFileWriter() {
+ void testRemoveFileWriter() {
String id = "1";
LoggingRegistry loggingRegistry = LoggingRegistry.getInstance();
diff --git a/core/src/test/java/org/apache/hop/core/logging/MetricsRegistryTest.java b/core/src/test/java/org/apache/hop/core/logging/MetricsRegistryTest.java
index 1271af945b..5195b0b653 100644
--- a/core/src/test/java/org/apache/hop/core/logging/MetricsRegistryTest.java
+++ b/core/src/test/java/org/apache/hop/core/logging/MetricsRegistryTest.java
@@ -16,7 +16,7 @@
*/
package org.apache.hop.core.logging;
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
import java.util.ArrayList;
import java.util.List;
@@ -26,21 +26,23 @@ import java.util.concurrent.CountDownLatch;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.TimeUnit;
-import org.apache.hop.junit.rules.RestoreHopEnvironment;
-import org.junit.Before;
-import org.junit.ClassRule;
-import org.junit.Test;
+import org.apache.hop.core.metrics.IMetricsSnapshot;
+import org.apache.hop.junit.rules.RestoreHopEnvironmentExtension;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.ExtendWith;
-public class MetricsRegistryTest {
- @ClassRule public static RestoreHopEnvironment env = new RestoreHopEnvironment();
+/** Unit test for {@link MetricsRegistry} */
+@ExtendWith(RestoreHopEnvironmentExtension.class)
+class MetricsRegistryTest {
private MetricsRegistry metricsRegistry;
private List<String> logIds;
- private int threadCount = 100;
- private int logChannelIdCount = 20;
+ private final int threadCount = 100;
+ private final int logChannelIdCount = 20;
private CountDownLatch countDownLatch = null;
- @Before
- public void setUp() {
+ @BeforeEach
+ void setUp() {
metricsRegistry = MetricsRegistry.getInstance();
metricsRegistry.reset();
logIds = new ArrayList<>(logChannelIdCount);
@@ -51,26 +53,27 @@ public class MetricsRegistryTest {
}
@Test
- public void testConcurrencySnap() throws Exception {
+ void testConcurrencySnap() throws Exception {
ExecutorService service = Executors.newFixedThreadPool(threadCount);
for (int i = 0; i < threadCount; i++) {
service.submit(new ConcurrentPutIfAbsent(logIds.get(i % 20)));
}
countDownLatch.countDown();
service.awaitTermination(2000, TimeUnit.MILLISECONDS);
- int expectedQueueCount = logChannelIdCount > threadCount ? threadCount : logChannelIdCount;
+ int expectedQueueCount = Math.min(logChannelIdCount, threadCount);
+
assertEquals(expectedQueueCount, metricsRegistry.getSnapshotLists().size());
}
- private class ConcurrentPutIfAbsent implements Callable<Queue> {
- private String id;
+ private class ConcurrentPutIfAbsent implements Callable<Queue<IMetricsSnapshot>> {
+ private final String id;
ConcurrentPutIfAbsent(String id) {
this.id = id;
}
@Override
- public Queue call() throws Exception {
+ public Queue<IMetricsSnapshot> call() throws Exception {
countDownLatch.await();
return metricsRegistry.getSnapshotList(id);
}
diff --git a/core/src/test/java/org/apache/hop/core/metrics/MetricsDurationTest.java b/core/src/test/java/org/apache/hop/core/metrics/MetricsDurationTest.java
index d003245ae0..c4126943f1 100644
--- a/core/src/test/java/org/apache/hop/core/metrics/MetricsDurationTest.java
+++ b/core/src/test/java/org/apache/hop/core/metrics/MetricsDurationTest.java
@@ -17,21 +17,24 @@
package org.apache.hop.core.metrics;
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
-import java.util.Calendar;
+import java.time.LocalDate;
+import java.time.ZoneId;
import java.util.Date;
-import org.apache.hop.junit.rules.RestoreHopEnvironment;
-import org.junit.ClassRule;
-import org.junit.Test;
+import org.apache.hop.junit.rules.RestoreHopEnvironmentExtension;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.ExtendWith;
-public class MetricsDurationTest {
-
- @ClassRule public static RestoreHopEnvironment env = new RestoreHopEnvironment();
+/** Unit test for {@link MetricsDuration} */
+@ExtendWith(RestoreHopEnvironmentExtension.class)
+class MetricsDurationTest {
@Test
- public void test() {
- Date startDate = new Date((2016 - 1900), Calendar.JANUARY, 10);
+ void test() {
+ LocalDate localDate = LocalDate.of(2016, 1, 10);
+ Date startDate = Date.from(localDate.atStartOfDay(ZoneId.systemDefault()).toInstant());
+
Long duration = 4L;
MetricsDuration metric =
new MetricsDuration(startDate, "theDesc", "theSubj", "theLogChannel", duration);
diff --git a/core/src/test/java/org/apache/hop/core/parameters/DuplicateParamExceptionTest.java b/core/src/test/java/org/apache/hop/core/parameters/DuplicateParamExceptionTest.java
index 08c7c0daef..8173c9a1c0 100644
--- a/core/src/test/java/org/apache/hop/core/parameters/DuplicateParamExceptionTest.java
+++ b/core/src/test/java/org/apache/hop/core/parameters/DuplicateParamExceptionTest.java
@@ -16,24 +16,19 @@
*/
package org.apache.hop.core.parameters;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
-public class DuplicateParamExceptionTest {
+/** Unit test for {@link DuplicateParamException} */
+class DuplicateParamExceptionTest {
DuplicateParamException exception;
- @Before
- public void setUp() throws Exception {
- // Do nothing
- }
-
@Test
- public void testConstructors() {
+ void testConstructors() {
exception = new DuplicateParamException();
assertNotNull(exception);
NamedParamsExceptionTest.assertMessage("null", exception);
diff --git a/core/src/test/java/org/apache/hop/core/parameters/NamedParamsDefaultTest.java b/core/src/test/java/org/apache/hop/core/parameters/NamedParamsDefaultTest.java
index b83c0b1fb2..fa050fc01a 100644
--- a/core/src/test/java/org/apache/hop/core/parameters/NamedParamsDefaultTest.java
+++ b/core/src/test/java/org/apache/hop/core/parameters/NamedParamsDefaultTest.java
@@ -16,24 +16,26 @@
*/
package org.apache.hop.core.parameters;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNull;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNull;
+import static org.junit.jupiter.api.Assertions.assertThrows;
import static org.mockito.Mockito.spy;
import org.apache.hop.core.variables.Variables;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
-public class NamedParamsDefaultTest {
+/** Unit test for {@link INamedParameters} */
+class NamedParamsDefaultTest {
INamedParameters namedParams;
- @Before
- public void setUp() {
+ @BeforeEach
+ void setUp() {
namedParams = spy(new NamedParameters());
}
@Test
- public void testParameters() throws Exception {
+ void testParameters() throws Exception {
assertNull(namedParams.getParameterValue("var1"));
assertNull(namedParams.getParameterDefault("var1"));
assertNull(namedParams.getParameterDescription("var1"));
@@ -76,9 +78,12 @@ public class NamedParamsDefaultTest {
assertEquals("CCC", variables.getVariable("var3"));
}
- @Test(expected = DuplicateParamException.class)
- public void testAddParameterDefinitionWithException() throws DuplicateParamException {
- namedParams.addParameterDefinition("key", "value", "description");
+ @Test
+ void testAddParameterDefinitionWithException() throws DuplicateParamException {
namedParams.addParameterDefinition("key", "value", "description");
+
+ assertThrows(
+ DuplicateParamException.class,
+ () -> namedParams.addParameterDefinition("key", "value", "description"));
}
}
diff --git a/core/src/test/java/org/apache/hop/core/parameters/NamedParamsExceptionTest.java b/core/src/test/java/org/apache/hop/core/parameters/NamedParamsExceptionTest.java
index f0accaa876..257310f9af 100644
--- a/core/src/test/java/org/apache/hop/core/parameters/NamedParamsExceptionTest.java
+++ b/core/src/test/java/org/apache/hop/core/parameters/NamedParamsExceptionTest.java
@@ -16,19 +16,19 @@
*/
package org.apache.hop.core.parameters;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
-import org.junit.Test;
-
-public class NamedParamsExceptionTest {
+import org.junit.jupiter.api.Test;
+/** Unit test for {@link NamedParamsException} */
+class NamedParamsExceptionTest {
NamedParamsException exception;
@Test
- public void testConstructors() {
+ void testConstructors() {
exception = new NamedParamsException();
assertNotNull(exception);
assertMessage("null", exception);
diff --git a/core/src/test/java/org/apache/hop/core/parameters/UnknownParamExceptionTest.java b/core/src/test/java/org/apache/hop/core/parameters/UnknownParamExceptionTest.java
index cf3391cc64..00318f72e2 100644
--- a/core/src/test/java/org/apache/hop/core/parameters/UnknownParamExceptionTest.java
+++ b/core/src/test/java/org/apache/hop/core/parameters/UnknownParamExceptionTest.java
@@ -16,19 +16,19 @@
*/
package org.apache.hop.core.parameters;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
-import org.junit.Test;
-
-public class UnknownParamExceptionTest {
+import org.junit.jupiter.api.Test;
+/** Unit test for {@link UnknownParamException} */
+class UnknownParamExceptionTest {
UnknownParamException exception;
@Test
- public void testConstructors() {
+ void testConstructors() {
exception = new UnknownParamException();
assertNotNull(exception);
NamedParamsExceptionTest.assertMessage("null", exception);
diff --git a/core/src/test/java/org/apache/hop/core/plugins/PluginRegistryUnitTest.java b/core/src/test/java/org/apache/hop/core/plugins/PluginRegistryUnitTest.java
index 87e6bf30a6..f41f07d814 100644
--- a/core/src/test/java/org/apache/hop/core/plugins/PluginRegistryUnitTest.java
+++ b/core/src/test/java/org/apache/hop/core/plugins/PluginRegistryUnitTest.java
@@ -17,10 +17,11 @@
package org.apache.hop.core.plugins;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertThrows;
+import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.mockito.Mockito.any;
import static org.mockito.Mockito.atLeast;
import static org.mockito.Mockito.atLeastOnce;
@@ -41,15 +42,16 @@ import org.apache.hop.core.row.IValueMeta;
import org.apache.hop.core.row.RowBuffer;
import org.apache.hop.core.row.value.ValueMetaPlugin;
import org.apache.hop.core.row.value.ValueMetaPluginType;
-import org.apache.hop.junit.rules.RestoreHopEnvironment;
-import org.junit.ClassRule;
-import org.junit.Test;
+import org.apache.hop.junit.rules.RestoreHopEnvironmentExtension;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.ExtendWith;
-public class PluginRegistryUnitTest {
- @ClassRule public static RestoreHopEnvironment env = new RestoreHopEnvironment();
+/** Unit test for {@link PluginRegistry} */
+@ExtendWith(RestoreHopEnvironmentExtension.class)
+class PluginRegistryUnitTest {
@Test
- public void getGetPluginInformation() throws HopPluginException {
+ void getGetPluginInformation() throws HopPluginException {
PluginRegistry.getInstance().reset();
RowBuffer result = PluginRegistry.getInstance().getPluginInformation(BasePluginType.class);
assertNotNull(result);
@@ -62,7 +64,7 @@ public class PluginRegistryUnitTest {
/** Test that additional plugin mappings can be added via the PluginRegistry. */
@Test
- public void testSupplementalPluginMappings() throws Exception {
+ void testSupplementalPluginMappings() throws Exception {
PluginRegistry registry = PluginRegistry.getInstance();
IPlugin mockPlugin = mock(IPlugin.class);
when(mockPlugin.getIds()).thenReturn(new String[] {"mockPlugin"});
@@ -87,7 +89,7 @@ public class PluginRegistryUnitTest {
/** Test that several plugin jar can share the same classloader. */
@Test
- public void testPluginClassloaderGroup() throws Exception {
+ void testPluginClassloaderGroup() throws Exception {
PluginRegistry registry = PluginRegistry.getInstance();
IPlugin mockPlugin1 = mock(IPlugin.class);
when(mockPlugin1.getIds()).thenReturn(new String[] {"mockPlugin"});
@@ -129,16 +131,17 @@ public class PluginRegistryUnitTest {
assertNotEquals(ucl, registry.getClassLoader(mockPlugin1));
}
- @Test(expected = HopPluginClassMapException.class)
- public void testClassloadingPluginNoClassRegistered() throws HopPluginException {
+ @Test
+ void testClassloadingPluginNoClassRegistered() {
PluginRegistry registry = PluginRegistry.getInstance();
IPluginMock plugin = mock(IPluginMock.class);
when(plugin.loadClass(any())).thenReturn(null);
- registry.loadClass(plugin, Class.class);
+
+ assertThrows(HopPluginClassMapException.class, () -> registry.loadClass(plugin, Class.class));
}
@Test
- public void testMergingPluginFragment() throws HopPluginException {
+ void testMergingPluginFragment() throws HopPluginException {
// setup
// initialize Fragment Type
PluginRegistry registry = PluginRegistry.getInstance();
@@ -154,31 +157,6 @@ public class PluginRegistryUnitTest {
protected String extractID(ValueMetaPlugin annotation) {
return null;
}
-
- @Override
- protected String extractImageFile(ValueMetaPlugin annotation) {
- return null;
- }
-
- @Override
- protected String extractDocumentationUrl(ValueMetaPlugin annotation) {
- return null;
- }
-
- @Override
- protected String extractCasesUrl(ValueMetaPlugin annotation) {
- return null;
- }
-
- @Override
- protected String extractForumUrl(ValueMetaPlugin annotation) {
- return null;
- }
-
- @Override
- protected String extractSuggestion(ValueMetaPlugin annotation) {
- return null;
- }
};
assertTrue(fragmentType.isFragment());
diff --git a/core/src/test/java/org/apache/hop/core/plugins/PluginTest.java b/core/src/test/java/org/apache/hop/core/plugins/PluginTest.java
index e86513f9e1..c29ba98288 100644
--- a/core/src/test/java/org/apache/hop/core/plugins/PluginTest.java
+++ b/core/src/test/java/org/apache/hop/core/plugins/PluginTest.java
@@ -17,8 +17,8 @@
package org.apache.hop.core.plugins;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
@@ -27,13 +27,14 @@ import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
-public class PluginTest {
+/** Unit test for {@link IPlugin} */
+class PluginTest {
/** test that a plugin's fragment is added to the plugin */
@Test
- public void testFragmentMerge() {
+ void testFragmentMerge() {
Map<Class<?>, String> classMap =
new HashMap<>() {
{
@@ -112,7 +113,7 @@ public class PluginTest {
}
@Test
- public void testFragmentMergeWithNull() {
+ void testFragmentMergeWithNull() {
IPlugin plugin =
new Plugin(
new String[] {"plugintest"},
diff --git a/core/src/test/java/org/apache/hop/core/row/ValueDataUtilTest.java b/core/src/test/java/org/apache/hop/core/row/ValueDataUtilTest.java
index 295adb1a6a..2dd4dbffe5 100644
--- a/core/src/test/java/org/apache/hop/core/row/ValueDataUtilTest.java
+++ b/core/src/test/java/org/apache/hop/core/row/ValueDataUtilTest.java
@@ -17,11 +17,12 @@
package org.apache.hop.core.row;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertNull;
+import static org.junit.jupiter.api.Assertions.assertThrows;
+import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
@@ -40,14 +41,14 @@ import org.apache.hop.core.row.value.ValueMetaDate;
import org.apache.hop.core.row.value.ValueMetaInteger;
import org.apache.hop.core.row.value.ValueMetaNumber;
import org.apache.hop.core.row.value.ValueMetaString;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import org.mockito.stubbing.Answer;
-public class ValueDataUtilTest {
+/** Unit test for {@link ValueDataUtil} */
+class ValueDataUtilTest {
@Test
- public void testPlus() throws HopValueException {
-
+ void testPlus() throws HopValueException {
long longValue = 1;
assertEquals(
@@ -57,245 +58,259 @@ public class ValueDataUtilTest {
}
@Test
- public void checksumTest() throws Exception {
+ void checksumTest() throws Exception {
String path = getClass().getResource("txt-sample.txt").getPath();
String checksum = ValueDataUtil.createChecksum(path, "MD5", false);
assertEquals("098f6bcd4621d373cade4e832627b4f6", checksum);
}
@Test
- public void checksumMissingFileTest() throws Exception {
+ void checksumMissingFileTest() throws Exception {
String nonExistingFile = "nonExistingFile";
String checksum = ValueDataUtil.createChecksum(nonExistingFile, "MD5", false);
assertNull(checksum);
}
@Test
- public void checksumWithFailIfNoFileTest() throws Exception {
+ void checksumWithFailIfNoFileTest() throws Exception {
String path = getClass().getResource("txt-sample.txt").getPath();
String checksum = ValueDataUtil.createChecksum(path, "MD5", true);
assertEquals("098f6bcd4621d373cade4e832627b4f6", checksum);
}
- @Test(expected = HopFileNotFoundException.class)
- public void checksumFailIfNoFileTest() throws HopFileNotFoundException {
+ @Test
+ void checksumFailIfNoFileTest() {
String nonExistingPath = "nonExistingPath";
- ValueDataUtil.createChecksum(nonExistingPath, "MD5", true);
+ assertThrows(
+ HopFileNotFoundException.class,
+ () -> ValueDataUtil.createChecksum(nonExistingPath, "MD5", true));
}
@Test
- public void checksumNullPathNoFailTest() throws HopFileNotFoundException {
+ void checksumNullPathNoFailTest() throws HopFileNotFoundException {
assertNull(ValueDataUtil.createChecksum(null, "MD5", false));
}
@Test
- public void checksumNullPathFailTest() throws HopFileNotFoundException {
+ void checksumNullPathFailTest() throws HopFileNotFoundException {
assertNull(ValueDataUtil.createChecksum(null, "MD5", true));
}
@Test
- public void checksumCRC32Test() throws Exception {
+ void checksumCRC32Test() throws Exception {
String path = getClass().getResource("txt-sample.txt").getPath();
long checksum = ValueDataUtil.checksumCRC32(path, false);
- assertEquals(3632233996l, checksum);
+ assertEquals(3632233996L, checksum);
}
@Test
- public void checksumCRC32MissingFileTest() throws Exception {
+ void checksumCRC32MissingFileTest() throws Exception {
String nonExistingFile = "nonExistingFile";
long checksum = ValueDataUtil.checksumCRC32(nonExistingFile, false);
assertEquals(0, checksum);
}
@Test
- public void checksumCRC32NoFailIfNoFileTest() throws HopFileNotFoundException {
+ void checksumCRC32NoFailIfNoFileTest() throws HopFileNotFoundException {
String nonExistingPath = "nonExistingPath";
long checksum = ValueDataUtil.checksumCRC32(nonExistingPath, false);
assertEquals(0, checksum);
}
- @Test(expected = HopFileNotFoundException.class)
- public void checksumCRC32FailIfNoFileTest() throws HopFileNotFoundException {
+ @Test
+ void checksumCRC32FailIfNoFileTest() {
String nonExistingPath = "nonExistingPath";
- ValueDataUtil.checksumCRC32(nonExistingPath, true);
+
+ assertThrows(
+ HopFileNotFoundException.class, () -> ValueDataUtil.checksumCRC32(nonExistingPath, true));
}
@Test
- public void checksumCRC32NullPathNoFailTest() throws HopFileNotFoundException {
+ void checksumCRC32NullPathNoFailTest() throws HopFileNotFoundException {
long checksum = ValueDataUtil.checksumCRC32(null, false);
assertEquals(0, checksum);
}
@Test
- public void checksumCRC32NullPathFailTest() throws HopFileNotFoundException {
+ void checksumCRC32NullPathFailTest() throws HopFileNotFoundException {
long checksum = ValueDataUtil.checksumCRC32(null, true);
assertEquals(0, checksum);
}
@Test
- public void checksumAdlerWithFailIfNoFileTest() throws Exception {
+ void checksumAdlerWithFailIfNoFileTest() throws Exception {
String path = getClass().getResource("txt-sample.txt").getPath();
long checksum = ValueDataUtil.checksumAdler32(path, true);
assertEquals(73204161L, checksum);
}
@Test
- public void checksumAdlerWithoutFailIfNoFileTest() throws Exception {
+ void checksumAdlerWithoutFailIfNoFileTest() throws Exception {
String path = getClass().getResource("txt-sample.txt").getPath();
long checksum = ValueDataUtil.checksumAdler32(path, false);
assertEquals(73204161L, checksum);
}
@Test
- public void checksumAdlerNoFailIfNoFileTest() throws HopFileNotFoundException {
+ void checksumAdlerNoFailIfNoFileTest() throws HopFileNotFoundException {
String nonExistingPath = "nonExistingPath";
long checksum = ValueDataUtil.checksumAdler32(nonExistingPath, false);
assertEquals(0, checksum);
}
- @Test(expected = HopFileNotFoundException.class)
- public void checksumAdlerFailIfNoFileTest() throws HopFileNotFoundException {
+ @Test
+ void checksumAdlerFailIfNoFileTest() {
String nonExistingPath = "nonExistingPath";
- ValueDataUtil.checksumAdler32(nonExistingPath, true);
+
+ assertThrows(
+ HopFileNotFoundException.class, () -> ValueDataUtil.checksumAdler32(nonExistingPath, true));
}
@Test
- public void checksumAdlerNullPathNoFailTest() throws HopFileNotFoundException {
+ void checksumAdlerNullPathNoFailTest() throws HopFileNotFoundException {
long checksum = ValueDataUtil.checksumAdler32(null, false);
assertEquals(0, checksum);
}
@Test
- public void checksumAdlerNullPathFailTest() throws HopFileNotFoundException {
+ void checksumAdlerNullPathFailTest() throws HopFileNotFoundException {
long checksum = ValueDataUtil.checksumAdler32(null, true);
assertEquals(0, checksum);
}
@Test
- public void xmlFileWellFormedTest() throws HopFileNotFoundException {
+ void xmlFileWellFormedTest() throws HopFileNotFoundException {
String xmlFilePath = getClass().getResource("xml-sample.xml").getPath();
boolean wellFormed = ValueDataUtil.isXmlFileWellFormed(xmlFilePath, true);
assertTrue(wellFormed);
}
@Test
- public void xmlFileBadlyFormedTest() throws HopFileNotFoundException {
+ void xmlFileBadlyFormedTest() throws HopFileNotFoundException {
String invalidXmlFilePath = getClass().getResource("invalid-xml-sample.xml").getPath();
boolean wellFormed = ValueDataUtil.isXmlFileWellFormed(invalidXmlFilePath, true);
assertFalse(wellFormed);
}
@Test
- public void xmlFileWellFormedWithoutFailIfNoFileTest() throws HopFileNotFoundException {
+ void xmlFileWellFormedWithoutFailIfNoFileTest() throws HopFileNotFoundException {
String xmlFilePath = getClass().getResource("xml-sample.xml").getPath();
boolean wellFormed = ValueDataUtil.isXmlFileWellFormed(xmlFilePath, false);
assertTrue(wellFormed);
}
@Test
- public void xmlFileBadlyFormedWithNoFailIfNoFileTest() throws HopFileNotFoundException {
+ void xmlFileBadlyFormedWithNoFailIfNoFileTest() throws HopFileNotFoundException {
String invalidXmlFilePath = getClass().getResource("invalid-xml-sample.xml").getPath();
boolean wellFormed = ValueDataUtil.isXmlFileWellFormed(invalidXmlFilePath, false);
assertFalse(wellFormed);
}
@Test
- public void xmlFileWellFormedNoFailIfNoFileTest() throws HopFileNotFoundException {
+ void xmlFileWellFormedNoFailIfNoFileTest() throws HopFileNotFoundException {
String nonExistingPath = "nonExistingPath";
boolean wellFormed = ValueDataUtil.isXmlFileWellFormed(nonExistingPath, false);
assertFalse(wellFormed);
}
- @Test(expected = HopFileNotFoundException.class)
- public void xmlFileWellFormedFailIfNoFileTest() throws HopFileNotFoundException {
+ @Test
+ void xmlFileWellFormedFailIfNoFileTest() {
String nonExistingPath = "nonExistingPath";
- ValueDataUtil.isXmlFileWellFormed(nonExistingPath, true);
+
+ assertThrows(
+ HopFileNotFoundException.class,
+ () -> ValueDataUtil.isXmlFileWellFormed(nonExistingPath, true));
}
@Test
- public void xmlFileWellFormedNullPathNoFailTest() throws HopFileNotFoundException {
+ void xmlFileWellFormedNullPathNoFailTest() throws HopFileNotFoundException {
boolean wellFormed = ValueDataUtil.isXmlFileWellFormed(null, false);
assertFalse(wellFormed);
}
@Test
- public void xmlFileWellFormedNullPathFailTest() throws HopFileNotFoundException {
+ void xmlFileWellFormedNullPathFailTest() throws HopFileNotFoundException {
boolean wellFormed = ValueDataUtil.isXmlFileWellFormed(null, true);
assertFalse(wellFormed);
}
@Test
- public void loadFileContentInBinary() throws Exception {
+ void loadFileContentInBinary() throws Exception {
String path = getClass().getResource("txt-sample.txt").getPath();
byte[] content = ValueDataUtil.loadFileContentInBinary(path, true);
assertTrue(Arrays.equals("test".getBytes(), content));
}
@Test
- public void loadFileContentInBinaryNoFailIfNoFileTest() throws Exception {
+ void loadFileContentInBinaryNoFailIfNoFileTest() throws Exception {
String nonExistingPath = "nonExistingPath";
assertNull(ValueDataUtil.loadFileContentInBinary(nonExistingPath, false));
}
- @Test(expected = HopFileNotFoundException.class)
- public void loadFileContentInBinaryFailIfNoFileTest()
- throws HopFileNotFoundException, HopValueException {
+ @Test
+ void loadFileContentInBinaryFailIfNoFileTest() {
String nonExistingPath = "nonExistingPath";
- ValueDataUtil.loadFileContentInBinary(nonExistingPath, true);
+
+ assertThrows(
+ HopFileNotFoundException.class,
+ () -> ValueDataUtil.loadFileContentInBinary(nonExistingPath, true));
}
@Test
- public void loadFileContentInBinaryNullPathNoFailTest() throws Exception {
+ void loadFileContentInBinaryNullPathNoFailTest() throws Exception {
assertNull(ValueDataUtil.loadFileContentInBinary(null, false));
}
@Test
- public void loadFileContentInBinaryNullPathFailTest()
+ void loadFileContentInBinaryNullPathFailTest()
throws HopFileNotFoundException, HopValueException {
assertNull(ValueDataUtil.loadFileContentInBinary(null, true));
}
@Test
- public void getFileEncodingWithFailIfNoFileTest() throws Exception {
+ void getFileEncodingWithFailIfNoFileTest() throws Exception {
String path = getClass().getResource("txt-sample.txt").getPath();
String encoding = ValueDataUtil.getFileEncoding(new ValueMetaString(), path, true);
assertEquals("US-ASCII", encoding);
}
@Test
- public void getFileEncodingWithoutFailIfNoFileTest() throws Exception {
+ void getFileEncodingWithoutFailIfNoFileTest() throws Exception {
String path = getClass().getResource("txt-sample.txt").getPath();
String encoding = ValueDataUtil.getFileEncoding(new ValueMetaString(), path, false);
assertEquals("US-ASCII", encoding);
}
@Test
- public void getFileEncodingNoFailIfNoFileTest() throws Exception {
+ void getFileEncodingNoFailIfNoFileTest() throws Exception {
String nonExistingPath = "nonExistingPath";
String encoding = ValueDataUtil.getFileEncoding(new ValueMetaString(), nonExistingPath, false);
assertNull(encoding);
}
- @Test(expected = HopFileNotFoundException.class)
- public void getFileEncodingFailIfNoFileTest() throws HopFileNotFoundException, HopValueException {
+ @Test
+ void getFileEncodingFailIfNoFileTest() {
String nonExistingPath = "nonExistingPath";
- ValueDataUtil.getFileEncoding(new ValueMetaString(), nonExistingPath, true);
+
+ assertThrows(
+ HopFileNotFoundException.class,
+ () -> ValueDataUtil.getFileEncoding(new ValueMetaString(), nonExistingPath, true));
}
@Test
- public void getFileEncodingNullPathNoFailTest() throws Exception {
+ void getFileEncodingNullPathNoFailTest() throws Exception {
String encoding = ValueDataUtil.getFileEncoding(new ValueMetaString(), null, false);
assertNull(encoding);
}
@Test
- public void getFileEncodingNullPathFailTest() throws HopFileNotFoundException, HopValueException {
+ void getFileEncodingNullPathFailTest() throws HopFileNotFoundException, HopValueException {
String encoding = ValueDataUtil.getFileEncoding(new ValueMetaString(), null, true);
assertNull(encoding);
}
@Test
- public void testMulitplyBigNumbers() {
+ void testMulitplyBigNumbers() {
BigDecimal field1 = new BigDecimal("123456789012345678901.1234567890123456789");
BigDecimal field2 = new BigDecimal("1.0");
BigDecimal field3 = new BigDecimal("2.0");
@@ -316,7 +331,7 @@ public class ValueDataUtilTest {
}
@Test
- public void testDivisionBigNumbers() {
+ void testDivisionBigNumbers() {
BigDecimal field1 = new BigDecimal("123456789012345678901.1234567890123456789");
BigDecimal field2 = new BigDecimal("1.0");
BigDecimal field3 = new BigDecimal("2.0");
@@ -335,7 +350,7 @@ public class ValueDataUtilTest {
}
@Test
- public void testRemainderBigNumbers() throws Exception {
+ void testRemainderBigNumbers() throws Exception {
BigDecimal field1 = new BigDecimal("123456789012345678901.1234567890123456789");
BigDecimal field2 = new BigDecimal("1.0");
BigDecimal field3 = new BigDecimal("2.0");
@@ -354,7 +369,7 @@ public class ValueDataUtilTest {
}
@Test
- public void testSumWithNullValues() throws Exception {
+ void testSumWithNullValues() throws Exception {
IValueMeta metaA = new ValueMetaInteger();
metaA.setStorageType(IValueMeta.STORAGE_TYPE_NORMAL);
IValueMeta metaB = new ValueMetaInteger();
@@ -367,7 +382,7 @@ public class ValueDataUtilTest {
}
@Test
- public void testSumConvertingStorageTypeToNormal() throws Exception {
+ void testSumConvertingStorageTypeToNormal() throws Exception {
IValueMeta metaA = mock(ValueMetaInteger.class);
metaA.setStorageType(IValueMeta.STORAGE_TYPE_BINARY_STRING);
@@ -385,66 +400,66 @@ public class ValueDataUtilTest {
// String manipulation tests
@Test
- public void testInitCap() {
+ void testInitCap() {
assertEquals("Hello World", ValueDataUtil.initCap("hello world"));
assertEquals("Apache Hop", ValueDataUtil.initCap("apache hop"));
assertNull(ValueDataUtil.initCap(null));
}
@Test
- public void testUpperCase() {
+ void testUpperCase() {
assertEquals("HELLO", ValueDataUtil.upperCase("hello"));
assertEquals("APACHE HOP", ValueDataUtil.upperCase("Apache Hop"));
assertNull(ValueDataUtil.upperCase(null));
}
@Test
- public void testLowerCase() {
+ void testLowerCase() {
assertEquals("hello", ValueDataUtil.lowerCase("HELLO"));
assertEquals("apache hop", ValueDataUtil.lowerCase("Apache Hop"));
assertNull(ValueDataUtil.lowerCase(null));
}
@Test
- public void testRemoveCR() {
+ void testRemoveCR() {
assertEquals("helloworld", ValueDataUtil.removeCR("hello\rworld"));
assertNull(ValueDataUtil.removeCR(null));
}
@Test
- public void testRemoveLF() {
+ void testRemoveLF() {
assertEquals("helloworld", ValueDataUtil.removeLF("hello\nworld"));
assertNull(ValueDataUtil.removeLF(null));
}
@Test
- public void testRemoveCRLF() {
+ void testRemoveCRLF() {
assertEquals("helloworld", ValueDataUtil.removeCRLF("hello\r\nworld"));
assertNull(ValueDataUtil.removeCRLF(null));
}
@Test
- public void testRemoveTAB() {
+ void testRemoveTAB() {
assertEquals("helloworld", ValueDataUtil.removeTAB("hello\tworld"));
assertNull(ValueDataUtil.removeTAB(null));
}
@Test
- public void testGetDigits() {
+ void testGetDigits() {
assertEquals("123", ValueDataUtil.getDigits("abc123def"));
assertEquals("", ValueDataUtil.getDigits("abcdef"));
assertNull(ValueDataUtil.getDigits(null));
}
@Test
- public void testRemoveDigits() {
+ void testRemoveDigits() {
assertEquals("abcdef", ValueDataUtil.removeDigits("abc123def"));
assertEquals("abcdef", ValueDataUtil.removeDigits("abcdef"));
assertNull(ValueDataUtil.removeDigits(null));
}
@Test
- public void testStringLen() {
+ void testStringLen() {
assertEquals(5, ValueDataUtil.stringLen("hello"));
assertEquals(0, ValueDataUtil.stringLen(""));
assertEquals(0, ValueDataUtil.stringLen(null));
@@ -452,7 +467,7 @@ public class ValueDataUtilTest {
// String distance/similarity tests
@Test
- public void testLevenshteinDistance() {
+ void testLevenshteinDistance() {
Long distance = ValueDataUtil.getLevenshteinDistance("kitten", "sitting");
assertEquals(Long.valueOf(3), distance);
@@ -461,7 +476,7 @@ public class ValueDataUtilTest {
}
@Test
- public void testDamerauLevenshteinDistance() {
+ void testDamerauLevenshteinDistance() {
Long distance = ValueDataUtil.getDamerauLevenshteinDistance("abc", "acb");
assertEquals(Long.valueOf(1), distance);
@@ -469,7 +484,7 @@ public class ValueDataUtilTest {
}
@Test
- public void testJaroSimilitude() {
+ void testJaroSimilitude() {
Double similarity = ValueDataUtil.getJaroSimilitude("martha", "marhta");
assertTrue(similarity > 0.9);
@@ -477,7 +492,7 @@ public class ValueDataUtilTest {
}
@Test
- public void testJaroWinklerSimilitude() {
+ void testJaroWinklerSimilitude() {
Double similarity = ValueDataUtil.getJaroWinklerSimilitude("martha", "marhta");
assertTrue(similarity > 0.9);
@@ -486,28 +501,28 @@ public class ValueDataUtilTest {
// Phonetic algorithms tests
@Test
- public void testMetaphone() {
+ void testMetaphone() {
String metaphone = ValueDataUtil.getMetaphone("hello");
assertEquals("HL", metaphone);
assertNull(ValueDataUtil.getMetaphone(null));
}
@Test
- public void testDoubleMetaphone() {
+ void testDoubleMetaphone() {
String doubleMetaphone = ValueDataUtil.getDoubleMetaphone("hello");
assertEquals("HL", doubleMetaphone);
assertNull(ValueDataUtil.getDoubleMetaphone(null));
}
@Test
- public void testSoundEx() {
+ void testSoundEx() {
String soundex = ValueDataUtil.getSoundEx("hello");
assertEquals("H400", soundex);
assertNull(ValueDataUtil.getSoundEx(null));
}
@Test
- public void testRefinedSoundEx() {
+ void testRefinedSoundEx() {
String refinedSoundex = ValueDataUtil.getRefinedSoundEx("hello");
assertNotNull(refinedSoundex);
assertNull(ValueDataUtil.getRefinedSoundEx(null));
@@ -515,7 +530,7 @@ public class ValueDataUtilTest {
// Math operations tests
@Test
- public void testAbs() throws HopValueException {
+ void testAbs() throws HopValueException {
assertEquals(5L, ValueDataUtil.abs(new ValueMetaInteger(), (long) -5));
assertEquals(5.5, ValueDataUtil.abs(new ValueMetaNumber(), -5.5));
assertEquals(
@@ -523,7 +538,7 @@ public class ValueDataUtilTest {
}
@Test
- public void testSqrt() throws HopValueException {
+ void testSqrt() throws HopValueException {
Object result = ValueDataUtil.sqrt(new ValueMetaNumber(), 16.0);
assertEquals(4.0, (Double) result, 0.001);
@@ -532,7 +547,7 @@ public class ValueDataUtilTest {
}
@Test
- public void testCeil() throws HopValueException {
+ void testCeil() throws HopValueException {
assertEquals(6.0, ValueDataUtil.ceil(new ValueMetaNumber(), 5.3));
assertEquals(5L, ValueDataUtil.ceil(new ValueMetaInteger(), 5L));
assertEquals(
@@ -541,7 +556,7 @@ public class ValueDataUtilTest {
}
@Test
- public void testFloor() throws HopValueException {
+ void testFloor() throws HopValueException {
assertEquals(5.0, ValueDataUtil.floor(new ValueMetaNumber(), 5.9));
assertEquals(5L, ValueDataUtil.floor(new ValueMetaInteger(), 5L));
assertEquals(
@@ -550,21 +565,21 @@ public class ValueDataUtilTest {
}
@Test
- public void testRoundNoDigits() throws HopValueException {
+ void testRoundNoDigits() throws HopValueException {
assertEquals(5.0, ValueDataUtil.round(new ValueMetaNumber(), 5.4));
assertEquals(6.0, ValueDataUtil.round(new ValueMetaNumber(), 5.5));
assertEquals(5L, ValueDataUtil.round(new ValueMetaInteger(), 5L));
}
@Test
- public void testRoundWithDigits() throws HopValueException {
+ void testRoundWithDigits() throws HopValueException {
Object result = ValueDataUtil.round(new ValueMetaNumber(), 5.456, new ValueMetaInteger(), 2L);
assertEquals(5.46, (Double) result, 0.001);
}
// Date operations tests
@Test
- public void testRemoveTimeFromDate() throws HopValueException {
+ void testRemoveTimeFromDate() throws HopValueException {
Calendar cal = Calendar.getInstance();
cal.set(2024, Calendar.JANUARY, 15, 14, 30, 45);
Date dateWithTime = cal.getTime();
@@ -580,7 +595,7 @@ public class ValueDataUtilTest {
}
@Test
- public void testAddDays() throws HopValueException {
+ void testAddDays() throws HopValueException {
Calendar cal = Calendar.getInstance();
cal.set(2024, Calendar.JANUARY, 15, 0, 0, 0);
Date date = cal.getTime();
@@ -594,7 +609,7 @@ public class ValueDataUtilTest {
}
@Test
- public void testAddHours() throws HopValueException {
+ void testAddHours() throws HopValueException {
Calendar cal = Calendar.getInstance();
cal.set(2024, Calendar.JANUARY, 15, 10, 0, 0);
Date date = cal.getTime();
@@ -608,7 +623,7 @@ public class ValueDataUtilTest {
}
@Test
- public void testAddMinutes() throws HopValueException {
+ void testAddMinutes() throws HopValueException {
Calendar cal = Calendar.getInstance();
cal.set(2024, Calendar.JANUARY, 15, 10, 30, 0);
Date date = cal.getTime();
@@ -622,7 +637,7 @@ public class ValueDataUtilTest {
}
@Test
- public void testYearOfDate() throws HopValueException {
+ void testYearOfDate() throws HopValueException {
Calendar cal = Calendar.getInstance();
cal.set(2024, Calendar.JANUARY, 15);
Date date = cal.getTime();
@@ -632,7 +647,7 @@ public class ValueDataUtilTest {
}
@Test
- public void testMonthOfDate() throws HopValueException {
+ void testMonthOfDate() throws HopValueException {
Calendar cal = Calendar.getInstance();
cal.set(2024, Calendar.MARCH, 15);
Date date = cal.getTime();
@@ -642,7 +657,7 @@ public class ValueDataUtilTest {
}
@Test
- public void testDayOfMonth() throws HopValueException {
+ void testDayOfMonth() throws HopValueException {
Calendar cal = Calendar.getInstance();
cal.set(2024, Calendar.JANUARY, 15);
Date date = cal.getTime();
@@ -652,7 +667,7 @@ public class ValueDataUtilTest {
}
@Test
- public void testHourOfDay() throws HopValueException {
+ void testHourOfDay() throws HopValueException {
Calendar cal = Calendar.getInstance();
cal.set(2024, Calendar.JANUARY, 15, 14, 30, 0);
Date date = cal.getTime();
@@ -663,14 +678,14 @@ public class ValueDataUtilTest {
// NVL function tests
@Test
- public void testNvlWithNullFirstValue() throws HopValueException {
+ void testNvlWithNullFirstValue() throws HopValueException {
String result =
(String) ValueDataUtil.nvl(new ValueMetaString(), null, new ValueMetaString(), "default");
assertEquals("default", result);
}
@Test
- public void testNvlWithNonNullFirstValue() throws HopValueException {
+ void testNvlWithNonNullFirstValue() throws HopValueException {
String result =
(String)
ValueDataUtil.nvl(
@@ -680,7 +695,7 @@ public class ValueDataUtilTest {
}
@Test
- public void testNvlWithIntegers() throws HopValueException {
+ void testNvlWithIntegers() throws HopValueException {
Long result =
(Long) ValueDataUtil.nvl(new ValueMetaInteger(), null, new ValueMetaInteger(), 100L);
assertEquals(Long.valueOf(100), result);
@@ -688,14 +703,14 @@ public class ValueDataUtilTest {
// URL encoding/decoding tests
@Test
- public void testUrlEncode() {
+ void testUrlEncode() {
String encoded = ValueDataUtil.urlEncode("hello world");
assertEquals("hello+world", encoded);
assertNull(ValueDataUtil.urlEncode(null));
}
@Test
- public void testUrlDecode() {
+ void testUrlDecode() {
String decoded = ValueDataUtil.urlDecode("hello+world");
assertEquals("hello world", decoded);
assertNull(ValueDataUtil.urlDecode(null));
@@ -703,41 +718,41 @@ public class ValueDataUtilTest {
// Hex encoding/decoding tests
@Test
- public void testByteToHexEncode() throws HopValueException {
+ void testByteToHexEncode() throws HopValueException {
String hex = ValueDataUtil.byteToHexEncode(new ValueMetaString(), "test");
assertEquals("74657374", hex);
}
@Test
- public void testHexToByteDecode() throws HopValueException {
+ void testHexToByteDecode() throws HopValueException {
String decoded = ValueDataUtil.hexToByteDecode(new ValueMetaString(), "74657374");
assertEquals("test", decoded);
}
// XML/HTML escape tests
@Test
- public void testEscapeXml() {
+ void testEscapeXml() {
String escaped = ValueDataUtil.escapeXml("<hello>");
assertTrue(escaped.contains("<") && escaped.contains(">"));
assertNull(ValueDataUtil.escapeXml(null));
}
@Test
- public void testUnEscapeXml() {
+ void testUnEscapeXml() {
String unescaped = ValueDataUtil.unEscapeXml("<hello>");
assertEquals("<hello>", unescaped);
assertNull(ValueDataUtil.unEscapeXml(null));
}
@Test
- public void testEscapeHtml() {
+ void testEscapeHtml() {
String escaped = ValueDataUtil.escapeHtml("<hello>");
assertTrue(escaped.contains("<") && escaped.contains(">"));
assertNull(ValueDataUtil.escapeHtml(null));
}
@Test
- public void testUnEscapeHtml() {
+ void testUnEscapeHtml() {
String unescaped = ValueDataUtil.unEscapeHtml("<hello>");
assertEquals("<hello>", unescaped);
assertNull(ValueDataUtil.unEscapeHtml(null));
@@ -745,7 +760,7 @@ public class ValueDataUtilTest {
// Test getZeroForValueMetaType
@Test
- public void testGetZeroForValueMetaType() throws HopValueException {
+ void testGetZeroForValueMetaType() throws HopValueException {
assertEquals(0L, ValueDataUtil.getZeroForValueMetaType(new ValueMetaInteger()));
assertEquals((double) 0, ValueDataUtil.getZeroForValueMetaType(new ValueMetaNumber()));
assertEquals(
@@ -753,19 +768,22 @@ public class ValueDataUtilTest {
assertEquals("", ValueDataUtil.getZeroForValueMetaType(new ValueMetaString()));
}
- @Test(expected = HopValueException.class)
- public void testGetZeroForValueMetaTypeWithNull() throws HopValueException {
- ValueDataUtil.getZeroForValueMetaType(null);
+ @Test
+ void testGetZeroForValueMetaTypeWithNull() {
+
+ assertThrows(HopValueException.class, () -> ValueDataUtil.getZeroForValueMetaType(null));
}
- @Test(expected = HopValueException.class)
- public void testGetZeroForValueMetaTypeWithUnsupportedType() throws HopValueException {
- ValueDataUtil.getZeroForValueMetaType(new ValueMetaBoolean());
+ @Test
+ void testGetZeroForValueMetaTypeWithUnsupportedType() {
+ assertThrows(
+ HopValueException.class,
+ () -> ValueDataUtil.getZeroForValueMetaType(new ValueMetaBoolean()));
}
// Test minus operation
@Test
- public void testMinus() throws HopValueException {
+ void testMinus() throws HopValueException {
Object result =
ValueDataUtil.minus(
new ValueMetaInteger(), 10L,
@@ -781,7 +799,7 @@ public class ValueDataUtilTest {
// Test multiply operation
@Test
- public void testMultiply() throws HopValueException {
+ void testMultiply() throws HopValueException {
Object result =
ValueDataUtil.multiply(
new ValueMetaInteger(), 5L,
@@ -797,7 +815,7 @@ public class ValueDataUtilTest {
// Test divide operation
@Test
- public void testDivide() throws HopValueException {
+ void testDivide() throws HopValueException {
Object result =
ValueDataUtil.divide(
new ValueMetaInteger(), 10L,
@@ -813,7 +831,7 @@ public class ValueDataUtilTest {
// Test isXmlWellFormed (for string content, not file)
@Test
- public void testIsXmlWellFormed() {
+ void testIsXmlWellFormed() {
assertTrue(
ValueDataUtil.isXmlWellFormed(
new ValueMetaString(), "<?xml version=\"1.0\"?><root>test</root>"));
@@ -823,7 +841,7 @@ public class ValueDataUtilTest {
// SQL escape test
@Test
- public void testEscapeSql() {
+ void testEscapeSql() {
String escaped = ValueDataUtil.escapeSql("O'Reilly");
assertEquals("O''Reilly", escaped);
assertNull(ValueDataUtil.escapeSql(null));
@@ -831,7 +849,7 @@ public class ValueDataUtilTest {
// CDATA test
@Test
- public void testUseCDATA() {
+ void testUseCDATA() {
String cdata = ValueDataUtil.useCDATA("<test>data</test>");
assertTrue(cdata.startsWith("<![CDATA[") && cdata.endsWith("]]>"));
assertNull(ValueDataUtil.useCDATA(null));
@@ -839,7 +857,7 @@ public class ValueDataUtilTest {
// Percentage functions tests
@Test
- public void testPercent1() throws HopValueException {
+ void testPercent1() throws HopValueException {
// percent1: A / B * 100
Object result =
ValueDataUtil.percent1(
@@ -849,7 +867,7 @@ public class ValueDataUtilTest {
}
@Test
- public void testPercent2() throws HopValueException {
+ void testPercent2() throws HopValueException {
// percent2: A - (A * B / 100)
Object result =
ValueDataUtil.percent2(
@@ -859,7 +877,7 @@ public class ValueDataUtilTest {
}
@Test
- public void testPercent3() throws HopValueException {
+ void testPercent3() throws HopValueException {
// percent3: A + (A * B / 100)
Object result =
ValueDataUtil.percent3(
@@ -870,7 +888,7 @@ public class ValueDataUtilTest {
// Combination functions tests
@Test
- public void testCombination1() throws HopValueException {
+ void testCombination1() throws HopValueException {
// combination1: A + B * C
Object result =
ValueDataUtil.combination1(
@@ -881,7 +899,7 @@ public class ValueDataUtilTest {
}
@Test
- public void testCombination2() throws HopValueException {
+ void testCombination2() throws HopValueException {
// combination2: SQRT(A * A + B * B)
Object result =
ValueDataUtil.combination2(new ValueMetaNumber(), 3.0, new ValueMetaNumber(), 4.0);
@@ -890,7 +908,7 @@ public class ValueDataUtilTest {
// Additional date operations tests
@Test
- public void testAddSeconds() throws HopValueException {
+ void testAddSeconds() throws HopValueException {
Calendar cal = Calendar.getInstance();
cal.set(2024, Calendar.JANUARY, 15, 10, 30, 0);
Date date = cal.getTime();
@@ -905,7 +923,7 @@ public class ValueDataUtilTest {
}
@Test
- public void testAddMonths() throws HopValueException {
+ void testAddMonths() throws HopValueException {
Calendar cal = Calendar.getInstance();
cal.set(2024, Calendar.JANUARY, 15);
Date date = cal.getTime();
@@ -919,7 +937,7 @@ public class ValueDataUtilTest {
}
@Test
- public void testQuarterOfDate() throws HopValueException {
+ void testQuarterOfDate() throws HopValueException {
Calendar cal = Calendar.getInstance();
// Q1 - January
@@ -944,7 +962,7 @@ public class ValueDataUtilTest {
}
@Test
- public void testWeekOfYear() throws HopValueException {
+ void testWeekOfYear() throws HopValueException {
Calendar cal = Calendar.getInstance();
cal.set(2024, Calendar.JANUARY, 15);
Date date = cal.getTime();
@@ -954,7 +972,7 @@ public class ValueDataUtilTest {
}
@Test
- public void testWeekOfYearISO8601() throws HopValueException {
+ void testWeekOfYearISO8601() throws HopValueException {
Calendar cal = Calendar.getInstance();
cal.set(2024, Calendar.JANUARY, 15);
Date date = cal.getTime();
@@ -964,7 +982,7 @@ public class ValueDataUtilTest {
}
@Test
- public void testYearOfDateISO8601() throws HopValueException {
+ void testYearOfDateISO8601() throws HopValueException {
Calendar cal = Calendar.getInstance();
cal.set(2024, Calendar.JANUARY, 1);
Date date = cal.getTime();
@@ -974,7 +992,7 @@ public class ValueDataUtilTest {
}
@Test
- public void testDayOfYear() throws HopValueException {
+ void testDayOfYear() throws HopValueException {
Calendar cal = Calendar.getInstance();
cal.set(2024, Calendar.JANUARY, 1);
Date date = cal.getTime();
@@ -985,11 +1003,11 @@ public class ValueDataUtilTest {
cal.set(2024, Calendar.DECEMBER, 31);
date = cal.getTime();
day = (Long) ValueDataUtil.dayOfYear(new ValueMetaDate(), date);
- assertTrue(day == 366); // 2024 is a leap year
+ assertEquals(366, (long) day); // 2024 is a leap year
}
@Test
- public void testMinuteOfHour() throws HopValueException {
+ void testMinuteOfHour() throws HopValueException {
Calendar cal = Calendar.getInstance();
cal.set(2024, Calendar.JANUARY, 15, 14, 35, 0);
Date date = cal.getTime();
@@ -999,7 +1017,7 @@ public class ValueDataUtilTest {
}
@Test
- public void testSecondOfMinute() throws HopValueException {
+ void testSecondOfMinute() throws HopValueException {
Calendar cal = Calendar.getInstance();
cal.set(2024, Calendar.JANUARY, 15, 14, 30, 45);
Date date = cal.getTime();
@@ -1009,7 +1027,7 @@ public class ValueDataUtilTest {
}
@Test
- public void testDayOfWeek() throws HopValueException {
+ void testDayOfWeek() throws HopValueException {
Calendar cal = Calendar.getInstance();
cal.set(2024, Calendar.JANUARY, 15); // Monday
Date date = cal.getTime();
@@ -1020,34 +1038,34 @@ public class ValueDataUtilTest {
// Hex encoding tests
@Test
- public void testCharToHexEncode() throws HopValueException {
+ void testCharToHexEncode() throws HopValueException {
String hex = ValueDataUtil.charToHexEncode(new ValueMetaString(), "A");
assertEquals("0041", hex);
}
@Test
- public void testHexToCharDecode() throws HopValueException {
+ void testHexToCharDecode() throws HopValueException {
String decoded = ValueDataUtil.hexToCharDecode(new ValueMetaString(), "0041");
assertEquals("A", decoded);
}
// String utility functions tests
@Test
- public void testRightPadString() {
+ void testRightPadString() {
assertEquals("test ", ValueDataUtil.rightPad("test", 6));
assertEquals("test", ValueDataUtil.rightPad("test", 4));
assertEquals("te", ValueDataUtil.rightPad("test", 2)); // Truncates if limit is shorter
}
@Test
- public void testRightPadStringBuffer() {
+ void testRightPadStringBuffer() {
StringBuffer sb = new StringBuffer("test");
String result = ValueDataUtil.rightPad(sb, 6);
assertEquals("test ", result);
}
@Test
- public void testReplace() {
+ void testReplace() {
String result = ValueDataUtil.replace("hello world", "world", "universe");
assertEquals("hello universe", result);
@@ -1056,28 +1074,28 @@ public class ValueDataUtilTest {
}
@Test
- public void testReplaceBuffer() {
+ void testReplaceBuffer() {
StringBuffer buffer = new StringBuffer("hello world");
ValueDataUtil.replaceBuffer(buffer, "world", "universe");
assertEquals("hello universe", buffer.toString());
}
@Test
- public void testNrSpacesBefore() {
+ void testNrSpacesBefore() {
assertEquals(0, ValueDataUtil.nrSpacesBefore("test"));
assertEquals(3, ValueDataUtil.nrSpacesBefore(" test"));
assertEquals(0, ValueDataUtil.nrSpacesBefore(""));
}
@Test
- public void testNrSpacesAfter() {
+ void testNrSpacesAfter() {
assertEquals(0, ValueDataUtil.nrSpacesAfter("test"));
assertEquals(3, ValueDataUtil.nrSpacesAfter("test "));
assertEquals(0, ValueDataUtil.nrSpacesAfter(""));
}
@Test
- public void testOnlySpaces() {
+ void testOnlySpaces() {
assertTrue(ValueDataUtil.onlySpaces(" "));
assertTrue(ValueDataUtil.onlySpaces(""));
assertFalse(ValueDataUtil.onlySpaces(" a "));
@@ -1086,7 +1104,7 @@ public class ValueDataUtilTest {
// Date difference tests
@Test
- public void testDateDiff() throws HopValueException {
+ void testDateDiff() throws HopValueException {
Calendar cal1 = Calendar.getInstance();
cal1.set(2024, Calendar.JANUARY, 1, 0, 0, 0);
Date date1 = cal1.getTime();
@@ -1101,7 +1119,7 @@ public class ValueDataUtilTest {
}
@Test
- public void testDateDiffHours() throws HopValueException {
+ void testDateDiffHours() throws HopValueException {
Calendar cal1 = Calendar.getInstance();
cal1.set(2024, Calendar.JANUARY, 1, 0, 0, 0);
Date date1 = cal1.getTime();
@@ -1116,7 +1134,7 @@ public class ValueDataUtilTest {
}
@Test
- public void testDateDiffMinutes() throws HopValueException {
+ void testDateDiffMinutes() throws HopValueException {
Calendar cal1 = Calendar.getInstance();
cal1.set(2024, Calendar.JANUARY, 1, 0, 0, 0);
Date date1 = cal1.getTime();
@@ -1132,7 +1150,7 @@ public class ValueDataUtilTest {
// Test addTimeToDate
@Test
- public void testAddTimeToDate() throws HopValueException {
+ void testAddTimeToDate() throws HopValueException {
Calendar dateCal = Calendar.getInstance();
dateCal.set(2024, Calendar.JANUARY, 15, 0, 0, 0);
Date date = dateCal.getTime();
@@ -1155,7 +1173,7 @@ public class ValueDataUtilTest {
// Test plus3
@Test
- public void testPlus3() throws HopValueException {
+ void testPlus3() throws HopValueException {
Object result =
ValueDataUtil.plus3(
new ValueMetaInteger(), 10L,
@@ -1173,23 +1191,23 @@ public class ValueDataUtilTest {
// Test multiplyDoubles and multiplyLongs
@Test
- public void testMultiplyDoubles() {
+ void testMultiplyDoubles() {
assertEquals(Double.valueOf(6.0), ValueDataUtil.multiplyDoubles(2.0, 3.0));
}
@Test
- public void testMultiplyLongs() {
+ void testMultiplyLongs() {
assertEquals(Long.valueOf(6), ValueDataUtil.multiplyLongs(2L, 3L));
}
// Test divideDoubles and divideLongs
@Test
- public void testDivideDoubles() {
+ void testDivideDoubles() {
assertEquals(Double.valueOf(2.0), ValueDataUtil.divideDoubles(6.0, 3.0));
}
@Test
- public void testDivideLongs() {
+ void testDivideLongs() {
assertEquals(Long.valueOf(2), ValueDataUtil.divideLongs(6L, 3L));
}
}
diff --git a/core/src/test/java/org/apache/hop/core/row/ValueMetaTest.java b/core/src/test/java/org/apache/hop/core/row/ValueMetaTest.java
index 1b0b01b7e0..18e382e6fd 100644
--- a/core/src/test/java/org/apache/hop/core/row/ValueMetaTest.java
+++ b/core/src/test/java/org/apache/hop/core/row/ValueMetaTest.java
@@ -17,9 +17,12 @@
package org.apache.hop.core.row;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertInstanceOf;
+import static org.junit.jupiter.api.Assertions.assertNotEquals;
+import static org.junit.jupiter.api.Assertions.assertNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+import static org.junit.jupiter.api.Assertions.fail;
import java.math.BigDecimal;
import java.util.Calendar;
@@ -35,13 +38,13 @@ import org.apache.hop.core.row.value.ValueMetaInteger;
import org.apache.hop.core.row.value.ValueMetaNumber;
import org.apache.hop.core.row.value.ValueMetaPluginType;
import org.apache.hop.core.row.value.ValueMetaString;
-import org.apache.hop.junit.rules.RestoreHopEnvironment;
-import org.junit.ClassRule;
-import org.junit.Test;
+import org.apache.hop.junit.rules.RestoreHopEnvironmentExtension;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.ExtendWith;
/** Test functionality in ValueMeta */
-public class ValueMetaTest {
- @ClassRule public static RestoreHopEnvironment env = new RestoreHopEnvironment();
+@ExtendWith(RestoreHopEnvironmentExtension.class)
+class ValueMetaTest {
/**
* Compare to byte arrays for equality.
@@ -66,7 +69,7 @@ public class ValueMetaTest {
}
@Test
- public void testCvtStringToBinaryString() throws Exception {
+ void testCvtStringToBinaryString() throws Exception {
ValueMetaString val1 = new ValueMetaString("STR1");
val1.setLength(6);
val1.setStringEncoding("UTF8");
@@ -95,7 +98,7 @@ public class ValueMetaTest {
}
@Test
- public void testCvtStringBinaryString() throws Exception {
+ void testCvtStringBinaryString() throws Exception {
ValueMetaString val1 = new ValueMetaString("STR1");
val1.setLength(6);
val1.setStringEncoding("UTF8");
@@ -117,7 +120,7 @@ public class ValueMetaTest {
}
@Test
- public void testIntegerToStringToInteger() throws Exception {
+ void testIntegerToStringToInteger() throws Exception {
IValueMeta intValueMeta = new ValueMetaInteger("i");
intValueMeta.setConversionMask(null);
intValueMeta.setLength(7);
@@ -137,7 +140,7 @@ public class ValueMetaTest {
}
@Test
- public void testNumberToStringToNumber() throws Exception {
+ void testNumberToStringToNumber() throws Exception {
IValueMeta numValueMeta = new ValueMetaNumber("i");
numValueMeta.setConversionMask(null);
numValueMeta.setLength(7, 3);
@@ -159,7 +162,7 @@ public class ValueMetaTest {
}
@Test
- public void testBigNumberToStringToBigNumber() throws Exception {
+ void testBigNumberToStringToBigNumber() throws Exception {
IValueMeta numValueMeta = new ValueMetaBigNumber("i");
numValueMeta.setLength(42, 9);
numValueMeta.setDecimalSymbol(".");
@@ -179,7 +182,7 @@ public class ValueMetaTest {
}
@Test
- public void testBigNumberToStringToBigNumberWithByteLimitValues() throws Exception {
+ void testBigNumberToStringToBigNumberWithByteLimitValues() throws Exception {
IValueMeta numValueMeta = new ValueMetaBigNumber("i");
numValueMeta.setDecimalSymbol(".");
numValueMeta.setGroupingSymbol(",");
@@ -199,7 +202,7 @@ public class ValueMetaTest {
}
@Test
- public void testByteToStringToBigNumberWithByteLimitValues() throws Exception {
+ void testByteToStringToBigNumberWithByteLimitValues() throws Exception {
ValueMetaBigNumber numValueMeta = new ValueMetaBigNumber("i");
numValueMeta.setDecimalSymbol(".");
numValueMeta.setGroupingSymbol(",");
@@ -225,7 +228,7 @@ public class ValueMetaTest {
}
@Test
- public void testBigNumberToStringToBigNumberWithShortLimitValues() throws Exception {
+ void testBigNumberToStringToBigNumberWithShortLimitValues() throws Exception {
IValueMeta numValueMeta = new ValueMetaBigNumber("i");
numValueMeta.setDecimalSymbol(".");
numValueMeta.setGroupingSymbol(",");
@@ -245,7 +248,7 @@ public class ValueMetaTest {
}
@Test
- public void testShortToStringToBigNumberWithShortLimitValues() throws Exception {
+ void testShortToStringToBigNumberWithShortLimitValues() throws Exception {
ValueMetaBigNumber numValueMeta = new ValueMetaBigNumber("i");
numValueMeta.setDecimalSymbol(".");
numValueMeta.setGroupingSymbol(",");
@@ -271,7 +274,7 @@ public class ValueMetaTest {
}
@Test
- public void testBigNumberToStringToBigNumberWithIntLimitValues() throws Exception {
+ void testBigNumberToStringToBigNumberWithIntLimitValues() throws Exception {
IValueMeta numValueMeta = new ValueMetaBigNumber("i");
numValueMeta.setDecimalSymbol(".");
numValueMeta.setGroupingSymbol(",");
@@ -292,7 +295,7 @@ public class ValueMetaTest {
}
@Test
- public void testIntToStringToBigNumberWithIntLimitValues() throws Exception {
+ void testIntToStringToBigNumberWithIntLimitValues() throws Exception {
ValueMetaBigNumber numValueMeta = new ValueMetaBigNumber("i");
numValueMeta.setDecimalSymbol(".");
numValueMeta.setGroupingSymbol(",");
@@ -319,7 +322,7 @@ public class ValueMetaTest {
}
@Test
- public void testBigNumberToStringToBigNumberWithLongLimitValues() throws Exception {
+ void testBigNumberToStringToBigNumberWithLongLimitValues() throws Exception {
IValueMeta numValueMeta = new ValueMetaBigNumber("i");
numValueMeta.setDecimalSymbol(".");
numValueMeta.setGroupingSymbol(",");
@@ -342,7 +345,7 @@ public class ValueMetaTest {
}
@Test
- public void testLongToStringToBigNumberWithLongLimitValues() throws Exception {
+ void testLongToStringToBigNumberWithLongLimitValues() throws Exception {
ValueMetaBigNumber numValueMeta = new ValueMetaBigNumber("i");
numValueMeta.setDecimalSymbol(".");
numValueMeta.setGroupingSymbol(",");
@@ -371,7 +374,7 @@ public class ValueMetaTest {
}
@Test
- public void testBigNumberToStringToBigNumberWithFloatLimitValues() throws Exception {
+ void testBigNumberToStringToBigNumberWithFloatLimitValues() throws Exception {
IValueMeta numValueMeta = new ValueMetaBigNumber("i");
numValueMeta.setDecimalSymbol(".");
numValueMeta.setGroupingSymbol(",");
@@ -392,7 +395,7 @@ public class ValueMetaTest {
}
@Test
- public void testFloatToStringToBigNumberWithFloatLimitValues() throws Exception {
+ void testFloatToStringToBigNumberWithFloatLimitValues() throws Exception {
ValueMetaBigNumber numValueMeta = new ValueMetaBigNumber("i");
numValueMeta.setDecimalSymbol(".");
numValueMeta.setGroupingSymbol(",");
@@ -422,7 +425,7 @@ public class ValueMetaTest {
}
@Test
- public void testBigNumberToStringToBigNumberWithDoubleLimitValues() throws Exception {
+ void testBigNumberToStringToBigNumberWithDoubleLimitValues() throws Exception {
IValueMeta numValueMeta = new ValueMetaBigNumber("i");
numValueMeta.setDecimalSymbol(".");
numValueMeta.setGroupingSymbol(",");
@@ -443,7 +446,7 @@ public class ValueMetaTest {
}
@Test
- public void testDoubleToStringToBigNumberWithDoubleLimitValues() throws Exception {
+ void testDoubleToStringToBigNumberWithDoubleLimitValues() throws Exception {
ValueMetaBigNumber numValueMeta = new ValueMetaBigNumber("i");
numValueMeta.setDecimalSymbol(".");
numValueMeta.setGroupingSymbol(",");
@@ -465,7 +468,7 @@ public class ValueMetaTest {
}
@Test
- public void testBigNumberToStringToBigNumberWithNumberCloseToZero() throws Exception {
+ void testBigNumberToStringToBigNumberWithNumberCloseToZero() throws Exception {
IValueMeta numValueMeta = new ValueMetaBigNumber("i");
numValueMeta.setDecimalSymbol(",");
numValueMeta.setGroupingSymbol(".");
@@ -492,7 +495,7 @@ public class ValueMetaTest {
}
@Test
- public void testToStringToBigNumberWithNumberCloseToZero() throws Exception {
+ void testToStringToBigNumberWithNumberCloseToZero() throws Exception {
ValueMetaBigNumber numValueMeta = new ValueMetaBigNumber("i");
numValueMeta.setDecimalSymbol(",");
numValueMeta.setGroupingSymbol(".");
@@ -520,7 +523,7 @@ public class ValueMetaTest {
}
@Test
- public void testPDI17366Conversion() throws Exception {
+ void testPDI17366Conversion() throws Exception {
ValueMetaBigNumber numValueMeta = new ValueMetaBigNumber("i");
numValueMeta.setDecimalSymbol(",");
numValueMeta.setGroupingSymbol(".");
@@ -545,7 +548,7 @@ public class ValueMetaTest {
}
@Test
- public void testDateToStringToDate() throws Exception {
+ void testDateToStringToDate() throws Exception {
TimeZone.setDefault(TimeZone.getTimeZone("CET"));
IValueMeta datValueMeta = new ValueMetaDate("i");
@@ -565,7 +568,7 @@ public class ValueMetaTest {
}
@Test
- public void testDateStringDL8601() throws Exception {
+ void testDateStringDL8601() throws Exception {
TimeZone.setDefault(TimeZone.getTimeZone("America/New_York"));
IValueMeta datValueMeta = new ValueMetaString();
@@ -575,9 +578,9 @@ public class ValueMetaTest {
// make sure it's what we expect...
Calendar c = Calendar.getInstance();
c.setTime(res);
- assertEquals("Month should be 2", 2, c.get(Calendar.MONTH));
- assertEquals("Day should be 8", 8, c.get(Calendar.DAY_OF_MONTH));
- assertEquals("Year should be 2008", 2008, c.get(Calendar.YEAR));
+ assertEquals(2, c.get(Calendar.MONTH), "Month should be 2");
+ assertEquals(8, c.get(Calendar.DAY_OF_MONTH), "Day should be 8");
+ assertEquals(2008, c.get(Calendar.YEAR), "Year should be 2008");
} catch (Exception ex) {
fail("Error converting date." + ex.getMessage());
}
@@ -589,9 +592,9 @@ public class ValueMetaTest {
// make sure it's what we expect...
Calendar c = Calendar.getInstance();
c.setTime(res);
- assertEquals("Month should be 2", 2, c.get(Calendar.MONTH));
- assertEquals("Day should be 8", 8, c.get(Calendar.DAY_OF_MONTH));
- assertEquals("Year should be 2008", 2008, c.get(Calendar.YEAR));
+ assertEquals(2, c.get(Calendar.MONTH), "Month should be 2");
+ assertEquals(8, c.get(Calendar.DAY_OF_MONTH), "Day should be 8");
+ assertEquals(2008, c.get(Calendar.YEAR), "Year should be 2008");
} catch (Exception ex) {
fail("Error converting date." + ex.getMessage());
}
@@ -603,16 +606,16 @@ public class ValueMetaTest {
// make sure it's what we expect...
Calendar c = Calendar.getInstance();
c.setTime(res);
- assertEquals("Month should be 2", 2, c.get(Calendar.MONTH));
- assertEquals("Day should be 8", 8, c.get(Calendar.DAY_OF_MONTH));
- assertEquals("Year should be 2008", 2008, c.get(Calendar.YEAR));
+ assertEquals(2, c.get(Calendar.MONTH), "Month should be 2");
+ assertEquals(8, c.get(Calendar.DAY_OF_MONTH), "Day should be 8");
+ assertEquals(2008, c.get(Calendar.YEAR), "Year should be 2008");
} catch (Exception ex) {
fail("Error converting date." + ex.getMessage());
}
}
@Test
- public void testDateStringUTC() throws Exception {
+ void testDateStringUTC() throws Exception {
TimeZone.setDefault(TimeZone.getTimeZone("America/New_York"));
IValueMeta datValueMeta = new ValueMetaString();
@@ -622,16 +625,16 @@ public class ValueMetaTest {
// make sure it's what we expect...
Calendar c = Calendar.getInstance();
c.setTime(res);
- assertEquals("Month should be 2", 2, c.get(Calendar.MONTH));
- assertEquals("Day should be 8", 8, c.get(Calendar.DAY_OF_MONTH));
- assertEquals("Year should be 2008", 2008, c.get(Calendar.YEAR));
+ assertEquals(2, c.get(Calendar.MONTH), "Month should be 2");
+ assertEquals(8, c.get(Calendar.DAY_OF_MONTH), "Day should be 8");
+ assertEquals(2008, c.get(Calendar.YEAR), "Year should be 2008");
} catch (Exception ex) {
fail("Error converting date." + ex.getMessage());
}
}
@Test
- public void testDateStringOffset() throws Exception {
+ void testDateStringOffset() throws Exception {
TimeZone.setDefault(TimeZone.getTimeZone("America/New_York"));
IValueMeta datValueMeta = new ValueMetaString();
@@ -641,9 +644,9 @@ public class ValueMetaTest {
// make sure it's what we expect...
Calendar c = Calendar.getInstance();
c.setTime(res);
- assertEquals("Month should be 2", 2, c.get(Calendar.MONTH));
- assertEquals("Day should be 8", 8, c.get(Calendar.DAY_OF_MONTH));
- assertEquals("Year should be 2008", 2008, c.get(Calendar.YEAR));
+ assertEquals(2, c.get(Calendar.MONTH), "Month should be 2");
+ assertEquals(8, c.get(Calendar.DAY_OF_MONTH), "Day should be 8");
+ assertEquals(2008, c.get(Calendar.YEAR), "Year should be 2008");
} catch (Exception ex) {
fail("Error converting date." + ex.getMessage());
}
@@ -654,16 +657,16 @@ public class ValueMetaTest {
// make sure it's what we expect...
Calendar c = Calendar.getInstance();
c.setTime(res);
- assertEquals("Month should be 2", 2, c.get(Calendar.MONTH));
- assertEquals("Day should be 8", 8, c.get(Calendar.DAY_OF_MONTH));
- assertEquals("Year should be 2008", 2008, c.get(Calendar.YEAR));
+ assertEquals(2, c.get(Calendar.MONTH), "Month should be 2");
+ assertEquals(8, c.get(Calendar.DAY_OF_MONTH), "Day should be 8");
+ assertEquals(2008, c.get(Calendar.YEAR), "Year should be 2008");
} catch (Exception ex) {
fail("Error converting date." + ex.getMessage());
}
}
@Test
- public void testDateString8601() throws Exception {
+ void testDateString8601() throws Exception {
TimeZone.setDefault(TimeZone.getTimeZone("Europe/Kaliningrad"));
IValueMeta datValueMeta = new ValueMetaString();
@@ -672,9 +675,9 @@ public class ValueMetaTest {
Date res = datValueMeta.getDate("2011-03-13T02:23:18.000Z");
Calendar c = Calendar.getInstance();
c.setTime(res);
- assertEquals("Month should be 2", 2, c.get(Calendar.MONTH));
- assertEquals("Day should be 13", 13, c.get(Calendar.DAY_OF_MONTH));
- assertEquals("Year should be 2011", 2011, c.get(Calendar.YEAR));
+ assertEquals(2, c.get(Calendar.MONTH), "Month should be 2");
+ assertEquals(13, c.get(Calendar.DAY_OF_MONTH), "Day should be 13");
+ assertEquals(2011, c.get(Calendar.YEAR), "Year should be 2011");
} catch (Exception ex) {
fail("Error converting date." + ex.getMessage());
}
@@ -686,11 +689,12 @@ public class ValueMetaTest {
datValueMeta.getDate("2011-03-13T02:23:18.000Z");
fail("Expected exception when trying to convert date");
} catch (Exception ex) {
+ // ignore
}
}
@Test
- public void testConvertDataDate() throws Exception {
+ void testConvertDataDate() throws Exception {
TimeZone.setDefault(TimeZone.getTimeZone("CET"));
IValueMeta source = new ValueMetaString("src");
@@ -707,7 +711,7 @@ public class ValueMetaTest {
}
@Test
- public void testConvertDataInteger() throws Exception {
+ void testConvertDataInteger() throws Exception {
IValueMeta source = new ValueMetaString("src");
source.setConversionMask(" #,##0");
source.setLength(12, 3);
@@ -727,7 +731,7 @@ public class ValueMetaTest {
}
@Test
- public void testConvertDataNumber() throws Exception {
+ void testConvertDataNumber() throws Exception {
IValueMeta source = new ValueMetaString("src");
source.setConversionMask("###,###,##0.000");
source.setLength(3, 0);
@@ -752,11 +756,9 @@ public class ValueMetaTest {
* converted from the byte[] to Integer, rather left untouched until it's needed.
*
* <p>However at that time we do need it we should get the correct value back.
- *
- * @throws Exception
*/
@Test
- public void testLazyConversionInteger() throws Exception {
+ void testLazyConversionInteger() throws Exception {
byte[] data = ("1234").getBytes();
IValueMeta intValueMeta = new ValueMetaInteger("i");
intValueMeta.setConversionMask(null);
@@ -782,11 +784,9 @@ public class ValueMetaTest {
* converted from the byte[] to Integer, rather left untouched until it's needed.
*
* <p>However at that time we do need it we should get the correct value back.
- *
- * @throws Exception
*/
@Test
- public void testLazyConversionNumber() throws Exception {
+ void testLazyConversionNumber() throws Exception {
byte[] data = ("1,234.56").getBytes();
IValueMeta numValueMeta = new ValueMetaNumber("i");
numValueMeta.setConversionMask(null);
@@ -830,11 +830,9 @@ public class ValueMetaTest {
* converted from the byte[] to Integer, rather left untouched until it's needed.
*
* <p>However at that time we do need it we should get the correct value back.
- *
- * @throws Exception
*/
@Test
- public void testLazyConversionBigNumber() throws Exception {
+ void testLazyConversionBigNumber() throws Exception {
String originalValue = "34983433433212304121900934.5634314343";
byte[] data = originalValue.getBytes();
IValueMeta numValueMeta = new ValueMetaBigNumber("i");
@@ -876,7 +874,7 @@ public class ValueMetaTest {
}
@Test
- public void testLazyConversionNullInteger() throws Exception {
+ void testLazyConversionNullInteger() throws Exception {
byte[] data = new byte[0];
IValueMeta intValueMeta = new ValueMetaBoolean("i");
intValueMeta.setConversionMask(null);
@@ -886,19 +884,19 @@ public class ValueMetaTest {
intValueMeta.setStorageMetadata(strValueMeta);
Double numberValue = intValueMeta.getNumber(data);
- assertEquals(null, numberValue);
+ assertNull(numberValue);
Long integerValue = intValueMeta.getInteger(data);
- assertEquals(null, integerValue);
+ assertNull(integerValue);
BigDecimal bigNumberValue = intValueMeta.getBigNumber(data);
- assertEquals(null, bigNumberValue);
+ assertNull(bigNumberValue);
Date dateValue = intValueMeta.getDate(data);
- assertEquals(null, dateValue);
+ assertNull(dateValue);
String string = intValueMeta.getString(data);
- assertEquals(null, string);
+ assertNull(string);
}
@Test
- public void testLazyConversionNullNumber() throws Exception {
+ void testLazyConversionNullNumber() throws Exception {
byte[] data = new byte[0];
IValueMeta intValueMeta = new ValueMetaNumber("i");
intValueMeta.setConversionMask(null);
@@ -908,22 +906,22 @@ public class ValueMetaTest {
intValueMeta.setStorageMetadata(strValueMeta);
Double numberValue = intValueMeta.getNumber(data);
- assertEquals(null, numberValue);
+ assertNull(numberValue);
Long integerValue = intValueMeta.getInteger(data);
- assertEquals(null, integerValue);
+ assertNull(integerValue);
BigDecimal bigNumberValue = intValueMeta.getBigNumber(data);
- assertEquals(null, bigNumberValue);
+ assertNull(bigNumberValue);
Date dateValue = intValueMeta.getDate(data);
- assertEquals(null, dateValue);
+ assertNull(dateValue);
String string = intValueMeta.getString(data);
- assertEquals(null, string);
+ assertNull(string);
Boolean b = intValueMeta.getBoolean(data);
- assertEquals(null, b);
+ assertNull(b);
}
@Test
- public void testCompareIntegersNormalStorageData() throws Exception {
+ void testCompareIntegersNormalStorageData() throws Exception {
Long integer1 = 1234L;
Long integer2 = 1235L;
Long integer3 = 1233L;
@@ -937,18 +935,18 @@ public class ValueMetaTest {
assertTrue(one.compare(integer1, integer2) < 0);
assertTrue(one.compare(integer1, integer3) > 0);
assertEquals(0, one.compare(integer1, integer4));
- assertTrue(one.compare(integer1, integer5) != 0);
+ assertNotEquals(0, one.compare(integer1, integer5));
assertEquals(0, one.compare(integer5, integer6));
assertTrue(one.compare(integer1, two, integer2) < 0);
assertTrue(one.compare(integer1, two, integer3) > 0);
assertEquals(0, one.compare(integer1, two, integer4));
- assertTrue(one.compare(integer1, two, integer5) != 0);
+ assertNotEquals(0, one.compare(integer1, two, integer5));
assertEquals(0, one.compare(integer5, two, integer6));
}
@Test
- public void testCompareNumbersNormalStorageData() throws Exception {
+ void testCompareNumbersNormalStorageData() throws Exception {
Double number1 = 1234.56;
Double number2 = 1235.56;
Double number3 = 1233.56;
@@ -962,18 +960,19 @@ public class ValueMetaTest {
assertTrue(one.compare(number1, number2) < 0);
assertTrue(one.compare(number1, number3) > 0);
assertEquals(0, one.compare(number1, number4));
- assertTrue(one.compare(number1, number5) != 0);
+ assertNotEquals(0, one.compare(number1, number5));
assertEquals(0, one.compare(number5, number6));
assertTrue(one.compare(number1, two, number2) < 0);
assertTrue(one.compare(number1, two, number3) > 0);
assertEquals(0, one.compare(number1, two, number4));
- assertTrue(one.compare(number1, two, number5) != 0);
+
+ assertNotEquals(0, one.compare(number1, two, number5));
assertEquals(0, one.compare(number5, two, number6));
}
@Test
- public void testCompareBigNumberNormalStorageData() throws Exception {
+ void testCompareBigNumberNormalStorageData() throws Exception {
BigDecimal number1 = new BigDecimal("987908798769876.23943409");
BigDecimal number2 = new BigDecimal("999908798769876.23943409");
BigDecimal number3 = new BigDecimal("955908798769876.23943409");
@@ -987,18 +986,18 @@ public class ValueMetaTest {
assertTrue(one.compare(number1, number2) < 0);
assertTrue(one.compare(number1, number3) > 0);
assertEquals(0, one.compare(number1, number4));
- assertTrue(one.compare(number1, number5) != 0);
+ assertNotEquals(0, one.compare(number1, number5));
assertEquals(0, one.compare(number5, number6));
assertTrue(one.compare(number1, two, number2) < 0);
assertTrue(one.compare(number1, two, number3) > 0);
assertEquals(0, one.compare(number1, two, number4));
- assertTrue(one.compare(number1, two, number5) != 0);
+ assertNotEquals(0, one.compare(number1, two, number5));
assertEquals(0, one.compare(number5, two, number6));
}
@Test
- public void testCompareDatesNormalStorageData() throws Exception {
+ void testCompareDatesNormalStorageData() throws Exception {
Date date1 = new Date();
Date date2 = new Date(date1.getTime() + 3600);
Date date3 = new Date(date1.getTime() - 3600);
@@ -1012,18 +1011,20 @@ public class ValueMetaTest {
assertTrue(one.compare(date1, date2) < 0);
assertTrue(one.compare(date1, date3) > 0);
assertEquals(0, one.compare(date1, date4));
- assertTrue(one.compare(date1, date5) != 0);
+
+ assertNotEquals(0, one.compare(date1, date5));
assertEquals(0, one.compare(date5, date6));
assertTrue(one.compare(date1, two, date2) < 0);
assertTrue(one.compare(date1, two, date3) > 0);
assertEquals(0, one.compare(date1, two, date4));
- assertTrue(one.compare(date1, two, date5) != 0);
+
+ assertNotEquals(0, one.compare(date1, two, date5));
assertEquals(0, one.compare(date5, two, date6));
}
@Test
- public void testCompareBooleanNormalStorageData() throws Exception {
+ void testCompareBooleanNormalStorageData() throws Exception {
Boolean boolean1 = Boolean.FALSE;
Boolean boolean2 = Boolean.TRUE;
Boolean boolean3 = Boolean.FALSE;
@@ -1035,17 +1036,19 @@ public class ValueMetaTest {
assertTrue(one.compare(boolean1, boolean2) < 0);
assertEquals(0, one.compare(boolean1, boolean3));
- assertTrue(one.compare(boolean1, boolean4) != 0);
+
+ assertNotEquals(0, one.compare(boolean1, boolean4));
assertEquals(0, one.compare(boolean4, boolean5));
assertTrue(one.compare(boolean1, two, boolean2) < 0);
assertEquals(0, one.compare(boolean1, two, boolean3));
- assertTrue(one.compare(boolean1, two, boolean4) != 0);
+
+ assertNotEquals(0, one.compare(boolean1, two, boolean4));
assertEquals(0, one.compare(boolean4, two, boolean5));
}
@Test
- public void testCompareStringsNormalStorageData() throws Exception {
+ void testCompareStringsNormalStorageData() throws Exception {
String string1 = "bbbbb";
String string2 = "ccccc";
String string3 = "aaaaa";
@@ -1059,25 +1062,27 @@ public class ValueMetaTest {
assertTrue(one.compare(string1, string2) < 0);
assertTrue(one.compare(string1, string3) > 0);
assertEquals(0, one.compare(string1, string4));
- assertTrue(one.compare(string1, string5) != 0);
+
+ assertNotEquals(0, one.compare(string1, string5));
assertEquals(0, one.compare(string5, string6));
assertTrue(one.compare(string1, two, string2) < 0);
assertTrue(one.compare(string1, two, string3) > 0);
assertEquals(0, one.compare(string1, two, string4));
- assertTrue(one.compare(string1, two, string5) != 0);
+
+ assertNotEquals(0, one.compare(string1, two, string5));
assertEquals(0, one.compare(string5, two, string6));
}
@Test
- public void testValueMetaInheritance() {
- assertTrue(new ValueMetaBoolean() instanceof IValueMeta);
- assertTrue(new ValueMetaString() instanceof IValueMeta);
- assertTrue(new ValueMetaDate() instanceof IValueMeta);
+ void testValueMetaInheritance() {
+ assertInstanceOf(IValueMeta.class, new ValueMetaBoolean());
+ assertInstanceOf(IValueMeta.class, new ValueMetaString());
+ assertInstanceOf(IValueMeta.class, new ValueMetaDate());
}
@Test
- public void testGetNativeDataTypeClass() throws HopException {
+ void testGetNativeDataTypeClass() throws HopException {
PluginRegistry.addPluginType(ValueMetaPluginType.getInstance());
PluginRegistry.init();
String[] valueMetaNames = ValueMetaFactory.getValueMetaNames();
diff --git a/core/src/test/java/org/apache/hop/core/row/value/ValueMetaFactoryTest.java b/core/src/test/java/org/apache/hop/core/row/value/ValueMetaFactoryTest.java
index 6ecc439f98..c867346c11 100644
--- a/core/src/test/java/org/apache/hop/core/row/value/ValueMetaFactoryTest.java
+++ b/core/src/test/java/org/apache/hop/core/row/value/ValueMetaFactoryTest.java
@@ -17,13 +17,15 @@
package org.apache.hop.core.row.value;
-import static org.junit.Assert.assertArrayEquals;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNotSame;
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
+import static org.junit.jupiter.api.Assertions.assertArrayEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertInstanceOf;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertNotSame;
+import static org.junit.jupiter.api.Assertions.assertNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+import static org.junit.jupiter.api.Assertions.fail;
import java.math.BigDecimal;
import java.util.Arrays;
@@ -35,21 +37,22 @@ import org.apache.hop.core.exception.HopException;
import org.apache.hop.core.exception.HopPluginException;
import org.apache.hop.core.exception.HopValueException;
import org.apache.hop.core.row.IValueMeta;
-import org.apache.hop.junit.rules.RestoreHopEnvironment;
-import org.junit.BeforeClass;
-import org.junit.ClassRule;
-import org.junit.Test;
+import org.apache.hop.junit.rules.RestoreHopEnvironmentExtension;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.ExtendWith;
-public class ValueMetaFactoryTest {
- @ClassRule public static RestoreHopEnvironment env = new RestoreHopEnvironment();
+/** Unit test for {@link ValueMetaFactory} */
+@ExtendWith(RestoreHopEnvironmentExtension.class)
+class ValueMetaFactoryTest {
- @BeforeClass
- public static void beforeClassSetUp() throws HopException {
+ @BeforeAll
+ static void beforeClassSetUp() throws HopException {
HopClientEnvironment.init();
}
@Test
- public void testClone() throws HopException {
+ void testClone() throws HopException {
IValueMeta original = new ValueMetaString();
original.setCollatorLocale(Locale.CANADA);
original.setCollatorStrength(3);
@@ -63,6 +66,8 @@ public class ValueMetaFactoryTest {
if (expected == null && actual == null) {
return;
}
+ assertNotNull(expected);
+
assertEquals(expected.getName(), actual.getName());
assertEquals(expected.getType(), actual.getType());
assertEquals(expected.getLength(), actual.getLength());
@@ -95,235 +100,233 @@ public class ValueMetaFactoryTest {
}
@Test
- public void testCreateValueMeta() throws HopPluginException {
+ void testCreateValueMeta() throws HopPluginException {
IValueMeta testObject;
- try {
- testObject = ValueMetaFactory.createValueMeta(Integer.MIN_VALUE);
- fail();
- } catch (HopPluginException expected) {
- // Do nothing, Integer.MIN_VALUE is not a valid option
- }
-
- try {
- testObject = ValueMetaFactory.createValueMeta(null, Integer.MIN_VALUE);
- fail();
- } catch (HopPluginException expected) {
- // Do nothing, Integer.MIN_VALUE is not a valid option
- }
-
- try {
- testObject = ValueMetaFactory.createValueMeta(null, Integer.MIN_VALUE, 10, 10);
- fail();
- } catch (HopPluginException expected) {
- // Do nothing, Integer.MIN_VALUE is not a valid option
- }
-
testObject = ValueMetaFactory.createValueMeta(IValueMeta.TYPE_NONE);
- assertTrue(testObject instanceof ValueMetaNone);
- assertEquals(null, testObject.getName());
+ assertInstanceOf(ValueMetaNone.class, testObject);
+ assertNull(testObject.getName());
assertEquals(-1, testObject.getLength());
assertEquals(-1, testObject.getPrecision());
testObject = ValueMetaFactory.createValueMeta("testNone", IValueMeta.TYPE_NONE);
- assertTrue(testObject instanceof ValueMetaNone);
+ assertInstanceOf(ValueMetaNone.class, testObject);
assertEquals("testNone", testObject.getName());
assertEquals(-1, testObject.getLength());
assertEquals(-1, testObject.getPrecision());
testObject = ValueMetaFactory.createValueMeta("testNone", IValueMeta.TYPE_NONE, 10, 20);
- assertTrue(testObject instanceof ValueMetaNone);
+ assertInstanceOf(ValueMetaNone.class, testObject);
assertEquals("testNone", testObject.getName());
assertEquals(10, testObject.getLength());
assertEquals(20, testObject.getPrecision());
testObject = ValueMetaFactory.createValueMeta(IValueMeta.TYPE_NUMBER);
- assertTrue(testObject instanceof ValueMetaNumber);
- assertEquals(null, testObject.getName());
+ assertInstanceOf(ValueMetaNumber.class, testObject);
+ assertNull(testObject.getName());
assertEquals(-1, testObject.getLength());
assertEquals(-1, testObject.getPrecision());
- testObject = ValueMetaFactory.createValueMeta("testNumber", IValueMeta.TYPE_NUMBER);
- assertTrue(testObject instanceof ValueMetaNumber);
- assertEquals("testNumber", testObject.getName());
- assertEquals(-1, testObject.getLength());
- assertEquals(-1, testObject.getPrecision());
+ testCreateValueMeta_1(testObject);
+ testCreateValueMeta_2(testObject);
+ testCreateValueMeta_3(testObject);
+ testCreateValueMeta_4(testObject);
+ testCreateValueMeta_5(testObject);
+ testCreateValueMeta_6(testObject);
+ }
- testObject = ValueMetaFactory.createValueMeta("testNumber", IValueMeta.TYPE_NUMBER, 10, 20);
- assertTrue(testObject instanceof ValueMetaNumber);
- assertEquals("testNumber", testObject.getName());
+ private void testCreateValueMeta_1(IValueMeta testObject) throws HopPluginException {
+ testObject =
+ ValueMetaFactory.createValueMeta("testTimestamp", IValueMeta.TYPE_TIMESTAMP, 10, 20);
+ assertInstanceOf(ValueMetaTimestamp.class, testObject);
+ assertEquals("testTimestamp", testObject.getName());
assertEquals(10, testObject.getLength());
assertEquals(20, testObject.getPrecision());
- testObject = ValueMetaFactory.createValueMeta(IValueMeta.TYPE_STRING);
- assertTrue(testObject instanceof ValueMetaString);
- assertEquals(null, testObject.getName());
+ testObject = ValueMetaFactory.createValueMeta(IValueMeta.TYPE_INET);
+ assertInstanceOf(ValueMetaInternetAddress.class, testObject);
+ assertNull(testObject.getName());
assertEquals(-1, testObject.getLength());
assertEquals(-1, testObject.getPrecision());
- testObject = ValueMetaFactory.createValueMeta("testString", IValueMeta.TYPE_STRING);
- assertTrue(testObject instanceof ValueMetaString);
- assertEquals("testString", testObject.getName());
+ testObject = ValueMetaFactory.createValueMeta("testInternetAddress", IValueMeta.TYPE_INET);
+ assertInstanceOf(ValueMetaInternetAddress.class, testObject);
+ assertEquals("testInternetAddress", testObject.getName());
assertEquals(-1, testObject.getLength());
assertEquals(-1, testObject.getPrecision());
- testObject = ValueMetaFactory.createValueMeta("testString", IValueMeta.TYPE_STRING, 1000, 50);
- assertTrue(testObject instanceof ValueMetaString);
- assertEquals("testString", testObject.getName());
- assertEquals(1000, testObject.getLength());
- assertEquals(-1, testObject.getPrecision()); // Special case for String
+ testObject =
+ ValueMetaFactory.createValueMeta("testInternetAddress", IValueMeta.TYPE_INET, 10, 20);
+ assertInstanceOf(ValueMetaInternetAddress.class, testObject);
+ assertEquals("testInternetAddress", testObject.getName());
+ assertEquals(10, testObject.getLength());
+ assertEquals(20, testObject.getPrecision());
+ }
- testObject = ValueMetaFactory.createValueMeta(IValueMeta.TYPE_DATE);
- assertTrue(testObject instanceof ValueMetaDate);
- assertEquals(null, testObject.getName());
+ private void testCreateValueMeta_2(IValueMeta testObject) throws HopPluginException {
+ testObject = ValueMetaFactory.createValueMeta(IValueMeta.TYPE_BINARY);
+ assertInstanceOf(ValueMetaBinary.class, testObject);
+ assertNull(testObject.getName());
+ assertEquals(-1, testObject.getLength());
+ assertEquals(0, testObject.getPrecision()); // Special case for Binary
+
+ testObject = ValueMetaFactory.createValueMeta("testBinary", IValueMeta.TYPE_BINARY);
+ assertInstanceOf(ValueMetaBinary.class, testObject);
+ assertEquals("testBinary", testObject.getName());
+ assertEquals(-1, testObject.getLength());
+ assertEquals(0, testObject.getPrecision()); // Special case for Binary
+
+ testObject = ValueMetaFactory.createValueMeta("testBinary", IValueMeta.TYPE_BINARY, 10, 20);
+ assertInstanceOf(ValueMetaBinary.class, testObject);
+ assertEquals("testBinary", testObject.getName());
+ assertEquals(10, testObject.getLength());
+ assertEquals(0, testObject.getPrecision()); // Special case for Binary
+
+ testObject = ValueMetaFactory.createValueMeta(IValueMeta.TYPE_TIMESTAMP);
+ assertInstanceOf(ValueMetaTimestamp.class, testObject);
+ assertNull(testObject.getName());
assertEquals(-1, testObject.getLength());
assertEquals(-1, testObject.getPrecision());
- testObject = ValueMetaFactory.createValueMeta("testDate", IValueMeta.TYPE_DATE);
- assertTrue(testObject instanceof ValueMetaDate);
- assertEquals("testDate", testObject.getName());
+ testObject = ValueMetaFactory.createValueMeta("testTimestamp", IValueMeta.TYPE_TIMESTAMP);
+ assertInstanceOf(ValueMetaTimestamp.class, testObject);
+ assertEquals("testTimestamp", testObject.getName());
assertEquals(-1, testObject.getLength());
assertEquals(-1, testObject.getPrecision());
+ }
- testObject = ValueMetaFactory.createValueMeta("testDate", IValueMeta.TYPE_DATE, 10, 20);
- assertTrue(testObject instanceof ValueMetaDate);
- assertEquals("testDate", testObject.getName());
+ private void testCreateValueMeta_3(IValueMeta testObject) throws HopPluginException {
+ testObject = ValueMetaFactory.createValueMeta("testBigNumber", IValueMeta.TYPE_BIGNUMBER);
+ assertInstanceOf(ValueMetaBigNumber.class, testObject);
+ assertEquals("testBigNumber", testObject.getName());
+ assertEquals(-1, testObject.getLength());
+ assertEquals(-1, testObject.getPrecision());
+
+ testObject =
+ ValueMetaFactory.createValueMeta("testBigNumber", IValueMeta.TYPE_BIGNUMBER, 10, 20);
+ assertInstanceOf(ValueMetaBigNumber.class, testObject);
+ assertEquals("testBigNumber", testObject.getName());
assertEquals(10, testObject.getLength());
assertEquals(20, testObject.getPrecision());
- testObject = ValueMetaFactory.createValueMeta(IValueMeta.TYPE_BOOLEAN);
- assertTrue(testObject instanceof ValueMetaBoolean);
- assertEquals(null, testObject.getName());
+ testObject = ValueMetaFactory.createValueMeta(IValueMeta.TYPE_SERIALIZABLE);
+ assertInstanceOf(ValueMetaSerializable.class, testObject);
+ assertNull(testObject.getName());
assertEquals(-1, testObject.getLength());
assertEquals(-1, testObject.getPrecision());
- testObject = ValueMetaFactory.createValueMeta("testBoolean", IValueMeta.TYPE_BOOLEAN);
- assertTrue(testObject instanceof ValueMetaBoolean);
- assertEquals("testBoolean", testObject.getName());
+ testObject = ValueMetaFactory.createValueMeta("testSerializable", IValueMeta.TYPE_SERIALIZABLE);
+ assertInstanceOf(ValueMetaSerializable.class, testObject);
+ assertEquals("testSerializable", testObject.getName());
assertEquals(-1, testObject.getLength());
assertEquals(-1, testObject.getPrecision());
+ testObject =
+ ValueMetaFactory.createValueMeta("testSerializable", IValueMeta.TYPE_SERIALIZABLE, 10, 20);
+ assertInstanceOf(ValueMetaSerializable.class, testObject);
+ assertEquals("testSerializable", testObject.getName());
+ assertEquals(10, testObject.getLength());
+ assertEquals(20, testObject.getPrecision());
+ }
+
+ private void testCreateValueMeta_4(IValueMeta testObject) throws HopPluginException {
testObject = ValueMetaFactory.createValueMeta("testBoolean", IValueMeta.TYPE_BOOLEAN, 10, 20);
- assertTrue(testObject instanceof ValueMetaBoolean);
+ assertInstanceOf(ValueMetaBoolean.class, testObject);
assertEquals("testBoolean", testObject.getName());
assertEquals(10, testObject.getLength());
assertEquals(-1, testObject.getPrecision());
testObject = ValueMetaFactory.createValueMeta(IValueMeta.TYPE_INTEGER);
- assertTrue(testObject instanceof ValueMetaInteger);
- assertEquals(null, testObject.getName());
+ assertInstanceOf(ValueMetaInteger.class, testObject);
+ assertNull(testObject.getName());
assertEquals(-1, testObject.getLength());
assertEquals(0, testObject.getPrecision()); // Special case for Integer
testObject = ValueMetaFactory.createValueMeta("testInteger", IValueMeta.TYPE_INTEGER);
- assertTrue(testObject instanceof ValueMetaInteger);
+ assertInstanceOf(ValueMetaInteger.class, testObject);
assertEquals("testInteger", testObject.getName());
assertEquals(-1, testObject.getLength());
assertEquals(0, testObject.getPrecision()); // Special case for Integer
testObject = ValueMetaFactory.createValueMeta("testInteger", IValueMeta.TYPE_INTEGER, 10, 20);
- assertTrue(testObject instanceof ValueMetaInteger);
+ assertInstanceOf(ValueMetaInteger.class, testObject);
assertEquals("testInteger", testObject.getName());
assertEquals(10, testObject.getLength());
assertEquals(0, testObject.getPrecision()); // Special case for Integer
testObject = ValueMetaFactory.createValueMeta(IValueMeta.TYPE_BIGNUMBER);
- assertTrue(testObject instanceof ValueMetaBigNumber);
- assertEquals(null, testObject.getName());
- assertEquals(-1, testObject.getLength());
- assertEquals(-1, testObject.getPrecision());
-
- testObject = ValueMetaFactory.createValueMeta("testBigNumber", IValueMeta.TYPE_BIGNUMBER);
- assertTrue(testObject instanceof ValueMetaBigNumber);
- assertEquals("testBigNumber", testObject.getName());
+ assertInstanceOf(ValueMetaBigNumber.class, testObject);
+ assertNull(testObject.getName());
assertEquals(-1, testObject.getLength());
assertEquals(-1, testObject.getPrecision());
+ }
- testObject =
- ValueMetaFactory.createValueMeta("testBigNumber", IValueMeta.TYPE_BIGNUMBER, 10, 20);
- assertTrue(testObject instanceof ValueMetaBigNumber);
- assertEquals("testBigNumber", testObject.getName());
- assertEquals(10, testObject.getLength());
- assertEquals(20, testObject.getPrecision());
-
- testObject = ValueMetaFactory.createValueMeta(IValueMeta.TYPE_SERIALIZABLE);
- assertTrue(testObject instanceof ValueMetaSerializable);
- assertEquals(null, testObject.getName());
+ private void testCreateValueMeta_5(IValueMeta testObject) throws HopPluginException {
+ testObject = ValueMetaFactory.createValueMeta(IValueMeta.TYPE_DATE);
+ assertInstanceOf(ValueMetaDate.class, testObject);
+ assertNull(testObject.getName());
assertEquals(-1, testObject.getLength());
assertEquals(-1, testObject.getPrecision());
- testObject = ValueMetaFactory.createValueMeta("testSerializable", IValueMeta.TYPE_SERIALIZABLE);
- assertTrue(testObject instanceof ValueMetaSerializable);
- assertEquals("testSerializable", testObject.getName());
+ testObject = ValueMetaFactory.createValueMeta("testDate", IValueMeta.TYPE_DATE);
+ assertInstanceOf(ValueMetaDate.class, testObject);
+ assertEquals("testDate", testObject.getName());
assertEquals(-1, testObject.getLength());
assertEquals(-1, testObject.getPrecision());
- testObject =
- ValueMetaFactory.createValueMeta("testSerializable", IValueMeta.TYPE_SERIALIZABLE, 10, 20);
- assertTrue(testObject instanceof ValueMetaSerializable);
- assertEquals("testSerializable", testObject.getName());
+ testObject = ValueMetaFactory.createValueMeta("testDate", IValueMeta.TYPE_DATE, 10, 20);
+ assertInstanceOf(ValueMetaDate.class, testObject);
+ assertEquals("testDate", testObject.getName());
assertEquals(10, testObject.getLength());
assertEquals(20, testObject.getPrecision());
- testObject = ValueMetaFactory.createValueMeta(IValueMeta.TYPE_BINARY);
- assertTrue(testObject instanceof ValueMetaBinary);
- assertEquals(null, testObject.getName());
- assertEquals(-1, testObject.getLength());
- assertEquals(0, testObject.getPrecision()); // Special case for Binary
-
- testObject = ValueMetaFactory.createValueMeta("testBinary", IValueMeta.TYPE_BINARY);
- assertTrue(testObject instanceof ValueMetaBinary);
- assertEquals("testBinary", testObject.getName());
+ testObject = ValueMetaFactory.createValueMeta(IValueMeta.TYPE_BOOLEAN);
+ assertInstanceOf(ValueMetaBoolean.class, testObject);
+ assertNull(testObject.getName());
assertEquals(-1, testObject.getLength());
- assertEquals(0, testObject.getPrecision()); // Special case for Binary
-
- testObject = ValueMetaFactory.createValueMeta("testBinary", IValueMeta.TYPE_BINARY, 10, 20);
- assertTrue(testObject instanceof ValueMetaBinary);
- assertEquals("testBinary", testObject.getName());
- assertEquals(10, testObject.getLength());
- assertEquals(0, testObject.getPrecision()); // Special case for Binary
+ assertEquals(-1, testObject.getPrecision());
- testObject = ValueMetaFactory.createValueMeta(IValueMeta.TYPE_TIMESTAMP);
- assertTrue(testObject instanceof ValueMetaTimestamp);
- assertEquals(null, testObject.getName());
+ testObject = ValueMetaFactory.createValueMeta("testBoolean", IValueMeta.TYPE_BOOLEAN);
+ assertInstanceOf(ValueMetaBoolean.class, testObject);
+ assertEquals("testBoolean", testObject.getName());
assertEquals(-1, testObject.getLength());
assertEquals(-1, testObject.getPrecision());
+ }
- testObject = ValueMetaFactory.createValueMeta("testTimestamp", IValueMeta.TYPE_TIMESTAMP);
- assertTrue(testObject instanceof ValueMetaTimestamp);
- assertEquals("testTimestamp", testObject.getName());
+ private void testCreateValueMeta_6(IValueMeta testObject) throws HopPluginException {
+ testObject = ValueMetaFactory.createValueMeta("testNumber", IValueMeta.TYPE_NUMBER);
+ assertInstanceOf(ValueMetaNumber.class, testObject);
+ assertEquals("testNumber", testObject.getName());
assertEquals(-1, testObject.getLength());
assertEquals(-1, testObject.getPrecision());
- testObject =
- ValueMetaFactory.createValueMeta("testTimestamp", IValueMeta.TYPE_TIMESTAMP, 10, 20);
- assertTrue(testObject instanceof ValueMetaTimestamp);
- assertEquals("testTimestamp", testObject.getName());
+ testObject = ValueMetaFactory.createValueMeta("testNumber", IValueMeta.TYPE_NUMBER, 10, 20);
+ assertInstanceOf(ValueMetaNumber.class, testObject);
+ assertEquals("testNumber", testObject.getName());
assertEquals(10, testObject.getLength());
assertEquals(20, testObject.getPrecision());
- testObject = ValueMetaFactory.createValueMeta(IValueMeta.TYPE_INET);
- assertTrue(testObject instanceof ValueMetaInternetAddress);
- assertEquals(null, testObject.getName());
+ testObject = ValueMetaFactory.createValueMeta(IValueMeta.TYPE_STRING);
+ assertInstanceOf(ValueMetaString.class, testObject);
+ assertNull(testObject.getName());
assertEquals(-1, testObject.getLength());
assertEquals(-1, testObject.getPrecision());
- testObject = ValueMetaFactory.createValueMeta("testInternetAddress", IValueMeta.TYPE_INET);
- assertTrue(testObject instanceof ValueMetaInternetAddress);
- assertEquals("testInternetAddress", testObject.getName());
+ testObject = ValueMetaFactory.createValueMeta("testString", IValueMeta.TYPE_STRING);
+ assertInstanceOf(ValueMetaString.class, testObject);
+ assertEquals("testString", testObject.getName());
assertEquals(-1, testObject.getLength());
assertEquals(-1, testObject.getPrecision());
- testObject =
- ValueMetaFactory.createValueMeta("testInternetAddress", IValueMeta.TYPE_INET, 10, 20);
- assertTrue(testObject instanceof ValueMetaInternetAddress);
- assertEquals("testInternetAddress", testObject.getName());
- assertEquals(10, testObject.getLength());
- assertEquals(20, testObject.getPrecision());
+ testObject = ValueMetaFactory.createValueMeta("testString", IValueMeta.TYPE_STRING, 1000, 50);
+ assertInstanceOf(ValueMetaString.class, testObject);
+ assertEquals("testString", testObject.getName());
+ assertEquals(1000, testObject.getLength());
+ assertEquals(-1, testObject.getPrecision()); // Special case for String
}
@Test
- public void testGetValueMetaNames() {
+ void testGetValueMetaNames() {
List<String> dataTypes = Arrays.<String>asList(ValueMetaFactory.getValueMetaNames());
assertTrue(dataTypes.contains("Number"));
@@ -339,7 +342,7 @@ public class ValueMetaFactoryTest {
}
@Test
- public void testGetAllValueMetaNames() {
+ void testGetAllValueMetaNames() {
List<String> dataTypes = Arrays.<String>asList(ValueMetaFactory.getAllValueMetaNames());
assertTrue(dataTypes.contains("Number"));
@@ -355,7 +358,7 @@ public class ValueMetaFactoryTest {
}
@Test
- public void testGetValueMetaName() {
+ void testGetValueMetaName() {
assertEquals("-", ValueMetaFactory.getValueMetaName(Integer.MIN_VALUE));
assertEquals("None", ValueMetaFactory.getValueMetaName(IValueMeta.TYPE_NONE));
assertEquals("Number", ValueMetaFactory.getValueMetaName(IValueMeta.TYPE_NUMBER));
@@ -371,7 +374,7 @@ public class ValueMetaFactoryTest {
}
@Test
- public void testGetIdForValueMeta() {
+ void testGetIdForValueMeta() {
assertEquals(IValueMeta.TYPE_NONE, ValueMetaFactory.getIdForValueMeta(null));
assertEquals(IValueMeta.TYPE_NONE, ValueMetaFactory.getIdForValueMeta(""));
assertEquals(IValueMeta.TYPE_NONE, ValueMetaFactory.getIdForValueMeta("None"));
@@ -388,7 +391,7 @@ public class ValueMetaFactoryTest {
}
@Test
- public void testGetValueMetaPluginClasses() throws HopPluginException {
+ void testGetValueMetaPluginClasses() throws HopPluginException {
List<IValueMeta> dataTypes = ValueMetaFactory.getValueMetaPluginClasses();
boolean numberExists = false;
@@ -448,31 +451,32 @@ public class ValueMetaFactoryTest {
}
@Test
- public void testGuessValueMetaInterface() {
- assertTrue(
- ValueMetaFactory.guessValueMetaInterface(new BigDecimal(1.0))
- instanceof ValueMetaBigNumber);
- assertTrue(ValueMetaFactory.guessValueMetaInterface(1.0) instanceof ValueMetaNumber);
- assertTrue(ValueMetaFactory.guessValueMetaInterface(1L) instanceof ValueMetaInteger);
- assertTrue(ValueMetaFactory.guessValueMetaInterface(new String()) instanceof ValueMetaString);
- assertTrue(ValueMetaFactory.guessValueMetaInterface(new Date()) instanceof ValueMetaDate);
- assertTrue(ValueMetaFactory.guessValueMetaInterface(Boolean.FALSE) instanceof ValueMetaBoolean);
- assertTrue(ValueMetaFactory.guessValueMetaInterface(Boolean.TRUE) instanceof ValueMetaBoolean);
- assertTrue(ValueMetaFactory.guessValueMetaInterface(false) instanceof ValueMetaBoolean);
- assertTrue(ValueMetaFactory.guessValueMetaInterface(true) instanceof ValueMetaBoolean);
- assertTrue(ValueMetaFactory.guessValueMetaInterface(new byte[10]) instanceof ValueMetaBinary);
+ void testGuessValueMetaInterface() {
+ assertInstanceOf(
+ ValueMetaBigNumber.class, ValueMetaFactory.guessValueMetaInterface(new BigDecimal("1.0")));
+ assertInstanceOf(ValueMetaNumber.class, ValueMetaFactory.guessValueMetaInterface(1.0));
+ assertInstanceOf(ValueMetaInteger.class, ValueMetaFactory.guessValueMetaInterface(1L));
+ assertInstanceOf(ValueMetaString.class, ValueMetaFactory.guessValueMetaInterface(""));
+ assertInstanceOf(ValueMetaDate.class, ValueMetaFactory.guessValueMetaInterface(new Date()));
+ assertInstanceOf(
+ ValueMetaBoolean.class, ValueMetaFactory.guessValueMetaInterface(Boolean.FALSE));
+ assertInstanceOf(
+ ValueMetaBoolean.class, ValueMetaFactory.guessValueMetaInterface(Boolean.TRUE));
+ assertInstanceOf(ValueMetaBoolean.class, ValueMetaFactory.guessValueMetaInterface(false));
+ assertInstanceOf(ValueMetaBoolean.class, ValueMetaFactory.guessValueMetaInterface(true));
+ assertInstanceOf(ValueMetaBinary.class, ValueMetaFactory.guessValueMetaInterface(new byte[10]));
// Test Unsupported Data Types
- assertEquals(null, ValueMetaFactory.guessValueMetaInterface(null));
- assertEquals(null, ValueMetaFactory.guessValueMetaInterface((short) 1));
- assertEquals(null, ValueMetaFactory.guessValueMetaInterface((byte) 1));
- assertEquals(null, ValueMetaFactory.guessValueMetaInterface(1.0F));
- assertEquals(null, ValueMetaFactory.guessValueMetaInterface(new StringBuilder()));
- assertEquals(null, ValueMetaFactory.guessValueMetaInterface((byte) 1));
+ assertNull(ValueMetaFactory.guessValueMetaInterface(null));
+ assertNull(ValueMetaFactory.guessValueMetaInterface((short) 1));
+ assertNull(ValueMetaFactory.guessValueMetaInterface((byte) 1));
+ assertNull(ValueMetaFactory.guessValueMetaInterface(1.0F));
+ assertNull(ValueMetaFactory.guessValueMetaInterface(new StringBuilder()));
+ assertNull(ValueMetaFactory.guessValueMetaInterface((byte) 1));
}
@Test
- public void testGetNativeDataTypeClass() throws HopPluginException {
+ void testGetNativeDataTypeClass() throws HopPluginException {
for (String valueMetaName : ValueMetaFactory.getValueMetaNames()) {
int valueMetaID = ValueMetaFactory.getIdForValueMeta(valueMetaName);
IValueMeta valueMeta = ValueMetaFactory.createValueMeta(valueMetaID);
diff --git a/core/src/test/java/org/apache/hop/core/row/value/timestamp/SimpleTimestampFormatTest.java b/core/src/test/java/org/apache/hop/core/row/value/timestamp/SimpleTimestampFormatTest.java
index 695104d0dc..ab69dd6173 100644
--- a/core/src/test/java/org/apache/hop/core/row/value/timestamp/SimpleTimestampFormatTest.java
+++ b/core/src/test/java/org/apache/hop/core/row/value/timestamp/SimpleTimestampFormatTest.java
@@ -16,7 +16,8 @@
*/
package org.apache.hop.core.row.value.timestamp;
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNull;
import java.sql.Timestamp;
import java.text.ParseException;
@@ -28,49 +29,48 @@ import java.util.HashSet;
import java.util.Locale;
import java.util.ResourceBundle;
import java.util.Set;
-import org.apache.hop.junit.rules.RestoreHopEnvironment;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.ClassRule;
-import org.junit.Ignore;
-import org.junit.Test;
+import org.apache.hop.junit.rules.RestoreHopEnvironmentExtension;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Disabled;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.ExtendWith;
/** User: Dzmitry Stsiapanau Date: 3/17/14 Time: 4:46 PM */
-public class SimpleTimestampFormatTest {
- @ClassRule public static RestoreHopEnvironment env = new RestoreHopEnvironment();
-
+@ExtendWith(RestoreHopEnvironmentExtension.class)
+class SimpleTimestampFormatTest {
private static Locale formatLocale;
- private Set<Locale> locales =
+ private final Set<Locale> locales =
new HashSet<>(Arrays.asList(Locale.US, Locale.GERMANY, Locale.JAPANESE, Locale.CHINESE));
private ResourceBundle tdb;
- private static String stringNinePrecision = "2014-03-15 15:30:45.123456789";
- private static String stringFourPrecision = "2014-03-15 15:30:45.1234";
- private static String stringThreePrecision = "2014-03-15 15:30:45.123";
- private static String stringWithoutPrecision = "2014-03-15 15:30:45";
- private static String stringWithoutPrecisionWithDot = "2014-11-15 15:30:45.000";
- private Timestamp timestampNinePrecision = Timestamp.valueOf(stringNinePrecision);
- private Timestamp timestampFourPrecision = Timestamp.valueOf(stringFourPrecision);
- private Timestamp timestampThreePrecision = Timestamp.valueOf(stringThreePrecision);
- private Timestamp timestampWithoutPrecision = Timestamp.valueOf(stringWithoutPrecision);
- private Timestamp timestampWithoutPrecisionWithDot =
+ private final String stringNinePrecision = "2014-03-15 15:30:45.123456789";
+ private final String stringFourPrecision = "2014-03-15 15:30:45.1234";
+ private final String stringThreePrecision = "2014-03-15 15:30:45.123";
+ private final String stringWithoutPrecision = "2014-03-15 15:30:45";
+ private final String stringWithoutPrecisionWithDot = "2014-11-15 15:30:45.000";
+ private final Timestamp timestampNinePrecision = Timestamp.valueOf(stringNinePrecision);
+ private final Timestamp timestampFourPrecision = Timestamp.valueOf(stringFourPrecision);
+ private final Timestamp timestampThreePrecision = Timestamp.valueOf(stringThreePrecision);
+ private final Timestamp timestampWithoutPrecision = Timestamp.valueOf(stringWithoutPrecision);
+ private final Timestamp timestampWithoutPrecisionWithDot =
Timestamp.valueOf(stringWithoutPrecisionWithDot);
- private Date dateThreePrecision = new Date(timestampThreePrecision.getTime());
- private Date dateWithoutPrecision = new Date(timestampWithoutPrecision.getTime());
+ private final Date dateThreePrecision = new Date(timestampThreePrecision.getTime());
+ private final Date dateWithoutPrecision = new Date(timestampWithoutPrecision.getTime());
- @Before
- public void setUp() {
+ @BeforeEach
+ void setUp() {
formatLocale = Locale.getDefault(Locale.Category.FORMAT);
}
- @After
- public void tearDown() {
+ @AfterEach
+ void tearDown() {
Locale.setDefault(Locale.Category.FORMAT, formatLocale);
}
@Test
- @Ignore("This test needs to be reviewed")
- public void testFormat() {
+ @Disabled("This test needs to be reviewed")
+ void testFormat() {
for (Locale locale : locales) {
Locale.setDefault(Locale.Category.FORMAT, locale);
tdb =
@@ -92,33 +92,33 @@ public class SimpleTimestampFormatTest {
private void checkFormat(String patternName, SimpleTimestampFormat stf) {
String localeForErrorMSG = Locale.getDefault(Locale.Category.FORMAT).toLanguageTag();
assertEquals(
- localeForErrorMSG + "=locale localized pattern= " + stf.toLocalizedPattern(),
tdb.getString("TIMESTAMP.NINE." + patternName),
- (stf.format(timestampNinePrecision)));
+ (stf.format(timestampNinePrecision)),
+ localeForErrorMSG + "=locale localized pattern= " + stf.toLocalizedPattern());
assertEquals(
- localeForErrorMSG + "=locale localized pattern= " + stf.toLocalizedPattern(),
tdb.getString("TIMESTAMP.THREE." + patternName),
- (stf.format(timestampThreePrecision)));
+ (stf.format(timestampThreePrecision)),
+ localeForErrorMSG + "=locale localized pattern= " + stf.toLocalizedPattern());
assertEquals(
- localeForErrorMSG + "=locale localized pattern= " + stf.toLocalizedPattern(),
tdb.getString("TIMESTAMP.ZERO." + patternName),
- (stf.format(timestampWithoutPrecision)));
+ (stf.format(timestampWithoutPrecision)),
+ localeForErrorMSG + "=locale localized pattern= " + stf.toLocalizedPattern());
assertEquals(
- localeForErrorMSG + "=locale localized pattern= " + stf.toLocalizedPattern(),
tdb.getString("TIMESTAMP.DOT." + patternName),
- (stf.format(timestampWithoutPrecisionWithDot)));
+ (stf.format(timestampWithoutPrecisionWithDot)),
+ localeForErrorMSG + "=locale localized pattern= " + stf.toLocalizedPattern());
assertEquals(
- localeForErrorMSG + "=locale localized pattern= " + stf.toLocalizedPattern(),
tdb.getString("DATE.THREE." + patternName),
- (stf.format(dateThreePrecision)));
+ (stf.format(dateThreePrecision)),
+ localeForErrorMSG + "=locale localized pattern= " + stf.toLocalizedPattern());
assertEquals(
- localeForErrorMSG + "=locale localized pattern= " + stf.toLocalizedPattern(),
tdb.getString("DATE.ZERO." + patternName),
- (stf.format(dateWithoutPrecision)));
+ (stf.format(dateWithoutPrecision)),
+ localeForErrorMSG + "=locale localized pattern= " + stf.toLocalizedPattern());
}
@Test
- public void testParse() throws Exception {
+ void testParse() throws Exception {
for (Locale locale : locales) {
Locale.setDefault(Locale.Category.FORMAT, locale);
tdb =
@@ -210,20 +210,20 @@ public class SimpleTimestampFormatTest {
throws ParseException {
if (date instanceof Timestamp) {
assertEquals(
- localeForErrorMSG + "=locale localized pattern= " + stf.toLocalizedPattern(),
date,
- (stf.parse(tdb.getString(patternName))));
+ (stf.parse(tdb.getString(patternName))),
+ localeForErrorMSG + "=locale localized pattern= " + stf.toLocalizedPattern());
} else {
assertEquals(
- localeForErrorMSG + "=locale localized pattern= " + stf.toLocalizedPattern(),
date,
- (stf.parse(tdb.getString(patternName))));
+ (stf.parse(tdb.getString(patternName))),
+ localeForErrorMSG + "=locale localized pattern= " + stf.toLocalizedPattern());
}
}
@Test
- @Ignore("This test needs to be reviewed")
- public void testToPattern() {
+ @Disabled("This test needs to be reviewed")
+ void testToPattern() {
for (Locale locale : locales) {
Locale.setDefault(Locale.Category.FORMAT, locale);
tdb =
@@ -240,8 +240,8 @@ public class SimpleTimestampFormatTest {
}
@Test
- @Ignore("This test needs to be reviewed")
- public void testToLocalizedPattern() {
+ @Disabled("This test needs to be reviewed")
+ void testToLocalizedPattern() {
for (Locale locale : locales) {
Locale.setDefault(Locale.Category.FORMAT, locale);
tdb =
@@ -262,8 +262,8 @@ public class SimpleTimestampFormatTest {
}
@Test
- @Ignore("This test needs to be reviewed")
- public void testApplyPattern() {
+ @Disabled("This test needs to be reviewed")
+ void testApplyPattern() {
for (Locale locale : locales) {
Locale.setDefault(Locale.Category.FORMAT, locale);
tdb =
@@ -278,7 +278,7 @@ public class SimpleTimestampFormatTest {
}
@Test
- public void testApplyLocalizedPattern() {
+ void testApplyLocalizedPattern() {
Locale.setDefault(Locale.Category.FORMAT, Locale.US);
SimpleTimestampFormat stf = new SimpleTimestampFormat(new SimpleDateFormat().toPattern());
for (Locale locale : locales) {
@@ -288,15 +288,15 @@ public class SimpleTimestampFormatTest {
"org/apache/hop/core/row/value/timestamp/messages/testdates", locale);
stf.applyLocalizedPattern(tdb.getString("PATTERN.LOCALE.DEFAULT"));
assertEquals(
- locale.toLanguageTag(),
tdb.getString("PATTERN.LOCALE.DEFAULT"),
- stf.toLocalizedPattern());
+ stf.toLocalizedPattern(),
+ locale.toLanguageTag());
checkFormat("LOCALE.DEFAULT", stf);
}
}
@Test
- public void testParseNull() throws Exception {
+ void testParseNull() {
String pattern = "yyyy-MM-dd HH:mm:ss.S";
SimpleTimestampFormat stf = new SimpleTimestampFormat(pattern);
// This value mimics a bad parse that might return null from super.parse()
@@ -305,6 +305,6 @@ public class SimpleTimestampFormatTest {
ParsePosition pos = new ParsePosition(0);
java.util.Date result = stf.parse(invalidValue, pos);
// Should return null (and set error index) instead of throwing NPE
- assertEquals(null, result);
+ assertNull(result);
}
}
diff --git a/core/src/test/java/org/apache/hop/core/spreadsheet/KCellTypeTest.java b/core/src/test/java/org/apache/hop/core/spreadsheet/KCellTypeTest.java
index 93cdd0d094..ce9b71c9f5 100644
--- a/core/src/test/java/org/apache/hop/core/spreadsheet/KCellTypeTest.java
+++ b/core/src/test/java/org/apache/hop/core/spreadsheet/KCellTypeTest.java
@@ -17,14 +17,15 @@
package org.apache.hop.core.spreadsheet;
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
-public class KCellTypeTest {
+/** Unit test for {@link KCellType} */
+class KCellTypeTest {
@Test
- public void testEnums() {
+ void testEnums() {
assertEquals("Empty", KCellType.EMPTY.getDescription());
assertEquals("Boolean", KCellType.BOOLEAN.getDescription());
assertEquals("Boolean formula", KCellType.BOOLEAN_FORMULA.getDescription());
diff --git a/core/src/test/java/org/apache/hop/core/svg/SvgImageTest.java b/core/src/test/java/org/apache/hop/core/svg/SvgImageTest.java
index 406a2557cd..fcf6ce6e99 100644
--- a/core/src/test/java/org/apache/hop/core/svg/SvgImageTest.java
+++ b/core/src/test/java/org/apache/hop/core/svg/SvgImageTest.java
@@ -16,27 +16,27 @@
*/
package org.apache.hop.core.svg;
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.mockito.Mockito.mock;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
import org.w3c.dom.Document;
/** Unit tests for the SvgImage class */
-public class SvgImageTest {
+class SvgImageTest {
SvgImage image;
Document document;
- @Before
- public void setUp() {
+ @BeforeEach
+ void setUp() {
document = mock(Document.class);
image = new SvgImage(document);
}
@Test
- public void testGetDocument() {
+ void testGetDocument() {
assertEquals(document, image.getDocument());
}
}
diff --git a/core/src/test/java/org/apache/hop/core/svg/SvgSupportTest.java b/core/src/test/java/org/apache/hop/core/svg/SvgSupportTest.java
index 966f75c1fe..617264465a 100644
--- a/core/src/test/java/org/apache/hop/core/svg/SvgSupportTest.java
+++ b/core/src/test/java/org/apache/hop/core/svg/SvgSupportTest.java
@@ -16,48 +16,39 @@
*/
package org.apache.hop.core.svg;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
import java.io.ByteArrayInputStream;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
/** Unit tests for the SvgSupport class */
-public class SvgSupportTest {
-
+class SvgSupportTest {
public static final String SVG_IMAGE =
- "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\"?>\n"
- + "<svg xmlns=\"http://www.w3.org/2000/svg\" version=\"1.0\"\n"
- + "\twidth=\"38\" height=\"32\" viewBox=\"0 0 39.875 33.6667\">\n"
- + "<path style=\"stroke: none; fill: #323296;\" d=\"M 10,0 L 30.5,0 39.875,17.5 30.5,33.6667 10,33.6667 L 0,17.5"
- + "L 10,0 z\"/>\n</svg>";
-
- @Before
- public void setUp() {
- // This isn't really a setup line, instead it is here to show that we didn't privatize the
- // default constructor.
- // It will stop compiling if we make that change to the code. However it should probably be
- // refactored a bit
- // further than that, to better support unit testing.
- new SvgSupport();
- }
+ """
+ <?xml version="1.0" encoding="UTF-8" standalone="no"?>
+ <svg xmlns="http://www.w3.org/2000/svg" version="1.0"
+ width="38" height="32" viewBox="0 0 39.875 33.6667">
+ <path style="stroke: none; fill: #323296;"
+ d="M 10,0 L 30.5,0 39.875,17.5 30.5,33.6667 10,33.6667 L 0,17.5 L 10,0 z"/>
+ </svg>
+ """;
@Test
- public void testIsSvgEnabled() {
+ void testIsSvgEnabled() {
assertTrue(SvgSupport.isSvgEnabled());
}
@Test
- public void testLoadSvgImage() throws Exception {
+ void testLoadSvgImage() throws Exception {
SvgImage image = SvgSupport.loadSvgImage(new ByteArrayInputStream(SVG_IMAGE.getBytes()));
assertNotNull(image);
}
@Test
- public void testToPngName() {
+ void testToPngName() {
assertTrue(SvgSupport.isPngName("my_file.png"));
assertTrue(SvgSupport.isPngName("my_file.PNG"));
assertTrue(SvgSupport.isPngName(".png"));
@@ -67,7 +58,7 @@ public class SvgSupportTest {
}
@Test
- public void testToSvgName() {
+ void testToSvgName() {
assertTrue(SvgSupport.isSvgName("my_file.svg"));
assertTrue(SvgSupport.isSvgName("my_file.SVG"));
assertTrue(SvgSupport.isSvgName(".svg"));
diff --git a/core/src/test/java/org/apache/hop/core/util/DateDetectorTest.java b/core/src/test/java/org/apache/hop/core/util/DateDetectorTest.java
index bf8a5a73e7..360e9b1488 100644
--- a/core/src/test/java/org/apache/hop/core/util/DateDetectorTest.java
+++ b/core/src/test/java/org/apache/hop/core/util/DateDetectorTest.java
@@ -16,20 +16,25 @@
*/
package org.apache.hop.core.util;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Iterator;
import org.apache.commons.collections4.BidiMap;
-import org.junit.BeforeClass;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.Test;
-public class DateDetectorTest {
+/**
+ * Unit test for {@link DateDetector}
+ *
+ * @author lance 2026/3/6 17:03
+ */
+class DateDetectorTest {
private static final String SAMPLE_REGEXP = "^\\d{1,2}/\\d{1,2}/\\d{4}\\s\\d{1,2}:\\d{2}:\\d{2}$";
@@ -52,8 +57,8 @@ public class DateDetectorTest {
private static String sampleDateStringUs;
- @BeforeClass
- public static void setUpClass() {
+ @BeforeAll
+ static void setUpClass() {
SimpleDateFormat format = new SimpleDateFormat(SAMPLE_DATE_FORMAT);
sampleDate = new Date(0);
sampleDateString = format.format(sampleDate);
@@ -64,13 +69,13 @@ public class DateDetectorTest {
}
@Test
- public void testGetRegexpByDateFormat() {
+ void testGetRegexpByDateFormat() {
assertNull(DateDetector.getRegexpByDateFormat(null));
assertEquals(SAMPLE_REGEXP, DateDetector.getRegexpByDateFormat(SAMPLE_DATE_FORMAT));
}
@Test
- public void testGetRegexpByDateFormatLocale() {
+ void testGetRegexpByDateFormatLocale() {
assertNull(DateDetector.getRegexpByDateFormat(null, null));
assertNull(DateDetector.getRegexpByDateFormat(null, LOCALE_EN_US));
// return null if we pass US dateformat without locale
@@ -80,13 +85,13 @@ public class DateDetectorTest {
}
@Test
- public void testGetDateFormatByRegex() {
+ void testGetDateFormatByRegex() {
assertNull(DateDetector.getDateFormatByRegex(null));
assertEquals(SAMPLE_DATE_FORMAT, DateDetector.getDateFormatByRegex(SAMPLE_REGEXP));
}
@Test
- public void testGetDateFormatByRegexLocale() {
+ void testGetDateFormatByRegexLocale() {
assertNull(DateDetector.getDateFormatByRegex(null, null));
assertNull(DateDetector.getDateFormatByRegex(null, LOCALE_EN_US));
// return eu if we pass en_US regexp without locale
@@ -96,7 +101,7 @@ public class DateDetectorTest {
}
@Test
- public void testGetDateFromString() throws ParseException {
+ void testGetDateFromString() throws ParseException {
assertEquals(sampleDateUs, DateDetector.getDateFromString(sampleDateStringUs));
try {
DateDetector.getDateFromString(null);
@@ -106,7 +111,7 @@ public class DateDetectorTest {
}
@Test
- public void testGetDateFromStringLocale() throws ParseException {
+ void testGetDateFromStringLocale() throws ParseException {
assertEquals(sampleDateUs, DateDetector.getDateFromString(sampleDateStringUs, LOCALE_EN_US));
try {
DateDetector.getDateFromString(null);
@@ -121,7 +126,7 @@ public class DateDetectorTest {
}
@Test
- public void testGetDateFromStringByFormat() throws ParseException {
+ void testGetDateFromStringByFormat() throws ParseException {
assertEquals(
sampleDate, DateDetector.getDateFromStringByFormat(sampleDateString, SAMPLE_DATE_FORMAT));
try {
@@ -137,13 +142,13 @@ public class DateDetectorTest {
}
@Test
- public void testDetectDateFormat() {
+ void testDetectDateFormat() {
assertEquals(SAMPLE_DATE_FORMAT, DateDetector.detectDateFormat(sampleDateString, LOCALE_ES));
assertNull(DateDetector.detectDateFormat(null));
}
@Test
- public void testIsValidDate() {
+ void testIsValidDate() {
assertTrue(DateDetector.isValidDate(sampleDateStringUs));
assertFalse(DateDetector.isValidDate(null));
assertTrue(DateDetector.isValidDate(sampleDateString, SAMPLE_DATE_FORMAT));
@@ -151,7 +156,7 @@ public class DateDetectorTest {
}
@Test
- public void testIsValidDateFormatToStringDate() {
+ void testIsValidDateFormatToStringDate() {
assertTrue(
DateDetector.isValidDateFormatToStringDate(SAMPLE_DATE_FORMAT_US, sampleDateStringUs));
assertFalse(DateDetector.isValidDateFormatToStringDate(null, sampleDateStringUs));
@@ -159,7 +164,7 @@ public class DateDetectorTest {
}
@Test
- public void testIsValidDateFormatToStringDateLocale() {
+ void testIsValidDateFormatToStringDateLocale() {
assertTrue(
DateDetector.isValidDateFormatToStringDate(
SAMPLE_DATE_FORMAT_US, sampleDateStringUs, LOCALE_EN_US));
@@ -172,20 +177,21 @@ public class DateDetectorTest {
}
@Test
- public void testAllPatterns() {
+ void testAllPatterns() {
testPatternsFrom(DateDetector.DATE_FORMAT_TO_REGEXPS_US, LOCALE_EN_US);
testPatternsFrom(DateDetector.DATE_FORMAT_TO_REGEXPS, LOCALE_ES);
}
+ @SuppressWarnings("all")
private void testPatternsFrom(BidiMap formatToRegExps, String locale) {
Iterator iterator = formatToRegExps.keySet().iterator();
while (iterator.hasNext()) {
String pattern = (String) iterator.next();
String dateString = buildTestDate(pattern);
assertEquals(
- "Did not detect a matching date pattern using the date \"" + dateString + "\"",
pattern,
- DateDetector.detectDateFormatBiased(dateString, locale, pattern));
+ DateDetector.detectDateFormatBiased(dateString, locale, pattern),
+ "Did not detect a matching date pattern using the date \"" + dateString + "\"");
}
}
diff --git a/core/src/test/java/org/apache/hop/core/util/JsonUtilTest.java b/core/src/test/java/org/apache/hop/core/util/JsonUtilTest.java
index 19cd4f2ec4..a607c49568 100644
--- a/core/src/test/java/org/apache/hop/core/util/JsonUtilTest.java
+++ b/core/src/test/java/org/apache/hop/core/util/JsonUtilTest.java
@@ -17,12 +17,12 @@
package org.apache.hop.core.util;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertSame;
-import static org.junit.Assert.assertThrows;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertNull;
+import static org.junit.jupiter.api.Assertions.assertSame;
+import static org.junit.jupiter.api.Assertions.assertThrows;
+import static org.junit.jupiter.api.Assertions.assertTrue;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.JsonNode;
@@ -32,16 +32,17 @@ import java.io.InputStream;
import java.nio.charset.StandardCharsets;
import java.util.List;
import java.util.Map;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
-public class JsonUtilTest {
-
- // -------------------------
- // Singletons
- // -------------------------
+/**
+ * Unit test for {@link JsonUtil}
+ *
+ * @author lance 2026/3/6 17:01
+ */
+class JsonUtilTest {
@Test
- public void testSingletons() {
+ void testSingletons() {
assertNotNull(JsonUtil.jsonReader());
assertNotNull(JsonUtil.jsonMapper());
// same instance each call
@@ -49,45 +50,41 @@ public class JsonUtilTest {
assertSame(JsonUtil.jsonMapper(), JsonUtil.jsonMapper());
}
- // -------------------------
- // Parse
- // -------------------------
-
@Test
- public void testParseCharSequence() throws Exception {
+ void testParseCharSequence() throws Exception {
JsonNode n = JsonUtil.parse("{a:1, b:\"x\"}");
assertEquals(1, n.get("a").intValue());
assertEquals("x", n.get("b").textValue());
}
@Test
- public void testParseBytes() throws Exception {
+ void testParseBytes() throws Exception {
byte[] bytes = "{\"k\":true}".getBytes(StandardCharsets.UTF_8);
JsonNode n = JsonUtil.parse(bytes);
assertTrue(n.get("k").booleanValue());
}
@Test
- public void testParseStream() throws Exception {
+ void testParseStream() throws Exception {
InputStream in = new ByteArrayInputStream("{\"n\":42}".getBytes(StandardCharsets.UTF_8));
JsonNode n = JsonUtil.parse(in);
assertEquals(42, n.get("n").intValue());
}
@Test
- public void testParseNulls() throws Exception {
+ void testParseNulls() throws Exception {
assertNull(JsonUtil.parse((CharSequence) null));
assertNull(JsonUtil.parse((byte[]) null));
assertNull(JsonUtil.parse((InputStream) null));
}
@Test
- public void testParseInvalid() {
+ void testParseInvalid() {
assertThrows(JsonProcessingException.class, () -> JsonUtil.parse("{oops"));
}
@Test
- public void testParseTextValue() throws Exception {
+ void testParseTextValue() throws Exception {
var bytes = "{\"a\":1}".getBytes(StandardCharsets.UTF_8);
assertEquals(1, JsonUtil.parseTextValue(bytes).get("a").intValue());
@@ -114,7 +111,7 @@ public class JsonUtilTest {
// -------------------------
@Test
- public void testMapObjectToJson() {
+ void testMapObjectToJson() {
assertNull(JsonUtil.mapObjectToJson(null));
ObjectNode node = JsonUtil.jsonMapper().createObjectNode().put("x", 1);
@@ -130,7 +127,7 @@ public class JsonUtilTest {
}
@Test
- public void testMapJsonToString() throws Exception {
+ void testMapJsonToString() throws Exception {
ObjectNode o = JsonUtil.jsonMapper().createObjectNode().put("a", 1).put("b", "x");
String compact = JsonUtil.mapJsonToString(o, false);
@@ -144,7 +141,7 @@ public class JsonUtilTest {
}
@Test
- public void testMapJsonToBytes() throws Exception {
+ void testMapJsonToBytes() throws Exception {
ObjectNode o = JsonUtil.jsonMapper().createObjectNode().put("a", "u");
byte[] bytes = JsonUtil.mapJsonToBytes(o);
assertNotNull(bytes);
diff --git a/core/src/test/java/org/apache/hop/core/util/StringEvaluatorTest.java b/core/src/test/java/org/apache/hop/core/util/StringEvaluatorTest.java
index a4cdce8061..389f49a5f6 100644
--- a/core/src/test/java/org/apache/hop/core/util/StringEvaluatorTest.java
+++ b/core/src/test/java/org/apache/hop/core/util/StringEvaluatorTest.java
@@ -17,10 +17,10 @@
package org.apache.hop.core.util;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNotEquals;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertNotEquals;
+import static org.junit.jupiter.api.Assertions.assertTrue;
import java.util.ArrayList;
import java.util.Arrays;
@@ -30,40 +30,41 @@ import java.util.List;
import java.util.Locale;
import org.apache.hop.core.HopClientEnvironment;
import org.apache.hop.core.exception.HopException;
-import org.junit.AfterClass;
-import org.junit.Before;
-import org.junit.BeforeClass;
-import org.junit.Ignore;
-import org.junit.Test;
+import org.junit.jupiter.api.AfterAll;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Disabled;
+import org.junit.jupiter.api.Test;
/** Test class for StringEvaluator functionality. */
-public class StringEvaluatorTest {
+class StringEvaluatorTest {
private StringEvaluator evaluator;
private static Locale defaultLocale;
- @BeforeClass
- public static void setUpClass() {
+ @BeforeAll
+ static void setUpClass() {
defaultLocale = Locale.getDefault();
}
- @Before
- public void setUp() throws HopException {
+ @BeforeEach
+ void setUp() throws HopException {
HopClientEnvironment.init();
evaluator = new StringEvaluator();
Locale.setDefault(Locale.US);
}
- @AfterClass
- public static void tearDown() {
+ @AfterAll
+ static void tearDown() {
Locale.setDefault(defaultLocale);
}
- /////////////////////////////////////
+ // ///////////////////////////////////
// common
- ////////////////////////////////////
+ // /////////////////////////////////
+
@Test
- public void testEmpty() {
+ void testEmpty() {
evaluator.evaluateString("");
assertTrue(evaluator.getStringEvaluationResults().isEmpty());
@@ -72,7 +73,7 @@ public class StringEvaluatorTest {
}
@Test
- public void testGetValues_WithoutDublicate() {
+ void testGetValues_WithoutDuplicate() {
List<String> strings = Arrays.asList("name1", "name2");
for (String string : strings) {
evaluator.evaluateString(string);
@@ -83,30 +84,28 @@ public class StringEvaluatorTest {
Collections.sort(actualStrings);
Iterator<String> exIterator = strings.iterator();
- Iterator<String> iterator = actualStrings.iterator();
- while (iterator.hasNext()) {
- assertEquals(exIterator.next(), iterator.next());
+ for (String actualString : actualStrings) {
+ assertEquals(exIterator.next(), actualString);
}
}
@Test
- public void testGetValues_Duplicate() {
+ void testGetValues_Duplicate() {
String dublicatedString = "name1";
- List<String> strings = Arrays.asList(dublicatedString);
+ List<String> strings = List.of(dublicatedString);
for (String string : strings) {
evaluator.evaluateString(string);
}
evaluator.evaluateString(dublicatedString);
assertEquals(strings.size(), evaluator.getValues().size());
Iterator<String> exIterator = strings.iterator();
- Iterator<String> iterator = evaluator.getValues().iterator();
- while (iterator.hasNext()) {
- assertEquals(exIterator.next(), iterator.next());
+ for (String s : evaluator.getValues()) {
+ assertEquals(exIterator.next(), s);
}
}
@Test
- public void testGetCount() {
+ void testGetCount() {
List<String> strings = Arrays.asList("02/29/2000", "03/29/2000");
for (String string : strings) {
evaluator.evaluateString(string);
@@ -115,9 +114,9 @@ public class StringEvaluatorTest {
}
@Test
- public void testGetAdvicedResult_NullInput() {
+ void testGetAdvicedResult_NullInput() {
String expectedNull = "";
- List<String> strings = Arrays.asList(expectedNull);
+ List<String> strings = List.of(expectedNull);
for (String string : strings) {
evaluator.evaluateString(string);
}
@@ -126,7 +125,7 @@ public class StringEvaluatorTest {
}
@Test
- public void testGetAdvicedResult_MinMaxInput() {
+ void testGetAdvicedResult_MinMaxInput() {
String expectedMin = "500";
String expectedMax = "1000";
List<String> strings = Arrays.asList(expectedMax, expectedMin);
@@ -139,11 +138,12 @@ public class StringEvaluatorTest {
assertEquals(expectedMax.length(), evaluator.getMaxLength());
}
- /////////////////////////////////////
+ // ///////////////////////////////////
// mixed types
- ////////////////////////////////////
+ // //////////////////////////////////
+
@Test
- public void testIntegerWithNumber() {
+ void testIntegerWithNumber() {
List<String> strings = Arrays.asList("1", "1.1");
String mask = "#.#";
for (String string : strings) {
@@ -154,28 +154,29 @@ public class StringEvaluatorTest {
assertEquals(mask, evaluator.getAdvicedResult().getConversionMeta().getConversionMask());
}
- /////////////////////////////////////
+ // ///////////////////////////////////
// number types
- ////////////////////////////////////
+ // / /////////////////////////////////
+
@Test
- public void testNumberWithPoint() {
+ void testNumberWithPoint() {
testNumber("#.#", "1.1");
}
@Test
- @Ignore("This test needs to be reviewed")
- public void testNumberWithGroupAndPoint() {
+ @Disabled("This test needs to be reviewed")
+ void testNumberWithGroupAndPoint() {
testNumber("#,###,###.#", "1,111,111.1");
}
@Test
- @Ignore("This test needs to be reviewed")
- public void testNumbers() {
+ @Disabled("This test needs to be reviewed")
+ void testNumbers() {
testNumber("#,###,###.#", "1,111,111.1", "1,111");
}
@Test
- public void testStringAsNumber() {
+ void testStringAsNumber() {
evaluator.evaluateString("1");
evaluator.evaluateString("1.111111111");
evaluator.evaluateString("1,111");
@@ -196,16 +197,17 @@ public class StringEvaluatorTest {
assertEquals(mask, evaluator.getAdvicedResult().getConversionMeta().getConversionMask());
}
- /////////////////////////////////////
+ // ///////////////////////////////////
// integer types
- ////////////////////////////////////
+ // //////////////////////////////////
+
@Test
- public void testInteger() {
+ void testInteger() {
testInteger("#", "1");
}
@Test
- public void testIntegerWithGroup() {
+ void testIntegerWithGroup() {
testInteger("#", "1111");
}
@@ -218,11 +220,12 @@ public class StringEvaluatorTest {
assertEquals(mask, evaluator.getAdvicedResult().getConversionMeta().getConversionMask());
}
- /////////////////////////////////////
+ // ///////////////////////////////////
// currency types
- ////////////////////////////////////
+
+ // / /////////////////////////////////
@Test
- public void testCurrency() {
+ void testCurrency() {
testCurrencyBasic("+123", "-123", "(123)");
}
@@ -234,26 +237,27 @@ public class StringEvaluatorTest {
assertTrue(evaluator.getAdvicedResult().getConversionMeta().isString());
}
- /////////////////////////////////////
+ // ///////////////////////////////////
// boolean types
- ////////////////////////////////////
+
+ // / /////////////////////////////////
@Test
- public void testBooleanY() {
+ void testBooleanY() {
testBoolean("Y");
}
@Test
- public void testBooleanN() {
+ void testBooleanN() {
testBoolean("N");
}
@Test
- public void testBooleanTrue() {
+ void testBooleanTrue() {
testBoolean("True");
}
@Test
- public void testBooleanFalse() {
+ void testBooleanFalse() {
testBoolean("False");
}
@@ -265,26 +269,27 @@ public class StringEvaluatorTest {
assertTrue(evaluator.getAdvicedResult().getConversionMeta().isBoolean());
}
- /////////////////////////////////////
+ // ///////////////////////////////////
// Date types, use default USA format
- ////////////////////////////////////
+
+ // / /////////////////////////////////
@Test
- public void testDate() {
+ void testDate() {
testDefaultDateFormat("MM/dd/yyyy", "10/10/2000");
}
@Test
- public void testDateArray() {
+ void testDateArray() {
testDefaultDateFormat("MM/dd/yyyy", "10/10/2000", "11/10/2000", "12/10/2000");
}
@Test
- public void testTimeStamp() {
+ void testTimeStamp() {
testDefaultDateFormat("MM/dd/yyyy HH:mm:ss", "10/10/2000 00:00:00");
}
@Test
- public void testTimeStampSeconds() {
+ void testTimeStampSeconds() {
testDefaultDateFormat("MM/dd/yyyy HH:mm:ss", "10/10/2000 00:00:00");
}
@@ -299,38 +304,38 @@ public class StringEvaluatorTest {
}
@Test
- public void testDate2YearDigits() {
+ void testDate2YearDigits() {
testDefaultDateFormat("MM/dd/yy", "10/10/20", "11/10/20", "12/10/20");
}
@Test
- public void testCustomDateFormat() {
+ void testCustomDateFormat() {
String sampleFormat = "MM/dd/yyyy HH:mm:ss";
ArrayList<String> dateFormats = new ArrayList<>();
dateFormats.add(sampleFormat);
- StringEvaluator evaluator = new StringEvaluator(true, new ArrayList<>(), dateFormats);
- evaluator.evaluateString("02/29/2000 00:00:00");
- assertFalse(evaluator.getStringEvaluationResults().isEmpty());
- assertTrue(evaluator.getAdvicedResult().getConversionMeta().isDate());
+ StringEvaluator strEvaluator = new StringEvaluator(true, new ArrayList<>(), dateFormats);
+ strEvaluator.evaluateString("02/29/2000 00:00:00");
+ assertFalse(strEvaluator.getStringEvaluationResults().isEmpty());
+ assertTrue(strEvaluator.getAdvicedResult().getConversionMeta().isDate());
assertEquals(
- sampleFormat, evaluator.getAdvicedResult().getConversionMeta().getConversionMask());
+ sampleFormat, strEvaluator.getAdvicedResult().getConversionMeta().getConversionMask());
}
@Test
- public void testAdviceedOneDateFormat() {
+ void testAdviceOneDateFormat() {
String sampleLongFormat = "MM/dd/yyyy HH:mm:ss";
String sampleShortFormat = "MM/dd/yy HH:mm:ss";
ArrayList<String> dateFormats = new ArrayList<>();
dateFormats.add(sampleLongFormat);
dateFormats.add(sampleShortFormat);
- StringEvaluator evaluator = new StringEvaluator(true, new ArrayList<>(), dateFormats);
- evaluator.evaluateString("02/29/20 00:00:00");
- assertFalse(evaluator.getStringEvaluationResults().isEmpty());
- assertTrue(evaluator.getAdvicedResult().getConversionMeta().isDate());
+ StringEvaluator strEvaluator = new StringEvaluator(true, new ArrayList<>(), dateFormats);
+ strEvaluator.evaluateString("02/29/20 00:00:00");
+ assertFalse(strEvaluator.getStringEvaluationResults().isEmpty());
+ assertTrue(strEvaluator.getAdvicedResult().getConversionMeta().isDate());
assertNotEquals(
- sampleLongFormat, evaluator.getAdvicedResult().getConversionMeta().getConversionMask());
- // should advice short format
+ sampleLongFormat, strEvaluator.getAdvicedResult().getConversionMeta().getConversionMask());
+ // should advise short format
assertEquals(
- sampleShortFormat, evaluator.getAdvicedResult().getConversionMeta().getConversionMask());
+ sampleShortFormat, strEvaluator.getAdvicedResult().getConversionMeta().getConversionMask());
}
}
diff --git a/core/src/test/java/org/apache/hop/core/util/StringUtilTest.java b/core/src/test/java/org/apache/hop/core/util/StringUtilTest.java
index fd92486005..7a9a77b082 100644
--- a/core/src/test/java/org/apache/hop/core/util/StringUtilTest.java
+++ b/core/src/test/java/org/apache/hop/core/util/StringUtilTest.java
@@ -17,15 +17,21 @@
package org.apache.hop.core.util;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+import static org.junit.jupiter.api.Assertions.fail;
+
import java.util.HashMap;
import java.util.Map;
-import junit.framework.TestCase;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
/** Test class for the basic functionality of StringUtil. */
-public class StringUtilTest extends TestCase {
+class StringUtilTest {
/** Test initCap */
- public void testinitCap() {
+ @Test
+ void testingCap() {
assertEquals("", StringUtil.initCap(null));
assertEquals("", StringUtil.initCap(""));
assertEquals("", StringUtil.initCap(" "));
@@ -43,7 +49,7 @@ public class StringUtilTest extends TestCase {
/**
* Create an example map to be used for variable resolution.
*
- * @return Map of variablenames/values.
+ * @return Map of variable names/values.
*/
Map<String, String> createVariables1(String open, String close) {
Map<String, String> map = new HashMap<>();
@@ -73,7 +79,8 @@ public class StringUtilTest extends TestCase {
}
/** Test the basic substitute call. */
- public void testSubstituteBasic() {
+ @Test
+ void testSubstituteBasic() {
Map<String, String> map = createVariables1("${", "}");
assertEquals("|${BAD_KEY}|", StringUtil.substitute("|${BAD_KEY}|", map, "${", "}"));
assertEquals("|${NULL}|", StringUtil.substitute("|${NULL}|", map, "${", "}"));
@@ -89,6 +96,7 @@ public class StringUtilTest extends TestCase {
StringUtil.substitute("|${recursive_all}|", map, "${", "}", 0);
fail("recursive check is failing");
} catch (RuntimeException rex) {
+ // ignore
}
map = createVariables1("%%", "%%");
@@ -104,13 +112,13 @@ public class StringUtilTest extends TestCase {
StringUtil.substitute("|%%recursive_all%%|", map, "%%", "%%");
fail("recursive check is failing");
} catch (RuntimeException rex) {
+ // ignore
}
map = createVariables1("${", "}");
assertEquals("||", StringUtil.environmentSubstitute("|%%EMPTY%%|", map));
assertEquals("|case1|", StringUtil.environmentSubstitute("|%%checkcase%%|", map));
assertEquals("|case2|", StringUtil.environmentSubstitute("|%%CheckCase%%|", map));
- assertEquals("|case3|", StringUtil.environmentSubstitute("|%%CHECKCASE%%|", map));
assertEquals("|Arecurse|", StringUtil.environmentSubstitute("|%%recursive1%%|", map));
assertEquals("|recurseB|", StringUtil.environmentSubstitute("|%%recursive3%%|", map));
assertEquals("|ZfinalB|", StringUtil.environmentSubstitute("|%%recursive5%%|", map));
@@ -119,11 +127,13 @@ public class StringUtilTest extends TestCase {
StringUtil.environmentSubstitute("|%%recursive_all%%|", map);
fail("recursive check is failing");
} catch (RuntimeException rex) {
+ // ignore
}
}
/** Test isEmpty() call. */
- public void testIsEmpty() {
+ @Test
+ void testIsEmpty() {
assertTrue(StringUtil.isEmpty((String) null));
assertTrue(StringUtil.isEmpty(""));
@@ -132,14 +142,16 @@ public class StringUtilTest extends TestCase {
}
/** Test getIndent() call. */
- public void testGetIndent() {
+ @Test
+ void testGetIndent() {
assertEquals("", StringUtil.getIndent(0));
assertEquals(" ", StringUtil.getIndent(1));
assertEquals(" ", StringUtil.getIndent(2));
assertEquals(" ", StringUtil.getIndent(3));
}
- public void testIsVariable() {
+ @Test
+ void testIsVariable() {
assertTrue(StringUtil.isVariable("${somename}"));
assertTrue(StringUtil.isVariable("%%somename%%"));
assertTrue(StringUtil.isVariable("$[somename]"));
@@ -147,7 +159,8 @@ public class StringUtilTest extends TestCase {
assertFalse(StringUtil.isVariable(null));
}
- public void testSafeToLowerCase() {
+ @Test
+ void testSafeToLowerCase() {
assertNull(StringUtil.safeToLowerCase(null));
assertEquals("", StringUtil.safeToLowerCase(""));
assertEquals(" ", StringUtil.safeToLowerCase(" "));
@@ -160,7 +173,7 @@ public class StringUtilTest extends TestCase {
assertEquals("abc123", StringUtil.safeToLowerCase((new ToString("ABC123")).toString()));
}
- class ToString {
+ static class ToString {
private String string;
ToString() {}
@@ -176,32 +189,32 @@ public class StringUtilTest extends TestCase {
}
@Test
- public void testTrimStart_Single() {
+ void testTrimStart_Single() {
assertEquals("file/path/", StringUtil.trimStart("/file/path/", '/'));
}
@Test
- public void testTrimStart_Many() {
+ void testTrimStart_Many() {
assertEquals("file/path/", StringUtil.trimStart("////file/path/", '/'));
}
@Test
- public void testTrimStart_None() {
+ void testTrimStart_None() {
assertEquals("file/path/", StringUtil.trimStart("file/path/", '/'));
}
@Test
- public void testTrimEnd_Single() {
+ void testTrimEnd_Single() {
assertEquals("/file/path", StringUtil.trimEnd("/file/path/", '/'));
}
@Test
- public void testTrimEnd_Many() {
+ void testTrimEnd_Many() {
assertEquals("/file/path", StringUtil.trimEnd("/file/path///", '/'));
}
@Test
- public void testTrimEnd_None() {
+ void testTrimEnd_None() {
assertEquals("/file/path", StringUtil.trimEnd("/file/path", '/'));
}
}
diff --git a/core/src/test/java/org/apache/hop/core/util/UtilsTest.java b/core/src/test/java/org/apache/hop/core/util/UtilsTest.java
index 39877646a9..27965f927f 100644
--- a/core/src/test/java/org/apache/hop/core/util/UtilsTest.java
+++ b/core/src/test/java/org/apache/hop/core/util/UtilsTest.java
@@ -16,11 +16,11 @@
*/
package org.apache.hop.core.util;
-import static org.junit.Assert.assertArrayEquals;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertSame;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertArrayEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertSame;
+import static org.junit.jupiter.api.Assertions.assertTrue;
import java.util.ArrayList;
import java.util.Arrays;
@@ -28,63 +28,64 @@ import java.util.List;
import org.apache.hop.core.HopClientEnvironment;
import org.apache.hop.core.exception.HopException;
import org.apache.hop.core.variables.Variables;
-import org.apache.hop.junit.rules.RestoreHopEnvironment;
-import org.junit.BeforeClass;
-import org.junit.ClassRule;
-import org.junit.Test;
+import org.apache.hop.junit.rules.RestoreHopEnvironmentExtension;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.ExtendWith;
-public class UtilsTest {
- @ClassRule public static RestoreHopEnvironment env = new RestoreHopEnvironment();
+/** Unit test for {@link Utils} */
+@ExtendWith(RestoreHopEnvironmentExtension.class)
+class UtilsTest {
- @BeforeClass
- public static void setUpBeforeClass() throws HopException {
+ @BeforeAll
+ static void setUpBeforeClass() throws HopException {
HopClientEnvironment.init();
}
@Test
- public void testIsEmpty() {
+ void testIsEmpty() {
assertTrue(Utils.isEmpty((String) null));
assertTrue(Utils.isEmpty(""));
assertFalse(Utils.isEmpty("test"));
}
@Test
- public void testIsEmptyStringArray() {
+ void testIsEmptyStringArray() {
assertTrue(Utils.isEmpty((String[]) null));
assertTrue(Utils.isEmpty(new String[] {}));
assertFalse(Utils.isEmpty(new String[] {"test"}));
}
@Test
- public void testIsEmptyObjectArray() {
+ void testIsEmptyObjectArray() {
assertTrue(Utils.isEmpty((Object[]) null));
assertTrue(Utils.isEmpty(new Object[] {}));
assertFalse(Utils.isEmpty(new Object[] {"test"}));
}
@Test
- public void testIsEmptyList() {
+ void testIsEmptyList() {
assertTrue(Utils.isEmpty((List<String>) null));
assertTrue(Utils.isEmpty(new ArrayList<>()));
assertFalse(Utils.isEmpty(Arrays.asList("test", 1)));
}
@Test
- public void testIsEmptyStringBuffer() {
+ void testIsEmptyStringBuffer() {
assertTrue(Utils.isEmpty((StringBuffer) null));
- assertTrue(Utils.isEmpty(new StringBuffer("")));
+ assertTrue(Utils.isEmpty(new StringBuffer()));
assertFalse(Utils.isEmpty(new StringBuffer("test")));
}
@Test
- public void testIsEmptyStringBuilder() {
+ void testIsEmptyStringBuilder() {
assertTrue(Utils.isEmpty((StringBuilder) null));
- assertTrue(Utils.isEmpty(new StringBuilder("")));
+ assertTrue(Utils.isEmpty(new StringBuilder()));
assertFalse(Utils.isEmpty(new StringBuilder("test")));
}
@Test
- public void testResolvePassword() {
+ void testResolvePassword() {
String password = "password";
// is supposed the password stays the same
assertSame(
@@ -92,7 +93,7 @@ public class UtilsTest {
}
@Test
- public void testResolvePasswordEncrypted() {
+ void testResolvePasswordEncrypted() {
String decPassword = "password";
// is supposed encrypted with Encr.bat util
String encPassword = "Encrypted 2be98afc86aa7f2e4bb18bd63c99dbdde";
@@ -102,14 +103,14 @@ public class UtilsTest {
}
@Test
- public void testResolvePasswordNull() {
+ void testResolvePasswordNull() {
String password = null;
// null is valid input parameter
assertSame(password, Utils.resolvePassword(Variables.getADefaultVariableSpace(), password));
}
@Test
- public void testResolvePasswordVariable() {
+ void testResolvePasswordVariable() {
String passwordKey = "PASS_VAR";
String passwordVar = "${" + passwordKey + "}";
String passwordValue = "password";
@@ -120,22 +121,11 @@ public class UtilsTest {
}
@Test
- public void testNormalizeArraysMethods() {
+ void testNormalizeArraysMethods() {
String[] s1 = new String[] {"one"};
String[] s2 = new String[] {"one", "two"};
- String[] s3 = new String[] {"one", "two", "three"};
long[] l1 = new long[] {1};
long[] l2 = new long[] {1, 2};
- long[] l3 = new long[] {1, 2, 3};
- short[] sh1 = new short[] {1};
- short[] sh2 = new short[] {1, 2};
- short[] sh3 = new short[] {1, 2, 3};
- boolean[] b1 = new boolean[] {true};
- boolean[] b2 = new boolean[] {true, false};
- boolean[] b3 = new boolean[] {true, false, true};
- int[] i1 = new int[] {1};
- int[] i2 = new int[] {1, 2};
- int[] i3 = new int[] {1, 3};
String[][] newS = Utils.normalizeArrays(3, s1, s2);
assertEquals(2, newS.length);
@@ -165,6 +155,18 @@ public class UtilsTest {
assertArrayEquals(newL[0], l2);
assertSame(newL[0], l2); // If arrays are equal sized, it should return original object
+ testNormalizeArraysMethods_1();
+ }
+
+ private void testNormalizeArraysMethods_1() {
+ short[] sh1 = new short[] {1};
+ short[] sh2 = new short[] {1, 2};
+
+ boolean[] b1 = new boolean[] {true};
+ boolean[] b2 = new boolean[] {true, false};
+ int[] i1 = new int[] {1};
+ int[] i2 = new int[] {1, 2};
+
short[][] newSh = Utils.normalizeArrays(3, sh1, sh2);
assertEquals(2, newSh.length);
assertEquals(3, newSh[0].length);
@@ -208,7 +210,7 @@ public class UtilsTest {
}
@Test
- public void testDamerauLevenshteinDistance() {
+ void testDamerauLevenshteinDistance() {
int distance = Utils.getDamerauLevenshteinDistance("Hello", "Hallow");
assertEquals(2, distance);
distance = Utils.getDamerauLevenshteinDistance("Green", "Grean");
diff --git a/core/src/test/java/org/apache/hop/core/variables/VariableRegistryTest.java b/core/src/test/java/org/apache/hop/core/variables/VariableRegistryTest.java
index 5807054d34..32d3552c9b 100644
--- a/core/src/test/java/org/apache/hop/core/variables/VariableRegistryTest.java
+++ b/core/src/test/java/org/apache/hop/core/variables/VariableRegistryTest.java
@@ -17,21 +17,21 @@
package org.apache.hop.core.variables;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
import org.apache.hop.core.Const;
-import org.apache.hop.junit.rules.RestoreHopEnvironment;
-import org.junit.ClassRule;
-import org.junit.Test;
+import org.apache.hop.junit.rules.RestoreHopEnvironmentExtension;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.ExtendWith;
-public class VariableRegistryTest {
-
- @ClassRule public static RestoreHopEnvironment env = new RestoreHopEnvironment();
+/** Unit test for {@link VariableRegistry} */
+@ExtendWith(RestoreHopEnvironmentExtension.class)
+class VariableRegistryTest {
@Test
- public void testInit() throws Exception {
-
+ void testInit() throws Exception {
VariableRegistry.init();
VariableRegistry registry = VariableRegistry.getInstance();
@@ -40,7 +40,7 @@ public class VariableRegistryTest {
assertNotNull(describedVariable);
boolean actual = Boolean.parseBoolean(describedVariable.getValue());
- assertEquals(false, actual);
+ assertFalse(actual);
assertEquals(
"Specifies the password encoder plugin to use by ID (Hop is the default).",
diff --git a/core/src/test/java/org/apache/hop/core/variables/VariablesTest.java b/core/src/test/java/org/apache/hop/core/variables/VariablesTest.java
index ac789ce6e9..b6e82312c5 100644
--- a/core/src/test/java/org/apache/hop/core/variables/VariablesTest.java
+++ b/core/src/test/java/org/apache/hop/core/variables/VariablesTest.java
@@ -17,15 +17,16 @@
package org.apache.hop.core.variables;
-import static org.junit.Assert.assertArrayEquals;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertArrayEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.anyString;
import static org.mockito.Mockito.doAnswer;
import static org.mockito.Mockito.doCallRealMethod;
import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
import java.util.ArrayList;
@@ -37,7 +38,7 @@ import java.util.concurrent.Future;
import org.apache.hop.core.exception.HopValueException;
import org.apache.hop.core.row.RowMeta;
import org.apache.hop.core.row.value.ValueMetaString;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import org.mockito.invocation.InvocationOnMock;
import org.mockito.stubbing.Answer;
@@ -46,16 +47,15 @@ import org.mockito.stubbing.Answer;
*
* @see Variables
*/
-public class VariablesTest {
-
- private Variables variables = new Variables();
+class VariablesTest {
+ private final Variables variables = new Variables();
/**
* Checks if an ConcurrentModificationException while iterating over the System properties is
* occurred.
*/
@Test
- public void testinItializeVariablesFrom() {
+ void initializeVariablesFrom() {
final Variables variablesMock = mock(Variables.class);
doCallRealMethod().when(variablesMock).initializeFrom(any(IVariables.class));
@@ -69,7 +69,7 @@ public class VariablesTest {
@Override
public Map<String, String> answer(InvocationOnMock invocation) throws Throwable {
if (System.getProperty(keyStub) == null) {
- modifySystemproperties();
+ modifySystemProperties();
}
if (invocation.getArguments()[1] != null) {
@@ -84,9 +84,10 @@ public class VariablesTest {
.put(anyString(), anyString());
variablesMock.initializeFrom(null);
+ verify(variablesMock).initializeFrom(null);
}
- private void modifySystemproperties() {
+ private void modifySystemProperties() {
final String keyStub = "key";
final String valueStub = "value";
@@ -94,13 +95,9 @@ public class VariablesTest {
thread.start();
}
- /**
- * Spawns 20 threads that modify variables to test concurrent modification error fix.
- *
- * @throws Exception
- */
+ /** Spawns 20 threads that modify variables to test concurrent modification error fix. */
@Test
- public void testConcurrentModification() throws Exception {
+ void testConcurrentModification() throws Exception {
int threads = 20;
List<Callable<Boolean>> callables = new ArrayList<>();
@@ -127,7 +124,7 @@ public class VariablesTest {
}
@Test
- public void testFieldSubstitution() throws HopValueException {
+ void testFieldSubstitution() throws HopValueException {
Object[] rowData = new Object[] {"DataOne", "DataTwo"};
RowMeta rm = new RowMeta();
rm.addValueMeta(new ValueMetaString("FieldOne"));
@@ -141,7 +138,7 @@ public class VariablesTest {
}
@Test
- public void testEnvironmentSubstitute() {
+ void testEnvironmentSubstitute() {
Variables vars = new Variables();
vars.setVariable("VarOne", "DataOne");
vars.setVariable("VarTwo", "DataTwo");
diff --git a/core/src/test/java/org/apache/hop/core/vfs/HopVfsTest.java b/core/src/test/java/org/apache/hop/core/vfs/HopVfsTest.java
index d30c8b132c..ae1e4ee413 100644
--- a/core/src/test/java/org/apache/hop/core/vfs/HopVfsTest.java
+++ b/core/src/test/java/org/apache/hop/core/vfs/HopVfsTest.java
@@ -17,22 +17,24 @@
package org.apache.hop.core.vfs;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
import java.io.OutputStream;
import org.apache.commons.vfs2.FileObject;
import org.apache.hop.core.variables.Variables;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
-public class HopVfsTest {
+/** Unit test for {@link HopVfs} */
+class HopVfsTest {
/**
* Test to validate that startsWitScheme() returns true if the fileName starts with known protocol
* like zip: jar: then it returns true else returns false
*/
@Test
- public void testStartsWithScheme() {
+ void testStartsWithScheme() {
String fileName =
"zip:file:///SavedLinkedres.zip!Calculate median and percentiles using the group by transforms.hpl";
assertTrue(HopVfs.startsWithScheme(fileName, new Variables()));
@@ -43,7 +45,7 @@ public class HopVfsTest {
}
@Test
- public void testCheckForSchemeSuccess() {
+ void testCheckForSchemeSuccess() {
String[] schemes = {"hdfs"};
String vfsFilename = "hdfs://company.com:8020/tmp/acltest/";
@@ -52,7 +54,7 @@ public class HopVfsTest {
}
@Test
- public void testCheckForSchemeFail() {
+ void testCheckForSchemeFail() {
String[] schemes = {"file"};
String vfsFilename = "hdfs://company.com:8020/tmp/acltest/";
@@ -61,9 +63,11 @@ public class HopVfsTest {
}
@Test
- public void testRamFilesCache() throws Exception {
+ void testRamFilesCache() throws Exception {
String filename = "ram:///test-file.txt";
FileObject fileObject = HopVfs.getFileObject(filename);
+
+ assertNotNull(fileObject);
try (OutputStream outputStream = fileObject.getContent().getOutputStream()) {
outputStream.write("Test-content".getBytes());
}
diff --git a/core/src/test/java/org/apache/hop/core/xml/XmlFormatterTest.java b/core/src/test/java/org/apache/hop/core/xml/XmlFormatterTest.java
index 05caf9644e..2692240ba5 100644
--- a/core/src/test/java/org/apache/hop/core/xml/XmlFormatterTest.java
+++ b/core/src/test/java/org/apache/hop/core/xml/XmlFormatterTest.java
@@ -17,28 +17,33 @@
package org.apache.hop.core.xml;
import static org.custommonkey.xmlunit.XMLAssert.assertXMLEqual;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
import java.io.InputStream;
+import java.nio.charset.StandardCharsets;
import org.apache.commons.io.IOUtils;
import org.custommonkey.xmlunit.XMLUnit;
-import org.junit.BeforeClass;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.Test;
-public class XmlFormatterTest {
+/** Unit test for {@link XmlFormatter} */
+class XmlFormatterTest {
- @BeforeClass
- public static void setupClass() {
+ @BeforeAll
+ static void setupClass() {
XMLUnit.setIgnoreWhitespace(true);
}
@Test
- public void test1() throws Exception {
+ void test1() throws Exception {
String inXml, expectedXml;
try (InputStream in = XmlFormatterTest.class.getResourceAsStream("XMLFormatterIn1.xml")) {
- inXml = IOUtils.toString(in);
+ assertNotNull(in);
+ inXml = IOUtils.toString(in, StandardCharsets.UTF_8);
}
try (InputStream in = XmlFormatterTest.class.getResourceAsStream("XMLFormatterExpected1.xml")) {
- expectedXml = IOUtils.toString(in);
+ assertNotNull(in);
+ expectedXml = IOUtils.toString(in, StandardCharsets.UTF_8);
}
String result = XmlFormatter.format(inXml);
@@ -46,13 +51,16 @@ public class XmlFormatterTest {
}
@Test
- public void test2() throws Exception {
+ void test2() throws Exception {
String inXml, expectedXml;
- try (InputStream in = XmlFormatterTest.class.getResourceAsStream("XMLFormatterIn2.xml")) {
- inXml = IOUtils.toString(in);
- }
try (InputStream in = XmlFormatterTest.class.getResourceAsStream("XMLFormatterExpected2.xml")) {
- expectedXml = IOUtils.toString(in);
+ assertNotNull(in);
+ expectedXml = IOUtils.toString(in, StandardCharsets.UTF_8);
+ }
+
+ try (InputStream in = XmlFormatterTest.class.getResourceAsStream("XMLFormatterIn2.xml")) {
+ assertNotNull(in);
+ inXml = IOUtils.toString(in, StandardCharsets.UTF_8);
}
String result = XmlFormatter.format(inXml);
@@ -60,14 +68,17 @@ public class XmlFormatterTest {
}
@Test
- public void test3() throws Exception {
+ void test3() throws Exception {
String inXml, expectedXml;
try (InputStream in = XmlFormatterTest.class.getResourceAsStream("XMLFormatterIn3cdata.xml")) {
- inXml = IOUtils.toString(in);
+ assertNotNull(in);
+ inXml = IOUtils.toString(in, StandardCharsets.UTF_8);
}
try (InputStream in =
XmlFormatterTest.class.getResourceAsStream("XMLFormatterExpected3cdata.xml")) {
- expectedXml = IOUtils.toString(in);
+ assertNotNull(in);
+ expectedXml = IOUtils.toString(in, StandardCharsets.UTF_8);
+ assertNotNull(expectedXml);
}
String result = XmlFormatter.format(inXml);
@@ -75,15 +86,17 @@ public class XmlFormatterTest {
}
@Test
- public void test4() throws Exception {
+ void test4() throws Exception {
String inXml, expectedXml;
try (InputStream in =
XmlFormatterTest.class.getResourceAsStream("XMLFormatterIn4multilinecdata.xml")) {
- inXml = IOUtils.toString(in);
+ assertNotNull(in);
+ inXml = IOUtils.toString(in, StandardCharsets.UTF_8);
}
try (InputStream in =
XmlFormatterTest.class.getResourceAsStream("XMLFormatterExpected4multilinecdata.xml")) {
- expectedXml = IOUtils.toString(in);
+ assertNotNull(in);
+ expectedXml = IOUtils.toString(in, StandardCharsets.UTF_8);
}
String result = XmlFormatter.format(inXml);
diff --git a/core/src/test/java/org/apache/hop/core/xml/XmlHandlerUnitTest.java b/core/src/test/java/org/apache/hop/core/xml/XmlHandlerUnitTest.java
index 20400214f3..09005f593f 100644
--- a/core/src/test/java/org/apache/hop/core/xml/XmlHandlerUnitTest.java
+++ b/core/src/test/java/org/apache/hop/core/xml/XmlHandlerUnitTest.java
@@ -17,116 +17,94 @@
package org.apache.hop.core.xml;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNull;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertNull;
import java.io.ByteArrayInputStream;
-import java.io.File;
import java.io.IOException;
-import java.io.PrintWriter;
import java.math.BigDecimal;
import java.util.Calendar;
import java.util.GregorianCalendar;
import javax.xml.parsers.DocumentBuilder;
import org.apache.hop.core.Const;
-import org.apache.hop.junit.rules.RestoreHopEnvironment;
-import org.junit.ClassRule;
-import org.junit.Ignore;
-import org.junit.Test;
+import org.apache.hop.junit.rules.RestoreHopEnvironmentExtension;
+import org.junit.jupiter.api.Disabled;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.ExtendWith;
import org.w3c.dom.Document;
import org.w3c.dom.Node;
-public class XmlHandlerUnitTest {
- @ClassRule public static RestoreHopEnvironment env = new RestoreHopEnvironment();
-
- /**
- * @see <a href="https://en.wikipedia.org/wiki/Billion_laughs" />
- */
- private static final String MALICIOUS_XML =
- "<?xml version=\"1.0\"?>\n"
- + "<!DOCTYPE lolz [\n"
- + " <!ENTITY lol \"lol\">\n"
- + " <!ELEMENT lolz (#PCDATA)>\n"
- + " <!ENTITY lol1 \"&lol;&lol;&lol;&lol;&lol;&lol;&lol;&lol;&lol;&lol;\">\n"
- + " <!ENTITY lol2 \"&lol1;&lol1;&lol1;&lol1;&lol1;&lol1;&lol1;&lol1;&lol1;&lol1;\">\n"
- + " <!ENTITY lol3 \"&lol2;&lol2;&lol2;&lol2;&lol2;&lol2;&lol2;&lol2;&lol2;&lol2;\">\n"
- + " <!ENTITY lol4 \"&lol3;&lol3;&lol3;&lol3;&lol3;&lol3;&lol3;&lol3;&lol3;&lol3;\">\n"
- + " <!ENTITY lol5 \"&lol4;&lol4;&lol4;&lol4;&lol4;&lol4;&lol4;&lol4;&lol4;&lol4;\">\n"
- + " <!ENTITY lol6 \"&lol5;&lol5;&lol5;&lol5;&lol5;&lol5;&lol5;&lol5;&lol5;&lol5;\">\n"
- + " <!ENTITY lol7 \"&lol6;&lol6;&lol6;&lol6;&lol6;&lol6;&lol6;&lol6;&lol6;&lol6;\">\n"
- + " <!ENTITY lol8 \"&lol7;&lol7;&lol7;&lol7;&lol7;&lol7;&lol7;&lol7;&lol7;&lol7;\">\n"
- + " <!ENTITY lol9 \"&lol8;&lol8;&lol8;&lol8;&lol8;&lol8;&lol8;&lol8;&lol8;&lol8;\">\n"
- + "]>\n"
- + "<lolz>&lol9;</lolz>";
-
+/** Unit test for {@link XmlHandler} */
+@ExtendWith(RestoreHopEnvironmentExtension.class)
+class XmlHandlerUnitTest {
private static final String CR = Const.CR;
@Test
- public void openTagWithNotNull() {
+ void openTagWithNotNull() {
assertEquals("<qwerty>", XmlHandler.openTag("qwerty"));
}
@Test
- public void openTagWithNull() {
+ void openTagWithNull() {
assertEquals("<null>", XmlHandler.openTag(null));
}
@Test
- public void openTagWithExternalBuilder() {
+ void openTagWithExternalBuilder() {
StringBuilder builder = new StringBuilder("qwe");
XmlHandler.openTag(builder, "rty");
assertEquals("qwe<rty>", builder.toString());
}
@Test
- public void closeTagWithNotNull() {
+ void closeTagWithNotNull() {
assertEquals("</qwerty>", XmlHandler.closeTag("qwerty"));
}
@Test
- public void closeTagWithNull() {
+ void closeTagWithNull() {
assertEquals("</null>", XmlHandler.closeTag(null));
}
@Test
- public void closeTagWithExternalBuilder() {
+ void closeTagWithExternalBuilder() {
StringBuilder builder = new StringBuilder("qwe");
XmlHandler.closeTag(builder, "rty");
assertEquals("qwe</rty>", builder.toString());
}
@Test
- public void buildCdataWithNotNull() {
+ void buildCdataWithNotNull() {
assertEquals("<![CDATA[qwerty]]>", XmlHandler.buildCDATA("qwerty"));
}
@Test
- public void buildCdataWithNull() {
+ void buildCdataWithNull() {
assertEquals("<![CDATA[]]>", XmlHandler.buildCDATA(null));
}
@Test
- public void buildCdataWithExternalBuilder() {
+ void buildCdataWithExternalBuilder() {
StringBuilder builder = new StringBuilder("qwe");
XmlHandler.buildCDATA(builder, "rty");
assertEquals("qwe<![CDATA[rty]]>", builder.toString());
}
@Test
- public void timestamp2stringTest() {
+ void timestamp2stringTest() {
String actual = XmlHandler.timestamp2string(null);
assertNull(actual);
}
@Test
- public void date2stringTest() {
+ void date2stringTest() {
String actual = XmlHandler.date2string(null);
assertNull(actual);
}
@Test
- public void addTagValueBigDecimal() {
+ void addTagValueBigDecimal() {
BigDecimal input = new BigDecimal("1234567890123456789.01");
assertEquals(
"<bigdec>1234567890123456789.01</bigdec>" + CR, XmlHandler.addTagValue("bigdec", input));
@@ -138,7 +116,7 @@ public class XmlHandlerUnitTest {
}
@Test
- public void addTagValueBoolean() {
+ void addTagValueBoolean() {
assertEquals("<abool>Y</abool>" + CR, XmlHandler.addTagValue("abool", true));
assertEquals("<abool>Y</abool>" + CR, XmlHandler.addTagValue("abool", true, true));
assertEquals("<abool>Y</abool>", XmlHandler.addTagValue("abool", true, false));
@@ -148,10 +126,10 @@ public class XmlHandlerUnitTest {
}
@Test
- public void addTagValueDate() {
+ void addTagValueDate() {
String result = "2014/12/29 15:59:45.789";
Calendar aDate = new GregorianCalendar();
- aDate.set(2014, (12 - 1), 29, 15, 59, 45);
+ aDate.set(2014, (Calendar.DECEMBER), 29, 15, 59, 45);
aDate.set(Calendar.MILLISECOND, 789);
assertEquals(
@@ -164,7 +142,7 @@ public class XmlHandlerUnitTest {
}
@Test
- public void addTagValueLong() {
+ void addTagValueLong() {
long input = 123;
assertEquals("<along>123</along>" + CR, XmlHandler.addTagValue("along", input));
assertEquals("<along>123</along>" + CR, XmlHandler.addTagValue("along", input, true));
@@ -179,7 +157,7 @@ public class XmlHandlerUnitTest {
}
@Test
- public void addTagValueInt() {
+ void addTagValueInt() {
int input = 456;
assertEquals("<anint>456</anint>" + CR, XmlHandler.addTagValue("anint", input));
assertEquals("<anint>456</anint>" + CR, XmlHandler.addTagValue("anint", input, true));
@@ -194,7 +172,7 @@ public class XmlHandlerUnitTest {
}
@Test
- public void addTagValueDouble() {
+ void addTagValueDouble() {
double input = 123.45;
assertEquals("<adouble>123.45</adouble>" + CR, XmlHandler.addTagValue("adouble", input));
assertEquals("<adouble>123.45</adouble>" + CR, XmlHandler.addTagValue("adouble", input, true));
@@ -211,9 +189,9 @@ public class XmlHandlerUnitTest {
XmlHandler.addTagValue("adouble", Double.MIN_NORMAL, false));
}
- @Ignore("This test needs to be reviewed")
@Test
- public void addTagValueBinary() throws IOException {
+ @Disabled("This test needs to be reviewed")
+ void addTagValueBinary() throws IOException {
byte[] input = "Test Data".getBytes();
String result = "H4sIAAAAAAAAAAtJLS5RcEksSQQAL4PL8QkAAAA=";
@@ -227,7 +205,7 @@ public class XmlHandlerUnitTest {
}
@Test
- public void addTagValueWithSurrogateCharacters() throws Exception {
+ void addTagValueWithSurrogateCharacters() throws Exception {
String expected =
"<testTag attributeTest=\"test attribute value \uD842\uDFB7\" >a\uD800\uDC01\uD842\uDFB7ﻉDtest \uD802\uDF44<</testTag>";
String tagValueWithSurrogates = "a\uD800\uDC01\uD842\uDFB7ﻉDtest \uD802\uDF44<";
@@ -245,7 +223,7 @@ public class XmlHandlerUnitTest {
}
@Test
- public void testEscapingXmlBagCharacters() {
+ void testEscapingXmlBagCharacters() {
String testString = "[value_start (\"'<&>) value_end]";
String expectedStrAfterConversion =
"<[value_start ("'<&>) value_end] "
@@ -257,28 +235,18 @@ public class XmlHandlerUnitTest {
assertEquals(expectedStrAfterConversion, result);
}
- private File createTmpFile(String content) throws Exception {
- File tmpFile = File.createTempFile("XmlHandlerUnitTest", ".xml");
- tmpFile.deleteOnExit();
-
- try (PrintWriter writer = new PrintWriter(tmpFile)) {
- writer.write(content);
- }
-
- return tmpFile;
- }
-
@Test
- public void testGetSubNode() throws Exception {
+ void testGetSubNode() throws Exception {
String testXML =
- "<?xml version=\"1.0\"?>\n"
- + "<root>\n"
- + "<xpto>A</xpto>\n"
- + "<xpto>B</xpto>\n"
- + "<xpto>C</xpto>\n"
- + "<xpto>D</xpto>\n"
- + "</root>\n";
-
+ """
+ <?xml version="1.0"?>
+ <root>
+ <xpto>A</xpto>
+ <xpto>B</xpto>
+ <xpto>C</xpto>
+ <xpto>D</xpto>
+ </root>
+ """;
DocumentBuilder builder = XmlHandler.createDocumentBuilder(false, false);
Document parse = builder.parse(new ByteArrayInputStream(testXML.getBytes()));
@@ -289,15 +257,17 @@ public class XmlHandlerUnitTest {
}
@Test
- public void testGetLastSubNode() throws Exception {
+ void testGetLastSubNode() throws Exception {
String testXML =
- "<?xml version=\"1.0\"?>\n"
- + "<root>\n"
- + "<xpto>A</xpto>\n"
- + "<xpto>B</xpto>\n"
- + "<xpto>C</xpto>\n"
- + "<xpto>D</xpto>\n"
- + "</root>\n";
+ """
+ <?xml version="1.0"?>
+ <root>
+ <xpto>A</xpto>
+ <xpto>B</xpto>
+ <xpto>C</xpto>
+ <xpto>D</xpto>
+ </root>
+ """;
DocumentBuilder builder = XmlHandler.createDocumentBuilder(false, false);
@@ -309,15 +279,17 @@ public class XmlHandlerUnitTest {
}
@Test
- public void testGetSubNodeByNr_WithCache() throws Exception {
+ void testGetSubNodeByNr_WithCache() throws Exception {
String testXML =
- "<?xml version=\"1.0\"?>\n"
- + "<root>\n"
- + "<xpto>0</xpto>\n"
- + "<xpto>1</xpto>\n"
- + "<xpto>2</xpto>\n"
- + "<xpto>3</xpto>\n"
- + "</root>\n";
+ """
+ <?xml version="1.0"?>
+ <root>
+ <xpto>0</xpto>
+ <xpto>1</xpto>
+ <xpto>2</xpto>
+ <xpto>3</xpto>
+ </root>
+ """;
DocumentBuilder builder = XmlHandler.createDocumentBuilder(false, false);
@@ -339,16 +311,17 @@ public class XmlHandlerUnitTest {
}
@Test
- public void testGetSubNodeByNr_WithoutCache() throws Exception {
+ void testGetSubNodeByNr_WithoutCache() throws Exception {
String testXML =
- "<?xml version=\"1.0\"?>\n"
- + "<root>\n"
- + "<xpto>0</xpto>\n"
- + "<xpto>1</xpto>\n"
- + "<xpto>2</xpto>\n"
- + "<xpto>3</xpto>\n"
- + "</root>\n";
-
+ """
+ <?xml version="1.0"?>
+ <root>
+ <xpto>0</xpto>
+ <xpto>1</xpto>
+ <xpto>2</xpto>
+ <xpto>3</xpto>
+ </root>
+ """;
DocumentBuilder builder = XmlHandler.createDocumentBuilder(false, false);
Document parse = builder.parse(new ByteArrayInputStream(testXML.getBytes()));
diff --git a/core/src/test/java/org/apache/hop/core/xml/XmlUtilsTest.java b/core/src/test/java/org/apache/hop/core/xml/XmlUtilsTest.java
index b9473a5c71..87df2de394 100644
--- a/core/src/test/java/org/apache/hop/core/xml/XmlUtilsTest.java
+++ b/core/src/test/java/org/apache/hop/core/xml/XmlUtilsTest.java
@@ -17,26 +17,27 @@
package org.apache.hop.core.xml;
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertTrue;
import javax.xml.XMLConstants;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.SAXParserFactory;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
-public class XmlUtilsTest {
+/** Unit test for {@link XmlParserFactoryProducer} */
+class XmlUtilsTest {
@Test
- public void secureFeatureEnabledAfterDocBuilderFactoryCreation() throws Exception {
+ void secureFeatureEnabledAfterDocBuilderFactoryCreation() throws Exception {
DocumentBuilderFactory documentBuilderFactory =
XmlParserFactoryProducer.createSecureDocBuilderFactory();
- assertEquals(true, documentBuilderFactory.getFeature(XMLConstants.FEATURE_SECURE_PROCESSING));
+ assertTrue(documentBuilderFactory.getFeature(XMLConstants.FEATURE_SECURE_PROCESSING));
}
@Test
- public void secureFeatureEnabledAfterSAXParserFactoryCreation() throws Exception {
+ void secureFeatureEnabledAfterSAXParserFactoryCreation() throws Exception {
SAXParserFactory saxParserFactory = XmlParserFactoryProducer.createSecureSAXParserFactory();
- assertEquals(true, saxParserFactory.getFeature(XMLConstants.FEATURE_SECURE_PROCESSING));
+ assertTrue(saxParserFactory.getFeature(XMLConstants.FEATURE_SECURE_PROCESSING));
}
}
diff --git a/core/src/test/java/org/apache/hop/i18n/GlobalMessageUtilTest.java b/core/src/test/java/org/apache/hop/i18n/GlobalMessageUtilTest.java
index df2a1840e5..97a51953d3 100644
--- a/core/src/test/java/org/apache/hop/i18n/GlobalMessageUtilTest.java
+++ b/core/src/test/java/org/apache/hop/i18n/GlobalMessageUtilTest.java
@@ -17,45 +17,49 @@
package org.apache.hop.i18n;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+
import java.util.Locale;
-import org.apache.hop.junit.rules.RestoreHopEnvironment;
-import org.junit.Assert;
-import org.junit.ClassRule;
-import org.junit.Test;
+import org.apache.hop.junit.rules.RestoreHopEnvironmentExtension;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.ExtendWith;
-public class GlobalMessageUtilTest {
- @ClassRule public static RestoreHopEnvironment env = new RestoreHopEnvironment();
+/** Unit test for {@link GlobalMessageUtil} */
+@ExtendWith(RestoreHopEnvironmentExtension.class)
+class GlobalMessageUtilTest {
@Test
- public void testGetLocaleString() {
- Assert.assertEquals("", GlobalMessageUtil.getLocaleString(null));
- Assert.assertEquals("", GlobalMessageUtil.getLocaleString(new Locale("")));
- Assert.assertEquals("en", GlobalMessageUtil.getLocaleString(Locale.ENGLISH));
- Assert.assertEquals("en_US", GlobalMessageUtil.getLocaleString(Locale.US));
- Assert.assertEquals("en", GlobalMessageUtil.getLocaleString(new Locale("EN")));
- Assert.assertEquals("en_US", GlobalMessageUtil.getLocaleString(new Locale("EN", "us")));
+ void testGetLocaleString() {
+ assertEquals("", GlobalMessageUtil.getLocaleString(null));
+ assertEquals("", GlobalMessageUtil.getLocaleString(Locale.of("")));
+ assertEquals("en", GlobalMessageUtil.getLocaleString(Locale.ENGLISH));
+ assertEquals("en_US", GlobalMessageUtil.getLocaleString(Locale.US));
+ assertEquals("en", GlobalMessageUtil.getLocaleString(Locale.of("EN")));
+ assertEquals("en_US", GlobalMessageUtil.getLocaleString(Locale.of("EN", "us")));
}
@Test
- public void isMissingKey() {
- Assert.assertTrue(GlobalMessageUtil.isMissingKey(null));
- Assert.assertFalse(GlobalMessageUtil.isMissingKey(""));
- Assert.assertFalse(GlobalMessageUtil.isMissingKey(" "));
- Assert.assertTrue(GlobalMessageUtil.isMissingKey("!foo!"));
- Assert.assertTrue(GlobalMessageUtil.isMissingKey("!foo! "));
- Assert.assertTrue(GlobalMessageUtil.isMissingKey(" !foo!"));
- Assert.assertFalse(GlobalMessageUtil.isMissingKey("!foo"));
- Assert.assertFalse(GlobalMessageUtil.isMissingKey("foo!"));
- Assert.assertFalse(GlobalMessageUtil.isMissingKey("foo"));
- Assert.assertFalse(GlobalMessageUtil.isMissingKey("!"));
- Assert.assertFalse(GlobalMessageUtil.isMissingKey(" !"));
+ void isMissingKey() {
+ assertTrue(GlobalMessageUtil.isMissingKey(null));
+ assertFalse(GlobalMessageUtil.isMissingKey(""));
+ assertFalse(GlobalMessageUtil.isMissingKey(" "));
+ assertTrue(GlobalMessageUtil.isMissingKey("!foo!"));
+ assertTrue(GlobalMessageUtil.isMissingKey("!foo! "));
+ assertTrue(GlobalMessageUtil.isMissingKey(" !foo!"));
+ assertFalse(GlobalMessageUtil.isMissingKey("!foo"));
+ assertFalse(GlobalMessageUtil.isMissingKey("foo!"));
+ assertFalse(GlobalMessageUtil.isMissingKey("foo"));
+ assertFalse(GlobalMessageUtil.isMissingKey("!"));
+ assertFalse(GlobalMessageUtil.isMissingKey(" !"));
}
@Test
- public void calculateString() {
+ void calculateString() {
// "fr", "FR"
- Assert.assertEquals(
+ assertEquals(
"Une certaine valeur foo",
GlobalMessageUtil.calculateString(
GlobalMessages.SYSTEM_BUNDLE_PACKAGE,
@@ -74,10 +78,10 @@ public class GlobalMessageUtilTest {
new String[] {"foo"},
GlobalMessages.PKG,
GlobalMessages.BUNDLE_NAME);
- Assert.assertEquals("Some Value foo", str);
+ assertEquals("Some Value foo", str);
// "jp"
- Assert.assertEquals(
+ assertEquals(
"何らかの値 foo",
GlobalMessageUtil.calculateString(
GlobalMessages.SYSTEM_BUNDLE_PACKAGE,
@@ -96,12 +100,12 @@ public class GlobalMessageUtilTest {
new String[] {"foo"},
GlobalMessages.PKG,
GlobalMessages.BUNDLE_NAME);
- Assert.assertEquals("何らかの値 foo", str);
+ assertEquals("何らかの値 foo", str);
// try with multiple packages
// make sure the selected language is used correctly
LanguageChoice.getInstance().setDefaultLocale(Locale.FRANCE); // "fr", "FR"
- Assert.assertEquals(
+ assertEquals(
"Une certaine valeur foo",
GlobalMessageUtil.calculateString(
new String[] {GlobalMessages.SYSTEM_BUNDLE_PACKAGE},
@@ -112,7 +116,7 @@ public class GlobalMessageUtilTest {
LanguageChoice.getInstance()
.setDefaultLocale(Locale.FRENCH); // "fr" - fall back on "default" messages.properties
- Assert.assertEquals(
+ assertEquals(
"Some Value foo",
GlobalMessageUtil.calculateString(
new String[] {GlobalMessages.SYSTEM_BUNDLE_PACKAGE},
@@ -123,7 +127,7 @@ public class GlobalMessageUtilTest {
LanguageChoice.getInstance()
.setDefaultLocale(Locale.FRENCH); // "fr" - fall back on foo/messages_fr.properties
- Assert.assertEquals(
+ assertEquals(
"Une certaine valeur foo",
GlobalMessageUtil.calculateString(
new String[] {GlobalMessages.SYSTEM_BUNDLE_PACKAGE, "org.apache.hop.foo"},
@@ -133,7 +137,7 @@ public class GlobalMessageUtilTest {
GlobalMessages.BUNDLE_NAME));
LanguageChoice.getInstance().setDefaultLocale(Locale.JAPANESE); // "jp"
- Assert.assertEquals(
+ assertEquals(
"何らかの値 foo",
GlobalMessageUtil.calculateString(
new String[] {GlobalMessages.SYSTEM_BUNDLE_PACKAGE},
@@ -143,7 +147,7 @@ public class GlobalMessageUtilTest {
GlobalMessages.BUNDLE_NAME));
LanguageChoice.getInstance().setDefaultLocale(Locale.JAPAN); // "jp", "JP" - fall back on "jp"
- Assert.assertEquals(
+ assertEquals(
"何らかの値 foo",
GlobalMessageUtil.calculateString(
new String[] {GlobalMessages.SYSTEM_BUNDLE_PACKAGE},
diff --git a/core/src/test/java/org/apache/hop/i18n/GlobalMessagesTest.java b/core/src/test/java/org/apache/hop/i18n/GlobalMessagesTest.java
index b468634623..39bb09ff71 100644
--- a/core/src/test/java/org/apache/hop/i18n/GlobalMessagesTest.java
+++ b/core/src/test/java/org/apache/hop/i18n/GlobalMessagesTest.java
@@ -17,14 +17,15 @@
package org.apache.hop.i18n;
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
import java.util.Locale;
import java.util.ResourceBundle;
import java.util.UUID;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
-public class GlobalMessagesTest {
+/** Unit test for {@link GlobalMessages} */
+class GlobalMessagesTest {
/*
* Reading properties file without native2ascii. (use UTF8 characters) #620
*/
@@ -34,7 +35,7 @@ public class GlobalMessagesTest {
* to validate that old-style escaped ISO-8859-1 files are read correctly as before
*/
@Test
- public void testGetBundleOldASCII() throws Exception {
+ void testGetBundleOldASCII() throws Exception {
final String pkgName = "org.apache.hop/i18n/messages/test_ascii_messages";
final String msgKey = "System.Dialog.SelectEnvironmentVar.Title";
@@ -77,7 +78,7 @@ public class GlobalMessagesTest {
* to validate that new-style UTF8 files are read correctly
*/
@Test
- public void testGetBundleNewUTF8() throws Exception {
+ void testGetBundleNewUTF8() throws Exception {
final String pkgName = "org.apache.hop/i18n/messages/test_utf8_messages";
final String msgKey = "System.Dialog.SelectEnvironmentVar.Title";
@@ -118,7 +119,7 @@ public class GlobalMessagesTest {
* to validate the format of an unmatched string
*/
@Test
- public void testUnmatchedString() {
+ void testUnmatchedString() {
String messageId = UUID.randomUUID().toString();
assertEquals("!" + messageId + "!", GlobalMessages.getInstance().getString(messageId));
}
diff --git a/core/src/test/java/org/apache/hop/metadata/serializer/json/JsonMetadataSerializerTest.java b/core/src/test/java/org/apache/hop/metadata/serializer/json/JsonMetadataSerializerTest.java
index 4b76b3baff..771a3eacbe 100644
--- a/core/src/test/java/org/apache/hop/metadata/serializer/json/JsonMetadataSerializerTest.java
+++ b/core/src/test/java/org/apache/hop/metadata/serializer/json/JsonMetadataSerializerTest.java
@@ -17,10 +17,12 @@
package org.apache.hop.metadata.serializer.json;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNull;
+
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
-import junit.framework.TestCase;
import org.apache.hop.core.Const;
import org.apache.hop.core.encryption.HopTwoWayPasswordEncoder;
import org.apache.hop.core.exception.HopException;
@@ -33,32 +35,24 @@ import org.apache.hop.metadata.serializer.json.person.Person;
import org.apache.hop.metadata.serializer.json.person.interest.Cooking;
import org.apache.hop.metadata.serializer.json.person.interest.Music;
import org.apache.hop.metadata.serializer.json.person.interest.Running;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
-public class JsonMetadataSerializerTest extends TestCase {
+/** Unit test for {@link JsonMetadataSerializer} */
+class JsonMetadataSerializerTest {
private JsonMetadataProvider metadataProvider;
- @Override
- protected void setUp() throws Exception {
- String baseFolder =
- System.getProperty("java.io.tmpdir")
- + Const.FILE_SEPARATOR
- + "metadata"; // UUID.randomUUID();
+ @BeforeEach
+ void setUp() {
+ String baseFolder = System.getProperty("java.io.tmpdir") + Const.FILE_SEPARATOR + "metadata";
metadataProvider =
new JsonMetadataProvider(
new HopTwoWayPasswordEncoder(), baseFolder, Variables.getADefaultVariableSpace());
}
- @Override
- protected void tearDown() throws Exception {
- // TODO: Remove the temp folder
- //
-
- }
-
@Test
- public void testPersonSerialization() throws HopException {
+ void testPersonSerialization() throws HopException {
Map<String, String> attributes = new HashMap<>();
attributes.put("attribute1", "value1");
attributes.put("attribute2", "value2");
diff --git a/core/src/test/java/org/apache/hop/metadata/serializer/xml/XmlMetadataUtilTest.java b/core/src/test/java/org/apache/hop/metadata/serializer/xml/XmlMetadataUtilTest.java
index 991cd51b3d..ae15d12a96 100644
--- a/core/src/test/java/org/apache/hop/metadata/serializer/xml/XmlMetadataUtilTest.java
+++ b/core/src/test/java/org/apache/hop/metadata/serializer/xml/XmlMetadataUtilTest.java
@@ -17,21 +17,23 @@
package org.apache.hop.metadata.serializer.xml;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+
import java.util.Arrays;
-import junit.framework.TestCase;
import org.apache.hop.core.Const;
import org.apache.hop.core.xml.XmlHandler;
import org.apache.hop.metadata.serializer.xml.classes.Field;
import org.apache.hop.metadata.serializer.xml.classes.Info;
import org.apache.hop.metadata.serializer.xml.classes.MetaData;
import org.apache.hop.metadata.serializer.xml.classes.TestEnum;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import org.w3c.dom.Node;
-public class XmlMetadataUtilTest extends TestCase {
+/** Unit test for {@link XmlMetadataUtil} */
+class XmlMetadataUtilTest {
@Test
- public void testMetaXml() throws Exception {
+ void testMetaXml() throws Exception {
MetaData metaTest = new MetaData();
metaTest.setFilename("filename.csv");
metaTest.setGroup("\"");
diff --git a/core/src/test/java/org/apache/hop/server/HttpUtilTest.java b/core/src/test/java/org/apache/hop/server/HttpUtilTest.java
index e1d3381935..4cbc01c9b5 100644
--- a/core/src/test/java/org/apache/hop/server/HttpUtilTest.java
+++ b/core/src/test/java/org/apache/hop/server/HttpUtilTest.java
@@ -25,30 +25,25 @@ import java.nio.ByteBuffer;
import java.nio.CharBuffer;
import java.nio.charset.Charset;
import java.nio.charset.CharsetEncoder;
-import java.security.NoSuchAlgorithmException;
import java.util.zip.GZIPOutputStream;
import org.apache.commons.codec.binary.Base64;
import org.apache.hop.core.variables.Variables;
-import org.apache.hop.junit.rules.RestoreHopEnvironment;
-import org.junit.ClassRule;
-import org.junit.Test;
+import org.apache.hop.junit.rules.RestoreHopEnvironmentExtension;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.ExtendWith;
-public class HttpUtilTest {
- @ClassRule public static RestoreHopEnvironment env = new RestoreHopEnvironment();
+/** Unit test for {@link HttpUtil} */
+@ExtendWith(RestoreHopEnvironmentExtension.class)
+class HttpUtilTest {
- public static final String DEFAULT_ENCODING = "UTF-8";
- public static final String STANDART =
+ static final String DEFAULT_ENCODING = "UTF-8";
+ static final String STANDART =
"(\u256e\u00b0-\u00b0)\u256e\u2533\u2501\u2501\u2533\u30c6\u30fc\u30d6"
+ "\u30eb(\u256f\u00b0\u25a1\u00b0)\u256f\u253b\u2501\u2501\u253b\u30aa\u30d5";
- /**
- * Test that we can decode/encode Strings without loss of data.
- *
- * @throws IOException
- * @throws NoSuchAlgorithmException
- */
+ /** Test that we can decode/encode Strings without loss of data. */
@Test
- public final void testDecodeBase64ZippedString() throws IOException {
+ final void testDecodeBase64ZippedString() throws IOException {
String enc64 = this.canonicalBase64Encode(STANDART);
// decode string
String decoded = HttpUtil.decodeBase64ZippedString(enc64);
@@ -57,7 +52,7 @@ public class HttpUtilTest {
}
@Test
- public void testConstructUrl() throws Exception {
+ void testConstructUrl() throws Exception {
Variables variables = new Variables();
String expected = "hostname:1234/webAppName?param=value";
@@ -77,13 +72,9 @@ public class HttpUtilTest {
variables, "hostname", String.valueOf(1234), "webAppName", "?param=value", true));
}
- /**
- * Test that we can encode and decode String using only static class-under-test methods.
- *
- * @throws IOException
- */
+ /** Test that we can encode and decode String using only static class-under-test methods. */
@Test
- public void testEncodeBase64ZippedString() throws IOException {
+ void testEncodeBase64ZippedString() throws IOException {
String enc64 = HttpUtil.encodeBase64ZippedString(STANDART);
String decoded = HttpUtil.decodeBase64ZippedString(enc64);
@@ -91,12 +82,11 @@ public class HttpUtilTest {
}
/**
- * https://www.securecoding.cert.org/confluence/display/java/IDS12-J.+Perform+lossless+conversion+
+ * <a
+ * href="https://www.securecoding.cert.org/confluence/display/java/IDS12-J.+Perform+lossless+conversion+">...</a>
* of+String+data+between+differing+character+encodings
*
* @param in string to encode
- * @return
- * @throws IOException
*/
private String canonicalBase64Encode(String in) throws IOException {
Charset charset = Charset.forName(DEFAULT_ENCODING);
diff --git a/core/src/test/java/org/apache/hop/server/ServerConnectionManagerTest.java b/core/src/test/java/org/apache/hop/server/ServerConnectionManagerTest.java
index 8c1dfbf1ff..9b4e35313b 100644
--- a/core/src/test/java/org/apache/hop/server/ServerConnectionManagerTest.java
+++ b/core/src/test/java/org/apache/hop/server/ServerConnectionManagerTest.java
@@ -17,34 +17,36 @@
package org.apache.hop.server;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
import javax.net.ssl.SSLContext;
-import org.junit.Before;
-import org.junit.Test;
-
-public class ServerConnectionManagerTest {
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+/** Unit test for {@link ServerConnectionManager} */
+class ServerConnectionManagerTest {
private SSLContext defaultContext;
- @Before
- public void setUp() throws Exception {
+ @BeforeEach
+ void setUp() throws Exception {
ServerConnectionManager.reset();
defaultContext = SSLContext.getDefault();
}
@Test
- public void shouldOverrideDefaultSSLContextByDefault() throws Exception {
+ void shouldOverrideDefaultSSLContextByDefault() throws Exception {
System.clearProperty("javax.net.ssl.keyStore");
ServerConnectionManager instance = ServerConnectionManager.getInstance();
+
+ assertNotNull(instance);
assertNotEquals(defaultContext, SSLContext.getDefault());
}
@Test
- public void shouldNotOverrideDefaultSSLContextIfKeystoreIsSet() throws Exception {
+ void shouldNotOverrideDefaultSSLContextIfKeystoreIsSet() throws Exception {
System.setProperty("javax.net.ssl.keyStore", "NONE");
- ServerConnectionManager instance = ServerConnectionManager.getInstance();
assertEquals(defaultContext, SSLContext.getDefault());
}
}
diff --git a/engine/src/test/java/org/apache/hop/base/AbstractMetaTest.java b/engine/src/test/java/org/apache/hop/base/AbstractMetaTest.java
index 703a320896..8845f35e2d 100644
--- a/engine/src/test/java/org/apache/hop/base/AbstractMetaTest.java
+++ b/engine/src/test/java/org/apache/hop/base/AbstractMetaTest.java
@@ -16,11 +16,11 @@
*/
package org.apache.hop.base;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.never;
@@ -49,38 +49,38 @@ import org.apache.hop.core.listeners.INameChangedListener;
import org.apache.hop.core.plugins.PluginRegistry;
import org.apache.hop.core.undo.ChangeAction;
import org.apache.hop.core.variables.IVariables;
-import org.apache.hop.junit.rules.RestoreHopEngineEnvironment;
+import org.apache.hop.junit.rules.RestoreHopEnvironmentExtension;
import org.apache.hop.pipeline.transform.TransformMeta;
-import org.junit.Before;
-import org.junit.BeforeClass;
-import org.junit.ClassRule;
-import org.junit.Test;
-
-public class AbstractMetaTest {
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.ExtendWith;
+
+/** Unit test for {@link AbstractMeta} */
+@ExtendWith(RestoreHopEnvironmentExtension.class)
+class AbstractMetaTest {
AbstractMeta meta;
- @ClassRule public static RestoreHopEngineEnvironment env = new RestoreHopEngineEnvironment();
-
- @BeforeClass
- public static void setUpBeforeClass() throws Exception {
+ @BeforeAll
+ static void setUpBeforeClass() throws Exception {
PluginRegistry.addPluginType(DatabasePluginType.getInstance());
PluginRegistry.init();
}
- @Before
- public void setUp() {
+ @BeforeEach
+ void setUp() {
meta = new AbstractMetaStub();
}
@Test
- public void testGetSetFilename() {
+ void testGetSetFilename() {
assertNull(meta.getFilename());
meta.setFilename("myfile");
assertEquals("myfile", meta.getFilename());
}
@Test
- public void testAddNameChangedListener() {
+ void testAddNameChangedListener() {
meta.fireNameChangedListeners("a", "a");
meta.fireNameChangedListeners("a", "b");
meta.addNameChangedListener(null);
@@ -96,7 +96,7 @@ public class AbstractMetaTest {
}
@Test
- public void testAddFilenameChangedListener() {
+ void testAddFilenameChangedListener() {
meta.fireFilenameChangedListeners("a", "a");
meta.fireFilenameChangedListeners("a", "b");
meta.addFilenameChangedListener(null);
@@ -112,7 +112,7 @@ public class AbstractMetaTest {
}
@Test
- public void testAddRemoveFireContentChangedListener() {
+ void testAddRemoveFireContentChangedListener() {
assertTrue(meta.getContentChangedListeners().isEmpty());
IContentChangedListener listener = mock(IContentChangedListener.class);
meta.addContentChangedListener(listener);
@@ -131,7 +131,7 @@ public class AbstractMetaTest {
}
@Test
- public void testAddCurrentDirectoryChangedListener() {
+ void testAddCurrentDirectoryChangedListener() {
meta.fireNameChangedListeners("a", "a");
meta.fireNameChangedListeners("a", "b");
meta.addCurrentDirectoryChangedListener(null);
@@ -148,7 +148,7 @@ public class AbstractMetaTest {
}
@Test
- public void testAddRemoveViewUndo() {
+ void testAddRemoveViewUndo() {
// addUndo() right now will fail with an NPE
assertEquals(0, meta.getUndoSize());
meta.clearUndo();
@@ -194,7 +194,7 @@ public class AbstractMetaTest {
}
@Test
- public void testGetSetAttributes() {
+ void testGetSetAttributes() {
assertNull(meta.getAttributesMap());
Map<String, Map<String, String>> attributesMap = new HashMap<>();
meta.setAttributesMap(attributesMap);
@@ -215,7 +215,7 @@ public class AbstractMetaTest {
}
@Test
- public void testNotes() {
+ void testNotes() {
assertNull(meta.getNotes());
// most note methods will NPE at this point, so call clear() to create an empty note list
meta.clear();
@@ -243,7 +243,7 @@ public class AbstractMetaTest {
List<NotePadMeta> selectedNotes = meta.getSelectedNotes();
assertNotNull(selectedNotes);
assertEquals(1, selectedNotes.size());
- assertEquals(note2, selectedNotes.get(0));
+ assertEquals(note2, selectedNotes.getFirst());
assertEquals(1, meta.indexOfNote(note2));
meta.removeNote(2);
assertEquals(2, meta.nrNotes());
@@ -268,7 +268,7 @@ public class AbstractMetaTest {
}
@Test
- public void testAddDeleteModifyObserver() {
+ void testAddDeleteModifyObserver() {
IHopObserver observer = mock(IHopObserver.class);
meta.addObserver(observer);
Object event = new Object();
@@ -281,17 +281,17 @@ public class AbstractMetaTest {
}
@Test
- public void testHasMissingPlugins() {
+ void testHasMissingPlugins() {
assertFalse(meta.hasMissingPlugins());
}
@Test
- public void testCanSave() {
+ void testCanSave() {
assertTrue(meta.canSave());
}
@Test
- public void testHasChanged() {
+ void testHasChanged() {
meta.clear();
assertFalse(meta.hasChanged());
meta.setChanged(true);
@@ -299,7 +299,7 @@ public class AbstractMetaTest {
}
@Test
- public void testMultithreadHammeringOfListener() throws Exception {
+ void testMultithreadHammeringOfListener() throws Exception {
CountDownLatch latch = new CountDownLatch(3);
AbstractMetaListenerThread th1 =
@@ -329,7 +329,7 @@ public class AbstractMetaTest {
* Stub class for AbstractMeta. No need to test the abstract methods here, they should be done in
* unit tests for proper child classes.
*/
- public static class AbstractMetaStub extends AbstractMeta {
+ static class AbstractMetaStub extends AbstractMeta {
@Override
protected String getExtension() {
@@ -378,17 +378,17 @@ public class AbstractMetaTest {
// Reuse this method to set a mock internal variable variables
@Override
- public void setInternalHopVariables(IVariables var) {
+ public void setInternalHopVariables(IVariables variables) {
// Do nothing
}
@Override
- protected void setInternalFilenameHopVariables(IVariables var) {
+ protected void setInternalFilenameHopVariables(IVariables variables) {
// Do nothing
}
@Override
- protected void setInternalNameHopVariable(IVariables var) {
+ protected void setInternalNameHopVariable(IVariables variables) {
// Do nothing
}
@@ -438,13 +438,13 @@ public class AbstractMetaTest {
}
}
- private class AbstractMetaListenerThread implements Runnable {
+ private static class AbstractMetaListenerThread implements Runnable {
AbstractMeta metaToWork;
int times;
CountDownLatch whenDone;
String message;
int maxListeners;
- private Random random;
+ private final Random random;
AbstractMetaListenerThread(
AbstractMeta aMeta, int times, CountDownLatch latch, int maxListeners) {
@@ -457,9 +457,7 @@ public class AbstractMetaTest {
@Override
public void run() {
-
// Add a bunch of listeners to start with
- //
for (int i = 0; i < random.nextInt(maxListeners) / 2; i++) {
metaToWork.addFilenameChangedListener(
new MockFilenameChangeListener(random.nextInt(maxListeners)));
diff --git a/engine/src/test/java/org/apache/hop/concurrency/ActiveSubPipelineConcurrencyTest.java b/engine/src/test/java/org/apache/hop/concurrency/ActiveSubPipelineConcurrencyTest.java
index 35704ccfee..cf38e26c32 100644
--- a/engine/src/test/java/org/apache/hop/concurrency/ActiveSubPipelineConcurrencyTest.java
+++ b/engine/src/test/java/org/apache/hop/concurrency/ActiveSubPipelineConcurrencyTest.java
@@ -24,7 +24,7 @@ import java.util.concurrent.atomic.AtomicBoolean;
import org.apache.hop.pipeline.PipelineMeta;
import org.apache.hop.pipeline.engine.IPipelineEngine;
import org.apache.hop.pipeline.engines.local.LocalPipelineEngine;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
/**
* In this test we add new elements to shared pipeline concurrently and get added elements from this
@@ -39,7 +39,7 @@ import org.junit.Test;
* {@link java.util.HashMap#size()} method (as a result there would be an error in {@link
* Getter#call()} ).
*/
-public class ActiveSubPipelineConcurrencyTest {
+class ActiveSubPipelineConcurrencyTest {
private static final int NUMBER_OF_GETTERS = 10;
private static final int NUMBER_OF_CREATES = 10;
private static final int NUMBER_OF_CREATE_CYCLES = 20;
@@ -49,7 +49,7 @@ public class ActiveSubPipelineConcurrencyTest {
private final Object lock = new Object();
@Test
- public void getAndCreateConcurrently() throws Exception {
+ void getAndCreateConcurrently() throws Exception {
AtomicBoolean condition = new AtomicBoolean(true);
IPipelineEngine<PipelineMeta> pipeline = new LocalPipelineEngine();
createSubPipeline(pipeline);
@@ -101,7 +101,7 @@ public class ActiveSubPipelineConcurrencyTest {
while (condition.get()) {
final String activeSubPipelineName =
createPipelineName(random.nextInt(INITIAL_NUMBER_OF_PIPELINE));
- IPipelineEngine subPipeline = pipeline.getActiveSubPipeline(activeSubPipelineName);
+ IPipelineEngine<?> subPipeline = pipeline.getActiveSubPipeline(activeSubPipelineName);
if (subPipeline == null) {
throw new IllegalStateException(
diff --git a/engine/src/test/java/org/apache/hop/concurrency/BaseRowSetConcurrentTest.java b/engine/src/test/java/org/apache/hop/concurrency/BaseRowSetConcurrentTest.java
index c42ac64617..4176d45229 100644
--- a/engine/src/test/java/org/apache/hop/concurrency/BaseRowSetConcurrentTest.java
+++ b/engine/src/test/java/org/apache/hop/concurrency/BaseRowSetConcurrentTest.java
@@ -17,6 +17,8 @@
package org.apache.hop.concurrency;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
@@ -26,8 +28,7 @@ import java.util.concurrent.atomic.AtomicBoolean;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import org.apache.hop.core.BlockingRowSet;
-import org.junit.Assert;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
/**
* We have a {@link org.apache.hop.core.BaseRowSet} with a bunch of attributes (originTransformName,
@@ -58,13 +59,13 @@ import org.junit.Test;
*
* <p>It calls toString method of shared blockingRowSet and verifies it's consistency.
*/
-public class BaseRowSetConcurrentTest {
+class BaseRowSetConcurrentTest {
private static final int MUTATE_CIRCLES = 100;
private static final int NUMBER_OF_MUTATORS = 20;
private static final int NUMBER_OF_GETTERS = 20;
@Test
- public void test() throws Exception {
+ void test() throws Exception {
BlockingRowSet sharedBlockingRowSet = new BlockingRowSet(100);
// fill data with initial values
sharedBlockingRowSet.setThreadNameFromToCopy("1", 1, "1", 1);
@@ -76,7 +77,7 @@ public class BaseRowSetConcurrentTest {
ConcurrencyTestRunner.runAndCheckNoExceptionRaised(mutators, getters, condition);
}
- private class Mutator extends StopOnErrorCallable<Object> {
+ private static class Mutator extends StopOnErrorCallable<Object> {
private static final String STRING_DEFAULT = "<def>";
private final BlockingRowSet blockingRowSet;
private final Random random;
@@ -102,7 +103,7 @@ public class BaseRowSetConcurrentTest {
}
}
- private class Getter extends StopOnErrorCallable<Object> {
+ private static class Getter extends StopOnErrorCallable<Object> {
private final BlockingRowSet blockingRowSet;
private Getter(BlockingRowSet blockingRowSet, AtomicBoolean condition) {
@@ -124,7 +125,7 @@ public class BaseRowSetConcurrentTest {
// we expect that all ids (and all digits are ids here) refer to the same set,
// that means that they are equal.
- Assert.assertEquals(1, ids.size());
+ assertEquals(1, ids.size());
}
/**
diff --git a/engine/src/test/java/org/apache/hop/concurrency/BaseTransformConcurrencyTest.java b/engine/src/test/java/org/apache/hop/concurrency/BaseTransformConcurrencyTest.java
index f86c0d978d..9d17520f41 100644
--- a/engine/src/test/java/org/apache/hop/concurrency/BaseTransformConcurrencyTest.java
+++ b/engine/src/test/java/org/apache/hop/concurrency/BaseTransformConcurrencyTest.java
@@ -34,9 +34,9 @@ import org.apache.hop.pipeline.transform.ITransformData;
import org.apache.hop.pipeline.transform.ITransformMeta;
import org.apache.hop.pipeline.transform.TransformMeta;
import org.apache.hop.pipeline.transform.TransformPartitioningMeta;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
-public class BaseTransformConcurrencyTest {
+class BaseTransformConcurrencyTest {
private static final String TRANSFORM_META = "TransformMeta";
private BaseTransform<ITransformMeta, ITransformData> baseTransform;
@@ -49,7 +49,7 @@ public class BaseTransformConcurrencyTest {
* modification exception.
*/
@Test
- public void testRowListeners() throws Exception {
+ void testRowListeners() throws Exception {
int modifiersAmount = 100;
int traversersAmount = 100;
@@ -61,7 +61,7 @@ public class BaseTransformConcurrencyTest {
.thenReturn(mock(TransformPartitioningMeta.class));
baseTransform =
- new BaseTransform(
+ new BaseTransform<>(
transformMeta, null, null, 0, pipelineMeta, spy(new LocalPipelineEngine()));
AtomicBoolean condition = new AtomicBoolean(true);
@@ -91,7 +91,7 @@ public class BaseTransformConcurrencyTest {
* modification exception.
*/
@Test
- public void testInputOutputRowSets() throws Exception {
+ void testInputOutputRowSets() throws Exception {
int modifiersAmount = 100;
int traversersAmount = 100;
@@ -103,7 +103,7 @@ public class BaseTransformConcurrencyTest {
.thenReturn(mock(TransformPartitioningMeta.class));
baseTransform =
- new BaseTransform(
+ new BaseTransform<>(
transformMeta, null, null, 0, pipelineMeta, spy(new LocalPipelineEngine()));
AtomicBoolean condition = new AtomicBoolean(true);
@@ -124,26 +124,28 @@ public class BaseTransformConcurrencyTest {
runner.checkNoExceptionRaised();
}
- private class RowSetsModifier extends StopOnErrorCallable<BaseTransform> {
+ private class RowSetsModifier
+ extends StopOnErrorCallable<BaseTransform<ITransformMeta, ITransformData>> {
RowSetsModifier(AtomicBoolean condition) {
super(condition);
}
@Override
- BaseTransform doCall() {
+ BaseTransform<ITransformMeta, ITransformData> doCall() {
baseTransform.addRowSetToInputRowSets(mock(IRowSet.class));
baseTransform.addRowSetToOutputRowSets(mock(IRowSet.class));
return null;
}
}
- private class RowSetsTraverser extends StopOnErrorCallable<BaseTransform> {
+ private class RowSetsTraverser
+ extends StopOnErrorCallable<BaseTransform<ITransformMeta, ITransformData>> {
RowSetsTraverser(AtomicBoolean condition) {
super(condition);
}
@Override
- BaseTransform doCall() {
+ BaseTransform<ITransformMeta, ITransformData> doCall() {
for (IRowSet rowSet : baseTransform.getInputRowSets()) {
rowSet.setRowMeta(mock(IRowMeta.class));
}
@@ -154,25 +156,27 @@ public class BaseTransformConcurrencyTest {
}
}
- private class RowListenersModifier extends StopOnErrorCallable<BaseTransform> {
+ private class RowListenersModifier
+ extends StopOnErrorCallable<BaseTransform<ITransformMeta, ITransformData>> {
RowListenersModifier(AtomicBoolean condition) {
super(condition);
}
@Override
- BaseTransform doCall() {
+ BaseTransform<ITransformMeta, ITransformData> doCall() {
baseTransform.addRowListener(mock(IRowListener.class));
return null;
}
}
- private class RowListenersTraverser extends StopOnErrorCallable<BaseTransform> {
+ private class RowListenersTraverser
+ extends StopOnErrorCallable<BaseTransform<ITransformMeta, ITransformData>> {
RowListenersTraverser(AtomicBoolean condition) {
super(condition);
}
@Override
- BaseTransform doCall() throws Exception {
+ BaseTransform<ITransformMeta, ITransformData> doCall() throws Exception {
for (IRowListener rowListener : baseTransform.getRowListeners()) {
rowListener.rowWrittenEvent(mock(IRowMeta.class), new Object[] {});
}
diff --git a/engine/src/test/java/org/apache/hop/concurrency/RowMetaConcurrencyTest.java b/engine/src/test/java/org/apache/hop/concurrency/RowMetaConcurrencyTest.java
index 41f5240ed0..d902ce2678 100644
--- a/engine/src/test/java/org/apache/hop/concurrency/RowMetaConcurrencyTest.java
+++ b/engine/src/test/java/org/apache/hop/concurrency/RowMetaConcurrencyTest.java
@@ -17,8 +17,8 @@
package org.apache.hop.concurrency;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertTrue;
import java.util.ArrayList;
import java.util.Collections;
@@ -34,14 +34,15 @@ import java.util.concurrent.atomic.AtomicBoolean;
import org.apache.hop.core.row.IValueMeta;
import org.apache.hop.core.row.RowMeta;
import org.apache.hop.core.row.value.ValueMetaString;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
-public class RowMetaConcurrencyTest {
+/** Unit test for {@link RowMeta} */
+class RowMetaConcurrencyTest {
private static final int CYCLES = 50;
@Test
- public void fiveAddersAgainstTenReaders() throws Exception {
+ void fiveAddersAgainstTenReaders() throws Exception {
final int addersAmount = 5;
final int readersAmount = 10;
@@ -73,13 +74,13 @@ public class RowMetaConcurrencyTest {
assertEquals(CYCLES * addersAmount, metas.size());
assertEquals(CYCLES * addersAmount, results.size());
for (IValueMeta meta : metas) {
- assertTrue(meta.getName(), results.remove(meta));
+ assertTrue(results.remove(meta), meta.getName());
}
assertTrue(results.isEmpty());
}
@Test
- public void fiveShufflersAgainstTenSearchers() throws Exception {
+ void fiveShufflersAgainstTenSearchers() throws Exception {
final int elementsAmount = 100;
final int shufflersAmount = 5;
final int searchersAmount = 10;
@@ -107,7 +108,8 @@ public class RowMetaConcurrencyTest {
}
@Test
- public void addRemoveSearch() throws Exception {
+ @SuppressWarnings("unchecked")
+ void addRemoveSearch() throws Exception {
final int addersAmount = 5;
final int removeAmount = 10;
final int searchersAmount = 10;
@@ -153,7 +155,7 @@ public class RowMetaConcurrencyTest {
ExecutionResult<List<String>> result = (ExecutionResult<List<String>>) results.get(remover);
assertTrue(result.getResult().isEmpty());
for (String name : remover.getToRemove()) {
- assertEquals(name, -1, rowMeta.indexOfValue(name));
+ assertEquals(-1, rowMeta.indexOfValue(name), name);
}
}
// adders should add all elements
@@ -162,7 +164,7 @@ public class RowMetaConcurrencyTest {
ExecutionResult<List<IValueMeta>> result =
(ExecutionResult<List<IValueMeta>>) results.get(adder);
for (IValueMeta meta : result.getResult()) {
- assertTrue(meta.getName(), metas.remove(meta));
+ assertTrue(metas.remove(meta), meta.getName());
}
}
assertEquals(searchersAmount, metas.size());
@@ -268,7 +270,7 @@ public class RowMetaConcurrencyTest {
private static class Remover extends StopOnErrorCallable<List<String>> {
private final RowMeta rowMeta;
- private final List<String> toRemove;
+ @lombok.Getter private final List<String> toRemove;
public Remover(AtomicBoolean condition, RowMeta rowMeta, List<String> toRemove) {
super(condition);
@@ -288,9 +290,5 @@ public class RowMetaConcurrencyTest {
}
return result;
}
-
- public List<String> getToRemove() {
- return toRemove;
- }
}
}
diff --git a/engine/src/test/java/org/apache/hop/concurrency/WorkflowMapConcurrencyTest.java b/engine/src/test/java/org/apache/hop/concurrency/WorkflowMapConcurrencyTest.java
index 7c054ca163..7612361926 100644
--- a/engine/src/test/java/org/apache/hop/concurrency/WorkflowMapConcurrencyTest.java
+++ b/engine/src/test/java/org/apache/hop/concurrency/WorkflowMapConcurrencyTest.java
@@ -33,9 +33,10 @@ import org.apache.hop.workflow.engine.IWorkflowEngine;
import org.apache.hop.workflow.engines.local.LocalWorkflowEngine;
import org.apache.hop.www.HopServerObjectEntry;
import org.apache.hop.www.WorkflowMap;
-import org.junit.BeforeClass;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.Test;
+/** Unit test for {@link WorkflowMap} */
public class WorkflowMapConcurrencyTest {
public static final String WORKFLOW_NAME_STRING = "workflow";
public static final String WORKFLOW_ID_STRING = "workflow";
@@ -48,8 +49,8 @@ public class WorkflowMapConcurrencyTest {
private static WorkflowMap workflowMap;
- @BeforeClass
- public static void init() {
+ @BeforeAll
+ static void init() {
workflowMap = new WorkflowMap();
for (int i = 0; i < INITIAL_WORKFLOW_MAP_SIZE; i++) {
workflowMap.addWorkflow(
@@ -68,7 +69,7 @@ public class WorkflowMapConcurrencyTest {
}
@Test
- public void updateGetAndReplaceConcurrently() throws Exception {
+ void updateGetAndReplaceConcurrently() throws Exception {
AtomicBoolean condition = new AtomicBoolean(true);
AtomicInteger generator = new AtomicInteger(10);
@@ -88,7 +89,6 @@ public class WorkflowMapConcurrencyTest {
replacers.add(new Replacer(workflowMap, condition));
}
- //noinspection unchecked
ConcurrencyTestRunner.runAndCheckNoExceptionRaised(
updaters, ListUtils.union(replacers, getters), condition);
}
@@ -184,8 +184,7 @@ public class WorkflowMapConcurrencyTest {
final String workflowName = WORKFLOW_NAME_STRING + i;
final String workflowId = WORKFLOW_ID_STRING + i;
- HopServerObjectEntry entry = new HopServerObjectEntry(workflowName, workflowId);
-
+ new HopServerObjectEntry(workflowName, workflowId);
workflowMap.replaceWorkflow(
mockWorkflow(i + 1), mockWorkflow(i + 1), mock(WorkflowConfiguration.class));
diff --git a/engine/src/test/java/org/apache/hop/concurrency/WorkflowTrackerConcurrencyTest.java b/engine/src/test/java/org/apache/hop/concurrency/WorkflowTrackerConcurrencyTest.java
index d6d8c8b007..9c27634915 100644
--- a/engine/src/test/java/org/apache/hop/concurrency/WorkflowTrackerConcurrencyTest.java
+++ b/engine/src/test/java/org/apache/hop/concurrency/WorkflowTrackerConcurrencyTest.java
@@ -17,27 +17,26 @@
package org.apache.hop.concurrency;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
import java.util.ArrayList;
-import java.util.Arrays;
import java.util.List;
import java.util.Random;
import java.util.concurrent.Callable;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.concurrent.atomic.AtomicInteger;
+import java.util.stream.Stream;
import org.apache.commons.collections4.ListUtils;
import org.apache.hop.core.gui.WorkflowTracker;
import org.apache.hop.workflow.ActionResult;
import org.apache.hop.workflow.WorkflowMeta;
import org.apache.hop.workflow.action.ActionMeta;
-import org.junit.BeforeClass;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.junit.runners.Parameterized;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.params.ParameterizedTest;
+import org.junit.jupiter.params.provider.MethodSource;
/**
* This test consists of two similar cases. There are three type of actors: getters, searchers and
@@ -47,32 +46,26 @@ import org.junit.runners.Parameterized;
* <tt>updatersCycles</tt> times. The difference between two cases is the second has a small limit
* of stored children, so the parent WorkflowTracker will be forced to remove some of its elements.
*/
-@RunWith(Parameterized.class)
-public class WorkflowTrackerConcurrencyTest {
-
+class WorkflowTrackerConcurrencyTest {
private static final int GETTERS_AMOUNT = 10;
-
private static final int SEARCHERS_AMOUNT = 20;
-
private static final int UPDATERS_AMOUNT = 5;
private static final int UPDATERS_CYCLES = 10;
-
private static final int JOBS_LIMIT = 20;
- @BeforeClass
- public static void setUp() {
+ @BeforeAll
+ static void setUp() {
// a guarding check for tests' parameters
int jobsToBeAdded = UPDATERS_AMOUNT * UPDATERS_CYCLES;
assertTrue(
- "The limit of stored workflows must be less than the amount of children to be added",
- JOBS_LIMIT < jobsToBeAdded);
+ JOBS_LIMIT < jobsToBeAdded,
+ "The limit of stored workflows must be less than the amount of children to be added");
}
- @Parameterized.Parameters
- public static List<Object[]> getData() {
- return Arrays.asList(
- new Object[] {new WorkflowTracker(mockWorkflowMeta("parent"))},
- new Object[] {new WorkflowTracker(mockWorkflowMeta("parent"), JOBS_LIMIT)});
+ static Stream<WorkflowTracker<WorkflowMeta>> trackerProvider() {
+ return Stream.of(
+ new WorkflowTracker<>(mockWorkflowMeta("parent")),
+ new WorkflowTracker<>(mockWorkflowMeta("parent"), JOBS_LIMIT));
}
private static WorkflowMeta mockWorkflowMeta(String name) {
@@ -81,14 +74,9 @@ public class WorkflowTrackerConcurrencyTest {
return meta;
}
- private final WorkflowTracker tracker;
-
- public WorkflowTrackerConcurrencyTest(WorkflowTracker tracker) {
- this.tracker = tracker;
- }
-
- @Test
- public void readAndUpdateTrackerConcurrently() throws Exception {
+ @ParameterizedTest
+ @MethodSource("trackerProvider")
+ void readAndUpdateTrackerConcurrently(WorkflowTracker<WorkflowMeta> tracker) throws Exception {
final AtomicBoolean condition = new AtomicBoolean(true);
List<Getter> getters = new ArrayList<>(GETTERS_AMOUNT);
@@ -100,7 +88,7 @@ public class WorkflowTrackerConcurrencyTest {
for (int i = 0; i < SEARCHERS_AMOUNT; i++) {
int lookingFor = UPDATERS_AMOUNT * UPDATERS_CYCLES / 2 + i;
assertTrue(
- "We are looking for reachable index", lookingFor < UPDATERS_AMOUNT * UPDATERS_CYCLES);
+ lookingFor < UPDATERS_AMOUNT * UPDATERS_CYCLES, "We are looking for reachable index");
searchers.add(
new Searcher(condition, tracker, mockActionMeta("workflow-action-" + lookingFor)));
}
@@ -111,7 +99,6 @@ public class WorkflowTrackerConcurrencyTest {
updaters.add(new Updater(tracker, UPDATERS_CYCLES, generator, "workflow-action-%d"));
}
- //noinspection unchecked
ConcurrencyTestRunner.runAndCheckNoExceptionRaised(
updaters, ListUtils.union(getters, searchers), condition);
assertEquals(UPDATERS_AMOUNT * UPDATERS_CYCLES, generator.get());
@@ -124,10 +111,10 @@ public class WorkflowTrackerConcurrencyTest {
}
private static class Getter extends StopOnErrorCallable<Object> {
- private final WorkflowTracker tracker;
+ private final WorkflowTracker<?> tracker;
private final Random random;
- public Getter(AtomicBoolean condition, WorkflowTracker tracker) {
+ public Getter(AtomicBoolean condition, WorkflowTracker<?> tracker) {
super(condition);
this.tracker = tracker;
this.random = new Random();
@@ -141,7 +128,8 @@ public class WorkflowTrackerConcurrencyTest {
continue;
}
int i = random.nextInt(amount);
- WorkflowTracker t = tracker.getWorkflowTracker(i);
+ @SuppressWarnings("unchecked")
+ WorkflowTracker<WorkflowMeta> t = tracker.getWorkflowTracker(i);
if (t == null) {
throw new IllegalStateException(
String.format(
@@ -154,10 +142,11 @@ public class WorkflowTrackerConcurrencyTest {
}
private static class Searcher extends StopOnErrorCallable<Object> {
- private final WorkflowTracker tracker;
+ private final WorkflowTracker<WorkflowMeta> tracker;
private final ActionMeta copy;
- public Searcher(AtomicBoolean condition, WorkflowTracker tracker, ActionMeta copy) {
+ public Searcher(
+ AtomicBoolean condition, WorkflowTracker<WorkflowMeta> tracker, ActionMeta copy) {
super(condition);
this.tracker = tracker;
this.copy = copy;
@@ -174,13 +163,16 @@ public class WorkflowTrackerConcurrencyTest {
}
private static class Updater implements Callable<Exception> {
- private final WorkflowTracker tracker;
+ private final WorkflowTracker<WorkflowMeta> tracker;
private final int cycles;
private final AtomicInteger idGenerator;
private final String resultNameTemplate;
public Updater(
- WorkflowTracker tracker, int cycles, AtomicInteger idGenerator, String resultNameTemplate) {
+ WorkflowTracker<WorkflowMeta> tracker,
+ int cycles,
+ AtomicInteger idGenerator,
+ String resultNameTemplate) {
this.tracker = tracker;
this.cycles = cycles;
this.idGenerator = idGenerator;
@@ -195,7 +187,8 @@ public class WorkflowTrackerConcurrencyTest {
int id = idGenerator.getAndIncrement();
ActionResult result = new ActionResult();
result.setActionName(String.format(resultNameTemplate, id));
- WorkflowTracker child = new WorkflowTracker(mockWorkflowMeta("child-" + id), result);
+ WorkflowTracker<WorkflowMeta> child =
+ new WorkflowTracker<>(mockWorkflowMeta("child-" + id), result);
tracker.addWorkflowTracker(child);
}
} catch (Exception e) {
diff --git a/engine/src/test/java/org/apache/hop/core/ConcurrentMapPropertiesTest.java b/engine/src/test/java/org/apache/hop/core/ConcurrentMapPropertiesTest.java
index 65dbd9fe6a..4d76efd4ed 100644
--- a/engine/src/test/java/org/apache/hop/core/ConcurrentMapPropertiesTest.java
+++ b/engine/src/test/java/org/apache/hop/core/ConcurrentMapPropertiesTest.java
@@ -16,6 +16,9 @@
*/
package org.apache.hop.core;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
@@ -27,13 +30,12 @@ import java.util.Map;
import java.util.Properties;
import java.util.UUID;
import java.util.stream.Collectors;
-import org.junit.Assert;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
-public class ConcurrentMapPropertiesTest {
+class ConcurrentMapPropertiesTest {
@Test
- public void runMapTests() throws IOException {
+ void runMapTests() throws IOException {
Properties p = new Properties();
ConcurrentMapProperties c = new ConcurrentMapProperties();
@@ -43,8 +45,8 @@ public class ConcurrentMapPropertiesTest {
c.put(unique, unique);
}
- Assert.assertEquals(p, c);
- Assert.assertEquals(p.size(), c.size());
+ assertEquals(p, c);
+ assertEquals(p.size(), c.size());
List<String> removeKeys = new ArrayList<>(c.size());
@@ -59,24 +61,24 @@ public class ConcurrentMapPropertiesTest {
p.remove(rmKey);
}
- Assert.assertEquals(p.size(), c.size());
- Assert.assertEquals(p, c);
+ assertEquals(p.size(), c.size());
+ assertEquals(p, c);
p.clear();
c.clear();
- Assert.assertEquals(p, c);
- Assert.assertEquals(0, p.size());
- Assert.assertEquals(0, c.size());
+ assertEquals(p, c);
+ assertEquals(0, p.size());
+ assertEquals(0, c.size());
Map<String, String> addKeys = removeKeys.stream().collect(Collectors.toMap(x -> x, x -> x));
p.putAll(addKeys);
c.putAll(addKeys);
- Assert.assertEquals(p, c);
+ assertEquals(p, c);
for (String property : removeKeys) {
- Assert.assertEquals(p.getProperty(property), c.getProperty(property));
+ assertEquals(p.getProperty(property), c.getProperty(property));
}
Path tempFile = Files.createTempFile("propstest", "props");
@@ -84,10 +86,10 @@ public class ConcurrentMapPropertiesTest {
c.store(new FileOutputStream(tempFile.toFile()), "No Comments");
c.clear();
- Assert.assertEquals(0, c.size());
+ assertTrue(c.isEmpty());
c.load(new FileInputStream(tempFile.toFile()));
- Assert.assertEquals(c, p);
+ assertEquals(c, p);
}
}
diff --git a/engine/src/test/java/org/apache/hop/core/NotePadMetaTest.java b/engine/src/test/java/org/apache/hop/core/NotePadMetaTest.java
index df87ce972a..bf6bce6794 100644
--- a/engine/src/test/java/org/apache/hop/core/NotePadMetaTest.java
+++ b/engine/src/test/java/org/apache/hop/core/NotePadMetaTest.java
@@ -18,17 +18,17 @@
package org.apache.hop.core;
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
import org.apache.hop.core.xml.XmlHandler;
import org.apache.hop.metadata.serializer.xml.XmlMetadataUtil;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import org.w3c.dom.Node;
-public class NotePadMetaTest {
+class NotePadMetaTest {
@Test
- public void testSerialization() throws Exception {
+ void testSerialization() throws Exception {
NotePadMeta note = new NotePadMeta();
note.setNote("This is a test");
diff --git a/engine/src/test/java/org/apache/hop/core/attributes/AttributesUtilTest.java b/engine/src/test/java/org/apache/hop/core/attributes/AttributesUtilTest.java
index ded91ed666..f9fa3ee0ef 100644
--- a/engine/src/test/java/org/apache/hop/core/attributes/AttributesUtilTest.java
+++ b/engine/src/test/java/org/apache/hop/core/attributes/AttributesUtilTest.java
@@ -17,22 +17,24 @@
package org.apache.hop.core.attributes;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.anyString;
import static org.mockito.ArgumentMatchers.nullable;
import java.util.HashMap;
import java.util.Map;
-import org.junit.AfterClass;
-import org.junit.BeforeClass;
-import org.junit.Test;
+import org.junit.jupiter.api.AfterAll;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.Test;
import org.mockito.MockedStatic;
import org.mockito.Mockito;
import org.w3c.dom.Node;
-public class AttributesUtilTest {
+/** Unit test for {@link AttributesUtil} */
+@SuppressWarnings("unchecked")
+class AttributesUtilTest {
private static MockedStatic<AttributesUtil> mockedAttributesUtil;
@@ -41,19 +43,18 @@ public class AttributesUtilTest {
private static final String A_VALUE = "aVALUE";
private static final String A_GROUP = "attributesGroup";
- @BeforeClass
- public static void setUpStaticMocks() {
+ @BeforeAll
+ static void setUpStaticMocks() {
mockedAttributesUtil = Mockito.mockStatic(AttributesUtil.class);
}
- @AfterClass
- public static void tearDownStaticMocks() {
+ @AfterAll
+ static void tearDownStaticMocks() {
mockedAttributesUtil.close();
}
@Test
- public void testGetAttributesXml_DefaultTag() {
-
+ void testGetAttributesXml_DefaultTag() {
mockedAttributesUtil
.when(() -> AttributesUtil.getAttributesXml(any(Map.class)))
.thenCallRealMethod();
@@ -85,8 +86,7 @@ public class AttributesUtilTest {
}
@Test
- public void testGetAttributesXml_CustomTag() {
-
+ void testGetAttributesXml_CustomTag() {
mockedAttributesUtil
.when(() -> AttributesUtil.getAttributesXml(any(Map.class), anyString()))
.thenCallRealMethod();
@@ -112,8 +112,7 @@ public class AttributesUtilTest {
}
@Test
- public void testGetAttributesXml_DefaultTag_NullParameter() {
-
+ void testGetAttributesXml_DefaultTag_NullParameter() {
mockedAttributesUtil
.when(() -> AttributesUtil.getAttributesXml(nullable(Map.class)))
.thenCallRealMethod();
@@ -130,8 +129,7 @@ public class AttributesUtilTest {
}
@Test
- public void testGetAttributesXml_CustomTag_NullParameter() {
-
+ void testGetAttributesXml_CustomTag_NullParameter() {
mockedAttributesUtil
.when(() -> AttributesUtil.getAttributesXml(nullable(Map.class), nullable(String.class)))
.thenCallRealMethod();
@@ -145,8 +143,7 @@ public class AttributesUtilTest {
}
@Test
- public void testGetAttributesXml_DefaultTag_EmptyMap() {
-
+ void testGetAttributesXml_DefaultTag_EmptyMap() {
mockedAttributesUtil
.when(() -> AttributesUtil.getAttributesXml(any(Map.class)))
.thenCallRealMethod();
@@ -165,8 +162,7 @@ public class AttributesUtilTest {
}
@Test
- public void testGetAttributesXml_CustomTag_EmptyMap() {
-
+ void testGetAttributesXml_CustomTag_EmptyMap() {
mockedAttributesUtil
.when(() -> AttributesUtil.getAttributesXml(any(Map.class), anyString()))
.thenCallRealMethod();
@@ -182,8 +178,7 @@ public class AttributesUtilTest {
}
@Test
- public void testLoadAttributes_NullParameter() {
-
+ void testLoadAttributes_NullParameter() {
mockedAttributesUtil
.when(() -> AttributesUtil.loadAttributes(any(Node.class)))
.thenCallRealMethod();
diff --git a/engine/src/test/java/org/apache/hop/core/auth/core/AuthenticationManagerTest.java b/engine/src/test/java/org/apache/hop/core/auth/core/AuthenticationManagerTest.java
index 2640d2c0cb..ea1c99c488 100644
--- a/engine/src/test/java/org/apache/hop/core/auth/core/AuthenticationManagerTest.java
+++ b/engine/src/test/java/org/apache/hop/core/auth/core/AuthenticationManagerTest.java
@@ -17,8 +17,8 @@
package org.apache.hop.core.auth.core;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
@@ -36,23 +36,25 @@ import org.apache.hop.core.auth.KerberosAuthenticationProvider;
import org.apache.hop.core.auth.NoAuthenticationAuthenticationProvider;
import org.apache.hop.core.auth.UsernamePasswordAuthenticationProvider;
import org.apache.hop.core.auth.core.impl.ClassloaderBridgingAuthenticationPerformer;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
import org.mockito.ArgumentCaptor;
-public class AuthenticationManagerTest {
+/** Unit test for {@link AuthenticationManager} */
+@SuppressWarnings("unchecked")
+class AuthenticationManagerTest {
private AuthenticationManager manager;
private NoAuthenticationAuthenticationProvider noAuthenticationAuthenticationProvider;
- @Before
- public void setup() {
+ @BeforeEach
+ void setup() {
manager = new AuthenticationManager();
noAuthenticationAuthenticationProvider = new NoAuthenticationAuthenticationProvider();
manager.registerAuthenticationProvider(noAuthenticationAuthenticationProvider);
}
@Test
- public void testNoAuthProviderAndConsumer()
+ void testNoAuthProviderAndConsumer()
throws AuthenticationConsumptionException, AuthenticationFactoryException {
manager.registerConsumerClass(DelegatingNoAuthConsumer.class);
IAuthenticationConsumer<Object, NoAuthenticationAuthenticationProvider> consumer =
@@ -67,7 +69,7 @@ public class AuthenticationManagerTest {
}
@Test
- public void testUsernamePasswordProviderConsumer()
+ void testUsernamePasswordProviderConsumer()
throws AuthenticationConsumptionException, AuthenticationFactoryException {
manager.registerConsumerClass(DelegatingNoAuthConsumer.class);
manager.registerConsumerClass(DelegatingUsernamePasswordConsumer.class);
@@ -86,7 +88,7 @@ public class AuthenticationManagerTest {
}
@Test
- public void testKerberosProviderConsumer()
+ void testKerberosProviderConsumer()
throws AuthenticationConsumptionException, AuthenticationFactoryException {
manager.registerConsumerClass(DelegatingNoAuthConsumer.class);
manager.registerConsumerClass(DelegatingUsernamePasswordConsumer.class);
@@ -104,7 +106,7 @@ public class AuthenticationManagerTest {
}
@Test
- public void testGetSupportedPerformers() throws AuthenticationFactoryException {
+ void testGetSupportedPerformers() throws AuthenticationFactoryException {
manager.registerConsumerClass(DelegatingNoAuthConsumer.class);
manager.registerConsumerClass(DelegatingUsernamePasswordConsumer.class);
manager.registerConsumerClass(DelegatingKerberosConsumer.class);
@@ -130,14 +132,13 @@ public class AuthenticationManagerTest {
}
@Test
- public void testRegisterUnregisterProvider() throws AuthenticationFactoryException {
+ void testRegisterUnregisterProvider() throws AuthenticationFactoryException {
manager.registerConsumerClass(DelegatingNoAuthConsumer.class);
manager.registerConsumerClass(DelegatingUsernamePasswordConsumer.class);
List<IAuthenticationPerformer<Object, IAuthenticationConsumer>> performers =
manager.getSupportedAuthenticationPerformers(Object.class, IAuthenticationConsumer.class);
assertEquals(1, performers.size());
- Set<String> ids =
- new HashSet<>(Arrays.asList(NoAuthenticationAuthenticationProvider.NO_AUTH_ID));
+ Set<String> ids = new HashSet<>(List.of(NoAuthenticationAuthenticationProvider.NO_AUTH_ID));
for (IAuthenticationPerformer<Object, IAuthenticationConsumer> performer : performers) {
ids.remove(performer.getAuthenticationProvider().getId());
}
@@ -161,7 +162,7 @@ public class AuthenticationManagerTest {
performers =
manager.getSupportedAuthenticationPerformers(Object.class, IAuthenticationConsumer.class);
assertEquals(1, performers.size());
- ids = new HashSet<>(Arrays.asList(NoAuthenticationAuthenticationProvider.NO_AUTH_ID));
+ ids = new HashSet<>(List.of(NoAuthenticationAuthenticationProvider.NO_AUTH_ID));
for (IAuthenticationPerformer<Object, IAuthenticationConsumer> performer : performers) {
ids.remove(performer.getAuthenticationProvider().getId());
}
@@ -169,7 +170,7 @@ public class AuthenticationManagerTest {
}
@Test
- public void testRegisterConsumerFactory()
+ void testRegisterConsumerFactory()
throws AuthenticationConsumptionException, AuthenticationFactoryException {
IAuthenticationConsumer<Object, KerberosAuthenticationProvider> authConsumer =
mock(IAuthenticationConsumer.class);
@@ -191,17 +192,15 @@ public class AuthenticationManagerTest {
}
@Test
- public void testClassLoaderBridgingPerformer()
+ void testClassLoaderBridgingPerformer()
throws AuthenticationConsumptionException, AuthenticationFactoryException {
manager.setAuthenticationPerformerFactory(
new IAuthenticationPerformerFactory() {
@Override
- public <ReturnType, CreateArgType, ConsumedType>
- IAuthenticationPerformer<ReturnType, CreateArgType> create(
- IAuthenticationProvider authenticationProvider,
- IAuthenticationConsumerFactory<ReturnType, CreateArgType, ConsumedType>
- authenticationConsumer) {
+ public <R, C, T> IAuthenticationPerformer<R, C> create(
+ IAuthenticationProvider authenticationProvider,
+ IAuthenticationConsumerFactory<R, C, T> authenticationConsumer) {
if (AuthenticationConsumerInvocationHandler.isCompatible(
authenticationConsumer.getConsumedType(), authenticationProvider)) {
return new ClassloaderBridgingAuthenticationPerformer<>(
diff --git a/engine/src/test/java/org/apache/hop/core/auth/core/impl/DefaultAuthenticationConsumerFactoryTest.java b/engine/src/test/java/org/apache/hop/core/auth/core/impl/DefaultAuthenticationConsumerFactoryTest.java
index 1840634043..c133b5f9e9 100644
--- a/engine/src/test/java/org/apache/hop/core/auth/core/impl/DefaultAuthenticationConsumerFactoryTest.java
+++ b/engine/src/test/java/org/apache/hop/core/auth/core/impl/DefaultAuthenticationConsumerFactoryTest.java
@@ -17,32 +17,42 @@
package org.apache.hop.core.auth.core.impl;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertThrows;
+
import org.apache.hop.core.auth.DelegatingKerberosConsumer;
import org.apache.hop.core.auth.core.AuthenticationFactoryException;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
-public class DefaultAuthenticationConsumerFactoryTest {
- @Test(expected = AuthenticationFactoryException.class)
- public void testDefaultAuthenticationConsumerFactoryFailsWithMultipleConstructors()
- throws AuthenticationFactoryException {
- new DefaultAuthenticationConsumerFactory(TwoConstructorConsumer.class);
+/** Unit test for {@link DefaultAuthenticationConsumerFactory} */
+class DefaultAuthenticationConsumerFactoryTest {
+
+ @Test
+ void testDefaultAuthenticationConsumerFactoryFailsWithMultipleConstructors() {
+ assertThrows(
+ AuthenticationFactoryException.class,
+ () -> new DefaultAuthenticationConsumerFactory(TwoConstructorConsumer.class));
}
- @Test(expected = AuthenticationFactoryException.class)
- public void testDefaultAuthenticationConsumerFactoryFailsWithWrongConstructorArgCount()
- throws AuthenticationFactoryException {
- new DefaultAuthenticationConsumerFactory(TwoConstructorArgConsumer.class);
+ @Test
+ void testDefaultAuthenticationConsumerFactoryFailsWithWrongConstructorArgCount() {
+ assertThrows(
+ AuthenticationFactoryException.class,
+ () -> new DefaultAuthenticationConsumerFactory(TwoConstructorArgConsumer.class));
}
- @Test(expected = AuthenticationFactoryException.class)
- public void testDefaultAuthenticationConsumerFactoryFailsNoConsumeMethod()
- throws AuthenticationFactoryException {
- new DefaultAuthenticationConsumerFactory(NoConsumeConsumer.class);
+ @Test
+ void testDefaultAuthenticationConsumerFactoryFailsNoConsumeMethod() {
+ assertThrows(
+ AuthenticationFactoryException.class,
+ () -> new DefaultAuthenticationConsumerFactory(TwoConstructorArgConsumer.class));
}
@Test
- public void testDefaultAuthenticationConsumerFactorySucceedsWithConsumer()
+ void testDefaultAuthenticationConsumerFactorySucceedsWithConsumer()
throws AuthenticationFactoryException {
- new DefaultAuthenticationConsumerFactory(DelegatingKerberosConsumer.class);
+ DefaultAuthenticationConsumerFactory factory =
+ new DefaultAuthenticationConsumerFactory(DelegatingKerberosConsumer.class);
+ assertNotNull(factory);
}
}
diff --git a/engine/src/test/java/org/apache/hop/core/compress/CompressionInputStreamTest.java b/engine/src/test/java/org/apache/hop/core/compress/CompressionInputStreamTest.java
index 304ce8c364..2da193bbbd 100644
--- a/engine/src/test/java/org/apache/hop/core/compress/CompressionInputStreamTest.java
+++ b/engine/src/test/java/org/apache/hop/core/compress/CompressionInputStreamTest.java
@@ -17,9 +17,9 @@
package org.apache.hop.core.compress;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNull;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertNull;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.anyInt;
import static org.mockito.Mockito.spy;
@@ -29,29 +29,27 @@ import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.InputStream;
import org.apache.hop.core.plugins.PluginRegistry;
-import org.apache.hop.junit.rules.RestoreHopEngineEnvironment;
-import org.junit.Before;
-import org.junit.BeforeClass;
-import org.junit.ClassRule;
-import org.junit.Test;
+import org.apache.hop.junit.rules.RestoreHopEnvironmentExtension;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.ExtendWith;
-public class CompressionInputStreamTest {
+@ExtendWith(RestoreHopEnvironmentExtension.class)
+class CompressionInputStreamTest {
+ static final String PROVIDER_NAME = "None";
- @ClassRule public static RestoreHopEngineEnvironment env = new RestoreHopEngineEnvironment();
+ CompressionProviderFactory factory = null;
+ CompressionInputStream inStream = null;
- public static final String PROVIDER_NAME = "None";
-
- public CompressionProviderFactory factory = null;
- public CompressionInputStream inStream = null;
-
- @BeforeClass
- public static void setUpBeforeClass() throws Exception {
+ @BeforeAll
+ static void setUpBeforeClass() throws Exception {
PluginRegistry.addPluginType(CompressionPluginType.getInstance());
PluginRegistry.init();
}
- @Before
- public void setUp() {
+ @BeforeEach
+ void setUp() {
factory = CompressionProviderFactory.getInstance();
ICompressionProvider provider = factory.getCompressionProviderByName(PROVIDER_NAME);
ByteArrayInputStream in = createTestInputStream();
@@ -59,31 +57,32 @@ public class CompressionInputStreamTest {
}
@Test
- public void testCtor() {
+ void testCtor() {
assertNotNull(inStream);
}
@Test
- public void getCompressionProvider() {
+ void getCompressionProvider() {
ICompressionProvider provider = inStream.getCompressionProvider();
assertEquals(PROVIDER_NAME, provider.getName());
}
@Test
- public void testNextEntry() throws IOException {
+ void testNextEntry() throws IOException {
assertNull(inStream.nextEntry());
}
@Test
- public void testClose() throws IOException {
+ void testClose() throws IOException {
ICompressionProvider provider = inStream.getCompressionProvider();
ByteArrayInputStream in = createTestInputStream();
inStream = new DummyCompressionIS(in, provider);
+ assertNotNull(inStream);
inStream.close();
}
@Test
- public void testRead() throws IOException {
+ void testRead() throws IOException {
ICompressionProvider provider = inStream.getCompressionProvider();
ByteArrayInputStream in = createTestInputStream();
inStream = new DummyCompressionIS(in, provider);
@@ -91,7 +90,7 @@ public class CompressionInputStreamTest {
}
@Test
- public void delegatesReadBuffer() throws Exception {
+ void delegatesReadBuffer() throws Exception {
ByteArrayInputStream in = createTestInputStream();
in = spy(in);
inStream = new DummyCompressionIS(in, inStream.getCompressionProvider());
@@ -100,7 +99,7 @@ public class CompressionInputStreamTest {
}
@Test
- public void delegatesReadBufferWithParams() throws Exception {
+ void delegatesReadBufferWithParams() throws Exception {
ByteArrayInputStream in = createTestInputStream();
in = spy(in);
inStream = new DummyCompressionIS(in, inStream.getCompressionProvider());
@@ -113,7 +112,7 @@ public class CompressionInputStreamTest {
}
private static class DummyCompressionIS extends CompressionInputStream {
- public DummyCompressionIS(InputStream in, ICompressionProvider provider) {
+ DummyCompressionIS(InputStream in, ICompressionProvider provider) {
super(in, provider);
}
}
diff --git a/engine/src/test/java/org/apache/hop/core/compress/CompressionOutputStreamTest.java b/engine/src/test/java/org/apache/hop/core/compress/CompressionOutputStreamTest.java
index aa0465eb4f..def2e2e9ec 100644
--- a/engine/src/test/java/org/apache/hop/core/compress/CompressionOutputStreamTest.java
+++ b/engine/src/test/java/org/apache/hop/core/compress/CompressionOutputStreamTest.java
@@ -17,36 +17,34 @@
package org.apache.hop.core.compress;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.OutputStream;
import org.apache.hop.core.plugins.PluginRegistry;
-import org.apache.hop.junit.rules.RestoreHopEngineEnvironment;
-import org.junit.Before;
-import org.junit.BeforeClass;
-import org.junit.ClassRule;
-import org.junit.Test;
+import org.apache.hop.junit.rules.RestoreHopEnvironmentExtension;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.ExtendWith;
-public class CompressionOutputStreamTest {
+@ExtendWith(RestoreHopEnvironmentExtension.class)
+class CompressionOutputStreamTest {
+ static final String PROVIDER_NAME = "None";
- @ClassRule public static RestoreHopEngineEnvironment env = new RestoreHopEngineEnvironment();
+ CompressionProviderFactory factory = null;
+ CompressionOutputStream outStream = null;
- public static final String PROVIDER_NAME = "None";
-
- public CompressionProviderFactory factory = null;
- public CompressionOutputStream outStream = null;
-
- @BeforeClass
- public static void setUpBeforeClass() throws Exception {
+ @BeforeAll
+ static void setUpBeforeClass() throws Exception {
PluginRegistry.addPluginType(CompressionPluginType.getInstance());
PluginRegistry.init();
}
- @Before
- public void setUp() {
+ @BeforeEach
+ void setUp() {
factory = CompressionProviderFactory.getInstance();
ICompressionProvider provider = factory.getCompressionProviderByName(PROVIDER_NAME);
ByteArrayOutputStream in = new ByteArrayOutputStream();
@@ -54,42 +52,45 @@ public class CompressionOutputStreamTest {
}
@Test
- public void testCtor() {
+ void testCtor() {
assertNotNull(outStream);
}
@Test
- public void getCompressionProvider() {
+ void getCompressionProvider() {
ICompressionProvider provider = outStream.getCompressionProvider();
assertEquals(PROVIDER_NAME, provider.getName());
}
@Test
- public void testClose() throws IOException {
+ void testClose() throws IOException {
ICompressionProvider provider = outStream.getCompressionProvider();
ByteArrayOutputStream out = new ByteArrayOutputStream();
outStream = new DummyCompressionOS(out, provider);
+ assertNotNull(outStream);
outStream.close();
}
@Test
- public void testWrite() throws IOException {
+ void testWrite() throws IOException {
ICompressionProvider provider = outStream.getCompressionProvider();
ByteArrayOutputStream out = new ByteArrayOutputStream();
outStream = new DummyCompressionOS(out, provider);
+ assertNotNull(outStream);
outStream.write("Test".getBytes());
}
@Test
- public void testAddEntry() throws IOException {
+ void testAddEntry() throws IOException {
ICompressionProvider provider = outStream.getCompressionProvider();
ByteArrayOutputStream out = new ByteArrayOutputStream();
outStream = new DummyCompressionOS(out, provider);
+ assertNotNull(outStream);
outStream.addEntry(null, null);
}
private static class DummyCompressionOS extends CompressionOutputStream {
- public DummyCompressionOS(OutputStream out, ICompressionProvider provider) {
+ DummyCompressionOS(OutputStream out, ICompressionProvider provider) {
super(out, provider);
}
}
diff --git a/engine/src/test/java/org/apache/hop/core/compress/CompressionPluginTypeTest.java b/engine/src/test/java/org/apache/hop/core/compress/CompressionPluginTypeTest.java
index 770fb98a8a..5be642f164 100644
--- a/engine/src/test/java/org/apache/hop/core/compress/CompressionPluginTypeTest.java
+++ b/engine/src/test/java/org/apache/hop/core/compress/CompressionPluginTypeTest.java
@@ -17,19 +17,19 @@
package org.apache.hop.core.compress;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNotSame;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertSame;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertNotSame;
+import static org.junit.jupiter.api.Assertions.assertNull;
+import static org.junit.jupiter.api.Assertions.assertSame;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
-public class CompressionPluginTypeTest {
+class CompressionPluginTypeTest {
@Test
- public void testGetInstance() {
+ void testGetInstance() {
CompressionPluginType instance = CompressionPluginType.getInstance();
CompressionPluginType instance2 = CompressionPluginType.getInstance();
assertSame(instance, instance2);
@@ -40,9 +40,9 @@ public class CompressionPluginTypeTest {
}
@Test
- public void testGetPluginInfo() {
+ void testGetPluginInfo() {
CompressionPluginType instance = CompressionPluginType.getInstance();
- CompressionPlugin a = new FakePlugin().getClass().getAnnotation(CompressionPlugin.class);
+ CompressionPlugin a = FakePlugin.class.getAnnotation(CompressionPlugin.class);
assertNotNull(a);
assertEquals("", instance.extractCategory(a));
assertEquals("Fake", instance.extractID(a));
@@ -56,5 +56,5 @@ public class CompressionPluginTypeTest {
}
@CompressionPlugin(id = "Fake", name = "FakePlugin")
- private class FakePlugin {}
+ private static class FakePlugin {}
}
diff --git a/engine/src/test/java/org/apache/hop/core/compress/CompressionProviderFactoryTest.java b/engine/src/test/java/org/apache/hop/core/compress/CompressionProviderFactoryTest.java
index e3a9212439..0a009f46a9 100644
--- a/engine/src/test/java/org/apache/hop/core/compress/CompressionProviderFactoryTest.java
+++ b/engine/src/test/java/org/apache/hop/core/compress/CompressionProviderFactoryTest.java
@@ -17,10 +17,10 @@
package org.apache.hop.core.compress;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
import java.util.Collection;
import java.util.HashMap;
@@ -29,35 +29,35 @@ import org.apache.hop.core.compress.hadoopsnappy.HadoopSnappyCompressionProvider
import org.apache.hop.core.compress.snappy.SnappyCompressionProvider;
import org.apache.hop.core.compress.zip.ZipCompressionProvider;
import org.apache.hop.core.plugins.PluginRegistry;
-import org.apache.hop.junit.rules.RestoreHopEngineEnvironment;
-import org.junit.Before;
-import org.junit.BeforeClass;
-import org.junit.ClassRule;
-import org.junit.Test;
+import org.apache.hop.junit.rules.RestoreHopEnvironmentExtension;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.ExtendWith;
-public class CompressionProviderFactoryTest {
- @ClassRule public static RestoreHopEngineEnvironment env = new RestoreHopEngineEnvironment();
+@ExtendWith(RestoreHopEnvironmentExtension.class)
+class CompressionProviderFactoryTest {
- public CompressionProviderFactory factory = null;
+ CompressionProviderFactory factory = null;
- @BeforeClass
- public static void setUpBeforeClass() throws Exception {
+ @BeforeAll
+ static void setUpBeforeClass() throws Exception {
PluginRegistry.addPluginType(CompressionPluginType.getInstance());
PluginRegistry.init();
}
- @Before
- public void setUp() {
+ @BeforeEach
+ void setUp() {
factory = CompressionProviderFactory.getInstance();
}
@Test
- public void testGetInstance() {
+ void testGetInstance() {
assertNotNull(factory);
}
@Test
- public void testCreateCoreProviders() {
+ void testCreateCoreProviders() {
ICompressionProvider provider = factory.createCompressionProviderInstance("None");
assertNotNull(provider);
assertTrue(provider.getClass().isAssignableFrom(NoneCompressionProvider.class));
@@ -94,7 +94,7 @@ public class CompressionProviderFactoryTest {
* factory
*/
@Test
- public void getCoreProviderNames() {
+ void getCoreProviderNames() {
final HashMap<String, Boolean> foundProvider =
new HashMap<>() {
{
@@ -123,7 +123,7 @@ public class CompressionProviderFactoryTest {
/** Test that all core compression plugins (None, Zip, GZip) are available via the factory */
@Test
- public void getCoreProviders() {
+ void getCoreProviders() {
final HashMap<String, Boolean> foundProvider =
new HashMap<>() {
{
@@ -151,7 +151,7 @@ public class CompressionProviderFactoryTest {
}
@Test
- public void getNonExistentProvider() {
+ void getNonExistentProvider() {
ICompressionProvider provider = factory.createCompressionProviderInstance("Fake");
assertNull(provider);
provider = factory.getCompressionProviderByName(null);
diff --git a/engine/src/test/java/org/apache/hop/core/compress/NoneCompressionProviderTest.java b/engine/src/test/java/org/apache/hop/core/compress/NoneCompressionProviderTest.java
index 9fcfc2af67..da009bee32 100644
--- a/engine/src/test/java/org/apache/hop/core/compress/NoneCompressionProviderTest.java
+++ b/engine/src/test/java/org/apache/hop/core/compress/NoneCompressionProviderTest.java
@@ -17,10 +17,10 @@
package org.apache.hop.core.compress;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
@@ -28,38 +28,37 @@ import java.io.IOException;
import org.apache.hop.core.compress.NoneCompressionProvider.NoneCompressionInputStream;
import org.apache.hop.core.compress.NoneCompressionProvider.NoneCompressionOutputStream;
import org.apache.hop.core.plugins.PluginRegistry;
-import org.apache.hop.junit.rules.RestoreHopEngineEnvironment;
-import org.junit.Before;
-import org.junit.BeforeClass;
-import org.junit.ClassRule;
-import org.junit.Test;
+import org.apache.hop.junit.rules.RestoreHopEnvironmentExtension;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.ExtendWith;
-public class NoneCompressionProviderTest {
- @ClassRule public static RestoreHopEngineEnvironment env = new RestoreHopEngineEnvironment();
+@ExtendWith(RestoreHopEnvironmentExtension.class)
+class NoneCompressionProviderTest {
+ static final String PROVIDER_NAME = "None";
- public static final String PROVIDER_NAME = "None";
+ CompressionProviderFactory factory = null;
- public CompressionProviderFactory factory = null;
-
- @BeforeClass
- public static void setUpBeforeClass() throws Exception {
+ @BeforeAll
+ static void setUpBeforeClass() throws Exception {
PluginRegistry.addPluginType(CompressionPluginType.getInstance());
PluginRegistry.init();
}
- @Before
- public void setUp() {
+ @BeforeEach
+ void setUp() {
factory = CompressionProviderFactory.getInstance();
}
@Test
- public void testCtor() {
+ void testCtor() {
NoneCompressionProvider ncp = new NoneCompressionProvider();
assertNotNull(ncp);
}
@Test
- public void testGetName() {
+ void testGetName() {
NoneCompressionProvider provider =
(NoneCompressionProvider) factory.getCompressionProviderByName(PROVIDER_NAME);
assertNotNull(provider);
@@ -67,7 +66,7 @@ public class NoneCompressionProviderTest {
}
@Test
- public void testGetProviderAttributes() {
+ void testGetProviderAttributes() {
NoneCompressionProvider provider =
(NoneCompressionProvider) factory.getCompressionProviderByName(PROVIDER_NAME);
assertEquals("No compression", provider.getDescription());
@@ -77,7 +76,7 @@ public class NoneCompressionProviderTest {
}
@Test
- public void testCreateInputStream() throws IOException {
+ void testCreateInputStream() throws IOException {
NoneCompressionProvider provider =
(NoneCompressionProvider) factory.getCompressionProviderByName(PROVIDER_NAME);
ByteArrayInputStream in = new ByteArrayInputStream("Test".getBytes());
@@ -88,7 +87,7 @@ public class NoneCompressionProviderTest {
}
@Test
- public void testCreateOutputStream() throws IOException {
+ void testCreateOutputStream() throws IOException {
NoneCompressionProvider provider =
(NoneCompressionProvider) factory.getCompressionProviderByName(PROVIDER_NAME);
ByteArrayOutputStream out = new ByteArrayOutputStream();
diff --git a/engine/src/test/java/org/apache/hop/core/compress/gzip/GzipCompressionInputStreamTest.java b/engine/src/test/java/org/apache/hop/core/compress/gzip/GzipCompressionInputStreamTest.java
index 2af42ea31d..633d205771 100644
--- a/engine/src/test/java/org/apache/hop/core/compress/gzip/GzipCompressionInputStreamTest.java
+++ b/engine/src/test/java/org/apache/hop/core/compress/gzip/GzipCompressionInputStreamTest.java
@@ -17,9 +17,9 @@
package org.apache.hop.core.compress.gzip;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNull;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertNull;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
@@ -30,60 +30,62 @@ import org.apache.hop.core.compress.CompressionPluginType;
import org.apache.hop.core.compress.CompressionProviderFactory;
import org.apache.hop.core.compress.ICompressionProvider;
import org.apache.hop.core.plugins.PluginRegistry;
-import org.apache.hop.junit.rules.RestoreHopEngineEnvironment;
-import org.junit.Before;
-import org.junit.BeforeClass;
-import org.junit.ClassRule;
-import org.junit.Test;
-
-public class GzipCompressionInputStreamTest {
- @ClassRule public static RestoreHopEngineEnvironment env = new RestoreHopEngineEnvironment();
+import org.apache.hop.junit.rules.RestoreHopEnvironmentExtension;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.ExtendWith;
+@ExtendWith(RestoreHopEnvironmentExtension.class)
+class GzipCompressionInputStreamTest {
public static final String PROVIDER_NAME = "GZip";
protected CompressionProviderFactory factory = null;
protected GzipCompressionInputStream inStream = null;
protected ICompressionProvider provider = null;
- @BeforeClass
- public static void setUpBeforeClass() throws Exception {
+ @BeforeAll
+ static void setUpBeforeClass() throws Exception {
PluginRegistry.addPluginType(CompressionPluginType.getInstance());
PluginRegistry.init();
}
- @Before
- public void setUp() throws Exception {
+ @BeforeEach
+ void setUp() throws Exception {
factory = CompressionProviderFactory.getInstance();
provider = factory.getCompressionProviderByName(PROVIDER_NAME);
inStream = new GzipCompressionInputStream(createGZIPInputStream(), provider) {};
}
@Test
- public void testCtor() {
+ void testCtor() {
assertNotNull(inStream);
}
@Test
- public void getZIPCompressionProvider() {
- ICompressionProvider provider = inStream.getCompressionProvider();
- assertEquals(PROVIDER_NAME, provider.getName());
+ void getZIPCompressionProvider() {
+ ICompressionProvider p = inStream.getCompressionProvider();
+ assertEquals(PROVIDER_NAME, p.getName());
}
@Test
- public void testNextEntry() throws IOException {
+ void testNextEntry() throws IOException {
assertNull(inStream.nextEntry());
}
@Test
- public void testClose() throws IOException {
+ void testClose() throws IOException {
inStream = new GzipCompressionInputStream(createGZIPInputStream(), provider) {};
+ assertNotNull(inStream);
inStream.close();
}
@Test
- public void testRead() throws IOException {
+ void testRead() throws IOException {
inStream = new GzipCompressionInputStream(createGZIPInputStream(), provider) {};
- inStream.read(new byte[100], 0, inStream.available());
+
+ int read = inStream.read(new byte[100], 0, inStream.available());
+ assertEquals(0, read);
}
protected InputStream createGZIPInputStream() throws IOException {
diff --git a/engine/src/test/java/org/apache/hop/core/compress/gzip/GzipCompressionOutputStreamTest.java b/engine/src/test/java/org/apache/hop/core/compress/gzip/GzipCompressionOutputStreamTest.java
index 57441fbc01..79efb06066 100644
--- a/engine/src/test/java/org/apache/hop/core/compress/gzip/GzipCompressionOutputStreamTest.java
+++ b/engine/src/test/java/org/apache/hop/core/compress/gzip/GzipCompressionOutputStreamTest.java
@@ -17,9 +17,9 @@
package org.apache.hop.core.compress.gzip;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.fail;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.fail;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
@@ -27,28 +27,28 @@ import org.apache.hop.core.compress.CompressionPluginType;
import org.apache.hop.core.compress.CompressionProviderFactory;
import org.apache.hop.core.compress.ICompressionProvider;
import org.apache.hop.core.plugins.PluginRegistry;
-import org.apache.hop.junit.rules.RestoreHopEngineEnvironment;
-import org.junit.Before;
-import org.junit.BeforeClass;
-import org.junit.ClassRule;
-import org.junit.Test;
+import org.apache.hop.junit.rules.RestoreHopEnvironmentExtension;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.ExtendWith;
-public class GzipCompressionOutputStreamTest {
- @ClassRule public static RestoreHopEngineEnvironment env = new RestoreHopEngineEnvironment();
+@ExtendWith(RestoreHopEnvironmentExtension.class)
+class GzipCompressionOutputStreamTest {
public static final String PROVIDER_NAME = "GZip";
public CompressionProviderFactory factory = null;
public GzipCompressionOutputStream outStream = null;
- @BeforeClass
- public static void setUpBeforeClass() throws Exception {
+ @BeforeAll
+ static void setUpBeforeClass() throws Exception {
PluginRegistry.addPluginType(CompressionPluginType.getInstance());
PluginRegistry.init();
}
- @Before
- public void setUp() throws Exception {
+ @BeforeEach
+ void setUp() throws Exception {
factory = CompressionProviderFactory.getInstance();
ICompressionProvider provider = factory.getCompressionProviderByName(PROVIDER_NAME);
ByteArrayOutputStream in = new ByteArrayOutputStream();
@@ -56,18 +56,18 @@ public class GzipCompressionOutputStreamTest {
}
@Test
- public void testCtor() {
+ void testCtor() {
assertNotNull(outStream);
}
@Test
- public void getCompressionProvider() {
+ void getCompressionProvider() {
ICompressionProvider provider = outStream.getCompressionProvider();
assertEquals(PROVIDER_NAME, provider.getName());
}
@Test
- public void testClose() throws IOException {
+ void testClose() throws IOException {
ICompressionProvider provider = outStream.getCompressionProvider();
ByteArrayOutputStream out = new ByteArrayOutputStream();
outStream = new GzipCompressionOutputStream(out, provider) {};
@@ -81,18 +81,20 @@ public class GzipCompressionOutputStreamTest {
}
@Test
- public void testWrite() throws IOException {
+ void testWrite() throws IOException {
ICompressionProvider provider = outStream.getCompressionProvider();
ByteArrayOutputStream out = new ByteArrayOutputStream();
outStream = new GzipCompressionOutputStream(out, provider);
+ assertNotNull(outStream);
outStream.write("Test".getBytes());
}
@Test
- public void testAddEntry() throws IOException {
+ void testAddEntry() throws IOException {
ICompressionProvider provider = outStream.getCompressionProvider();
ByteArrayOutputStream out = new ByteArrayOutputStream();
outStream = new GzipCompressionOutputStream(out, provider);
+ assertNotNull(outStream);
outStream.addEntry(null, null);
}
}
diff --git a/engine/src/test/java/org/apache/hop/core/compress/gzip/GzipCompressionProviderTest.java b/engine/src/test/java/org/apache/hop/core/compress/gzip/GzipCompressionProviderTest.java
index 26058ebf94..b0b5d218b9 100644
--- a/engine/src/test/java/org/apache/hop/core/compress/gzip/GzipCompressionProviderTest.java
+++ b/engine/src/test/java/org/apache/hop/core/compress/gzip/GzipCompressionProviderTest.java
@@ -17,9 +17,9 @@
package org.apache.hop.core.compress.gzip;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
@@ -29,38 +29,37 @@ import java.util.zip.GZIPOutputStream;
import org.apache.hop.core.compress.CompressionPluginType;
import org.apache.hop.core.compress.CompressionProviderFactory;
import org.apache.hop.core.plugins.PluginRegistry;
-import org.apache.hop.junit.rules.RestoreHopEngineEnvironment;
-import org.junit.Before;
-import org.junit.BeforeClass;
-import org.junit.ClassRule;
-import org.junit.Test;
-
-public class GzipCompressionProviderTest {
- @ClassRule public static RestoreHopEngineEnvironment env = new RestoreHopEngineEnvironment();
+import org.apache.hop.junit.rules.RestoreHopEnvironmentExtension;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.ExtendWith;
+@ExtendWith(RestoreHopEnvironmentExtension.class)
+class GzipCompressionProviderTest {
public static final String PROVIDER_NAME = "GZip";
public CompressionProviderFactory factory = null;
- @BeforeClass
- public static void setUpBeforeClass() throws Exception {
+ @BeforeAll
+ static void setUpBeforeClass() throws Exception {
PluginRegistry.addPluginType(CompressionPluginType.getInstance());
PluginRegistry.init();
}
- @Before
- public void setUp() {
+ @BeforeEach
+ void setUp() {
factory = CompressionProviderFactory.getInstance();
}
@Test
- public void testCtor() {
+ void testCtor() {
GzipCompressionProvider ncp = new GzipCompressionProvider();
assertNotNull(ncp);
}
@Test
- public void testGetName() {
+ void testGetName() {
GzipCompressionProvider provider =
(GzipCompressionProvider) factory.getCompressionProviderByName(PROVIDER_NAME);
assertNotNull(provider);
@@ -68,7 +67,7 @@ public class GzipCompressionProviderTest {
}
@Test
- public void testGetProviderAttributes() {
+ void testGetProviderAttributes() {
GzipCompressionProvider provider =
(GzipCompressionProvider) factory.getCompressionProviderByName(PROVIDER_NAME);
assertEquals("GZIP compression", provider.getDescription());
@@ -78,7 +77,7 @@ public class GzipCompressionProviderTest {
}
@Test
- public void testCreateInputStream() throws IOException {
+ void testCreateInputStream() throws IOException {
GzipCompressionProvider provider =
(GzipCompressionProvider) factory.getCompressionProviderByName(PROVIDER_NAME);
@@ -99,7 +98,7 @@ public class GzipCompressionProviderTest {
}
@Test
- public void testCreateOutputStream() throws IOException {
+ void testCreateOutputStream() throws IOException {
GzipCompressionProvider provider =
(GzipCompressionProvider) factory.getCompressionProviderByName(PROVIDER_NAME);
ByteArrayOutputStream out = new ByteArrayOutputStream();
diff --git a/engine/src/test/java/org/apache/hop/core/compress/snappy/SnappyCompressionInputStreamTest.java b/engine/src/test/java/org/apache/hop/core/compress/snappy/SnappyCompressionInputStreamTest.java
index 5e505933e0..159d081826 100644
--- a/engine/src/test/java/org/apache/hop/core/compress/snappy/SnappyCompressionInputStreamTest.java
+++ b/engine/src/test/java/org/apache/hop/core/compress/snappy/SnappyCompressionInputStreamTest.java
@@ -17,9 +17,9 @@
package org.apache.hop.core.compress.snappy;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNull;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertNull;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
@@ -28,59 +28,59 @@ import org.apache.hop.core.compress.CompressionPluginType;
import org.apache.hop.core.compress.CompressionProviderFactory;
import org.apache.hop.core.compress.ICompressionProvider;
import org.apache.hop.core.plugins.PluginRegistry;
-import org.apache.hop.junit.rules.RestoreHopEngineEnvironment;
-import org.junit.Before;
-import org.junit.BeforeClass;
-import org.junit.ClassRule;
-import org.junit.Test;
+import org.apache.hop.junit.rules.RestoreHopEnvironmentExtension;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.ExtendWith;
import org.xerial.snappy.SnappyInputStream;
import org.xerial.snappy.SnappyOutputStream;
-public class SnappyCompressionInputStreamTest {
- @ClassRule public static RestoreHopEngineEnvironment env = new RestoreHopEngineEnvironment();
-
+@ExtendWith(RestoreHopEnvironmentExtension.class)
+class SnappyCompressionInputStreamTest {
public static final String PROVIDER_NAME = "Snappy";
protected CompressionProviderFactory factory = null;
protected SnappyCompressionInputStream inStream = null;
protected ICompressionProvider provider = null;
- @BeforeClass
- public static void setUpBeforeClass() throws Exception {
+ @BeforeAll
+ static void setUpBeforeClass() throws Exception {
PluginRegistry.addPluginType(CompressionPluginType.getInstance());
PluginRegistry.init();
}
- @Before
- public void setUp() throws Exception {
+ @BeforeEach
+ void setUp() throws Exception {
factory = CompressionProviderFactory.getInstance();
provider = factory.getCompressionProviderByName(PROVIDER_NAME);
inStream = new SnappyCompressionInputStream(createSnappyInputStream(), provider) {};
}
@Test
- public void testCtor() {
+ void testCtor() {
assertNotNull(inStream);
}
@Test
- public void getCompressionProvider() {
+ void getCompressionProvider() {
assertEquals(PROVIDER_NAME, provider.getName());
}
@Test
- public void testNextEntry() throws IOException {
+ void testNextEntry() throws IOException {
assertNull(inStream.nextEntry());
}
@Test
- public void testClose() throws IOException {
+ void testClose() throws IOException {
inStream = new SnappyCompressionInputStream(createSnappyInputStream(), provider);
+ assertNotNull(inStream);
inStream.close();
}
@Test
- public void testRead() throws IOException {
+ void testRead() throws IOException {
assertEquals(inStream.available(), inStream.read(new byte[100], 0, inStream.available()));
}
diff --git a/engine/src/test/java/org/apache/hop/core/compress/snappy/SnappyCompressionOutputStreamTest.java b/engine/src/test/java/org/apache/hop/core/compress/snappy/SnappyCompressionOutputStreamTest.java
index 65ac9282e0..e0340a026f 100644
--- a/engine/src/test/java/org/apache/hop/core/compress/snappy/SnappyCompressionOutputStreamTest.java
+++ b/engine/src/test/java/org/apache/hop/core/compress/snappy/SnappyCompressionOutputStreamTest.java
@@ -17,8 +17,8 @@
package org.apache.hop.core.compress.snappy;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
@@ -26,28 +26,27 @@ import org.apache.hop.core.compress.CompressionPluginType;
import org.apache.hop.core.compress.CompressionProviderFactory;
import org.apache.hop.core.compress.ICompressionProvider;
import org.apache.hop.core.plugins.PluginRegistry;
-import org.apache.hop.junit.rules.RestoreHopEngineEnvironment;
-import org.junit.Before;
-import org.junit.BeforeClass;
-import org.junit.ClassRule;
-import org.junit.Test;
-
-public class SnappyCompressionOutputStreamTest {
- @ClassRule public static RestoreHopEngineEnvironment env = new RestoreHopEngineEnvironment();
+import org.apache.hop.junit.rules.RestoreHopEnvironmentExtension;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.ExtendWith;
+@ExtendWith(RestoreHopEnvironmentExtension.class)
+class SnappyCompressionOutputStreamTest {
public static final String PROVIDER_NAME = "Snappy";
public CompressionProviderFactory factory = null;
public SnappyCompressionOutputStream outStream = null;
- @BeforeClass
- public static void setUpBeforeClass() throws Exception {
+ @BeforeAll
+ static void setUpBeforeClass() throws Exception {
PluginRegistry.addPluginType(CompressionPluginType.getInstance());
PluginRegistry.init();
}
- @Before
- public void setUp() throws Exception {
+ @BeforeEach
+ void setUp() throws Exception {
factory = CompressionProviderFactory.getInstance();
ICompressionProvider provider = factory.getCompressionProviderByName(PROVIDER_NAME);
ByteArrayOutputStream in = new ByteArrayOutputStream();
@@ -55,37 +54,40 @@ public class SnappyCompressionOutputStreamTest {
}
@Test
- public void testCtor() {
+ void testCtor() {
assertNotNull(outStream);
}
@Test
- public void getCompressionProvider() {
+ void getCompressionProvider() {
ICompressionProvider provider = outStream.getCompressionProvider();
assertEquals(PROVIDER_NAME, provider.getName());
}
@Test
- public void testClose() throws IOException {
+ void testClose() throws IOException {
ICompressionProvider provider = outStream.getCompressionProvider();
ByteArrayOutputStream out = new ByteArrayOutputStream();
outStream = new SnappyCompressionOutputStream(out, provider);
+ assertNotNull(outStream);
outStream.close();
}
@Test
- public void testWrite() throws IOException {
+ void testWrite() throws IOException {
ICompressionProvider provider = outStream.getCompressionProvider();
ByteArrayOutputStream out = new ByteArrayOutputStream();
outStream = new SnappyCompressionOutputStream(out, provider);
+ assertNotNull(outStream);
outStream.write("Test".getBytes());
}
@Test
- public void testAddEntry() throws IOException {
+ void testAddEntry() throws IOException {
ICompressionProvider provider = outStream.getCompressionProvider();
ByteArrayOutputStream out = new ByteArrayOutputStream();
outStream = new SnappyCompressionOutputStream(out, provider);
+ assertNotNull(outStream);
outStream.addEntry(null, null);
}
}
diff --git a/engine/src/test/java/org/apache/hop/core/compress/snappy/SnappyCompressionProviderTest.java b/engine/src/test/java/org/apache/hop/core/compress/snappy/SnappyCompressionProviderTest.java
index 88fd3ade31..1b86c2b54d 100644
--- a/engine/src/test/java/org/apache/hop/core/compress/snappy/SnappyCompressionProviderTest.java
+++ b/engine/src/test/java/org/apache/hop/core/compress/snappy/SnappyCompressionProviderTest.java
@@ -17,10 +17,10 @@
package org.apache.hop.core.compress.snappy;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
@@ -28,40 +28,39 @@ import java.io.IOException;
import org.apache.hop.core.compress.CompressionPluginType;
import org.apache.hop.core.compress.CompressionProviderFactory;
import org.apache.hop.core.plugins.PluginRegistry;
-import org.apache.hop.junit.rules.RestoreHopEngineEnvironment;
-import org.junit.Before;
-import org.junit.BeforeClass;
-import org.junit.ClassRule;
-import org.junit.Test;
+import org.apache.hop.junit.rules.RestoreHopEnvironmentExtension;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.ExtendWith;
import org.xerial.snappy.SnappyInputStream;
import org.xerial.snappy.SnappyOutputStream;
-public class SnappyCompressionProviderTest {
- @ClassRule public static RestoreHopEngineEnvironment env = new RestoreHopEngineEnvironment();
-
+@ExtendWith(RestoreHopEnvironmentExtension.class)
+class SnappyCompressionProviderTest {
public static final String PROVIDER_NAME = "Snappy";
public CompressionProviderFactory factory = null;
- @BeforeClass
- public static void setUpBeforeClass() throws Exception {
+ @BeforeAll
+ static void setUpBeforeClass() throws Exception {
PluginRegistry.addPluginType(CompressionPluginType.getInstance());
PluginRegistry.init();
}
- @Before
- public void setUp() {
+ @BeforeEach
+ void setUp() {
factory = CompressionProviderFactory.getInstance();
}
@Test
- public void testCtor() {
+ void testCtor() {
SnappyCompressionProvider ncp = new SnappyCompressionProvider();
assertNotNull(ncp);
}
@Test
- public void testGetName() {
+ void testGetName() {
SnappyCompressionProvider provider =
(SnappyCompressionProvider) factory.getCompressionProviderByName(PROVIDER_NAME);
assertNotNull(provider);
@@ -69,7 +68,7 @@ public class SnappyCompressionProviderTest {
}
@Test
- public void testGetProviderAttributes() {
+ void testGetProviderAttributes() {
SnappyCompressionProvider provider =
(SnappyCompressionProvider) factory.getCompressionProviderByName(PROVIDER_NAME);
assertEquals("Snappy compression", provider.getDescription());
@@ -79,7 +78,7 @@ public class SnappyCompressionProviderTest {
}
@Test
- public void testCreateInputStream() throws IOException {
+ void testCreateInputStream() throws IOException {
SnappyCompressionProvider provider =
(SnappyCompressionProvider) factory.getCompressionProviderByName(PROVIDER_NAME);
SnappyInputStream in = createSnappyInputStream();
@@ -90,7 +89,7 @@ public class SnappyCompressionProviderTest {
}
@Test
- public void testCreateOutputStream() throws IOException {
+ void testCreateOutputStream() throws IOException {
SnappyCompressionProvider provider =
(SnappyCompressionProvider) factory.getCompressionProviderByName(PROVIDER_NAME);
ByteArrayOutputStream out = new ByteArrayOutputStream();
diff --git a/engine/src/test/java/org/apache/hop/core/compress/zip/ZipCompressionInputStreamTest.java b/engine/src/test/java/org/apache/hop/core/compress/zip/ZipCompressionInputStreamTest.java
index 3fe5dbaec6..92a6d0fc42 100644
--- a/engine/src/test/java/org/apache/hop/core/compress/zip/ZipCompressionInputStreamTest.java
+++ b/engine/src/test/java/org/apache/hop/core/compress/zip/ZipCompressionInputStreamTest.java
@@ -17,8 +17,8 @@
package org.apache.hop.core.compress.zip;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
@@ -30,28 +30,27 @@ import org.apache.hop.core.compress.CompressionPluginType;
import org.apache.hop.core.compress.CompressionProviderFactory;
import org.apache.hop.core.compress.ICompressionProvider;
import org.apache.hop.core.plugins.PluginRegistry;
-import org.apache.hop.junit.rules.RestoreHopEngineEnvironment;
-import org.junit.Before;
-import org.junit.BeforeClass;
-import org.junit.ClassRule;
-import org.junit.Test;
-
-public class ZipCompressionInputStreamTest {
- @ClassRule public static RestoreHopEngineEnvironment env = new RestoreHopEngineEnvironment();
+import org.apache.hop.junit.rules.RestoreHopEnvironmentExtension;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.ExtendWith;
+@ExtendWith(RestoreHopEnvironmentExtension.class)
+class ZipCompressionInputStreamTest {
public static final String PROVIDER_NAME = "Zip";
public CompressionProviderFactory factory = null;
public ZipCompressionInputStream inStream = null;
- @BeforeClass
- public static void setUpBeforeClass() throws Exception {
+ @BeforeAll
+ static void setUpBeforeClass() throws Exception {
PluginRegistry.addPluginType(CompressionPluginType.getInstance());
PluginRegistry.init();
}
- @Before
- public void setUp() throws Exception {
+ @BeforeEach
+ void setUp() throws Exception {
factory = CompressionProviderFactory.getInstance();
ICompressionProvider provider = factory.getCompressionProviderByName(PROVIDER_NAME);
ByteArrayInputStream in = new ByteArrayInputStream("Test".getBytes());
@@ -59,31 +58,34 @@ public class ZipCompressionInputStreamTest {
}
@Test
- public void testCtor() {
+ void testCtor() {
assertNotNull(inStream);
}
@Test
- public void getZIPCompressionProvider() {
+ void getZIPCompressionProvider() {
ICompressionProvider provider = inStream.getCompressionProvider();
assertEquals(PROVIDER_NAME, provider.getName());
}
@Test
- public void testNextEntry() throws IOException {
- assertNotNull(createZIPInputStream().getNextEntry());
+ void testNextEntry() throws IOException {
+ ZipInputStream zipInputStream = createZIPInputStream();
+ assertNotNull(zipInputStream);
+ assertNotNull(zipInputStream.getNextEntry());
}
@Test
- public void testClose() throws IOException {
+ void testClose() throws IOException {
createZIPInputStream().close();
}
@Test
- public void testRead() throws IOException {
+ void testRead() throws IOException {
ICompressionProvider provider = inStream.getCompressionProvider();
ByteArrayInputStream in = new ByteArrayInputStream("Test".getBytes());
inStream = new ZipCompressionInputStream(in, provider) {};
+ assertNotNull(inStream);
inStream.read(new byte[100], 0, inStream.available());
}
@@ -96,6 +98,7 @@ public class ZipCompressionInputStreamTest {
gos.write(testBytes);
ByteArrayInputStream in = new ByteArrayInputStream(baos.toByteArray());
+ assertNotNull(in);
return new ZipInputStream(in);
}
}
diff --git a/engine/src/test/java/org/apache/hop/core/compress/zip/ZipCompressionOutputStreamTest.java b/engine/src/test/java/org/apache/hop/core/compress/zip/ZipCompressionOutputStreamTest.java
index 165377d450..4c69bbe688 100644
--- a/engine/src/test/java/org/apache/hop/core/compress/zip/ZipCompressionOutputStreamTest.java
+++ b/engine/src/test/java/org/apache/hop/core/compress/zip/ZipCompressionOutputStreamTest.java
@@ -17,9 +17,9 @@
package org.apache.hop.core.compress.zip;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
@@ -33,82 +33,84 @@ import org.apache.hop.core.compress.CompressionPluginType;
import org.apache.hop.core.compress.CompressionProviderFactory;
import org.apache.hop.core.compress.ICompressionProvider;
import org.apache.hop.core.plugins.PluginRegistry;
-import org.apache.hop.junit.rules.RestoreHopEngineEnvironment;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.BeforeClass;
-import org.junit.ClassRule;
-import org.junit.Test;
+import org.apache.hop.junit.rules.RestoreHopEnvironmentExtension;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.ExtendWith;
-public class ZipCompressionOutputStreamTest {
- @ClassRule public static RestoreHopEngineEnvironment env = new RestoreHopEngineEnvironment();
+@ExtendWith(RestoreHopEnvironmentExtension.class)
+class ZipCompressionOutputStreamTest {
+ static final String PROVIDER_NAME = "Zip";
- public static final String PROVIDER_NAME = "Zip";
-
- public CompressionProviderFactory factory = null;
- public ZipCompressionOutputStream outStream = null;
+ CompressionProviderFactory factory = null;
+ ZipCompressionOutputStream outStream = null;
private ByteArrayOutputStream internalStream;
- @BeforeClass
- public static void setUpBeforeClass() throws Exception {
+ @BeforeAll
+ static void setUpBeforeClass() throws Exception {
PluginRegistry.addPluginType(CompressionPluginType.getInstance());
PluginRegistry.init();
}
- @Before
- public void setUp() {
+ @BeforeEach
+ void setUp() {
factory = CompressionProviderFactory.getInstance();
ICompressionProvider provider = factory.getCompressionProviderByName(PROVIDER_NAME);
internalStream = new ByteArrayOutputStream();
outStream = new ZipCompressionOutputStream(internalStream, provider);
}
- @After
- public void tearDown() {
+ @AfterEach
+ void tearDown() {
internalStream = null;
}
@Test
- public void testCtor() {
+ void testCtor() {
assertNotNull(outStream);
}
@Test
- public void getCompressionProvider() {
+ void getCompressionProvider() {
ICompressionProvider provider = outStream.getCompressionProvider();
assertEquals(PROVIDER_NAME, provider.getName());
}
@Test
- public void testClose() throws IOException {
+ void testClose() throws IOException {
ICompressionProvider provider = outStream.getCompressionProvider();
ByteArrayOutputStream out = new ByteArrayOutputStream();
outStream = new ZipCompressionOutputStream(out, provider);
+ assertNotNull(outStream);
outStream.close();
}
@Test
- public void testAddEntryAndWrite() throws IOException {
+ void testAddEntryAndWrite() throws IOException {
ICompressionProvider provider = outStream.getCompressionProvider();
ByteArrayOutputStream out = new ByteArrayOutputStream();
outStream = new ZipCompressionOutputStream(out, provider);
+ assertNotNull(outStream);
outStream.addEntry("./test.zip", null);
outStream.write("Test".getBytes());
}
@Test
- public void directoriesHierarchyIsIgnored() throws Exception {
+ void directoriesHierarchyIsIgnored() throws Exception {
outStream.addEntry(createFilePath("1", "~", "hop", "dir"), "txt");
outStream.close();
Map<String, String> map = readArchive(internalStream.toByteArray());
+ assertNotNull(map);
assertEquals(1, map.size());
assertEquals("1.txt", map.keySet().iterator().next());
}
@Test
- public void extraZipExtensionIsIgnored() throws Exception {
+ void extraZipExtensionIsIgnored() throws Exception {
outStream.addEntry(createFilePath("1.zip", "~", "hop", "dir"), "txt");
outStream.close();
@@ -118,7 +120,7 @@ public class ZipCompressionOutputStreamTest {
}
@Test
- public void absentExtensionIsOk() throws Exception {
+ void absentExtensionIsOk() throws Exception {
outStream.addEntry(createFilePath("1", "~", "hop", "dir"), null);
outStream.close();
@@ -128,7 +130,7 @@ public class ZipCompressionOutputStreamTest {
}
@Test
- public void createsWellFormedArchive() throws Exception {
+ void createsWellFormedArchive() throws Exception {
outStream.addEntry("1", "txt");
outStream.write("1.txt".getBytes());
outStream.addEntry("2", "txt");
@@ -161,7 +163,7 @@ public class ZipCompressionOutputStreamTest {
while ((read = stream.read(buf)) > 0) {
os.write(buf, 0, read);
}
- result.put(entry.getName(), new String(os.toByteArray()));
+ result.put(entry.getName(), os.toString());
}
return result;
diff --git a/engine/src/test/java/org/apache/hop/core/compress/zip/ZipCompressionProviderTest.java b/engine/src/test/java/org/apache/hop/core/compress/zip/ZipCompressionProviderTest.java
index 08992570aa..53ec767902 100644
--- a/engine/src/test/java/org/apache/hop/core/compress/zip/ZipCompressionProviderTest.java
+++ b/engine/src/test/java/org/apache/hop/core/compress/zip/ZipCompressionProviderTest.java
@@ -17,9 +17,9 @@
package org.apache.hop.core.compress.zip;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
@@ -29,38 +29,37 @@ import java.util.zip.ZipOutputStream;
import org.apache.hop.core.compress.CompressionPluginType;
import org.apache.hop.core.compress.CompressionProviderFactory;
import org.apache.hop.core.plugins.PluginRegistry;
-import org.apache.hop.junit.rules.RestoreHopEngineEnvironment;
-import org.junit.Before;
-import org.junit.BeforeClass;
-import org.junit.ClassRule;
-import org.junit.Test;
+import org.apache.hop.junit.rules.RestoreHopEnvironmentExtension;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.ExtendWith;
-public class ZipCompressionProviderTest {
- @ClassRule public static RestoreHopEngineEnvironment env = new RestoreHopEngineEnvironment();
+@ExtendWith(RestoreHopEnvironmentExtension.class)
+class ZipCompressionProviderTest {
+ static final String PROVIDER_NAME = "Zip";
- public static final String PROVIDER_NAME = "Zip";
+ CompressionProviderFactory factory = null;
- public CompressionProviderFactory factory = null;
-
- @BeforeClass
- public static void setUpBeforeClass() throws Exception {
+ @BeforeAll
+ static void setUpBeforeClass() throws Exception {
PluginRegistry.addPluginType(CompressionPluginType.getInstance());
PluginRegistry.init();
}
- @Before
- public void setUp() {
+ @BeforeEach
+ void setUp() {
factory = CompressionProviderFactory.getInstance();
}
@Test
- public void testCtor() {
+ void testCtor() {
ZipCompressionProvider ncp = new ZipCompressionProvider();
assertNotNull(ncp);
}
@Test
- public void testGetName() {
+ void testGetName() {
ZipCompressionProvider provider =
(ZipCompressionProvider) factory.getCompressionProviderByName(PROVIDER_NAME);
assertNotNull(provider);
@@ -68,7 +67,7 @@ public class ZipCompressionProviderTest {
}
@Test
- public void testGetProviderAttributes() {
+ void testGetProviderAttributes() {
ZipCompressionProvider provider =
(ZipCompressionProvider) factory.getCompressionProviderByName(PROVIDER_NAME);
assertEquals("ZIP compression", provider.getDescription());
@@ -78,7 +77,7 @@ public class ZipCompressionProviderTest {
}
@Test
- public void testCreateInputStream() throws IOException {
+ void testCreateInputStream() throws IOException {
ZipCompressionProvider provider =
(ZipCompressionProvider) factory.getCompressionProviderByName(PROVIDER_NAME);
ByteArrayInputStream in = new ByteArrayInputStream("Test".getBytes());
@@ -92,7 +91,7 @@ public class ZipCompressionProviderTest {
}
@Test
- public void testCreateOutputStream() throws IOException {
+ void testCreateOutputStream() throws IOException {
ZipCompressionProvider provider =
(ZipCompressionProvider) factory.getCompressionProviderByName(PROVIDER_NAME);
ByteArrayOutputStream out = new ByteArrayOutputStream();
diff --git a/engine/src/test/java/org/apache/hop/core/gui/WorkflowTrackerTest.java b/engine/src/test/java/org/apache/hop/core/gui/WorkflowTrackerTest.java
index 9b0be55537..c93a5c8306 100644
--- a/engine/src/test/java/org/apache/hop/core/gui/WorkflowTrackerTest.java
+++ b/engine/src/test/java/org/apache/hop/core/gui/WorkflowTrackerTest.java
@@ -17,32 +17,32 @@
package org.apache.hop.core.gui;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
import org.apache.hop.core.Const;
-import org.apache.hop.junit.rules.RestoreHopEngineEnvironment;
+import org.apache.hop.junit.rules.RestoreHopEnvironmentExtension;
import org.apache.hop.workflow.ActionResult;
import org.apache.hop.workflow.WorkflowMeta;
import org.apache.hop.workflow.action.ActionMeta;
import org.apache.hop.workflow.action.IAction;
-import org.junit.ClassRule;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.ExtendWith;
-public class WorkflowTrackerTest {
- @ClassRule public static RestoreHopEngineEnvironment env = new RestoreHopEngineEnvironment();
+@ExtendWith(RestoreHopEnvironmentExtension.class)
+class WorkflowTrackerTest {
- @Test
// Number of workflow trackers should be limited by HOP_MAX_JOB_TRACKER_SIZE
- public void testAddJobTracker() {
+ @Test
+ void testAddJobTracker() {
final String old = System.getProperty(Const.HOP_MAX_WORKFLOW_TRACKER_SIZE);
- final Integer maxTestSize = 30;
+ final int maxTestSize = 30;
try {
- System.setProperty(Const.HOP_MAX_WORKFLOW_TRACKER_SIZE, maxTestSize.toString());
+ System.setProperty(Const.HOP_MAX_WORKFLOW_TRACKER_SIZE, Integer.toString(maxTestSize));
WorkflowMeta workflowMeta = mock(WorkflowMeta.class);
WorkflowTracker workflowTracker = new WorkflowTracker(workflowMeta);
@@ -52,8 +52,8 @@ public class WorkflowTrackerTest {
}
assertTrue(
- "More JobTrackers than allowed were added",
- workflowTracker.getTotalNumberOfItems() <= maxTestSize);
+ workflowTracker.getTotalNumberOfItems() <= maxTestSize,
+ "More JobTrackers than allowed were added");
} finally {
if (old == null) {
System.clearProperty(Const.HOP_MAX_WORKFLOW_TRACKER_SIZE);
@@ -64,7 +64,7 @@ public class WorkflowTrackerTest {
}
@Test
- public void findJobTracker_EntryNameIsNull() {
+ void findJobTracker_EntryNameIsNull() {
WorkflowTracker workflowTracker = createTracker();
workflowTracker.addWorkflowTracker(createTracker());
@@ -74,19 +74,18 @@ public class WorkflowTrackerTest {
}
@Test
- public void findJobTracker_EntryNameNotFound() {
+ void findJobTracker_EntryNameNotFound() {
WorkflowTracker workflowTracker = createTracker();
for (int i = 0; i < 3; i++) {
workflowTracker.addWorkflowTracker(createTracker(Integer.toString(i)));
}
ActionMeta copy = createActionMeta("not match");
-
assertNull(workflowTracker.findWorkflowTracker(copy));
}
@Test
- public void findJobTracker_EntryNameFound() {
+ void findJobTracker_EntryNameFound() {
WorkflowTracker workflowTracker = createTracker();
WorkflowTracker[] children =
new WorkflowTracker[] {createTracker("0"), createTracker("1"), createTracker("2")};
@@ -95,7 +94,6 @@ public class WorkflowTrackerTest {
}
ActionMeta actionMeta = createActionMeta("1");
-
assertEquals(children[1], workflowTracker.findWorkflowTracker(actionMeta));
}
diff --git a/engine/src/test/java/org/apache/hop/core/injection/MetaAnnotationInjectionTest.java b/engine/src/test/java/org/apache/hop/core/injection/MetaAnnotationInjectionTest.java
index 914438a1cc..221f35f09e 100644
--- a/engine/src/test/java/org/apache/hop/core/injection/MetaAnnotationInjectionTest.java
+++ b/engine/src/test/java/org/apache/hop/core/injection/MetaAnnotationInjectionTest.java
@@ -17,16 +17,18 @@
package org.apache.hop.core.injection;
-import static org.junit.Assert.assertArrayEquals;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
+import static org.junit.jupiter.api.Assertions.assertArrayEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+import static org.junit.jupiter.api.Assertions.fail;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
+import lombok.Getter;
+import lombok.Setter;
import org.apache.hop.core.RowMetaAndData;
import org.apache.hop.core.exception.HopException;
import org.apache.hop.core.injection.bean.BeanInjectionInfo;
@@ -35,34 +37,29 @@ import org.apache.hop.core.injection.inheritance.MetaBeanChild;
import org.apache.hop.core.logging.HopLogStore;
import org.apache.hop.core.row.RowMeta;
import org.apache.hop.core.row.value.ValueMetaString;
-import org.apache.hop.junit.rules.RestoreHopEngineEnvironment;
+import org.apache.hop.junit.rules.RestoreHopEngineEnvironmentExtension;
import org.apache.hop.metadata.api.IHopMetadataProvider;
import org.apache.hop.metadata.serializer.memory.MemoryMetadataProvider;
-import org.junit.Before;
-import org.junit.ClassRule;
-import org.junit.Test;
-
-public class MetaAnnotationInjectionTest {
- @ClassRule public static RestoreHopEngineEnvironment env = new RestoreHopEngineEnvironment();
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.ExtendWith;
+@ExtendWith(RestoreHopEngineEnvironmentExtension.class)
+class MetaAnnotationInjectionTest {
private static final String FIELD_ONE = "FIELD_ONE";
-
private static final String COMPLEX_NAME = "COMPLEX_NAME";
-
private static final String TEST_NAME = "TEST_NAME";
-
private IHopMetadataProvider metadataProvider;
- @Before
- public void before() {
+ @BeforeEach
+ void before() {
HopLogStore.init();
metadataProvider = new MemoryMetadataProvider();
}
@Test
- public void testInjectionDescription() {
-
- BeanInjectionInfo<MetaBeanLevel1> ri = new BeanInjectionInfo(MetaBeanLevel1.class);
+ void testInjectionDescription() {
+ BeanInjectionInfo<MetaBeanLevel1> ri = new BeanInjectionInfo<>(MetaBeanLevel1.class);
assertEquals(3, ri.getGroups().size());
assertEquals("", ri.getGroups().get(0).getKey());
@@ -79,7 +76,7 @@ public class MetaAnnotationInjectionTest {
}
@Test
- public void testInjectionSets() throws Exception {
+ void testInjectionSets() throws Exception {
MetaBeanLevel1 obj = new MetaBeanLevel1();
RowMeta meta = new RowMeta();
@@ -87,12 +84,13 @@ public class MetaAnnotationInjectionTest {
meta.addValueMeta(new ValueMetaString("f2"));
meta.addValueMeta(new ValueMetaString("fstrint"));
meta.addValueMeta(new ValueMetaString("fstrlong"));
- meta.addValueMeta(new ValueMetaString("fstrboolean")); // TODO STLOCALE
+ // STLOCALE
+ meta.addValueMeta(new ValueMetaString("fstrboolean"));
List<RowMetaAndData> rows = new ArrayList<>();
rows.add(new RowMetaAndData(meta, "<sep>", "/tmp/file.txt", "123", "1234567891213", "y"));
rows.add(new RowMetaAndData(meta, "<sep>", "/tmp/file2.txt", "123", "1234567891213", "y"));
- BeanInjector inj = buildBeanInjectorFor(MetaBeanLevel1.class, metadataProvider);
+ BeanInjector<?> inj = buildBeanInjectorFor(MetaBeanLevel1.class, metadataProvider);
inj.setProperty(obj, "SEPARATOR", rows, "f1");
inj.setProperty(obj, "FILENAME", rows, "f2");
inj.setProperty(obj, "FILENAME_ARRAY", rows, "f2");
@@ -112,10 +110,10 @@ public class MetaAnnotationInjectionTest {
}
@Test
- public void testInjectionConstant() throws Exception {
+ void testInjectionConstant() throws Exception {
MetaBeanLevel1 obj = new MetaBeanLevel1();
- BeanInjector inj = buildBeanInjectorFor(MetaBeanLevel1.class, metadataProvider);
+ BeanInjector<?> inj = buildBeanInjectorFor(MetaBeanLevel1.class, metadataProvider);
inj.setProperty(obj, "SEPARATOR", null, "<sep>");
inj.setProperty(obj, "FINT", null, "123");
inj.setProperty(obj, "FLONG", null, "1234567891213");
@@ -141,9 +139,9 @@ public class MetaAnnotationInjectionTest {
}
@Test
- public void testInjectionForArrayPropertyWithoutDefaultConstructor_class_parameter()
+ void testInjectionForArrayPropertyWithoutDefaultConstructor_class_parameter()
throws HopException {
- BeanInjector beanInjector = buildBeanInjectorFor(MetadataBean.class, metadataProvider);
+ BeanInjector<?> beanInjector = buildBeanInjectorFor(MetadataBean.class, metadataProvider);
MetadataBean targetBean = new MetadataBean();
beanInjector.setProperty(targetBean, COMPLEX_NAME, createRowMetaAndData(), FIELD_ONE);
@@ -153,9 +151,9 @@ public class MetaAnnotationInjectionTest {
}
@Test
- public void testInjectionForArrayPropertyWithoutDefaultConstructorInterface_parameter()
+ void testInjectionForArrayPropertyWithoutDefaultConstructorInterface_parameter()
throws HopException {
- BeanInjector beanInjector =
+ BeanInjector<?> beanInjector =
buildBeanInjectorFor(MetadataBeanImplementsInterface.class, metadataProvider);
MetadataBeanImplementsInterface targetBean = new MetadataBeanImplementsInterface();
beanInjector.setProperty(targetBean, COMPLEX_NAME, createRowMetaAndData(), FIELD_ONE);
@@ -166,47 +164,54 @@ public class MetaAnnotationInjectionTest {
}
@Test
- public void testWrongDeclarations() {
+ void testWrongDeclarations() {
try {
- new BeanInjectionInfo(MetaBeanWrong1.class);
+ new BeanInjectionInfo<>(MetaBeanWrong1.class);
fail();
} catch (Exception ex) {
+ // ignore
}
try {
- new BeanInjectionInfo(MetaBeanWrong2.class);
+ new BeanInjectionInfo<>(MetaBeanWrong2.class);
fail();
} catch (Exception ex) {
+ // ignore
}
try {
- new BeanInjectionInfo(MetaBeanWrong3.class);
+ new BeanInjectionInfo<>(MetaBeanWrong3.class);
fail();
} catch (Exception ex) {
+ // ignore
}
try {
- new BeanInjectionInfo(MetaBeanWrong4.class);
+ new BeanInjectionInfo<>(MetaBeanWrong4.class);
fail();
} catch (Exception ex) {
+ // ignore
}
try {
- new BeanInjectionInfo(MetaBeanWrong5.class);
+ new BeanInjectionInfo<>(MetaBeanWrong5.class);
fail();
} catch (Exception ex) {
+ // ignore
}
try {
- new BeanInjectionInfo(MetaBeanWrong6.class);
+ new BeanInjectionInfo<>(MetaBeanWrong6.class);
fail();
} catch (Exception ex) {
+ // ignore
}
try {
- new BeanInjectionInfo(MetaBeanWrong7.class);
+ new BeanInjectionInfo<>(MetaBeanWrong7.class);
fail();
} catch (Exception ex) {
+ // ignore
}
}
@Test
- public void testGenerics() {
- BeanInjectionInfo<MetaBeanChild> ri = new BeanInjectionInfo(MetaBeanChild.class);
+ void testGenerics() {
+ BeanInjectionInfo<MetaBeanChild> ri = new BeanInjectionInfo<>(MetaBeanChild.class);
assertEquals(7, ri.getProperties().size());
assertTrue(ri.getProperties().containsKey("BASE_ITEM_NAME"));
@@ -220,10 +225,10 @@ public class MetaAnnotationInjectionTest {
assertEquals(String.class, ri.getProperties().get("A").getPropertyClass());
}
- private static BeanInjector buildBeanInjectorFor(
+ private static BeanInjector<?> buildBeanInjectorFor(
Class<?> clazz, IHopMetadataProvider metadataProvider) {
- BeanInjectionInfo metaBeanInfo = new BeanInjectionInfo(clazz);
- return new BeanInjector(metaBeanInfo, metadataProvider);
+ BeanInjectionInfo<?> metaBeanInfo = new BeanInjectionInfo<>(clazz);
+ return new BeanInjector<>(metaBeanInfo, metadataProvider);
}
private static List<RowMetaAndData> createRowMetaAndData() {
@@ -232,22 +237,18 @@ public class MetaAnnotationInjectionTest {
return Collections.singletonList(new RowMetaAndData(meta, TEST_NAME));
}
- private static interface MetadataInterface {}
+ private interface MetadataInterface {}
+ @Getter
+ @Setter
@InjectionSupported(localizationPrefix = "", groups = "COMPLEX")
public static class MetadataBean {
@InjectionDeep private ComplexField[] complexField;
-
- public ComplexField[] getComplexField() {
- return complexField;
- }
-
- public void setComplexField(ComplexField[] complexField) {
- this.complexField = complexField;
- }
}
+ @Getter
+ @Setter
public static class ComplexField {
@Injection(name = "COMPLEX_NAME", group = "COMPLEX")
@@ -258,36 +259,20 @@ public class MetaAnnotationInjectionTest {
public ComplexField(MetadataBean parentMeta) {
this.parentMeta = parentMeta;
}
-
- public String getFieldName() {
- return fieldName;
- }
-
- public void setFieldName(String fieldName) {
- this.fieldName = fieldName;
- }
-
- public MetadataBean getParentMeta() {
- return parentMeta;
- }
}
+ @Getter
+ @Setter
@InjectionSupported(localizationPrefix = "", groups = "COMPLEX")
public static class MetadataBeanImplementsInterface implements MetadataInterface {
@InjectionDeep private ComplexFieldWithInterfaceArg[] complexField;
-
- public ComplexFieldWithInterfaceArg[] getComplexField() {
- return complexField;
- }
-
- public void setComplexField(ComplexFieldWithInterfaceArg[] complexField) {
- this.complexField = complexField;
- }
}
+ @Getter
public static class ComplexFieldWithInterfaceArg {
+ @Setter
@Injection(name = "COMPLEX_NAME", group = "COMPLEX")
private String fieldName;
@@ -296,17 +281,5 @@ public class MetaAnnotationInjectionTest {
public ComplexFieldWithInterfaceArg(MetadataInterface parentMeta) {
this.parentMeta = parentMeta;
}
-
- public String getFieldName() {
- return fieldName;
- }
-
- public void setFieldName(String fieldName) {
- this.fieldName = fieldName;
- }
-
- public MetadataInterface getParentMeta() {
- return parentMeta;
- }
}
}
diff --git a/engine/src/test/java/org/apache/hop/core/injection/MetaPropInjectionTest.java b/engine/src/test/java/org/apache/hop/core/injection/MetaPropInjectionTest.java
index b96f3b901a..9feeb56d9a 100644
--- a/engine/src/test/java/org/apache/hop/core/injection/MetaPropInjectionTest.java
+++ b/engine/src/test/java/org/apache/hop/core/injection/MetaPropInjectionTest.java
@@ -17,10 +17,10 @@
package org.apache.hop.core.injection;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
import java.util.Arrays;
import java.util.List;
@@ -36,32 +36,26 @@ import org.apache.hop.core.row.IRowMeta;
import org.apache.hop.core.row.RowMetaBuilder;
import org.apache.hop.core.row.value.ValueMetaString;
import org.apache.hop.metadata.serializer.memory.MemoryMetadataProvider;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
-public class MetaPropInjectionTest {
+class MetaPropInjectionTest {
- /**
- * Test to see that the annotations are picked up properly in various scenarios
- *
- * @throws Exception
- */
+ /** Test to see that the annotations are picked up properly in various scenarios */
@Test
- public void testHopMetadataPropertyInjectionInfo() {
+ void testHopMetadataPropertyInjectionInfo() {
BeanInjectionInfo<PropBeanParent> info = new BeanInjectionInfo<>(PropBeanParent.class);
assertEquals(4, info.getGroups().size());
assertEquals(11, info.getProperties().size());
// String PropBeanParent.stringField
- //
BeanInjectionInfo<PropBeanParent>.Property prop = info.getProperties().get("str");
assertNotNull(prop);
assertEquals(2, prop.getPath().size());
- BeanLevelInfo beanLevelInfo = prop.getPath().get(1);
+ BeanLevelInfo<?> beanLevelInfo = prop.getPath().get(1);
assertEquals(String.class, beanLevelInfo.leafClass);
assertEquals("stringField", beanLevelInfo.field.getName());
// int PropBeanParent.intField
- //
prop = info.getProperties().get("int");
assertNotNull(prop);
assertEquals(2, prop.getPath().size());
@@ -70,7 +64,6 @@ public class MetaPropInjectionTest {
assertEquals("intField", beanLevelInfo.field.getName());
// long PropBeanParent.longField
- //
prop = info.getProperties().get("long");
assertNotNull(prop);
assertEquals(2, prop.getPath().size());
@@ -79,7 +72,6 @@ public class MetaPropInjectionTest {
assertEquals("longField", beanLevelInfo.field.getName());
// boolean PropBeanParent.booleanField
- //
prop = info.getProperties().get("boolean");
assertNotNull(prop);
assertEquals(2, prop.getPath().size());
@@ -87,32 +79,15 @@ public class MetaPropInjectionTest {
assertEquals(boolean.class, beanLevelInfo.leafClass);
assertEquals("booleanField", beanLevelInfo.field.getName());
- // PropBeanChild PropBeanParent.child
- //
- prop = info.getProperties().get("child1");
- assertNotNull(prop);
- assertEquals(3, prop.getPath().size());
- beanLevelInfo = prop.getPath().get(1);
- assertEquals(PropBeanChild.class, beanLevelInfo.leafClass);
- assertEquals("child", beanLevelInfo.field.getName());
- beanLevelInfo = prop.getPath().get(2);
- assertEquals(String.class, beanLevelInfo.leafClass);
- assertEquals("childField1", beanLevelInfo.field.getName());
-
- // PropBeanChild PropBeanParent.child
- //
- prop = info.getProperties().get("child2");
- assertNotNull(prop);
- assertEquals(3, prop.getPath().size());
- beanLevelInfo = prop.getPath().get(1);
- assertEquals(PropBeanChild.class, beanLevelInfo.leafClass);
- assertEquals("child", beanLevelInfo.field.getName());
- beanLevelInfo = prop.getPath().get(2);
- assertEquals(String.class, beanLevelInfo.leafClass);
- assertEquals("childField2", beanLevelInfo.field.getName());
+ testHopMetadataPropertyInjectionInfo_1(prop, info, beanLevelInfo);
+ testHopMetadataPropertyInjectionInfo_2(prop, info, beanLevelInfo);
+ }
+ private void testHopMetadataPropertyInjectionInfo_1(
+ BeanInjectionInfo<PropBeanParent>.Property prop,
+ BeanInjectionInfo<PropBeanParent> info,
+ BeanLevelInfo<?> beanLevelInfo) {
// PropBeanChild PropBeanParent.child
- //
prop = info.getProperties().get("f1");
assertNotNull(prop);
assertEquals(3, prop.getPath().size());
@@ -124,7 +99,6 @@ public class MetaPropInjectionTest {
assertEquals("f1", beanLevelInfo.field.getName());
// PropBeanChild PropBeanParent.child
- //
prop = info.getProperties().get("f2");
assertNotNull(prop);
assertEquals(3, prop.getPath().size());
@@ -136,7 +110,6 @@ public class MetaPropInjectionTest {
assertEquals("f2", beanLevelInfo.field.getName());
// PropBeanChild PropBeanParent.child
- //
prop = info.getProperties().get("string");
assertNotNull(prop);
assertEquals(3, prop.getPath().size());
@@ -150,7 +123,6 @@ public class MetaPropInjectionTest {
assertNull(beanLevelInfo.setter);
// PropBeanChild PropBeanParent.child
- //
prop = info.getProperties().get("grand_child_name");
assertNotNull(prop);
assertEquals(4, prop.getPath().size());
@@ -168,8 +140,35 @@ public class MetaPropInjectionTest {
assertEquals(String.class, prop.getPath().get(3).leafClass);
}
+ private void testHopMetadataPropertyInjectionInfo_2(
+ BeanInjectionInfo<PropBeanParent>.Property prop,
+ BeanInjectionInfo<PropBeanParent> info,
+ BeanLevelInfo<?> beanLevelInfo) {
+ // PropBeanChild PropBeanParent.child
+ prop = info.getProperties().get("child2");
+ assertNotNull(prop);
+ assertEquals(3, prop.getPath().size());
+ beanLevelInfo = prop.getPath().get(1);
+ assertEquals(PropBeanChild.class, beanLevelInfo.leafClass);
+ assertEquals("child", beanLevelInfo.field.getName());
+ beanLevelInfo = prop.getPath().get(2);
+ assertEquals(String.class, beanLevelInfo.leafClass);
+ assertEquals("childField2", beanLevelInfo.field.getName());
+
+ // PropBeanChild PropBeanParent.child
+ prop = info.getProperties().get("child1");
+ assertNotNull(prop);
+ assertEquals(3, prop.getPath().size());
+ beanLevelInfo = prop.getPath().get(1);
+ assertEquals(PropBeanChild.class, beanLevelInfo.leafClass);
+ assertEquals("child", beanLevelInfo.field.getName());
+ beanLevelInfo = prop.getPath().get(2);
+ assertEquals(String.class, beanLevelInfo.leafClass);
+ assertEquals("childField1", beanLevelInfo.field.getName());
+ }
+
@Test
- public void testHopMetadataPropertyInjection() throws Exception {
+ void testHopMetadataPropertyInjection() throws Exception {
// The object to inject into
//
PropBeanParent parent = new PropBeanParent();
@@ -189,16 +188,15 @@ public class MetaPropInjectionTest {
BeanInjector<PropBeanParent> injector = new BeanInjector<>(info, new MemoryMetadataProvider());
- injector.setProperty(parent, "str", Arrays.asList(parentMetadata), "stringValue");
- injector.setProperty(parent, "int", Arrays.asList(parentMetadata), "intValue");
- injector.setProperty(parent, "long", Arrays.asList(parentMetadata), "longValue");
- injector.setProperty(parent, "boolean", Arrays.asList(parentMetadata), "booleanValue");
- injector.setProperty(parent, "child1", Arrays.asList(parentMetadata), "childValue1");
- injector.setProperty(parent, "child2", Arrays.asList(parentMetadata), "childValue2");
- injector.setProperty(
- parent, "grand_child_name", Arrays.asList(parentMetadata), "grandChildName");
+ injector.setProperty(parent, "str", List.of(parentMetadata), "stringValue");
+ injector.setProperty(parent, "int", List.of(parentMetadata), "intValue");
+ injector.setProperty(parent, "long", List.of(parentMetadata), "longValue");
+ injector.setProperty(parent, "boolean", List.of(parentMetadata), "booleanValue");
+ injector.setProperty(parent, "child1", List.of(parentMetadata), "childValue1");
+ injector.setProperty(parent, "child2", List.of(parentMetadata), "childValue2");
+ injector.setProperty(parent, "grand_child_name", List.of(parentMetadata), "grandChildName");
injector.setProperty(
- parent, "grand_child_description", Arrays.asList(parentMetadata), "grandChildDescription");
+ parent, "grand_child_description", List.of(parentMetadata), "grandChildDescription");
assertEquals("someString", parent.getStringField());
assertEquals(123, parent.getIntField());
diff --git a/engine/src/test/java/org/apache/hop/core/logging/LogChannelFileWriterTest.java b/engine/src/test/java/org/apache/hop/core/logging/LogChannelFileWriterTest.java
index 3c8c6ae28a..231427d1a8 100644
--- a/engine/src/test/java/org/apache/hop/core/logging/LogChannelFileWriterTest.java
+++ b/engine/src/test/java/org/apache/hop/core/logging/LogChannelFileWriterTest.java
@@ -17,7 +17,7 @@
package org.apache.hop.core.logging;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.anyBoolean;
import static org.mockito.Mockito.atLeastOnce;
@@ -29,16 +29,16 @@ import static org.mockito.Mockito.when;
import java.io.OutputStream;
import org.apache.commons.vfs2.FileContent;
import org.apache.commons.vfs2.FileObject;
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.runner.RunWith;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.ExtendWith;
import org.mockito.ArgumentCaptor;
import org.mockito.Captor;
import org.mockito.Mock;
-import org.mockito.junit.MockitoJUnitRunner;
+import org.mockito.junit.jupiter.MockitoExtension;
-@RunWith(MockitoJUnitRunner.class)
-public class LogChannelFileWriterTest {
+@ExtendWith(MockitoExtension.class)
+class LogChannelFileWriterTest {
String id = "1";
String logMessage = "Log message";
@@ -48,15 +48,14 @@ public class LogChannelFileWriterTest {
@Mock OutputStream outputStream;
@Captor ArgumentCaptor<byte[]> captor;
- @Before
- public void setup() throws Exception {
+ @BeforeEach
+ void setup() throws Exception {
when(fileObject.getContent()).thenReturn(fileContent);
when(fileContent.getOutputStream(anyBoolean())).thenReturn(outputStream);
}
@Test
- public void test() throws Exception {
-
+ void test() throws Exception {
LogChannelFileWriter writer = new LogChannelFileWriter(id, fileObject, false);
LoggingRegistry.getInstance()
@@ -72,12 +71,12 @@ public class LogChannelFileWriterTest {
}
@Test
- public void testStartStopLogging() throws Exception {
+ void testStartStopLogging() throws Exception {
LogChannelFileWriter writer = new LogChannelFileWriter(id, fileObject, false);
doAnswer(
invocationOnMock -> {
- Thread.sleep(2000);
+ Thread.sleep(1000);
return null;
})
.when(outputStream)
diff --git a/engine/src/test/java/org/apache/hop/core/logging/LogMessageTest.java b/engine/src/test/java/org/apache/hop/core/logging/LogMessageTest.java
index de6329b960..e34e79a4d1 100644
--- a/engine/src/test/java/org/apache/hop/core/logging/LogMessageTest.java
+++ b/engine/src/test/java/org/apache/hop/core/logging/LogMessageTest.java
@@ -17,18 +17,19 @@
package org.apache.hop.core.logging;
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
import org.apache.hop.core.Const;
import org.apache.hop.core.config.HopConfig;
import org.apache.hop.core.variables.DescribedVariable;
-import org.apache.hop.junit.rules.RestoreHopEngineEnvironment;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.ClassRule;
-import org.junit.Test;
-
-public class LogMessageTest {
+import org.apache.hop.junit.rules.RestoreHopEngineEnvironmentExtension;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.ExtendWith;
+
+@ExtendWith(RestoreHopEngineEnvironmentExtension.class)
+class LogMessageTest {
private LogMessage logMessage;
private static final String LOG_MESSAGE = "Test Message";
@@ -36,21 +37,19 @@ public class LogMessageTest {
private static String treeLogChannelId;
private static String simpleLogChannelId;
- @ClassRule public static RestoreHopEngineEnvironment env = new RestoreHopEngineEnvironment();
-
- @Before
- public void setUp() {
+ @BeforeEach
+ void setUp() {
treeLogChannelId = LoggingRegistry.getInstance().registerLoggingSource(getTreeLoggingObject());
}
- @After
- public void tearDown() {
+ @AfterEach
+ void tearDown() {
LoggingRegistry.getInstance().removeIncludingChildren(treeLogChannelId);
System.clearProperty(Const.HOP_LOG_MARK_MAPPINGS);
}
@Test
- public void testWhenLogMarkMappingTurnOn_DetailedSubjectUsed() {
+ void testWhenLogMarkMappingTurnOn_DetailedSubjectUsed() {
turnOnLogMarkMapping();
logMessage = new LogMessage(LOG_MESSAGE, treeLogChannelId, LOG_LEVEL);
@@ -62,7 +61,7 @@ public class LogMessageTest {
}
@Test
- public void testWhenLogMarkMappingTurnOff_SimpleSubjectUsed() {
+ void testWhenLogMarkMappingTurnOff_SimpleSubjectUsed() {
turnOffLogMarkMapping();
logMessage = new LogMessage(LOG_MESSAGE, treeLogChannelId, LOG_LEVEL);
@@ -73,8 +72,7 @@ public class LogMessageTest {
}
@Test
- public void
- testWhenLogMarkMappingTurnOnAndNoSubMappingUsed_DetailedSubjectContainsOnlySimpleSubject() {
+ void testWhenLogMarkMappingTurnOnAndNoSubMappingUsed_DetailedSubjectContainsOnlySimpleSubject() {
turnOnLogMarkMapping();
simpleLogChannelId =
@@ -90,7 +88,7 @@ public class LogMessageTest {
}
@Test
- public void testToString() {
+ void testToString() {
turnOnLogMarkMapping();
simpleLogChannelId =
@@ -102,7 +100,7 @@ public class LogMessageTest {
}
@Test
- public void testToString_withOneArgument() {
+ void testToString_withOneArgument() {
turnOnLogMarkMapping();
simpleLogChannelId =
@@ -116,7 +114,7 @@ public class LogMessageTest {
}
@Test
- public void testGetMessage() {
+ void testGetMessage() {
LogMessage msg =
new LogMessage(
"m {0}, {1}, {2}, {3}, {4,number,#.00}, {5} {foe}",
diff --git a/engine/src/test/java/org/apache/hop/core/metadata/SerializableMetadataProviderTest.java b/engine/src/test/java/org/apache/hop/core/metadata/SerializableMetadataProviderTest.java
index a75a94c3a2..a681e21ce5 100644
--- a/engine/src/test/java/org/apache/hop/core/metadata/SerializableMetadataProviderTest.java
+++ b/engine/src/test/java/org/apache/hop/core/metadata/SerializableMetadataProviderTest.java
@@ -17,25 +17,25 @@
package org.apache.hop.core.metadata;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
import org.apache.hop.core.HopEnvironment;
import org.apache.hop.metadata.api.IHopMetadataSerializer;
import org.apache.hop.metadata.serializer.memory.MemoryMetadataProvider;
import org.apache.hop.server.HopServerMeta;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
-public class SerializableMetadataProviderTest {
+class SerializableMetadataProviderTest {
- @Before
- public void before() throws Exception {
+ @BeforeEach
+ void before() throws Exception {
HopEnvironment.init();
}
@Test
- public void testRoundTrip() throws Exception {
+ void testRoundTrip() throws Exception {
MemoryMetadataProvider source = new MemoryMetadataProvider();
IHopMetadataSerializer<HopServerMeta> sourceSerializer =
source.getSerializer(HopServerMeta.class);
diff --git a/engine/src/test/java/org/apache/hop/core/reflection/StringSearchResultTest.java b/engine/src/test/java/org/apache/hop/core/reflection/StringSearchResultTest.java
index 2c6062f18f..ee9c721bcc 100644
--- a/engine/src/test/java/org/apache/hop/core/reflection/StringSearchResultTest.java
+++ b/engine/src/test/java/org/apache/hop/core/reflection/StringSearchResultTest.java
@@ -17,21 +17,20 @@
package org.apache.hop.core.reflection;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
import org.apache.hop.core.Const;
import org.apache.hop.core.row.IRowMeta;
import org.apache.hop.core.row.IValueMeta;
import org.apache.hop.i18n.BaseMessages;
-import org.junit.Test;
-
-public class StringSearchResultTest {
+import org.junit.jupiter.api.Test;
+class StringSearchResultTest {
private Class<?> PKG = Const.class;
@Test
- public void testgetResultRowMeta() {
+ void testGetResultRowMeta() {
IRowMeta rm = StringSearchResult.getResultRowMeta();
assertNotNull(rm);
assertEquals(4, rm.getValueMetaList().size());
diff --git a/engine/src/test/java/org/apache/hop/core/util/ConfigurableStreamLoggerTest.java b/engine/src/test/java/org/apache/hop/core/util/ConfigurableStreamLoggerTest.java
index 5a26df0cc3..420b62efa3 100644
--- a/engine/src/test/java/org/apache/hop/core/util/ConfigurableStreamLoggerTest.java
+++ b/engine/src/test/java/org/apache/hop/core/util/ConfigurableStreamLoggerTest.java
@@ -23,29 +23,28 @@ import java.nio.charset.StandardCharsets;
import org.apache.hop.core.logging.ILogChannel;
import org.apache.hop.core.logging.LogChannel;
import org.apache.hop.core.logging.LogLevel;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
import org.mockito.Mockito;
-public class ConfigurableStreamLoggerTest {
-
- public static String INPUT = "str1\nstr2";
- public static String PREFIX = "OUTPUT";
- public static String OUT1 = "OUTPUT str1";
- public static String OUT2 = "OUTPUT str2";
+class ConfigurableStreamLoggerTest {
+ static final String INPUT = "str1\nstr2";
+ static final String PREFIX = "OUTPUT";
+ static final String OUT1 = "OUTPUT str1";
+ static final String OUT2 = "OUTPUT str2";
private ConfigurableStreamLogger streamLogger;
private ILogChannel log;
private InputStream is;
- @Before
- public void init() {
+ @BeforeEach
+ void init() {
log = Mockito.mock(LogChannel.class);
is = new ByteArrayInputStream(INPUT.getBytes(StandardCharsets.UTF_8));
}
@Test
- public void testLogError() {
+ void testLogError() {
streamLogger = new ConfigurableStreamLogger(log, is, LogLevel.ERROR, PREFIX);
streamLogger.run();
@@ -54,7 +53,7 @@ public class ConfigurableStreamLoggerTest {
}
@Test
- public void testLogMinimal() {
+ void testLogMinimal() {
streamLogger = new ConfigurableStreamLogger(log, is, LogLevel.MINIMAL, PREFIX);
streamLogger.run();
@@ -63,7 +62,7 @@ public class ConfigurableStreamLoggerTest {
}
@Test
- public void testLogBasic() {
+ void testLogBasic() {
streamLogger = new ConfigurableStreamLogger(log, is, LogLevel.BASIC, PREFIX);
streamLogger.run();
@@ -72,7 +71,7 @@ public class ConfigurableStreamLoggerTest {
}
@Test
- public void testLogDetailed() {
+ void testLogDetailed() {
streamLogger = new ConfigurableStreamLogger(log, is, LogLevel.DETAILED, PREFIX);
streamLogger.run();
@@ -81,7 +80,7 @@ public class ConfigurableStreamLoggerTest {
}
@Test
- public void testLogDebug() {
+ void testLogDebug() {
streamLogger = new ConfigurableStreamLogger(log, is, LogLevel.DEBUG, PREFIX);
streamLogger.run();
@@ -90,7 +89,7 @@ public class ConfigurableStreamLoggerTest {
}
@Test
- public void testLogRowlevel() {
+ void testLogRowLevel() {
streamLogger = new ConfigurableStreamLogger(log, is, LogLevel.ROWLEVEL, PREFIX);
streamLogger.run();
diff --git a/engine/src/test/java/org/apache/hop/core/util/JavaScriptUtilsTest.java b/engine/src/test/java/org/apache/hop/core/util/JavaScriptUtilsTest.java
index 3e9a440668..608ee3b313 100644
--- a/engine/src/test/java/org/apache/hop/core/util/JavaScriptUtilsTest.java
+++ b/engine/src/test/java/org/apache/hop/core/util/JavaScriptUtilsTest.java
@@ -17,17 +17,20 @@
package org.apache.hop.core.util;
-import static org.junit.Assert.assertArrayEquals;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertArrayEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertInstanceOf;
+import static org.junit.jupiter.api.Assertions.assertNull;
+import static org.junit.jupiter.api.Assertions.assertThrows;
import java.math.BigDecimal;
import java.util.Date;
+import java.util.Objects;
import org.apache.hop.core.row.IValueMeta;
-import org.junit.AfterClass;
-import org.junit.BeforeClass;
-import org.junit.Test;
+import org.junit.jupiter.api.AfterAll;
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.Test;
import org.mozilla.javascript.Context;
import org.mozilla.javascript.NativeJavaObject;
import org.mozilla.javascript.Scriptable;
@@ -35,7 +38,7 @@ import org.mozilla.javascript.ScriptableObject;
import org.mozilla.javascript.Undefined;
/** A set of tests for {@linkplain JavaScriptUtils} class. */
-public class JavaScriptUtilsTest {
+class JavaScriptUtilsTest {
private static final String UNDEFINED = Undefined.class.getName();
private static final String JAVA_OBJECT = NativeJavaObject.class.getName();
@@ -44,14 +47,14 @@ public class JavaScriptUtilsTest {
private static Context ctx;
private static ScriptableObject scope;
- @BeforeClass
- public static void setUp() {
+ @BeforeAll
+ static void setUp() {
ctx = Context.enter();
scope = ctx.initStandardObjects();
}
- @AfterClass
- public static void tearDown() {
+ @AfterAll
+ static void tearDown() {
scope = null;
ctx = null;
Context.exit();
@@ -68,46 +71,50 @@ public class JavaScriptUtilsTest {
// jsToNumber tests
@Test
- public void jsToNumber_Undefined() {
+ void jsToNumber_Undefined() {
assertNull(JavaScriptUtils.jsToNumber(null, UNDEFINED));
}
@Test
- public void jsToNumber_NativeJavaObject_Double() {
+ void jsToNumber_NativeJavaObject_Double() {
Scriptable value = getDoubleValue();
Number number = JavaScriptUtils.jsToNumber(value, JAVA_OBJECT);
+ Assertions.assertNotNull(number);
assertEquals(1.0, number.doubleValue(), 1e-6);
}
@Test
- public void jsToNumber_NativeJavaObject_Int() {
+ void jsToNumber_NativeJavaObject_Int() {
Scriptable value = getIntValue();
Number number = JavaScriptUtils.jsToNumber(value, JAVA_OBJECT);
+ Assertions.assertNotNull(number);
assertEquals(1.0, number.doubleValue(), 1e-6);
}
@Test
- public void jsToNumber_NativeNumber() {
+ void jsToNumber_NativeNumber() {
Scriptable value = Context.toObject(1.0, scope);
Number number = JavaScriptUtils.jsToNumber(value, NATIVE_NUMBER);
+ Assertions.assertNotNull(number);
assertEquals(1.0, number.doubleValue(), 1e-6);
}
@Test
- public void jsToNumber_JavaNumber() {
+ void jsToNumber_JavaNumber() {
Number number = JavaScriptUtils.jsToNumber(1.0, Double.class.getName());
+ Assertions.assertNotNull(number);
assertEquals(1.0, number.doubleValue(), 1e-6);
}
// jsToInteger tests
@Test
- public void jsToInteger_Undefined() {
+ void jsToInteger_Undefined() {
assertNull(JavaScriptUtils.jsToInteger(null, Undefined.class));
}
@Test
- public void jsToInteger_NaturalNumbers() {
+ void jsToInteger_NaturalNumbers() {
Number[] naturalNumbers = new Number[] {(byte) 1, (short) 1, 1, (long) 1};
for (Number number : naturalNumbers) {
@@ -116,57 +123,58 @@ public class JavaScriptUtilsTest {
}
@Test
- public void jsToInteger_String() {
+ void jsToInteger_String() {
assertEquals(Long.valueOf(1), JavaScriptUtils.jsToInteger("1", String.class));
}
- @Test(expected = NumberFormatException.class)
- public void jsToInteger_String_Unparseable() {
- JavaScriptUtils.jsToInteger("q", String.class);
+ @Test
+ void jsToInteger_String_Unparseable() {
+ assertThrows(NumberFormatException.class, () -> JavaScriptUtils.jsToInteger("q", String.class));
... 5074 lines suppressed ...