You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nifi.apache.org by ex...@apache.org on 2022/12/13 17:38:21 UTC
[nifi] branch main updated: NIFI-10877 Converted more nifi-framework-core tests from JUnit 4 to 5
This is an automated email from the ASF dual-hosted git repository.
exceptionfactory pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/nifi.git
The following commit(s) were added to refs/heads/main by this push:
new e21f622643 NIFI-10877 Converted more nifi-framework-core tests from JUnit 4 to 5
e21f622643 is described below
commit e21f622643236e110f39a65ba28abdb484756051
Author: dan-s1 <ds...@gmail.com>
AuthorDate: Fri Dec 9 16:46:29 2022 +0000
NIFI-10877 Converted more nifi-framework-core tests from JUnit 4 to 5
This closes #6775
Signed-off-by: David Handermann <ex...@apache.org>
---
.../EncryptedFileSystemRepositoryTest.groovy | 24 +-
.../serialization/FlowFromDOMFactoryTest.groovy | 9 +-
.../fingerprint/FingerprintFactoryGroovyIT.groovy | 21 +-
.../FingerprintFactoryGroovyTest.groovy | 27 +-
...cryptedSequentialAccessWriteAheadLogTest.groovy | 56 +--
.../apache/nifi/cluster/HeartbeatPayloadTest.java | 12 +-
.../nifi/cluster/ZooKeeperClientConfigTest.java | 42 +-
.../components/LongRunningTaskMonitorTest.java | 6 +-
.../nifi/controller/StandardFlowServiceTest.java | 110 ++---
.../nifi/controller/StandardProcessorNodeIT.java | 243 +++++------
.../TestEncryptedFileSystemSwapManager.java | 11 +-
.../nifi/controller/TestFileSystemSwapManager.java | 26 +-
.../apache/nifi/controller/TestFlowController.java | 115 +++--
.../nifi/controller/TestStandardFlowFileQueue.java | 56 +--
.../election/TestCuratorACLProviderFactory.java | 12 +-
.../queue/clustered/LoadBalancedQueueIT.java | 71 +--
.../TestContentRepositoryFlowFileAccess.java | 20 +-
.../queue/clustered/TestNaiveLimitThreshold.java | 6 +-
.../TestSocketLoadBalancedFlowFileQueue.java | 45 +-
.../clustered/TestSwappablePriorityQueue.java | 54 +--
.../client/async/nio/TestLoadBalanceSession.java | 57 ++-
.../server/TestStandardLoadBalanceProtocol.java | 49 +--
.../reporting/TestStandardReportingContext.java | 12 +-
.../SchemaRepositoryRecordSerdeTest.java | 14 +-
.../repository/StandardProcessSessionIT.java | 483 +++++++--------------
.../repository/TestFileSystemRepository.java | 90 ++--
.../TestWriteAheadFlowFileRepository.java | 60 ++-
.../claim/TestContentClaimWriteCache.java | 20 +-
.../repository/io/TestContentClaimInputStream.java | 12 +-
.../io/TestFlowFileAccessInputStream.java | 42 +-
.../repository/io/TestLimitedInputStream.java | 13 +-
.../scheduling/ProcessorLifecycleIT.java | 20 +-
.../scheduling/TestStandardProcessScheduler.java | 176 ++++----
.../serialization/StandardFlowSerializerTest.java | 14 +-
.../StandardControllerServiceProviderIT.java | 10 +-
.../StandardControllerServiceProviderTest.java | 22 +-
.../TestStandardControllerServiceProvider.java | 104 ++---
.../nifi/controller/state/TestStateMapSerDe.java | 10 +-
.../state/server/ITZooKeeperStateServerTLS.java | 100 ++---
.../TestZooKeeperStateServerConfigurations.java | 60 +--
...TestCachingConnectionStatusAnalyticsEngine.java | 8 +-
.../analytics/TestConnectionStatusAnalytics.java | 2 +-
.../analytics/TestStatusAnalyticsEngine.java | 39 +-
.../analytics/models/TestOrdinaryLeastSquares.java | 8 +-
.../analytics/models/TestSimpleRegression.java | 5 +-
...EmbeddedQuestDbStatusHistoryRepositoryTest.java | 8 +-
.../EmbeddedQuestDbRolloverHandlerTest.java | 306 -------------
...DbStatusHistoryRepositoryForComponentsTest.java | 19 +-
...dQuestDbStatusHistoryRepositoryForNodeTest.java | 11 +-
.../JsonNodeStatusHistoryDumpFactoryTest.java | 11 +-
.../status/history/StatusHistoryUtilTest.java | 17 +-
.../status/history/TestMetricRollingBuffer.java | 17 +-
...ComponentStatusRepositoryForComponentsTest.java | 2 +-
...latileComponentStatusRepositoryForNodeTest.java | 103 ++---
.../BufferedWriterForStatusStorageTest.java | 13 +-
.../swap/TestSchemaSwapSerializerDeserializer.java | 36 +-
.../swap/TestSimpleSwapSerializerDeserializer.java | 12 +-
.../nifi/controller/tasks/TestConnectableTask.java | 27 +-
.../events/TestNodeBulletinProcessingStrategy.java | 4 +-
.../nifi/fingerprint/FingerprintFactoryTest.java | 17 +-
.../nifi/integration/FrameworkIntegrationTest.java | 24 +-
.../cs/ControllerServiceReferenceIT.java | 2 +-
.../flowfilerepo/OOMEFlowFileRepoUpdateIT.java | 4 +-
.../integration/lifecycle/ContentCleanupIT.java | 10 +-
.../nifi/integration/parameters/ParametersIT.java | 22 +-
.../processgroup/StandardProcessGroupIT.java | 17 +-
.../processor/ProcessorParameterTokenIT.java | 13 +-
.../nifi/integration/swap/ClusteredSwapFileIT.java | 251 -----------
.../election/ITSecureClientZooKeeperFactory.java | 18 +-
.../nifi/persistence/TemplateSerializerTest.java | 4 +-
.../flow/mapping/NiFiRegistryFlowMapperTest.java | 15 +-
.../nifi/util/TestFileBasedVariableRegistry.java | 6 +-
72 files changed, 1262 insertions(+), 2123 deletions(-)
diff --git a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/groovy/org/apache/nifi/controller/repository/crypto/EncryptedFileSystemRepositoryTest.groovy b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/groovy/org/apache/nifi/controller/repository/crypto/EncryptedFileSystemRepositoryTest.groovy
index 9c8b9c904e..2c1962dae4 100644
--- a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/groovy/org/apache/nifi/controller/repository/crypto/EncryptedFileSystemRepositoryTest.groovy
+++ b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/groovy/org/apache/nifi/controller/repository/crypto/EncryptedFileSystemRepositoryTest.groovy
@@ -16,7 +16,6 @@
*/
package org.apache.nifi.controller.repository.crypto
-import org.apache.commons.lang3.SystemUtils
import org.apache.nifi.controller.repository.StandardContentRepositoryContext
import org.apache.nifi.controller.repository.claim.ContentClaim
import org.apache.nifi.controller.repository.claim.StandardResourceClaimManager
@@ -26,13 +25,12 @@ import org.apache.nifi.security.kms.StaticKeyProvider
import org.apache.nifi.util.NiFiProperties
import org.bouncycastle.jce.provider.BouncyCastleProvider
import org.bouncycastle.util.encoders.Hex
-import org.junit.After
-import org.junit.Assume
-import org.junit.Before
-import org.junit.BeforeClass
-import org.junit.Test
-import org.junit.runner.RunWith
-import org.junit.runners.JUnit4
+import org.junit.jupiter.api.AfterEach
+import org.junit.jupiter.api.BeforeEach
+import org.junit.jupiter.api.BeforeAll
+import org.junit.jupiter.api.Test
+import org.junit.jupiter.api.condition.DisabledOnOs
+import org.junit.jupiter.api.condition.OS
import org.slf4j.Logger
import org.slf4j.LoggerFactory
@@ -40,7 +38,7 @@ import java.nio.charset.StandardCharsets
import java.nio.file.Path
import java.security.Security
-@RunWith(JUnit4.class)
+@DisabledOnOs(OS.WINDOWS)
class EncryptedFileSystemRepositoryTest {
private static final Logger logger = LoggerFactory.getLogger(EncryptedFileSystemRepositoryTest.class)
@@ -64,10 +62,8 @@ class EncryptedFileSystemRepositoryTest {
(NiFiProperties.CONTENT_REPOSITORY_ENCRYPTION_KEY_PROVIDER_LOCATION) : ""
]
- @BeforeClass
+ @BeforeAll
static void setUpOnce() throws Exception {
- Assume.assumeTrue("Test only runs on *nix", !SystemUtils.IS_OS_WINDOWS)
-
Security.addProvider(new BouncyCastleProvider())
logger.metaClass.methodMissing = { String name, args ->
@@ -75,7 +71,7 @@ class EncryptedFileSystemRepositoryTest {
}
}
- @Before
+ @BeforeEach
void setUp() throws Exception {
// Use mock NiFiProperties w/ encrypted configs
repository = initializeRepository()
@@ -103,7 +99,7 @@ class EncryptedFileSystemRepositoryTest {
repository
}
- @After
+ @AfterEach
void tearDown() throws Exception {
repository.shutdown()
}
diff --git a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/groovy/org/apache/nifi/controller/serialization/FlowFromDOMFactoryTest.groovy b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/groovy/org/apache/nifi/controller/serialization/FlowFromDOMFactoryTest.groovy
index 200f368f1e..8766720e0c 100644
--- a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/groovy/org/apache/nifi/controller/serialization/FlowFromDOMFactoryTest.groovy
+++ b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/groovy/org/apache/nifi/controller/serialization/FlowFromDOMFactoryTest.groovy
@@ -18,20 +18,17 @@ package org.apache.nifi.controller.serialization
import org.apache.nifi.encrypt.EncryptionException
import org.apache.nifi.encrypt.PropertyEncryptor
-import org.junit.BeforeClass
-import org.junit.Test
-import org.junit.runner.RunWith
-import org.junit.runners.JUnit4
+import org.junit.jupiter.api.BeforeAll
+import org.junit.jupiter.api.Test
import org.slf4j.Logger
import org.slf4j.LoggerFactory
import static groovy.test.GroovyAssert.shouldFail
-@RunWith(JUnit4.class)
class FlowFromDOMFactoryTest {
private static final Logger logger = LoggerFactory.getLogger(FlowFromDOMFactoryTest.class)
- @BeforeClass
+ @BeforeAll
static void setUpOnce() throws Exception {
logger.metaClass.methodMissing = { String name, args ->
logger.info("[${name?.toUpperCase()}] ${(args as List).join(" ")}")
diff --git a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/groovy/org/apache/nifi/fingerprint/FingerprintFactoryGroovyIT.groovy b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/groovy/org/apache/nifi/fingerprint/FingerprintFactoryGroovyIT.groovy
index a29823fd7c..afb37cfff3 100644
--- a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/groovy/org/apache/nifi/fingerprint/FingerprintFactoryGroovyIT.groovy
+++ b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/groovy/org/apache/nifi/fingerprint/FingerprintFactoryGroovyIT.groovy
@@ -17,35 +17,33 @@
package org.apache.nifi.fingerprint
import org.apache.nifi.encrypt.PropertyEncryptor
+import org.apache.nifi.encrypt.SensitiveValueEncoder
import org.apache.nifi.nar.ExtensionManager
import org.apache.nifi.nar.StandardExtensionDiscoveringManager
import org.apache.nifi.util.NiFiProperties
import org.bouncycastle.jce.provider.BouncyCastleProvider
-import org.junit.After
-import org.junit.AfterClass
-import org.junit.Before
-import org.junit.BeforeClass
-import org.junit.Test
-import org.junit.runner.RunWith
-import org.junit.runners.JUnit4
+import org.junit.jupiter.api.AfterAll
+import org.junit.jupiter.api.BeforeAll
+import org.junit.jupiter.api.Test
import org.slf4j.Logger
import org.slf4j.LoggerFactory
import java.security.Security
-@RunWith(JUnit4.class)
class FingerprintFactoryGroovyIT extends GroovyTestCase {
private static final Logger logger = LoggerFactory.getLogger(FingerprintFactoryGroovyIT.class)
private static PropertyEncryptor mockEncryptor = [
encrypt: { String plaintext -> plaintext.reverse() },
decrypt: { String cipherText -> cipherText.reverse() }] as PropertyEncryptor
+ private static SensitiveValueEncoder mockSensitiveValueEncoder = [
+ getEncoded: { String plaintext -> "[MASKED] (${plaintext.sha256()})".toString() }] as SensitiveValueEncoder
private static ExtensionManager extensionManager = new StandardExtensionDiscoveringManager()
private static String originalPropertiesPath = System.getProperty(NiFiProperties.PROPERTIES_FILE_PATH)
private static final String NIFI_PROPERTIES_PATH = "src/test/resources/conf/nifi.properties"
- @BeforeClass
+ @BeforeAll
static void setUpOnce() throws Exception {
Security.addProvider(new BouncyCastleProvider())
@@ -54,7 +52,7 @@ class FingerprintFactoryGroovyIT extends GroovyTestCase {
}
}
- @AfterClass
+ @AfterAll
static void tearDownOnce() {
if (originalPropertiesPath) {
System.setProperty(NiFiProperties.PROPERTIES_FILE_PATH, originalPropertiesPath)
@@ -80,7 +78,8 @@ class FingerprintFactoryGroovyIT extends GroovyTestCase {
logger.info("Read initial flow: ${initialFlowXML[0..<100]}...")
// Create the FingerprintFactory with collaborators
- FingerprintFactory fingerprintFactory = new FingerprintFactory(mockEncryptor, extensionManager)
+ FingerprintFactory fingerprintFactory =
+ new FingerprintFactory(mockEncryptor, extensionManager, mockSensitiveValueEncoder)
def results = []
def resultDurations = []
diff --git a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/groovy/org/apache/nifi/fingerprint/FingerprintFactoryGroovyTest.groovy b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/groovy/org/apache/nifi/fingerprint/FingerprintFactoryGroovyTest.groovy
index 2bbc1f89d8..25700ca7b5 100644
--- a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/groovy/org/apache/nifi/fingerprint/FingerprintFactoryGroovyTest.groovy
+++ b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/groovy/org/apache/nifi/fingerprint/FingerprintFactoryGroovyTest.groovy
@@ -22,19 +22,16 @@ import org.apache.nifi.nar.ExtensionManager
import org.apache.nifi.nar.StandardExtensionDiscoveringManager
import org.apache.nifi.util.NiFiProperties
import org.bouncycastle.jce.provider.BouncyCastleProvider
-import org.junit.After
-import org.junit.AfterClass
-import org.junit.Before
-import org.junit.BeforeClass
-import org.junit.Test
-import org.junit.runner.RunWith
-import org.junit.runners.JUnit4
+import org.junit.jupiter.api.AfterEach
+import org.junit.jupiter.api.AfterAll
+import org.junit.jupiter.api.BeforeEach
+import org.junit.jupiter.api.BeforeAll
+import org.junit.jupiter.api.Test
import org.slf4j.Logger
import org.slf4j.LoggerFactory
import java.security.Security
-@RunWith(JUnit4.class)
class FingerprintFactoryGroovyTest extends GroovyTestCase {
private static final Logger logger = LoggerFactory.getLogger(FingerprintFactoryGroovyTest.class)
@@ -48,7 +45,7 @@ class FingerprintFactoryGroovyTest extends GroovyTestCase {
private static String originalPropertiesPath = System.getProperty(NiFiProperties.PROPERTIES_FILE_PATH)
private static final String NIFI_PROPERTIES_PATH = "src/test/resources/conf/nifi.properties"
- @BeforeClass
+ @BeforeAll
static void setUpOnce() throws Exception {
Security.addProvider(new BouncyCastleProvider())
@@ -57,17 +54,7 @@ class FingerprintFactoryGroovyTest extends GroovyTestCase {
}
}
- @Before
- void setUp() throws Exception {
-
- }
-
- @After
- void tearDown() throws Exception {
-
- }
-
- @AfterClass
+ @AfterAll
static void tearDownOnce() {
if (originalPropertiesPath) {
System.setProperty(NiFiProperties.PROPERTIES_FILE_PATH, originalPropertiesPath)
diff --git a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/groovy/org/apache/nifi/wali/EncryptedSequentialAccessWriteAheadLogTest.groovy b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/groovy/org/apache/nifi/wali/EncryptedSequentialAccessWriteAheadLogTest.groovy
index 71b96b0aec..fb00f21e8f 100644
--- a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/groovy/org/apache/nifi/wali/EncryptedSequentialAccessWriteAheadLogTest.groovy
+++ b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/groovy/org/apache/nifi/wali/EncryptedSequentialAccessWriteAheadLogTest.groovy
@@ -17,30 +17,38 @@
package org.apache.nifi.wali
-
-import org.apache.commons.lang3.SystemUtils
import org.apache.nifi.controller.queue.FlowFileQueue
-import org.apache.nifi.controller.repository.*
+import org.apache.nifi.controller.repository.EncryptedSchemaRepositoryRecordSerde
+import org.apache.nifi.controller.repository.LiveSerializedRepositoryRecord
+import org.apache.nifi.controller.repository.RepositoryRecordType
+import org.apache.nifi.controller.repository.SchemaRepositoryRecordSerde
+import org.apache.nifi.controller.repository.SerializedRepositoryRecord
+import org.apache.nifi.controller.repository.StandardFlowFileRecord
+import org.apache.nifi.controller.repository.StandardRepositoryRecord
+import org.apache.nifi.controller.repository.StandardRepositoryRecordSerdeFactory
import org.apache.nifi.controller.repository.claim.ResourceClaimManager
import org.apache.nifi.controller.repository.claim.StandardResourceClaimManager
import org.apache.nifi.repository.schema.NoOpFieldCache
import org.apache.nifi.security.kms.StaticKeyProvider
import org.apache.nifi.util.NiFiProperties
-import org.bouncycastle.jce.provider.BouncyCastleProvider
-import org.junit.*
-import org.junit.rules.TestName
-import org.junit.runner.RunWith
-import org.junit.runners.JUnit4
+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.TestInfo
+import org.junit.jupiter.api.condition.DisabledOnOs
+import org.junit.jupiter.api.condition.OS
import org.slf4j.Logger
import org.slf4j.LoggerFactory
import org.wali.SerDe
import org.wali.SerDeFactory
import org.wali.SingletonSerDeFactory
-import java.security.Security
+import static org.junit.jupiter.api.Assertions.assertNotNull
+import static org.junit.jupiter.api.Assertions.assertTrue
-@RunWith(JUnit4.class)
-class EncryptedSequentialAccessWriteAheadLogTest extends GroovyTestCase {
+@DisabledOnOs(OS.WINDOWS)
+class EncryptedSequentialAccessWriteAheadLogTest {
private static final Logger logger = LoggerFactory.getLogger(EncryptedSequentialAccessWriteAheadLogTest.class)
public static final String TEST_QUEUE_IDENTIFIER = "testQueueIdentifier"
@@ -62,20 +70,18 @@ class EncryptedSequentialAccessWriteAheadLogTest extends GroovyTestCase {
private EncryptedSchemaRepositoryRecordSerde esrrs
- @Rule
- public TestName testName = new TestName()
-
- @BeforeClass
+ private TestInfo testName
+
+ @BeforeAll
static void setUpOnce() throws Exception {
- Assume.assumeTrue("Test only runs on *nix", !SystemUtils.IS_OS_WINDOWS)
-
logger.metaClass.methodMissing = { String name, args ->
logger.debug("[${name?.toUpperCase()}] ${(args as List).join(" ")}")
}
}
- @Before
- void setUp() throws Exception {
+ @BeforeEach
+ void setUp(TestInfo testInfo) throws Exception {
+ testName = testInfo
claimManager = new StandardResourceClaimManager()
flowFileQueue = createAndRegisterMockQueue(TEST_QUEUE_IDENTIFIER)
byteArrayOutputStream = new ByteArrayOutputStream()
@@ -91,19 +97,19 @@ class EncryptedSequentialAccessWriteAheadLogTest extends GroovyTestCase {
esrrs = new EncryptedSchemaRepositoryRecordSerde(wrappedSerDe, properties)
}
- @After
+ @AfterEach
void tearDown() throws Exception {
claimManager.purge()
}
- private FlowFileQueue createMockQueue(String identifier = testName.methodName + new Date().toString()) {
+ private FlowFileQueue createMockQueue(String identifier = testName.testMethod.get().name + new Date().toString()) {
[getIdentifier: { ->
logger.mock("Retrieving flowfile queue identifier: ${identifier}" as String)
identifier
}] as FlowFileQueue
}
- private FlowFileQueue createAndRegisterMockQueue(String identifier = testName.methodName + new Date().toString()) {
+ private FlowFileQueue createAndRegisterMockQueue(String identifier = testName.testMethod.get().name + new Date().toString()) {
FlowFileQueue queue = createMockQueue(identifier)
queue
}
@@ -118,7 +124,7 @@ class EncryptedSequentialAccessWriteAheadLogTest extends GroovyTestCase {
}
private String getMockUUID() {
- "${testName.methodName ?: "no_test"}@${new Date().format("mmssSSS")}" as String
+ "${testName.testMethod.get().name ?: "no_test"}@${new Date().format("mmssSSS")}" as String
}
/** This test creates flowfile records, adds them to the repository, and then recovers them to ensure they were persisted */
@@ -188,7 +194,7 @@ class EncryptedSequentialAccessWriteAheadLogTest extends GroovyTestCase {
private SequentialAccessWriteAheadLog<SerializedRepositoryRecord> createWriteRepo(final SerDe<SerializedRepositoryRecord> serde) throws IOException {
final File targetDir = new File("target")
- final File storageDir = new File(targetDir, testName?.methodName ?: "unknown_test")
+ final File storageDir = new File(targetDir, testName.testMethod.get().name)
deleteRecursively(storageDir)
assertTrue(storageDir.mkdirs())
@@ -204,7 +210,7 @@ class EncryptedSequentialAccessWriteAheadLogTest extends GroovyTestCase {
private SequentialAccessWriteAheadLog<SerializedRepositoryRecord> createRecoveryRepo() throws IOException {
final File targetDir = new File("target")
- final File storageDir = new File(targetDir, testName?.methodName ?: "unknown_test")
+ final File storageDir = new File(targetDir, testName.testMethod.get().name)
final SerDe<SerializedRepositoryRecord> serde = buildEncryptedSerDe()
final SerDeFactory<SerializedRepositoryRecord> serdeFactory = new SingletonSerDeFactory<>(serde)
diff --git a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/java/org/apache/nifi/cluster/HeartbeatPayloadTest.java b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/java/org/apache/nifi/cluster/HeartbeatPayloadTest.java
index 429a791f5e..b7224676f5 100644
--- a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/java/org/apache/nifi/cluster/HeartbeatPayloadTest.java
+++ b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/java/org/apache/nifi/cluster/HeartbeatPayloadTest.java
@@ -16,16 +16,16 @@
*/
package org.apache.nifi.cluster;
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import org.apache.nifi.cluster.protocol.HeartbeatPayload;
import org.apache.nifi.util.NiFiProperties;
-import org.junit.Before;
-import org.junit.BeforeClass;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.Test;
/**
*/
@@ -36,12 +36,12 @@ public class HeartbeatPayloadTest {
private int totalFlowFileCount;
private ByteArrayOutputStream marshalledBytes;
- @BeforeClass
+ @BeforeAll
public static void setupSuite() {
System.setProperty(NiFiProperties.PROPERTIES_FILE_PATH, HeartbeatPayloadTest.class.getResource("/conf/nifi.properties").getFile());
}
- @Before
+ @BeforeEach
public void setup() {
payload = new HeartbeatPayload();
activeThreadCount = 15;
diff --git a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/java/org/apache/nifi/cluster/ZooKeeperClientConfigTest.java b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/java/org/apache/nifi/cluster/ZooKeeperClientConfigTest.java
index f54c10e538..cf3f5403c9 100644
--- a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/java/org/apache/nifi/cluster/ZooKeeperClientConfigTest.java
+++ b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/java/org/apache/nifi/cluster/ZooKeeperClientConfigTest.java
@@ -18,14 +18,15 @@ package org.apache.nifi.cluster;
import org.apache.nifi.controller.cluster.ZooKeeperClientConfig;
import org.apache.nifi.util.NiFiProperties;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import java.util.Properties;
-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.assertThrows;
+import static org.junit.jupiter.api.Assertions.assertTrue;
public class ZooKeeperClientConfigTest {
@@ -51,9 +52,10 @@ public class ZooKeeperClientConfigTest {
assertEquals(LOCAL_CONNECT_STRING, cleanedInput);
}
- @Test(expected = IllegalStateException.class)
+ @Test
public void testInvalidSingleEntry(){
- ZooKeeperClientConfig.cleanConnectString("local: 1a34 ");
+ assertThrows(IllegalStateException.class,
+ () -> ZooKeeperClientConfig.cleanConnectString("local: 1a34 "));
}
@Test
@@ -70,9 +72,10 @@ public class ZooKeeperClientConfigTest {
assertEquals(input, cleanedInput);
}
- @Test(expected = IllegalStateException.class)
+ @Test
public void testMultiValidEntrySkipOne(){
- ZooKeeperClientConfig.cleanConnectString("local:1234,local:1235,local:12a5,local:14952");
+ assertThrows(IllegalStateException.class, () ->
+ ZooKeeperClientConfig.cleanConnectString("local:1234,local:1235,local:12a5,local:14952"));
}
@Test
@@ -82,9 +85,10 @@ public class ZooKeeperClientConfigTest {
assertEquals("local:1234,local:1235,local:1295,local:14952", cleanedInput);
}
- @Test(expected = IllegalStateException.class)
+ @Test
public void testMultiValidOneNonsense(){
- ZooKeeperClientConfig.cleanConnectString(" local : 1234 , local: 1235:wack,local :1295,local:14952 ");
+ assertThrows(IllegalStateException.class, () ->
+ ZooKeeperClientConfig.cleanConnectString(" local : 1234 , local: 1235:wack,local :1295,local:14952 "));
}
@Test
@@ -95,7 +99,7 @@ public class ZooKeeperClientConfigTest {
final ZooKeeperClientConfig zkClientConfig = ZooKeeperClientConfig.createConfig(new NiFiProperties(properties));
assertTrue(zkClientConfig.isClientSecure());
- assertEquals(zkClientConfig.getConnectionSocket(), ZooKeeperClientConfig.NETTY_CLIENT_CNXN_SOCKET);
+ assertEquals(ZooKeeperClientConfig.NETTY_CLIENT_CNXN_SOCKET, zkClientConfig.getConnectionSocket());
}
@Test
@@ -106,7 +110,7 @@ public class ZooKeeperClientConfigTest {
final ZooKeeperClientConfig zkClientConfig = ZooKeeperClientConfig.createConfig(new NiFiProperties(properties));
assertFalse(zkClientConfig.isClientSecure());
- assertEquals(zkClientConfig.getConnectionSocket(), ZooKeeperClientConfig.NIO_CLIENT_CNXN_SOCKET);
+ assertEquals(ZooKeeperClientConfig.NIO_CLIENT_CNXN_SOCKET, zkClientConfig.getConnectionSocket());
}
@Test
@@ -117,7 +121,7 @@ public class ZooKeeperClientConfigTest {
final ZooKeeperClientConfig zkClientConfig = ZooKeeperClientConfig.createConfig(new NiFiProperties(properties));
assertFalse(zkClientConfig.isClientSecure());
- assertEquals(zkClientConfig.getConnectionSocket(), ZooKeeperClientConfig.NIO_CLIENT_CNXN_SOCKET);
+ assertEquals(ZooKeeperClientConfig.NIO_CLIENT_CNXN_SOCKET, zkClientConfig.getConnectionSocket());
}
@Test
@@ -128,7 +132,7 @@ public class ZooKeeperClientConfigTest {
final ZooKeeperClientConfig zkClientConfig = ZooKeeperClientConfig.createConfig(new NiFiProperties(properties));
assertTrue(zkClientConfig.isClientSecure());
- assertEquals(zkClientConfig.getConnectionSocket(), ZooKeeperClientConfig.NETTY_CLIENT_CNXN_SOCKET);
+ assertEquals(ZooKeeperClientConfig.NETTY_CLIENT_CNXN_SOCKET, zkClientConfig.getConnectionSocket());
}
@Test
@@ -140,15 +144,17 @@ public class ZooKeeperClientConfigTest {
final ZooKeeperClientConfig zkClientConfig = ZooKeeperClientConfig.createConfig(new NiFiProperties(properties));
assertTrue(zkClientConfig.isClientSecure());
- assertEquals(zkClientConfig.getConnectionSocket(), ZooKeeperClientConfig.NETTY_CLIENT_CNXN_SOCKET);
+ assertEquals(ZooKeeperClientConfig.NETTY_CLIENT_CNXN_SOCKET, zkClientConfig.getConnectionSocket());
}
- @Test(expected = RuntimeException.class)
+ @Test
public void testInvalidClientSecure() {
final Properties properties = new Properties();
properties.setProperty(NiFiProperties.ZOOKEEPER_CONNECT_STRING, LOCAL_CONNECT_STRING);
properties.setProperty(NiFiProperties.ZOOKEEPER_CLIENT_SECURE, "meh");
- ZooKeeperClientConfig.createConfig(new NiFiProperties(properties));
+
+ assertThrows(RuntimeException.class, () ->
+ ZooKeeperClientConfig.createConfig(new NiFiProperties(properties)));
}
@Test
diff --git a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/java/org/apache/nifi/components/LongRunningTaskMonitorTest.java b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/java/org/apache/nifi/components/LongRunningTaskMonitorTest.java
index 6dca04b397..8ba978910f 100644
--- a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/java/org/apache/nifi/components/LongRunningTaskMonitorTest.java
+++ b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/java/org/apache/nifi/components/LongRunningTaskMonitorTest.java
@@ -25,7 +25,7 @@ import org.apache.nifi.controller.flow.FlowManager;
import org.apache.nifi.events.EventReporter;
import org.apache.nifi.groups.ProcessGroup;
import org.apache.nifi.reporting.Severity;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import org.mockito.ArgumentCaptor;
import org.slf4j.Logger;
@@ -33,8 +33,8 @@ import java.text.NumberFormat;
import java.util.Arrays;
import java.util.Locale;
-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.ArgumentMatchers.eq;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.times;
diff --git a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/java/org/apache/nifi/controller/StandardFlowServiceTest.java b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/java/org/apache/nifi/controller/StandardFlowServiceTest.java
index d1607afeac..8dd8a8c9de 100644
--- a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/java/org/apache/nifi/controller/StandardFlowServiceTest.java
+++ b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/java/org/apache/nifi/controller/StandardFlowServiceTest.java
@@ -41,11 +41,11 @@ import org.apache.nifi.web.api.dto.ProcessGroupDTO;
import org.apache.nifi.web.api.dto.ProcessorConfigDTO;
import org.apache.nifi.web.api.dto.ProcessorDTO;
import org.apache.nifi.web.revision.RevisionManager;
-import org.junit.Assert;
-import org.junit.Before;
-import org.junit.BeforeClass;
-import org.junit.Ignore;
-import org.junit.Test;
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.Disabled;
+import org.junit.jupiter.api.Test;
import org.w3c.dom.Document;
import java.io.ByteArrayOutputStream;
@@ -54,12 +54,13 @@ import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
-import static org.junit.Assert.fail;
+import static org.junit.jupiter.api.Assertions.assertThrows;
+import static org.junit.jupiter.api.Assertions.fail;
import static org.mockito.Mockito.mock;
/**
*/
-@Ignore
+@Disabled
public class StandardFlowServiceTest {
private StandardFlowService flowService;
@@ -74,12 +75,12 @@ public class StandardFlowServiceTest {
private ExtensionManager extensionManager;
private StatusHistoryRepository statusHistoryRepository;
- @BeforeClass
+ @BeforeAll
public static void setupSuite() {
System.setProperty(NiFiProperties.PROPERTIES_FILE_PATH, StandardFlowServiceTest.class.getResource("/conf/nifi.properties").getFile());
}
- @Before
+ @BeforeEach
public void setup() throws Exception {
properties = NiFiProperties.createBasicNiFiProperties(null);
@@ -111,13 +112,16 @@ public class StandardFlowServiceTest {
String expectedFlow = new String(flowBytes).trim();
String actualFlow = new String(baos.toByteArray()).trim();
- Assert.assertEquals(expectedFlow, actualFlow);
+ Assertions.assertEquals(expectedFlow, actualFlow);
}
- @Test(expected = FlowSerializationException.class)
+ @Test
public void testLoadWithCorruptFlow() throws IOException {
byte[] flowBytes = IOUtils.toByteArray(StandardFlowServiceTest.class.getResourceAsStream("/conf/all-flow-corrupt.xml"));
- flowService.load(new StandardDataFlow(flowBytes, null, null, new HashSet<>()));
+
+ assertThrows(FlowSerializationException.class, () ->
+ flowService.load(new StandardDataFlow(flowBytes, null,
+ null, new HashSet<>())));
}
@Test
@@ -135,7 +139,7 @@ public class StandardFlowServiceTest {
String expectedFlow = new String(flowBytes).trim();
String actualFlow = new String(baos.toByteArray()).trim();
- Assert.assertEquals(expectedFlow, actualFlow);
+ Assertions.assertEquals(expectedFlow, actualFlow);
}
@Test
@@ -156,7 +160,7 @@ public class StandardFlowServiceTest {
String expectedFlow = new String(originalBytes).trim();
String actualFlow = new String(baos.toByteArray()).trim();
- Assert.assertEquals(expectedFlow, actualFlow);
+ Assertions.assertEquals(expectedFlow, actualFlow);
}
}
@@ -178,7 +182,7 @@ public class StandardFlowServiceTest {
String expectedFlow = new String(originalBytes).trim();
String actualFlow = new String(baos.toByteArray()).trim();
- Assert.assertEquals(expectedFlow, actualFlow);
+ Assertions.assertEquals(expectedFlow, actualFlow);
}
}
@@ -187,7 +191,7 @@ public class StandardFlowServiceTest {
return;
}
- Assert.assertEquals(expected.getComments(), actual.getComments());
+ Assertions.assertEquals(expected.getComments(), actual.getComments());
assertEquals(expected.getContents(), actual.getContents());
}
@@ -197,7 +201,7 @@ public class StandardFlowServiceTest {
}
// check connections
- Assert.assertEquals(expected.getConnections().size(), actual.getConnections().size());
+ Assertions.assertEquals(expected.getConnections().size(), actual.getConnections().size());
List<ConnectionDTO> expectedConnections = new ArrayList<>(expected.getConnections());
List<ConnectionDTO> actualConnections = new ArrayList<>(actual.getConnections());
for (int i = 0; i < expectedConnections.size(); i++) {
@@ -205,7 +209,7 @@ public class StandardFlowServiceTest {
}
// check groups
- Assert.assertEquals(expected.getProcessGroups().size(), actual.getProcessGroups().size());
+ Assertions.assertEquals(expected.getProcessGroups().size(), actual.getProcessGroups().size());
List<ProcessGroupDTO> expectedProcessGroups = new ArrayList<>(expected.getProcessGroups());
List<ProcessGroupDTO> actualProcessGroups = new ArrayList<>(actual.getProcessGroups());
for (int i = 0; i < expectedProcessGroups.size(); i++) {
@@ -213,7 +217,7 @@ public class StandardFlowServiceTest {
}
// check input ports
- Assert.assertEquals(expected.getInputPorts().size(), actual.getInputPorts().size());
+ Assertions.assertEquals(expected.getInputPorts().size(), actual.getInputPorts().size());
List<PortDTO> expectedInputPorts = new ArrayList<>(expected.getInputPorts());
List<PortDTO> actualInputPort = new ArrayList<>(actual.getInputPorts());
for (int i = 0; i < expectedInputPorts.size(); i++) {
@@ -221,7 +225,7 @@ public class StandardFlowServiceTest {
}
// check labels
- Assert.assertEquals(expected.getLabels().size(), actual.getLabels().size());
+ Assertions.assertEquals(expected.getLabels().size(), actual.getLabels().size());
List<LabelDTO> expectedLabels = new ArrayList<>(expected.getLabels());
List<LabelDTO> actualLabels = new ArrayList<>(actual.getLabels());
for (int i = 0; i < expectedLabels.size(); i++) {
@@ -229,7 +233,7 @@ public class StandardFlowServiceTest {
}
// check output ports
- Assert.assertEquals(expected.getOutputPorts().size(), actual.getOutputPorts().size());
+ Assertions.assertEquals(expected.getOutputPorts().size(), actual.getOutputPorts().size());
List<PortDTO> expectedOutputPorts = new ArrayList<>(expected.getOutputPorts());
List<PortDTO> actualOutputPort = new ArrayList<>(actual.getOutputPorts());
for (int i = 0; i < expectedOutputPorts.size(); i++) {
@@ -237,7 +241,7 @@ public class StandardFlowServiceTest {
}
// check processors
- Assert.assertEquals(expected.getProcessors().size(), actual.getProcessors().size());
+ Assertions.assertEquals(expected.getProcessors().size(), actual.getProcessors().size());
List<ProcessorDTO> expectedProcessors = new ArrayList<>(expected.getProcessors());
List<ProcessorDTO> actualProcessors = new ArrayList<>(actual.getProcessors());
for (int i = 0; i < expectedProcessors.size(); i++) {
@@ -250,12 +254,12 @@ public class StandardFlowServiceTest {
return;
}
- Assert.assertEquals(expected.getAvailableRelationships(), actual.getAvailableRelationships());
+ Assertions.assertEquals(expected.getAvailableRelationships(), actual.getAvailableRelationships());
assertEquals(expected.getDestination(), actual.getDestination());
- Assert.assertEquals(expected.getId(), actual.getId());
- Assert.assertEquals(expected.getName(), actual.getName());
- Assert.assertEquals(expected.getParentGroupId(), actual.getParentGroupId());
- Assert.assertEquals(expected.getSelectedRelationships(), actual.getSelectedRelationships());
+ Assertions.assertEquals(expected.getId(), actual.getId());
+ Assertions.assertEquals(expected.getName(), actual.getName());
+ Assertions.assertEquals(expected.getParentGroupId(), actual.getParentGroupId());
+ Assertions.assertEquals(expected.getSelectedRelationships(), actual.getSelectedRelationships());
assertEquals(expected.getSource(), actual.getSource());
}
@@ -264,10 +268,10 @@ public class StandardFlowServiceTest {
return;
}
- Assert.assertEquals(expected.getGroupId(), actual.getGroupId());
- Assert.assertEquals(expected.getId(), actual.getId());
- Assert.assertEquals(expected.getName(), actual.getName());
- Assert.assertEquals(expected.getType(), actual.getType());
+ Assertions.assertEquals(expected.getGroupId(), actual.getGroupId());
+ Assertions.assertEquals(expected.getId(), actual.getId());
+ Assertions.assertEquals(expected.getName(), actual.getName());
+ Assertions.assertEquals(expected.getType(), actual.getType());
}
private void assertEquals(PortDTO expected, PortDTO actual) {
@@ -275,9 +279,9 @@ public class StandardFlowServiceTest {
return;
}
- Assert.assertEquals(expected.getId(), actual.getId());
- Assert.assertEquals(expected.getName(), actual.getName());
- Assert.assertEquals(expected.getParentGroupId(), actual.getParentGroupId());
+ Assertions.assertEquals(expected.getId(), actual.getId());
+ Assertions.assertEquals(expected.getName(), actual.getName());
+ Assertions.assertEquals(expected.getParentGroupId(), actual.getParentGroupId());
}
private void assertEquals(LabelDTO expected, LabelDTO actual) {
@@ -285,10 +289,10 @@ public class StandardFlowServiceTest {
return;
}
- Assert.assertEquals(expected.getId(), actual.getId());
- Assert.assertEquals(expected.getLabel(), actual.getLabel());
- Assert.assertEquals(expected.getParentGroupId(), actual.getParentGroupId());
- Assert.assertEquals(expected.getStyle(), actual.getStyle());
+ Assertions.assertEquals(expected.getId(), actual.getId());
+ Assertions.assertEquals(expected.getLabel(), actual.getLabel());
+ Assertions.assertEquals(expected.getParentGroupId(), actual.getParentGroupId());
+ Assertions.assertEquals(expected.getStyle(), actual.getStyle());
}
private void assertEquals(ProcessorDTO expected, ProcessorDTO actual) {
@@ -296,14 +300,14 @@ public class StandardFlowServiceTest {
return;
}
- Assert.assertEquals(expected.getId(), actual.getId());
- Assert.assertEquals(expected.getName(), actual.getName());
- Assert.assertEquals(expected.getParentGroupId(), actual.getParentGroupId());
- Assert.assertEquals(expected.getStyle(), actual.getStyle());
- Assert.assertEquals(expected.getType(), actual.getType());
- Assert.assertEquals(expected.getState(), actual.getState());
- Assert.assertEquals(expected.getRelationships(), actual.getRelationships());
- Assert.assertEquals(expected.getValidationErrors(), actual.getValidationErrors());
+ Assertions.assertEquals(expected.getId(), actual.getId());
+ Assertions.assertEquals(expected.getName(), actual.getName());
+ Assertions.assertEquals(expected.getParentGroupId(), actual.getParentGroupId());
+ Assertions.assertEquals(expected.getStyle(), actual.getStyle());
+ Assertions.assertEquals(expected.getType(), actual.getType());
+ Assertions.assertEquals(expected.getState(), actual.getState());
+ Assertions.assertEquals(expected.getRelationships(), actual.getRelationships());
+ Assertions.assertEquals(expected.getValidationErrors(), actual.getValidationErrors());
assertEquals(expected.getConfig(), actual.getConfig());
}
@@ -312,12 +316,12 @@ public class StandardFlowServiceTest {
return;
}
- Assert.assertEquals(expected.getAnnotationData(), actual.getAnnotationData());
- Assert.assertEquals(expected.getComments(), actual.getComments());
- Assert.assertEquals(expected.getConcurrentlySchedulableTaskCount(), actual.getConcurrentlySchedulableTaskCount());
- Assert.assertEquals(expected.getCustomUiUrl(), actual.getCustomUiUrl());
- Assert.assertEquals(expected.getDescriptors(), actual.getDescriptors());
- Assert.assertEquals(expected.getProperties(), actual.getProperties());
- Assert.assertEquals(expected.getSchedulingPeriod(), actual.getSchedulingPeriod());
+ Assertions.assertEquals(expected.getAnnotationData(), actual.getAnnotationData());
+ Assertions.assertEquals(expected.getComments(), actual.getComments());
+ Assertions.assertEquals(expected.getConcurrentlySchedulableTaskCount(), actual.getConcurrentlySchedulableTaskCount());
+ Assertions.assertEquals(expected.getCustomUiUrl(), actual.getCustomUiUrl());
+ Assertions.assertEquals(expected.getDescriptors(), actual.getDescriptors());
+ Assertions.assertEquals(expected.getProperties(), actual.getProperties());
+ Assertions.assertEquals(expected.getSchedulingPeriod(), actual.getSchedulingPeriod());
}
}
diff --git a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/java/org/apache/nifi/controller/StandardProcessorNodeIT.java b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/java/org/apache/nifi/controller/StandardProcessorNodeIT.java
index b54fdf3350..87745803fb 100644
--- a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/java/org/apache/nifi/controller/StandardProcessorNodeIT.java
+++ b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/java/org/apache/nifi/controller/StandardProcessorNodeIT.java
@@ -30,10 +30,7 @@ import org.apache.nifi.components.ValidationContext;
import org.apache.nifi.components.state.StateManagerProvider;
import org.apache.nifi.controller.exception.ControllerServiceInstantiationException;
import org.apache.nifi.controller.exception.ProcessorInstantiationException;
-import org.apache.nifi.controller.flowrepository.FlowRepositoryClientInstantiationException;
import org.apache.nifi.controller.kerberos.KerberosConfig;
-import org.apache.nifi.controller.parameter.ParameterProviderInstantiationException;
-import org.apache.nifi.controller.reporting.ReportingTaskInstantiationException;
import org.apache.nifi.controller.repository.FlowFileEventRepository;
import org.apache.nifi.controller.scheduling.LifecycleState;
import org.apache.nifi.controller.scheduling.SchedulingAgent;
@@ -47,10 +44,8 @@ import org.apache.nifi.nar.ExtensionDiscoveringManager;
import org.apache.nifi.nar.InstanceClassLoader;
import org.apache.nifi.nar.NarClassLoader;
import org.apache.nifi.nar.NarCloseable;
-import org.apache.nifi.nar.OSUtil;
import org.apache.nifi.nar.StandardExtensionDiscoveringManager;
import org.apache.nifi.nar.SystemBundle;
-import org.apache.nifi.parameter.ParameterContext;
import org.apache.nifi.processor.AbstractProcessor;
import org.apache.nifi.processor.ProcessContext;
import org.apache.nifi.processor.ProcessSession;
@@ -74,9 +69,11 @@ import org.apache.nifi.util.MockPropertyValue;
import org.apache.nifi.util.MockVariableRegistry;
import org.apache.nifi.util.NiFiProperties;
import org.apache.nifi.util.SynchronousValidationTrigger;
-import org.junit.Assert;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.Timeout;
+import org.junit.jupiter.api.condition.EnabledOnOs;
+import org.junit.jupiter.api.condition.OS;
import java.io.File;
import java.net.MalformedURLException;
@@ -100,12 +97,13 @@ import java.util.concurrent.atomic.AtomicReference;
import java.util.function.Function;
import static org.hamcrest.CoreMatchers.containsString;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertThat;
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
-import static org.junit.Assume.assumeTrue;
+import static org.hamcrest.MatcherAssert.assertThat;
+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.assertThrows;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+import static org.junit.jupiter.api.Assertions.fail;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
@@ -118,7 +116,7 @@ public class StandardProcessorNodeIT {
private final AtomicReference<InstanceClassLoader> currentInstanceClassLoaderHolder = new AtomicReference<>();
- @Before
+ @BeforeEach
public void setup() {
variableRegistry = new MockVariableRegistry();
niFiProperties = NiFiProperties.createBasicNiFiProperties("src/test/resources/conf/nifi.properties");
@@ -138,7 +136,7 @@ public class StandardProcessorNodeIT {
extensionManager.discoverExtensions(systemBundle, Collections.emptySet());
}
- @Test(timeout = 10000)
+ @Timeout(10)
public void testStart() throws InterruptedException {
final ProcessorThatThrowsExceptionOnScheduled processor = new ProcessorThatThrowsExceptionOnScheduled();
final String uuid = UUID.randomUUID().toString();
@@ -205,11 +203,9 @@ public class StandardProcessorNodeIT {
}
}
+ @EnabledOnOs(OS.MAC)
@Test
- public void testNativeLibLoadedFromDynamicallyModifiesClasspathProperty() throws Exception {
- // GIVEN
- assumeTrue("Test only runs on Mac OS", new OSUtil(){}.isOsMac());
-
+ public void testNativeLibLoadedFromDynamicallyModifiesClasspathProperty() {
// Init NiFi
NarClassLoader narClassLoader = mock(NarClassLoader.class);
when(narClassLoader.getURLs()).thenReturn(new URL[0]);
@@ -519,28 +515,18 @@ public class StandardProcessorNodeIT {
// should be allowed to update when the group and id are the same but version is different
final BundleCoordinate diffVersion = new BundleCoordinate(existingCoordinate.getGroup(), existingCoordinate.getId(), "v2");
- assertTrue(!existingCoordinate.getVersion().equals(diffVersion.getVersion()));
+ assertNotEquals(existingCoordinate.getVersion(), diffVersion.getVersion());
procNode.verifyCanUpdateBundle(diffVersion);
// should not be allowed to update when the bundle id is different
final BundleCoordinate diffId = new BundleCoordinate(existingCoordinate.getGroup(), "different-id", existingCoordinate.getVersion());
- assertTrue(!existingCoordinate.getId().equals(diffId.getId()));
- try {
- procNode.verifyCanUpdateBundle(diffId);
- Assert.fail("Should have thrown exception");
- } catch (Exception e) {
-
- }
+ assertNotEquals(existingCoordinate.getId(), diffId.getId());
+ assertThrows(Exception.class, () -> procNode.verifyCanUpdateBundle(diffId));
// should not be allowed to update when the bundle group is different
final BundleCoordinate diffGroup = new BundleCoordinate("different-group", existingCoordinate.getId(), existingCoordinate.getVersion());
- assertTrue(!existingCoordinate.getGroup().equals(diffGroup.getGroup()));
- try {
- procNode.verifyCanUpdateBundle(diffGroup);
- Assert.fail("Should have thrown exception");
- } catch (Exception e) {
-
- }
+ assertNotEquals(existingCoordinate.getGroup(), diffGroup.getGroup());
+ assertThrows(Exception.class, () -> procNode.verifyCanUpdateBundle(diffGroup));
}
@Test
@@ -597,7 +583,7 @@ public class StandardProcessorNodeIT {
}
@Override
- public void reload(ProcessorNode existingNode, String newType, BundleCoordinate bundleCoordinate, Set<URL> additionalUrls) throws ProcessorInstantiationException {
+ public void reload(ProcessorNode existingNode, String newType, BundleCoordinate bundleCoordinate, Set<URL> additionalUrls) {
reload(newType, additionalUrls);
}
@@ -607,17 +593,17 @@ public class StandardProcessorNodeIT {
}
@Override
- public void reload(ReportingTaskNode existingNode, String newType, BundleCoordinate bundleCoordinate, Set<URL> additionalUrls) throws ReportingTaskInstantiationException {
+ public void reload(ReportingTaskNode existingNode, String newType, BundleCoordinate bundleCoordinate, Set<URL> additionalUrls) {
reload(newType, additionalUrls);
}
@Override
- public void reload(ParameterProviderNode existingNode, String newType, BundleCoordinate bundleCoordinate, Set<URL> additionalUrls) throws ParameterProviderInstantiationException {
+ public void reload(ParameterProviderNode existingNode, String newType, BundleCoordinate bundleCoordinate, Set<URL> additionalUrls) {
reload(newType, additionalUrls);
}
@Override
- public void reload(FlowRegistryClientNode existingNode, String newType, BundleCoordinate bundleCoordinate, Set<URL> additionalUrls) throws FlowRepositoryClientInstantiationException {
+ public void reload(FlowRegistryClientNode existingNode, String newType, BundleCoordinate bundleCoordinate, Set<URL> additionalUrls) {
reload(newType, additionalUrls);
}
@@ -648,101 +634,94 @@ public class StandardProcessorNodeIT {
private ValidationContextFactory createValidationContextFactory() {
- return new ValidationContextFactory() {
+ return (properties, annotationData, groupId, componentId, context, validateConnections) -> new ValidationContext() {
+
+ @Override
+ public ControllerServiceLookup getControllerServiceLookup() {
+ return null;
+ }
+
+ @Override
+ public ValidationContext getControllerServiceValidationContext(ControllerService controllerService) {
+ return null;
+ }
+
+ @Override
+ public ExpressionLanguageCompiler newExpressionLanguageCompiler() {
+ return null;
+ }
+
@Override
- public ValidationContext newValidationContext(Map<PropertyDescriptor, PropertyConfiguration> properties, String annotationData, String groupId, String componentId,
- ParameterContext context, boolean validateConnections) {
- return new ValidationContext() {
-
- @Override
- public ControllerServiceLookup getControllerServiceLookup() {
- return null;
- }
-
- @Override
- public ValidationContext getControllerServiceValidationContext(ControllerService controllerService) {
- return null;
- }
-
- @Override
- public ExpressionLanguageCompiler newExpressionLanguageCompiler() {
- return null;
- }
-
- @Override
- public PropertyValue getProperty(PropertyDescriptor property) {
- final PropertyConfiguration configuration = properties.get(property);
- return newPropertyValue(configuration == null ? null : configuration.getRawValue());
- }
-
- @Override
- public PropertyValue newPropertyValue(String value) {
- return new MockPropertyValue(value);
- }
-
- @Override
- public Map<PropertyDescriptor, String> getProperties() {
- final Map<PropertyDescriptor, String> propertyMap = new HashMap<>();
- properties.forEach((k, v) -> propertyMap.put(k, v == null ? null : v.getRawValue()));
- return propertyMap;
- }
-
- @Override
- public Map<String, String> getAllProperties() {
- final Map<String,String> propValueMap = new LinkedHashMap<>();
- for (final Map.Entry<PropertyDescriptor, String> entry : getProperties().entrySet()) {
- propValueMap.put(entry.getKey().getName(), entry.getValue());
- }
- return propValueMap;
- }
-
- @Override
- public String getAnnotationData() {
- return null;
- }
-
- @Override
- public boolean isValidationRequired(ControllerService service) {
- return false;
- }
-
- @Override
- public boolean isExpressionLanguagePresent(String value) {
- return false;
- }
-
- @Override
- public boolean isExpressionLanguageSupported(String propertyName) {
- return false;
- }
-
- @Override
- public String getProcessGroupIdentifier() {
- return groupId;
- }
-
- @Override
- public Collection<String> getReferencedParameters(final String propertyName) {
- return Collections.emptyList();
- }
-
- @Override
- public boolean isParameterDefined(final String parameterName) {
- return false;
- }
-
- @Override
- public boolean isParameterSet(final String parameterName) {
- return false;
- }
-
- @Override
- public boolean isDependencySatisfied(final PropertyDescriptor propertyDescriptor, final Function<String, PropertyDescriptor> propertyDescriptorLookup) {
- return false;
- }
- };
+ public PropertyValue getProperty(PropertyDescriptor property) {
+ final PropertyConfiguration configuration = properties.get(property);
+ return newPropertyValue(configuration == null ? null : configuration.getRawValue());
}
+ @Override
+ public PropertyValue newPropertyValue(String value) {
+ return new MockPropertyValue(value);
+ }
+
+ @Override
+ public Map<PropertyDescriptor, String> getProperties() {
+ final Map<PropertyDescriptor, String> propertyMap = new HashMap<>();
+ properties.forEach((k, v) -> propertyMap.put(k, v == null ? null : v.getRawValue()));
+ return propertyMap;
+ }
+
+ @Override
+ public Map<String, String> getAllProperties() {
+ final Map<String,String> propValueMap = new LinkedHashMap<>();
+ for (final Map.Entry<PropertyDescriptor, String> entry : getProperties().entrySet()) {
+ propValueMap.put(entry.getKey().getName(), entry.getValue());
+ }
+ return propValueMap;
+ }
+
+ @Override
+ public String getAnnotationData() {
+ return null;
+ }
+
+ @Override
+ public boolean isValidationRequired(ControllerService service) {
+ return false;
+ }
+
+ @Override
+ public boolean isExpressionLanguagePresent(String value) {
+ return false;
+ }
+
+ @Override
+ public boolean isExpressionLanguageSupported(String propertyName) {
+ return false;
+ }
+
+ @Override
+ public String getProcessGroupIdentifier() {
+ return groupId;
+ }
+
+ @Override
+ public Collection<String> getReferencedParameters(final String propertyName) {
+ return Collections.emptyList();
+ }
+
+ @Override
+ public boolean isParameterDefined(final String parameterName) {
+ return false;
+ }
+
+ @Override
+ public boolean isParameterSet(final String parameterName) {
+ return false;
+ }
+
+ @Override
+ public boolean isDependencySatisfied(final PropertyDescriptor propertyDescriptor, final Function<String, PropertyDescriptor> propertyDescriptorLookup) {
+ return false;
+ }
};
}
@@ -792,7 +771,7 @@ public class StandardProcessorNodeIT {
@Override
public void trigger() {
- Assert.fail("Should not have completed");
+ fail("Should not have completed");
}
}
}
diff --git a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/java/org/apache/nifi/controller/TestEncryptedFileSystemSwapManager.java b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/java/org/apache/nifi/controller/TestEncryptedFileSystemSwapManager.java
index a96dcfd25d..585be75981 100644
--- a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/java/org/apache/nifi/controller/TestEncryptedFileSystemSwapManager.java
+++ b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/java/org/apache/nifi/controller/TestEncryptedFileSystemSwapManager.java
@@ -28,8 +28,7 @@ import org.apache.nifi.controller.repository.claim.ResourceClaimManager;
import org.apache.nifi.events.EventReporter;
import org.apache.nifi.security.kms.StaticKeyProvider;
import org.apache.nifi.util.NiFiProperties;
-import org.junit.Assert;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import org.mockito.Mockito;
import java.io.File;
@@ -41,6 +40,8 @@ import java.util.List;
import java.util.Properties;
import java.util.UUID;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Mockito.when;
@@ -84,9 +85,9 @@ public class TestEncryptedFileSystemSwapManager {
// verify recovery of original content
final List<FlowFileRecord> flowFilesRecovered = swapContents.getFlowFiles();
- Assert.assertEquals(flowFiles.size(), flowFilesRecovered.size());
- Assert.assertTrue(flowFilesRecovered.containsAll(flowFiles));
- Assert.assertTrue(flowFiles.containsAll(flowFilesRecovered));
+ assertEquals(flowFiles.size(), flowFilesRecovered.size());
+ assertTrue(flowFilesRecovered.containsAll(flowFiles));
+ assertTrue(flowFiles.containsAll(flowFilesRecovered));
}
/**
diff --git a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/java/org/apache/nifi/controller/TestFileSystemSwapManager.java b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/java/org/apache/nifi/controller/TestFileSystemSwapManager.java
index 48de1bf007..a00b2c01f8 100644
--- a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/java/org/apache/nifi/controller/TestFileSystemSwapManager.java
+++ b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/java/org/apache/nifi/controller/TestFileSystemSwapManager.java
@@ -25,10 +25,8 @@ import org.apache.nifi.controller.repository.claim.ResourceClaim;
import org.apache.nifi.controller.repository.claim.ResourceClaimManager;
import org.apache.nifi.events.EventReporter;
import org.apache.nifi.stream.io.StreamUtils;
-import org.junit.Assert;
-import org.junit.Rule;
-import org.junit.Test;
-import org.junit.rules.TemporaryFolder;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.io.TempDir;
import org.mockito.Mockito;
import java.io.BufferedInputStream;
@@ -39,13 +37,15 @@ import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
+import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import java.util.concurrent.TimeUnit;
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertThrows;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.anyString;
import static org.mockito.Mockito.when;
@@ -90,12 +90,8 @@ public class TestFileSystemSwapManager {
flowFileRecords.add(new MockFlowFileRecord(i));
}
- try {
- swapManager.swapOut(flowFileRecords, flowFileQueue, "partition-1");
- Assert.fail("Expected IOException");
- } catch (final IOException ioe) {
- // expected
- }
+ assertThrows(IOException.class,
+ () -> swapManager.swapOut(flowFileRecords, flowFileQueue, "partition-1"));
}
@Test
@@ -153,11 +149,11 @@ public class TestFileSystemSwapManager {
return createSwapManager(flowFileRepo);
}
- @Rule
- public TemporaryFolder temporaryFolder = new TemporaryFolder();
+ @TempDir
+ public Path temporaryFolder;
- private FileSystemSwapManager createSwapManager(final FlowFileRepository flowFileRepo) throws IOException {
- final FileSystemSwapManager swapManager = new FileSystemSwapManager(temporaryFolder.newFolder().toPath());
+ private FileSystemSwapManager createSwapManager(final FlowFileRepository flowFileRepo) {
+ final FileSystemSwapManager swapManager = new FileSystemSwapManager(temporaryFolder);
final ResourceClaimManager resourceClaimManager = new NopResourceClaimManager();
swapManager.initialize(new SwapManagerInitializationContext() {
@Override
diff --git a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/java/org/apache/nifi/controller/TestFlowController.java b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/java/org/apache/nifi/controller/TestFlowController.java
index d98432e5dc..d6711cf6df 100644
--- a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/java/org/apache/nifi/controller/TestFlowController.java
+++ b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/java/org/apache/nifi/controller/TestFlowController.java
@@ -87,11 +87,10 @@ import org.apache.nifi.web.api.dto.ParameterContextReferenceDTO;
import org.apache.nifi.web.api.dto.PositionDTO;
import org.apache.nifi.web.api.dto.ProcessorConfigDTO;
import org.apache.nifi.web.api.dto.ProcessorDTO;
-import org.junit.After;
-import org.junit.Assert;
-import org.junit.Before;
-import org.junit.BeforeClass;
-import org.junit.Test;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.Test;
import java.io.File;
import java.io.FileInputStream;
@@ -118,13 +117,13 @@ import java.util.concurrent.TimeUnit;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNotEquals;
-import static org.junit.Assert.assertNotNull;
-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.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertNotEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+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 static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
@@ -145,12 +144,12 @@ public class TestFlowController {
private static List<String> allIdentifiers;
- @BeforeClass
+ @BeforeAll
public static void setupOnce() throws IOException {
allIdentifiers = getAllIdentifiers();
}
- @Before
+ @BeforeEach
public void setup() {
flowFileEventRepo = mock(FlowFileEventRepository.class);
@@ -219,7 +218,7 @@ public class TestFlowController {
standardFlowSynchronizer = new StandardFlowSynchronizer(xmlFlowSynchronizer, versionedFlowSynchronizer);
}
- @After
+ @AfterEach
public void cleanup() throws Exception {
controller.shutdown(true);
FileUtils.deleteDirectory(new File("./target/flowcontrollertest"));
@@ -413,7 +412,7 @@ public class TestFlowController {
assertEquals(authFingerprint, authorizer.getFingerprint());
}
- @Test(expected = UninheritableFlowException.class)
+ @Test
public void testSynchronizeFlowWhenAuthorizationsAreDifferent() throws IOException {
final File flowFile = new File("src/test/resources/conf/processor-with-cs-flow-0.7.0.xml");
final String flow = IOUtils.toString(new FileInputStream(flowFile), StandardCharsets.UTF_8);
@@ -424,15 +423,13 @@ public class TestFlowController {
controller.synchronize(standardFlowSynchronizer, proposedDataFlow, mock(FlowService.class), BundleUpdateStrategy.IGNORE_BUNDLE);
controller.initializeFlow();
- try {
- controller.synchronize(standardFlowSynchronizer, proposedDataFlow, mock(FlowService.class), BundleUpdateStrategy.IGNORE_BUNDLE);
- assertNotEquals(authFingerprint, authorizer.getFingerprint());
- } finally {
- purgeFlow();
- }
+ assertThrows(UninheritableFlowException.class,
+ () -> controller.synchronize(standardFlowSynchronizer, proposedDataFlow, mock(FlowService.class), BundleUpdateStrategy.IGNORE_BUNDLE));
+ assertNotEquals(authFingerprint, authorizer.getFingerprint());
+ purgeFlow();
}
- @Test(expected = FlowSynchronizationException.class)
+ @Test
public void testSynchronizeFlowWithInvalidParameterContextReference() throws IOException {
final File flowFile = new File("src/test/resources/conf/parameter-context-flow-error.xml");
final String flow = IOUtils.toString(new FileInputStream(flowFile), StandardCharsets.UTF_8);
@@ -440,12 +437,12 @@ public class TestFlowController {
final String authFingerprint = "<authorizations></authorizations>";
final DataFlow proposedDataFlow = new StandardDataFlow(flow.getBytes(StandardCharsets.UTF_8), null, authFingerprint.getBytes(StandardCharsets.UTF_8), Collections.emptySet());
- try {
- controller.synchronize(standardFlowSynchronizer, proposedDataFlow, mock(FlowService.class), BundleUpdateStrategy.IGNORE_BUNDLE);
- controller.initializeFlow();
- } finally {
- purgeFlow();
- }
+ assertThrows(FlowSynchronizationException.class,
+ () -> {
+ controller.synchronize(standardFlowSynchronizer, proposedDataFlow, mock(FlowService.class), BundleUpdateStrategy.IGNORE_BUNDLE);
+ controller.initializeFlow();
+ });
+ purgeFlow();
}
@Test
@@ -544,14 +541,9 @@ public class TestFlowController {
final DataFlow dataflowWithNullAuthorizations = new StandardDataFlow(flow.getBytes(StandardCharsets.UTF_8), null, null, Collections.emptySet());
- try {
- controller.synchronize(standardFlowSynchronizer, dataflowWithNullAuthorizations, mock(FlowService.class), BundleUpdateStrategy.IGNORE_BUNDLE);
- Assert.fail("Was able to synchronize controller with null authorizations but dataflow wasn't empty");
- } catch (final UninheritableFlowException expected) {
- // expected
- } finally {
- purgeFlow();
- }
+ assertThrows(UninheritableFlowException.class,
+ () -> controller.synchronize(standardFlowSynchronizer, dataflowWithNullAuthorizations, mock(FlowService.class), BundleUpdateStrategy.IGNORE_BUNDLE));
+ purgeFlow();
}
@Test
@@ -609,12 +601,11 @@ public class TestFlowController {
final DataFlow proposedDataFlow = mock(DataFlow.class);
when(proposedDataFlow.getMissingComponents()).thenReturn(missingComponents);
- try {
- controller.synchronize(standardFlowSynchronizer, proposedDataFlow, mock(FlowService.class), BundleUpdateStrategy.IGNORE_BUNDLE);
- Assert.fail("Should have thrown exception");
- } catch (UninheritableFlowException e) {
- assertTrue(e.getMessage().contains("Proposed flow has missing components that are not considered missing in the current flow (1,2)"));
- }
+ UninheritableFlowException uninheritableFlowException =
+ assertThrows(UninheritableFlowException.class,
+ () -> controller.synchronize(standardFlowSynchronizer, proposedDataFlow, mock(FlowService.class), BundleUpdateStrategy.IGNORE_BUNDLE));
+ assertTrue(uninheritableFlowException.getMessage().contains("Proposed flow has missing components " +
+ "that are not considered missing in the current flow (1,2)"), uninheritableFlowException.getMessage());
}
@Test
@@ -650,13 +641,12 @@ public class TestFlowController {
final DataFlow proposedDataFlow = mock(DataFlow.class);
when(proposedDataFlow.getMissingComponents()).thenReturn(new HashSet<>());
-
- try {
- standardFlowSynchronizer.sync(mockFlowController, proposedDataFlow, mock(FlowService.class), BundleUpdateStrategy.IGNORE_BUNDLE);
- Assert.fail("Should have thrown exception");
- } catch (UninheritableFlowException e) {
- assertTrue(e.getMessage(), e.getMessage().contains("Current flow has missing components that are not considered missing in the proposed flow (1,2,3)"));
- }
+ UninheritableFlowException uninheritableFlowException =
+ assertThrows(UninheritableFlowException.class,
+ () -> standardFlowSynchronizer.sync(mockFlowController, proposedDataFlow,
+ mock(FlowService.class), BundleUpdateStrategy.IGNORE_BUNDLE));
+ assertTrue(uninheritableFlowException.getMessage().contains("Current flow has missing components that are not" +
+ " considered missing in the proposed flow (1,2,3)"), uninheritableFlowException.getMessage());
}
@Test
@@ -679,12 +669,9 @@ public class TestFlowController {
controller.initializeFlow();
// second sync should fail because the bundle of the processor is different
- try {
- syncFlow("src/test/resources/nifi/fingerprint/flow4-with-different-bundle.xml", standardFlowSynchronizer);
- Assert.fail("Should have thrown UninheritableFlowException");
- } catch (UninheritableFlowException e) {
- //e.printStackTrace();
- }
+ assertThrows(UninheritableFlowException.class,
+ () -> syncFlow("src/test/resources/nifi/fingerprint/flow4-with-different-bundle.xml",
+ standardFlowSynchronizer));
}
private void syncFlow(String flowXmlFile, FlowSynchronizer standardFlowSynchronizer) throws IOException {
@@ -1062,7 +1049,7 @@ public class TestFlowController {
return false;
}
- @Test(expected = IllegalArgumentException.class)
+ @Test
public void testInstantiateSnippetWhenProcessorMissingBundle() throws Exception {
final String id = UUID.randomUUID().toString();
final BundleCoordinate coordinate = systemBundle.getBundleDetails().getCoordinate();
@@ -1071,7 +1058,7 @@ public class TestFlowController {
// create a processor dto
final ProcessorDTO processorDTO = new ProcessorDTO();
processorDTO.setId(UUID.randomUUID().toString()); // use a different id here
- processorDTO.setPosition(new PositionDTO(new Double(0), new Double(0)));
+ processorDTO.setPosition(new PositionDTO((double) 0, (double) 0));
processorDTO.setStyle(processorNode.getStyle());
processorDTO.setParentGroupId("1234");
processorDTO.setInputRequirement(processorNode.getInputRequirement().name());
@@ -1117,7 +1104,9 @@ public class TestFlowController {
// instantiate the snippet
assertEquals(0, controller.getFlowManager().getRootGroup().getProcessors().size());
- controller.getFlowManager().instantiateSnippet(controller.getFlowManager().getRootGroup(), flowSnippetDTO);
+ assertThrows(IllegalArgumentException.class,
+ () -> controller.getFlowManager().instantiateSnippet(controller.getFlowManager().getRootGroup(),
+ flowSnippetDTO));
}
@Test
@@ -1237,10 +1226,10 @@ public class TestFlowController {
assertEquals(0, controller.getFlowManager().getRootGroup().getProcessors().size());
controller.getFlowManager().instantiateSnippet(controller.getFlowManager().getRootGroup(), flowSnippetDTO);
assertEquals(1, controller.getFlowManager().getRootGroup().getProcessors().size());
- assertTrue(controller.getFlowManager().getRootGroup().getProcessors().iterator().next().getScheduledState().equals(ScheduledState.DISABLED));
+ assertEquals(controller.getFlowManager().getRootGroup().getProcessors().iterator().next().getScheduledState(), ScheduledState.DISABLED);
}
- @Test(expected = IllegalArgumentException.class)
+ @Test
public void testInstantiateSnippetWhenControllerServiceMissingBundle() throws ProcessorInstantiationException {
final String id = UUID.randomUUID().toString();
final BundleCoordinate coordinate = systemBundle.getBundleDetails().getCoordinate();
@@ -1269,7 +1258,9 @@ public class TestFlowController {
// instantiate the snippet
assertEquals(0, controller.getFlowManager().getRootGroup().getControllerServices(false).size());
- controller.getFlowManager().instantiateSnippet(controller.getFlowManager().getRootGroup(), flowSnippetDTO);
+ assertThrows(IllegalArgumentException.class,
+ () -> controller.getFlowManager().instantiateSnippet(controller.getFlowManager().getRootGroup(),
+ flowSnippetDTO));
}
@Test
diff --git a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/java/org/apache/nifi/controller/TestStandardFlowFileQueue.java b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/java/org/apache/nifi/controller/TestStandardFlowFileQueue.java
index 0925051b91..32fdd0b0f6 100644
--- a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/java/org/apache/nifi/controller/TestStandardFlowFileQueue.java
+++ b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/java/org/apache/nifi/controller/TestStandardFlowFileQueue.java
@@ -37,10 +37,9 @@ import org.apache.nifi.provenance.ProvenanceEventRecord;
import org.apache.nifi.provenance.ProvenanceEventRepository;
import org.apache.nifi.provenance.ProvenanceEventType;
import org.apache.nifi.provenance.StandardProvenanceEventRecord;
-import org.junit.Assert;
-import org.junit.Before;
-import org.junit.BeforeClass;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.Timeout;
import org.mockito.Mockito;
import org.mockito.invocation.InvocationOnMock;
import org.mockito.stubbing.Answer;
@@ -53,11 +52,12 @@ import java.util.List;
import java.util.Set;
import java.util.UUID;
-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;
public class TestStandardFlowFileQueue {
private MockSwapManager swapManager = null;
@@ -71,12 +71,7 @@ public class TestStandardFlowFileQueue {
private List<ProvenanceEventRecord> provRecords = new ArrayList<>();
- @BeforeClass
- public static void setupLogging() {
- System.setProperty("org.slf4j.simpleLogger.log.org.apache.nifi", "INFO");
- }
-
- @Before
+ @BeforeEach
@SuppressWarnings("unchecked")
public void setup() {
provRecords.clear();
@@ -202,7 +197,8 @@ public class TestStandardFlowFileQueue {
assertTrue(queue.isActiveQueueEmpty());
}
- @Test(timeout = 10000)
+ @Test
+ @Timeout(10)
public void testBackPressureAfterDrop() throws InterruptedException {
queue.setBackPressureObjectThreshold(10);
queue.setFlowFileExpiration("10 millis");
@@ -443,7 +439,7 @@ public class TestStandardFlowFileQueue {
for (int i = 0; i < 9998; i++) {
flowFile = queue.poll(expired);
- assertNotNull("Null FlowFile when i = " + i, flowFile);
+ assertNotNull(flowFile, "Null FlowFile when i = " + i);
queue.acknowledge(Collections.singleton(flowFile));
final QueueSize queueSize = queue.size();
@@ -459,7 +455,8 @@ public class TestStandardFlowFileQueue {
assertNull(flowFile);
}
- @Test(timeout = 120000)
+ @Test
+ @Timeout(120)
public void testDropSwappedFlowFiles() {
for (int i = 1; i <= 30000; i++) {
queue.put(new MockFlowFileRecord());
@@ -481,7 +478,8 @@ public class TestStandardFlowFileQueue {
}
- @Test(timeout = 5000)
+ @Test
+ @Timeout(5)
public void testListFlowFilesOnlyActiveQueue() throws InterruptedException {
for (int i = 0; i < 9999; i++) {
queue.put(new MockFlowFileRecord());
@@ -501,7 +499,8 @@ public class TestStandardFlowFileQueue {
}
- @Test(timeout = 5000)
+ @Test
+ @Timeout(5)
public void testListFlowFilesResultsLimited() throws InterruptedException {
for (int i = 0; i < 30050; i++) {
queue.put(new MockFlowFileRecord());
@@ -520,7 +519,8 @@ public class TestStandardFlowFileQueue {
assertNull(status.getFailureReason());
}
- @Test(timeout = 5000)
+ @Test
+ @Timeout(5)
public void testListFlowFilesResultsLimitedCollection() throws InterruptedException {
Collection<FlowFileRecord> tff = new ArrayList<>();
//Swap Size is 10000 records, so 30000 is equal to 3 swap files.
@@ -564,24 +564,14 @@ public class TestStandardFlowFileQueue {
// verify that unexpected ERROR's are handled in such a way that we keep retrying
for (int i = 0; i < 3; i++) {
- try {
- queue.poll(expiredRecords);
- Assert.fail("Expected OOME to be thrown");
- } catch (final OutOfMemoryError oome) {
- // expected
- }
+ assertThrows(OutOfMemoryError.class, () -> queue.poll(expiredRecords));
}
// verify that unexpected Runtime Exceptions are handled in such a way that we keep retrying
swapManager.setSwapInFailure(new NullPointerException("Intentional OOME for unit test"));
for (int i = 0; i < 3; i++) {
- try {
- queue.poll(expiredRecords);
- Assert.fail("Expected NPE to be thrown");
- } catch (final NullPointerException npe) {
- // expected
- }
+ assertThrows(NullPointerException.class, () -> queue.poll(expiredRecords));
}
swapManager.failSwapInAfterN = -1;
diff --git a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/java/org/apache/nifi/controller/leader/election/TestCuratorACLProviderFactory.java b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/java/org/apache/nifi/controller/leader/election/TestCuratorACLProviderFactory.java
index c4824c92a2..427f99cbd0 100644
--- a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/java/org/apache/nifi/controller/leader/election/TestCuratorACLProviderFactory.java
+++ b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/java/org/apache/nifi/controller/leader/election/TestCuratorACLProviderFactory.java
@@ -25,19 +25,19 @@ import org.apache.curator.framework.imps.DefaultACLProvider;
import org.apache.nifi.controller.cluster.ZooKeeperClientConfig;
import org.apache.nifi.util.NiFiProperties;
import org.apache.zookeeper.data.ACL;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-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;
public class TestCuratorACLProviderFactory {
private volatile String propsFile = TestCuratorACLProviderFactory.class.getResource("/flowcontrollertest.nifi.properties").getFile();
final Map<String, String> otherProps = new HashMap<>();
- @Before
+ @BeforeEach
public void setup(){
otherProps.put("nifi.zookeeper.connect.string", "local:1234");
otherProps.put("nifi.zookeeper.root.node", "/nifi");
diff --git a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/java/org/apache/nifi/controller/queue/clustered/LoadBalancedQueueIT.java b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/java/org/apache/nifi/controller/queue/clustered/LoadBalancedQueueIT.java
index c07ced2392..03b538fd70 100644
--- a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/java/org/apache/nifi/controller/queue/clustered/LoadBalancedQueueIT.java
+++ b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/java/org/apache/nifi/controller/queue/clustered/LoadBalancedQueueIT.java
@@ -59,8 +59,9 @@ import org.apache.nifi.provenance.ProvenanceRepository;
import org.apache.nifi.security.util.SslContextFactory;
import org.apache.nifi.security.util.TemporaryKeyStoreBuilder;
import org.apache.nifi.security.util.TlsConfiguration;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.Timeout;
import org.mockito.Mockito;
import org.mockito.invocation.InvocationOnMock;
import org.mockito.stubbing.Answer;
@@ -93,10 +94,10 @@ import java.util.concurrent.ConcurrentMap;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicReference;
-import static org.junit.Assert.assertArrayEquals;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-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.assertTrue;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.anyCollection;
import static org.mockito.Mockito.doAnswer;
@@ -139,7 +140,7 @@ public class LoadBalancedQueueIT {
private final Set<ClusterTopologyEventListener> clusterEventListeners = Collections.synchronizedSet(new HashSet<>());
private final AtomicReference<LoadBalanceCompression> compressionReference = new AtomicReference<>();
- @Before
+ @BeforeEach
public void setup() throws IOException, GeneralSecurityException {
compressionReference.set(LoadBalanceCompression.DO_NOT_COMPRESS);
@@ -216,7 +217,8 @@ public class LoadBalancedQueueIT {
return new NioAsyncLoadBalanceClientFactory(sslContext, 30000, flowFileContentAccess, eventReporter, new StandardLoadBalanceFlowFileCodec(), clusterCoordinator);
}
- @Test(timeout = 20_000)
+ @Test
+ @Timeout(20)
public void testNewNodeAdded() throws IOException, InterruptedException {
localNodeId = new NodeIdentifier("unit-test-local", "localhost", 7090, "localhost", 7090, "localhost", 7090, null, null, null, false, null);
nodeIdentifiers.add(localNodeId);
@@ -278,7 +280,7 @@ public class LoadBalancedQueueIT {
Thread.sleep(10L);
}
- assertFalse("Server's FlowFile Repo was never fully updated", serverRepoRecords.isEmpty());
+ assertFalse(serverRepoRecords.isEmpty(), "Server's FlowFile Repo was never fully updated");
assertEquals(totalFlowFileCount, serverRepoRecords.size());
@@ -306,7 +308,8 @@ public class LoadBalancedQueueIT {
}
}
- @Test(timeout = 90_000)
+ @Test
+ @Timeout(90)
public void testFailover() throws IOException, InterruptedException {
localNodeId = new NodeIdentifier("unit-test-local", "localhost", 7090, "localhost", 7090, "localhost", 7090, null, null, null, false, null);
nodeIdentifiers.add(localNodeId);
@@ -375,7 +378,7 @@ public class LoadBalancedQueueIT {
Thread.sleep(10L);
}
- assertFalse("Server's FlowFile Repo was never fully updated", serverRepoRecords.isEmpty());
+ assertFalse(serverRepoRecords.isEmpty(),"Server's FlowFile Repo was never fully updated");
assertEquals(expectedFlowFileReceiveCount, serverRepoRecords.size());
@@ -409,7 +412,8 @@ public class LoadBalancedQueueIT {
}
- @Test(timeout = 20_000)
+ @Test
+ @Timeout(20)
public void testTransferToRemoteNode() throws IOException, InterruptedException {
localNodeId = new NodeIdentifier("unit-test-local", "localhost", 7090, "localhost", 7090, "localhost", 7090, null, null, null, false, null);
nodeIdentifiers.add(localNodeId);
@@ -466,7 +470,7 @@ public class LoadBalancedQueueIT {
Thread.sleep(10L);
}
- assertFalse("Server's FlowFile Repo was never updated", serverRepoRecords.isEmpty());
+ assertFalse(serverRepoRecords.isEmpty(),"Server's FlowFile Repo was never updated");
assertEquals(1, serverRepoRecords.size());
@@ -497,7 +501,8 @@ public class LoadBalancedQueueIT {
}
- @Test(timeout = 20_000)
+ @Test
+ @Timeout(20)
public void testContentNotFound() throws IOException, InterruptedException {
localNodeId = new NodeIdentifier("unit-test-local", "localhost", 7090, "localhost", 7090, "localhost", 7090, null, null, null, false, null);
nodeIdentifiers.add(localNodeId);
@@ -567,7 +572,8 @@ public class LoadBalancedQueueIT {
}
- @Test(timeout = 20_000)
+ @Test
+ @Timeout(20)
public void testTransferToRemoteNodeAttributeCompression() throws IOException, InterruptedException {
localNodeId = new NodeIdentifier("unit-test-local", "localhost", 7090, "localhost", 7090, "localhost", 7090, null, null, null, false, null);
nodeIdentifiers.add(localNodeId);
@@ -626,7 +632,7 @@ public class LoadBalancedQueueIT {
Thread.sleep(10L);
}
- assertFalse("Server's FlowFile Repo was never updated", serverRepoRecords.isEmpty());
+ assertFalse(serverRepoRecords.isEmpty(), "Server's FlowFile Repo was never updated");
assertEquals(1, serverRepoRecords.size());
@@ -657,7 +663,8 @@ public class LoadBalancedQueueIT {
}
- @Test(timeout = 20_000)
+ @Test
+ @Timeout(20)
public void testTransferToRemoteNodeContentCompression() throws IOException, InterruptedException {
localNodeId = new NodeIdentifier("unit-test-local", "localhost", 7090, "localhost", 7090, "localhost", 7090, null, null, null, false, null);
nodeIdentifiers.add(localNodeId);
@@ -716,7 +723,7 @@ public class LoadBalancedQueueIT {
Thread.sleep(10L);
}
- assertFalse("Server's FlowFile Repo was never updated", serverRepoRecords.isEmpty());
+ assertFalse(serverRepoRecords.isEmpty(),"Server's FlowFile Repo was never updated");
assertEquals(1, serverRepoRecords.size());
@@ -746,7 +753,8 @@ public class LoadBalancedQueueIT {
}
}
- @Test(timeout = 20_000)
+ @Test
+ @Timeout(20)
public void testWithSSLContext() throws IOException, InterruptedException, UnrecoverableKeyException, CertificateException, NoSuchAlgorithmException, KeyStoreException, KeyManagementException {
localNodeId = new NodeIdentifier("unit-test-local", "localhost", 7090, "localhost", 7090, "localhost", 7090, null, null, null, false, null);
nodeIdentifiers.add(localNodeId);
@@ -803,7 +811,7 @@ public class LoadBalancedQueueIT {
Thread.sleep(10L);
}
- assertFalse("Server's FlowFile Repo was never updated", serverRepoRecords.isEmpty());
+ assertFalse(serverRepoRecords.isEmpty(), "Server's FlowFile Repo was never updated");
assertEquals(1, serverRepoRecords.size());
@@ -834,7 +842,8 @@ public class LoadBalancedQueueIT {
}
- @Test(timeout = 60_000)
+ @Test
+ @Timeout(60)
public void testReusingClient() throws IOException, InterruptedException, UnrecoverableKeyException, CertificateException, NoSuchAlgorithmException, KeyStoreException, KeyManagementException {
localNodeId = new NodeIdentifier("unit-test-local", "localhost", 7090, "localhost", 7090, "localhost", 7090, null, null, null, false, null);
nodeIdentifiers.add(localNodeId);
@@ -921,7 +930,8 @@ public class LoadBalancedQueueIT {
}
- @Test(timeout = 20_000)
+ @Test
+ @Timeout(20)
public void testLargePayload() throws IOException, InterruptedException, UnrecoverableKeyException, CertificateException, NoSuchAlgorithmException, KeyStoreException, KeyManagementException {
localNodeId = new NodeIdentifier("unit-test-local", "localhost", 7090, "localhost", 7090, "localhost", 7090, null, null, null, false, null);
nodeIdentifiers.add(localNodeId);
@@ -980,7 +990,7 @@ public class LoadBalancedQueueIT {
Thread.sleep(10L);
}
- assertFalse("Server's FlowFile Repo was never updated", serverRepoRecords.isEmpty());
+ assertFalse(serverRepoRecords.isEmpty(),"Server's FlowFile Repo was never updated");
assertEquals(1, serverRepoRecords.size());
@@ -1011,7 +1021,8 @@ public class LoadBalancedQueueIT {
}
- @Test(timeout = 60_000)
+ @Test
+ @Timeout(60)
public void testServerClosesUnexpectedly() throws IOException, InterruptedException {
doAnswer(new Answer<OutputStream>() {
@@ -1111,7 +1122,7 @@ public class LoadBalancedQueueIT {
Thread.sleep(10L);
}
- assertFalse("Server's FlowFile Repo was never updated", serverRepoRecords.isEmpty());
+ assertFalse(serverRepoRecords.isEmpty(),"Server's FlowFile Repo was never updated");
assertEquals(1, serverRepoRecords.size());
@@ -1142,7 +1153,8 @@ public class LoadBalancedQueueIT {
}
- @Test(timeout = 20_000)
+ @Test
+ @Timeout(20)
public void testNotAuthorized() throws IOException, InterruptedException {
localNodeId = new NodeIdentifier("unit-test-local", "localhost", 7090, "localhost", 7090, "localhost", 7090, null, null, null, false, null);
nodeIdentifiers.add(localNodeId);
@@ -1194,7 +1206,7 @@ public class LoadBalancedQueueIT {
Thread.sleep(5000L);
- assertTrue("Server's FlowFile Repo was updated", serverRepoRecords.isEmpty());
+ assertTrue(serverRepoRecords.isEmpty(),"Server's FlowFile Repo was updated");
assertTrue(clientRepoRecords.isEmpty());
assertEquals(2, flowFileQueue.size().getObjectCount());
@@ -1208,7 +1220,8 @@ public class LoadBalancedQueueIT {
}
- @Test(timeout = 35_000)
+ @Test
+ @Timeout(35)
public void testDestinationNodeQueueFull() throws IOException, InterruptedException {
localNodeId = new NodeIdentifier("unit-test-local", "localhost", 7090, "localhost", 7090, "localhost", 7090, null, null, null, false, null);
nodeIdentifiers.add(localNodeId);
@@ -1262,7 +1275,7 @@ public class LoadBalancedQueueIT {
Thread.sleep(5000L);
- assertTrue("Server's FlowFile Repo was updated", serverRepoRecords.isEmpty());
+ assertTrue(serverRepoRecords.isEmpty(),"Server's FlowFile Repo was updated");
assertTrue(clientRepoRecords.isEmpty());
assertEquals(2, flowFileQueue.size().getObjectCount());
diff --git a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/java/org/apache/nifi/controller/queue/clustered/TestContentRepositoryFlowFileAccess.java b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/java/org/apache/nifi/controller/queue/clustered/TestContentRepositoryFlowFileAccess.java
index 4d3609d679..f41a9605cc 100644
--- a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/java/org/apache/nifi/controller/queue/clustered/TestContentRepositoryFlowFileAccess.java
+++ b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/java/org/apache/nifi/controller/queue/clustered/TestContentRepositoryFlowFileAccess.java
@@ -27,16 +27,17 @@ import org.apache.nifi.controller.repository.claim.StandardContentClaim;
import org.apache.nifi.controller.repository.claim.StandardResourceClaim;
import org.apache.nifi.controller.repository.claim.StandardResourceClaimManager;
import org.apache.nifi.stream.io.StreamUtils;
-import org.junit.Assert;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import java.io.ByteArrayInputStream;
import java.io.EOFException;
import java.io.IOException;
import java.io.InputStream;
-import static org.junit.Assert.assertArrayEquals;
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertArrayEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertThrows;
+import static org.junit.jupiter.api.Assertions.fail;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
@@ -89,7 +90,7 @@ public class TestContentRepositoryFlowFileAccess {
try {
flowAccess.read(flowFile);
- Assert.fail("Expected ContentNotFoundException but it did not happen");
+ fail("Expected ContentNotFoundException but it did not happen");
} catch (final ContentNotFoundException thrown) {
// expected
thrown.getFlowFile().orElseThrow(() -> new AssertionError("Expected FlowFile to be provided"));
@@ -119,12 +120,7 @@ public class TestContentRepositoryFlowFileAccess {
final byte[] buffer = new byte[5];
StreamUtils.fillBuffer(repoStream, buffer);
- try {
- repoStream.read();
- Assert.fail("Expected EOFException because not enough bytes were in the InputStream for the FlowFile");
- } catch (final EOFException eof) {
- // expected
- }
+ assertThrows(EOFException.class, repoStream::read,
+ "Expected EOFException because not enough bytes were in the InputStream for the FlowFile");
}
-
}
diff --git a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/java/org/apache/nifi/controller/queue/clustered/TestNaiveLimitThreshold.java b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/java/org/apache/nifi/controller/queue/clustered/TestNaiveLimitThreshold.java
index e4f0c74a38..44f42fecec 100644
--- a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/java/org/apache/nifi/controller/queue/clustered/TestNaiveLimitThreshold.java
+++ b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/java/org/apache/nifi/controller/queue/clustered/TestNaiveLimitThreshold.java
@@ -17,10 +17,10 @@
package org.apache.nifi.controller.queue.clustered;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
+import org.junit.jupiter.api.Test;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertTrue;
-import org.junit.Test;
public class TestNaiveLimitThreshold {
diff --git a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/java/org/apache/nifi/controller/queue/clustered/TestSocketLoadBalancedFlowFileQueue.java b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/java/org/apache/nifi/controller/queue/clustered/TestSocketLoadBalancedFlowFileQueue.java
index 83eea46a34..36372964b0 100644
--- a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/java/org/apache/nifi/controller/queue/clustered/TestSocketLoadBalancedFlowFileQueue.java
+++ b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/java/org/apache/nifi/controller/queue/clustered/TestSocketLoadBalancedFlowFileQueue.java
@@ -42,9 +42,9 @@ import org.apache.nifi.events.EventReporter;
import org.apache.nifi.flowfile.FlowFile;
import org.apache.nifi.flowfile.FlowFilePrioritizer;
import org.apache.nifi.provenance.ProvenanceEventRepository;
-import org.junit.Assert;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.Timeout;
import org.mockito.Mockito;
import org.mockito.invocation.InvocationOnMock;
import org.mockito.stubbing.Answer;
@@ -60,12 +60,13 @@ import java.util.Map;
import java.util.Set;
import java.util.UUID;
-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.assertSame;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertDoesNotThrow;
+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.assertSame;
+import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.mockito.Mockito.doAnswer;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
@@ -86,7 +87,7 @@ public class TestSocketLoadBalancedFlowFileQueue {
private List<NodeIdentifier> nodeIds;
private int nodePort = 4096;
- @Before
+ @BeforeEach
public void setup() {
MockFlowFileRecord.resetIdGenerator();
connection = mock(Connection.class);
@@ -415,7 +416,8 @@ public class TestSocketLoadBalancedFlowFileQueue {
}
- @Test(timeout = 10000)
+ @Test
+ @Timeout(10)
public void testChangeInClusterTopologyTriggersRebalance() throws InterruptedException {
// Create partitioner that sends first 2 FlowFiles to Partition 0, next 2 to Partition 1, and then next 4 to Partition 3.
queue.setFlowFilePartitioner(new StaticSequencePartitioner(new int[] {0, 0, 1, 1, 3, 3, 3, 3}, true));
@@ -457,24 +459,25 @@ public class TestSocketLoadBalancedFlowFileQueue {
final NodeIdentifier node2Identifier = nodeIds.get(1);
// The local node partition starts out first
- Assert.assertEquals("local", firstPartition.getSwapPartitionName());
+ assertEquals("local", firstPartition.getSwapPartitionName());
// Simulate offloading the first node
clusterTopologyEventListener.onNodeStateChange(node1Identifier, NodeConnectionState.OFFLOADING);
// Now the remote partition for the second node should be returned
firstPartition = queue.putAndGetPartition(new MockFlowFileRecord());
- Assert.assertEquals(node2Identifier, firstPartition.getNodeIdentifier().get());
+ assertEquals(node2Identifier, firstPartition.getNodeIdentifier().get());
// Simulate reconnecting the first node
clusterTopologyEventListener.onNodeStateChange(node1Identifier, NodeConnectionState.CONNECTED);
// Now the local node partition is returned again
firstPartition = queue.putAndGetPartition(new MockFlowFileRecord());
- Assert.assertEquals("local", firstPartition.getSwapPartitionName());
+ assertEquals("local", firstPartition.getSwapPartitionName());
}
- @Test(timeout = 30000)
+ @Test
+ @Timeout(30)
public void testChangeInClusterTopologyTriggersRebalanceOnlyOnRemovedNodeIfNecessary() throws InterruptedException {
// Create partitioner that sends first 1 FlowFile to Partition 0, next to Partition 2, and then next 2 to Partition 2.
// Then, cycle back to partitions 0 and 1. This will result in partitions 0 & 1 getting 1 FlowFile each and Partition 2
@@ -506,7 +509,8 @@ public class TestSocketLoadBalancedFlowFileQueue {
}
}
- @Test(timeout = 10000)
+ @Test
+ @Timeout(10)
public void testChangeInPartitionerTriggersRebalance() throws InterruptedException {
// Create partitioner that sends first 2 FlowFiles to Partition 0, next 2 to Partition 1, and then next 4 to Partition 3.
queue.setFlowFilePartitioner(new StaticSequencePartitioner(new int[] {0, 1, 0, 1}, false));
@@ -525,7 +529,8 @@ public class TestSocketLoadBalancedFlowFileQueue {
assertPartitionSizes(expectedPartitionSizes);
}
- @Test(timeout = 10000)
+ @Test
+ @Timeout(10)
public void testDataInRemotePartitionForLocalIdIsMovedToLocalPartition() throws InterruptedException {
nodeIds.clear();
@@ -576,11 +581,7 @@ public class TestSocketLoadBalancedFlowFileQueue {
private void assertPartitionSizes(final int[] expectedSizes) {
final int[] partitionSizes = new int[queue.getPartitionCount()];
while (!Arrays.equals(expectedSizes, partitionSizes)) {
- try {
- Thread.sleep(10L);
- } catch (InterruptedException e) {
- Assert.fail("Interrupted");
- }
+ assertDoesNotThrow(() -> Thread.sleep(10L));
for (int i = 0; i < partitionSizes.length; i++) {
partitionSizes[i] = queue.getPartition(i).size().getObjectCount();
diff --git a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/java/org/apache/nifi/controller/queue/clustered/TestSwappablePriorityQueue.java b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/java/org/apache/nifi/controller/queue/clustered/TestSwappablePriorityQueue.java
index 95a204b63c..deb41f17e4 100644
--- a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/java/org/apache/nifi/controller/queue/clustered/TestSwappablePriorityQueue.java
+++ b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/java/org/apache/nifi/controller/queue/clustered/TestSwappablePriorityQueue.java
@@ -29,12 +29,11 @@ import org.apache.nifi.controller.repository.FlowFileRecord;
import org.apache.nifi.events.EventReporter;
import org.apache.nifi.flowfile.FlowFile;
import org.apache.nifi.flowfile.FlowFilePrioritizer;
-import org.apache.nifi.reporting.Severity;
import org.apache.nifi.util.MockFlowFile;
import org.apache.nifi.util.StringUtils;
-import org.junit.Assert;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.Timeout;
import org.mockito.Mockito;
import java.io.IOException;
@@ -44,12 +43,13 @@ import java.util.HashSet;
import java.util.List;
import java.util.Set;
-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.assertSame;
-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.assertSame;
+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.when;
@@ -66,17 +66,12 @@ public class TestSwappablePriorityQueue {
private SwappablePriorityQueue queue;
- @Before
+ @BeforeEach
public void setup() {
swapManager = new MockSwapManager();
events.clear();
- eventReporter = new EventReporter() {
- @Override
- public void reportEvent(final Severity severity, final String category, final String message) {
- events.add(message);
- }
- };
+ eventReporter = (severity, category, message) -> events.add(message);
when(flowFileQueue.getIdentifier()).thenReturn("unit-test");
queue = new SwappablePriorityQueue(swapManager, 10000, eventReporter, flowFileQueue, dropAction, "local");
@@ -629,7 +624,7 @@ public class TestSwappablePriorityQueue {
for (int i = 0; i < 9998; i++) {
flowFile = queue.poll(expired, 500000);
- assertNotNull("Null FlowFile when i = " + i, flowFile);
+ assertNotNull(flowFile, "Null FlowFile when i = " + i);
queue.acknowledge(Collections.singleton(flowFile));
final QueueSize queueSize = queue.size();
@@ -645,7 +640,8 @@ public class TestSwappablePriorityQueue {
assertNull(flowFile);
}
- @Test(timeout = 120000)
+ @Test
+ @Timeout(120)
public void testDropSwappedFlowFiles() {
for (int i = 1; i <= 30000; i++) {
queue.put(new MockFlowFileRecord());
@@ -663,7 +659,8 @@ public class TestSwappablePriorityQueue {
}
- @Test(timeout = 5000)
+ @Test
+ @Timeout(5)
public void testGetActiveFlowFilesReturnsAllActiveFlowFiles() throws InterruptedException {
for (int i = 0; i < 9999; i++) {
queue.put(new MockFlowFileRecord());
@@ -675,7 +672,8 @@ public class TestSwappablePriorityQueue {
}
- @Test(timeout = 5000)
+ @Test
+ @Timeout(5)
public void testListFlowFilesResultsLimited() throws InterruptedException {
for (int i = 0; i < 30050; i++) {
queue.put(new MockFlowFileRecord());
@@ -707,24 +705,14 @@ public class TestSwappablePriorityQueue {
// verify that unexpected ERROR's are handled in such a way that we keep retrying
for (int i = 0; i < 3; i++) {
- try {
- queue.poll(expiredRecords, 500000);
- Assert.fail("Expected OOME to be thrown");
- } catch (final OutOfMemoryError oome) {
- // expected
- }
+ assertThrows(OutOfMemoryError.class, () -> queue.poll(expiredRecords, 500000));
}
// verify that unexpected Runtime Exceptions are handled in such a way that we keep retrying
swapManager.setSwapInFailure(new NullPointerException("Intentional OOME for unit test"));
for (int i = 0; i < 3; i++) {
- try {
- queue.poll(expiredRecords, 500000);
- Assert.fail("Expected NPE to be thrown");
- } catch (final NullPointerException npe) {
- // expected
- }
+ assertThrows(NullPointerException.class, () -> queue.poll(expiredRecords, 500000));
}
swapManager.failSwapInAfterN = -1;
diff --git a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/java/org/apache/nifi/controller/queue/clustered/client/async/nio/TestLoadBalanceSession.java b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/java/org/apache/nifi/controller/queue/clustered/client/async/nio/TestLoadBalanceSession.java
index d43ee2be44..81e6d8c94f 100644
--- a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/java/org/apache/nifi/controller/queue/clustered/client/async/nio/TestLoadBalanceSession.java
+++ b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/java/org/apache/nifi/controller/queue/clustered/client/async/nio/TestLoadBalanceSession.java
@@ -25,10 +25,10 @@ import org.apache.nifi.controller.queue.clustered.client.StandardLoadBalanceFlow
import org.apache.nifi.controller.queue.clustered.client.async.TransactionFailureCallback;
import org.apache.nifi.controller.queue.clustered.protocol.LoadBalanceProtocolConstants;
import org.apache.nifi.controller.repository.FlowFileRecord;
-import org.junit.After;
-import org.junit.Assert;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.Timeout;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
@@ -49,9 +49,10 @@ import java.util.zip.CRC32;
import java.util.zip.CheckedOutputStream;
import java.util.zip.Checksum;
-import static org.junit.Assert.assertArrayEquals;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertArrayEquals;
+import static org.junit.jupiter.api.Assertions.assertDoesNotThrow;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertTrue;
public class TestLoadBalanceSession {
@@ -70,44 +71,39 @@ public class TestLoadBalanceSession {
private ServerSocket serverSocket;
private int port;
- @Before
+ @BeforeEach
public void setup() throws IOException {
received = new ByteArrayOutputStream();
serverSocket = new ServerSocket(0);
port = serverSocket.getLocalPort();
- final Thread thread = new Thread(new Runnable() {
- @Override
- public void run() {
- try (final Socket socket = serverSocket.accept()) {
- final InputStream in = socket.getInputStream();
- int data;
-
- socket.getOutputStream().write(LoadBalanceProtocolConstants.VERSION_ACCEPTED);
- socket.getOutputStream().write(LoadBalanceProtocolConstants.SPACE_AVAILABLE);
- socket.getOutputStream().write(LoadBalanceProtocolConstants.CONFIRM_CHECKSUM);
- socket.getOutputStream().write(LoadBalanceProtocolConstants.CONFIRM_COMPLETE_TRANSACTION);
-
- while ((data = in.read()) != -1) {
- received.write(data);
- }
- } catch (IOException e) {
- e.printStackTrace();
- Assert.fail();
+ final Thread thread = new Thread(() -> assertDoesNotThrow(() -> {
+ try (final Socket socket = serverSocket.accept()) {
+ final InputStream in = socket.getInputStream();
+ int data;
+
+ socket.getOutputStream().write(LoadBalanceProtocolConstants.VERSION_ACCEPTED);
+ socket.getOutputStream().write(LoadBalanceProtocolConstants.SPACE_AVAILABLE);
+ socket.getOutputStream().write(LoadBalanceProtocolConstants.CONFIRM_CHECKSUM);
+ socket.getOutputStream().write(LoadBalanceProtocolConstants.CONFIRM_COMPLETE_TRANSACTION);
+
+ while ((data = in.read()) != -1) {
+ received.write(data);
}
}
- });
+ }));
thread.setDaemon(true);
thread.start();
}
- @After
+ @AfterEach
public void shutdown() throws IOException {
serverSocket.close();
}
- @Test(timeout = 10000)
+ @Test
+ @Timeout(10)
public void testSunnyCase() throws InterruptedException, IOException {
final Queue<FlowFileRecord> flowFiles = new LinkedList<>();
final FlowFileRecord flowFile1 = new MockFlowFileRecord(5);
@@ -194,7 +190,8 @@ public class TestLoadBalanceSession {
}
- @Test(timeout = 10000)
+ @Test
+ @Timeout(10)
public void testLargeContent() throws InterruptedException, IOException {
final byte[] content = new byte[66000];
for (int i=0; i < 66000; i++) {
diff --git a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/java/org/apache/nifi/controller/queue/clustered/server/TestStandardLoadBalanceProtocol.java b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/java/org/apache/nifi/controller/queue/clustered/server/TestStandardLoadBalanceProtocol.java
index d74c2136df..9d655d115a 100644
--- a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/java/org/apache/nifi/controller/queue/clustered/server/TestStandardLoadBalanceProtocol.java
+++ b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/java/org/apache/nifi/controller/queue/clustered/server/TestStandardLoadBalanceProtocol.java
@@ -32,9 +32,8 @@ import org.apache.nifi.controller.repository.claim.ResourceClaim;
import org.apache.nifi.provenance.ProvenanceEventRecord;
import org.apache.nifi.provenance.ProvenanceEventType;
import org.apache.nifi.provenance.ProvenanceRepository;
-import org.junit.Assert;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
import org.mockito.Mockito;
import org.mockito.invocation.InvocationOnMock;
import org.mockito.stubbing.Answer;
@@ -70,9 +69,10 @@ import static org.apache.nifi.controller.queue.clustered.protocol.LoadBalancePro
import static org.apache.nifi.controller.queue.clustered.protocol.LoadBalanceProtocolConstants.REJECT_CHECKSUM;
import static org.apache.nifi.controller.queue.clustered.protocol.LoadBalanceProtocolConstants.SKIP_SPACE_CHECK;
import static org.apache.nifi.controller.queue.clustered.protocol.LoadBalanceProtocolConstants.SPACE_AVAILABLE;
-import static org.junit.Assert.assertArrayEquals;
-import static org.junit.Assert.assertEquals;
-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.assertThrows;
+import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.mockito.ArgumentMatchers.anyCollection;
import static org.mockito.ArgumentMatchers.anyList;
import static org.mockito.Mockito.times;
@@ -94,7 +94,7 @@ public class TestStandardLoadBalanceProtocol {
private ConcurrentMap<ContentClaim, byte[]> claimContents;
- @Before
+ @BeforeEach
public void setup() throws IOException, IllegalClusterStateException {
flowFileQueuePutRecords = new ArrayList<>();
flowFileQueueReceiveRecords = new ArrayList<>();
@@ -395,12 +395,9 @@ public class TestStandardLoadBalanceProtocol {
dos.flush();
dos.close();
- try {
- protocol.receiveFlowFiles(serverInput, serverOutput, "Unit Test", 1);
- Assert.fail("Expected EOFException but none was thrown");
- } catch (final EOFException eof) {
- // expected
- }
+ assertThrows(EOFException.class,
+ () -> protocol.receiveFlowFiles(serverInput, serverOutput,
+ "Unit Test", 1));
final byte[] serverResponse = serverOutput.toByteArray();
assertEquals(1, serverResponse.length);
@@ -442,12 +439,9 @@ public class TestStandardLoadBalanceProtocol {
dos.writeLong(1L); // Write bad checksum.
dos.write(COMPLETE_TRANSACTION);
- try {
- protocol.receiveFlowFiles(serverInput, serverOutput, "Unit Test", 1);
- Assert.fail("Expected TransactionAbortedException but none was thrown");
- } catch (final TransactionAbortedException e) {
- // expected
- }
+ assertThrows(TransactionAbortedException.class,
+ () -> protocol.receiveFlowFiles(serverInput, serverOutput,
+ "Unit Test", 1));
final byte[] serverResponse = serverOutput.toByteArray();
assertEquals(2, serverResponse.length);
@@ -496,12 +490,8 @@ public class TestStandardLoadBalanceProtocol {
dos.flush();
dos.close();
- try {
- protocol.receiveFlowFiles(serverInput, serverOutput, "Unit Test", 1);
- Assert.fail("Expected EOFException but none was thrown");
- } catch (final EOFException e) {
- // expected
- }
+ assertThrows(EOFException.class,
+ () -> protocol.receiveFlowFiles(serverInput, serverOutput, "Unit Test", 1));
final byte[] serverResponse = serverOutput.toByteArray();
assertEquals(1, serverResponse.length);
@@ -547,12 +537,9 @@ public class TestStandardLoadBalanceProtocol {
dos.writeLong(checksum.getValue());
dos.write(ABORT_TRANSACTION);
- try {
- protocol.receiveFlowFiles(serverInput, serverOutput, "Unit Test", 1);
- Assert.fail("Expected TransactionAbortedException but none was thrown");
- } catch (final TransactionAbortedException e) {
- // expected
- }
+ assertThrows(TransactionAbortedException.class,
+ () -> protocol.receiveFlowFiles(serverInput, serverOutput,
+ "Unit Test", 1));
final byte[] serverResponse = serverOutput.toByteArray();
assertEquals(2, serverResponse.length);
diff --git a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/java/org/apache/nifi/controller/reporting/TestStandardReportingContext.java b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/java/org/apache/nifi/controller/reporting/TestStandardReportingContext.java
index 4dfe8d2db6..3cab19d6cb 100644
--- a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/java/org/apache/nifi/controller/reporting/TestStandardReportingContext.java
+++ b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/java/org/apache/nifi/controller/reporting/TestStandardReportingContext.java
@@ -42,9 +42,9 @@ import org.apache.nifi.registry.VariableRegistry;
import org.apache.nifi.registry.variable.FileBasedVariableRegistry;
import org.apache.nifi.reporting.BulletinRepository;
import org.apache.nifi.util.NiFiProperties;
-import org.junit.After;
-import org.junit.Before;
-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.Mockito;
import java.io.File;
@@ -54,7 +54,7 @@ import java.util.LinkedHashSet;
import java.util.Map;
import java.util.Set;
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
public class TestStandardReportingContext {
@@ -71,7 +71,7 @@ public class TestStandardReportingContext {
private StatusHistoryRepository statusHistoryRepository;
private volatile String propsFile = TestStandardReportingContext.class.getResource("/flowcontrollertest.nifi.properties").getFile();
- @Before
+ @BeforeEach
public void setup() {
flowFileEventRepo = Mockito.mock(FlowFileEventRepository.class);
auditService = Mockito.mock(AuditService.class);
@@ -133,7 +133,7 @@ public class TestStandardReportingContext {
bulletinRepo, variableRegistry, extensionManager, statusHistoryRepository);
}
- @After
+ @AfterEach
public void cleanup() throws Exception {
controller.shutdown(true);
FileUtils.deleteDirectory(new File("./target/flowcontrollertest"));
diff --git a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/java/org/apache/nifi/controller/repository/SchemaRepositoryRecordSerdeTest.java b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/java/org/apache/nifi/controller/repository/SchemaRepositoryRecordSerdeTest.java
index 543d94b97d..e11c20be6a 100644
--- a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/java/org/apache/nifi/controller/repository/SchemaRepositoryRecordSerdeTest.java
+++ b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/java/org/apache/nifi/controller/repository/SchemaRepositoryRecordSerdeTest.java
@@ -21,9 +21,9 @@ import org.apache.nifi.controller.queue.FlowFileQueue;
import org.apache.nifi.controller.repository.claim.StandardResourceClaimManager;
import org.apache.nifi.controller.repository.schema.RepositoryRecordSchema;
import org.apache.nifi.repository.schema.NoOpFieldCache;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
@@ -34,8 +34,8 @@ import java.util.HashMap;
import java.util.Map;
import static org.apache.nifi.controller.repository.RepositoryRecordType.SWAP_IN;
-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.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
@@ -47,7 +47,7 @@ public class SchemaRepositoryRecordSerdeTest {
private ByteArrayOutputStream byteArrayOutputStream;
private DataOutputStream dataOutputStream;
- @Before
+ @BeforeEach
public void setup() {
resourceClaimManager = new StandardResourceClaimManager();
schemaRepositoryRecordSerde = new SchemaRepositoryRecordSerde(resourceClaimManager, new NoOpFieldCache());
@@ -56,7 +56,7 @@ public class SchemaRepositoryRecordSerdeTest {
dataOutputStream = new DataOutputStream(byteArrayOutputStream);
}
- @After
+ @AfterEach
public void teardown() {
resourceClaimManager.purge();
}
diff --git a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/java/org/apache/nifi/controller/repository/StandardProcessSessionIT.java b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/java/org/apache/nifi/controller/repository/StandardProcessSessionIT.java
index d94724c9a5..b69125107d 100644
--- a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/java/org/apache/nifi/controller/repository/StandardProcessSessionIT.java
+++ b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/java/org/apache/nifi/controller/repository/StandardProcessSessionIT.java
@@ -16,6 +16,7 @@
*/
package org.apache.nifi.controller.repository;
+import org.apache.commons.io.IOUtils;
import org.apache.nifi.components.state.Scope;
import org.apache.nifi.components.state.StateMap;
import org.apache.nifi.connectable.Connectable;
@@ -61,11 +62,10 @@ import org.apache.nifi.state.MockStateManager;
import org.apache.nifi.stream.io.StreamUtils;
import org.apache.nifi.util.MockFlowFile;
import org.apache.nifi.util.NiFiProperties;
-import org.junit.After;
-import org.junit.Assert;
-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.Disabled;
+import org.junit.jupiter.api.Test;
import org.mockito.Mockito;
import org.mockito.invocation.InvocationOnMock;
import org.mockito.stubbing.Answer;
@@ -103,15 +103,18 @@ import java.util.concurrent.atomic.AtomicReference;
import java.util.function.Predicate;
import java.util.regex.Pattern;
import java.util.stream.Collectors;
-
-import static org.junit.Assert.assertArrayEquals;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNotEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertSame;
-import static org.junit.Assert.assertTrue;
+import java.util.stream.Stream;
+
+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.assertNotEquals;
+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 static org.junit.jupiter.api.Assertions.fail;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.anyLong;
import static org.mockito.ArgumentMatchers.eq;
@@ -138,7 +141,7 @@ public class StandardProcessSessionIT {
private FlowFileEventRepository flowFileEventRepository;
private ResourceClaimManager resourceClaimManager;
- @After
+ @AfterEach
public void cleanup() {
session.rollback();
@@ -167,11 +170,11 @@ public class StandardProcessSessionIT {
if (!removed && dir.exists()) {
// we fail in this situation because it generally means that the StandardProcessSession did not
// close the OutputStream.
- Assert.fail("Could not clean up content repo: " + dir + " could not be removed");
+ fail("Could not clean up content repo: " + dir + " could not be removed");
}
}
- @Before
+ @BeforeEach
public void setup() throws IOException {
resourceClaimManager = new StandardResourceClaimManager();
@@ -343,23 +346,15 @@ public class StandardProcessSessionIT {
}
final ProcessSession secondSession = new StandardProcessSession(context, () -> false, new NopPerformanceTracker());
- try {
- session.migrate(secondSession, children);
- Assert.fail("Expected a FlowFileHandlingException to be thrown because a child FlowFile was migrated while its parent was not");
- } catch (final FlowFileHandlingException expected) {
- }
+ assertThrows(FlowFileHandlingException.class, () -> session.migrate(secondSession, children),
+ "Expected a FlowFileHandlingException to be thrown because a child FlowFile was migrated while its parent was not");
- try {
- session.migrate(secondSession, Collections.singletonList(flowFile));
- Assert.fail("Expected a FlowFileHandlingException to be thrown because parent was forked and then migrated without children");
- } catch (final FlowFileHandlingException expected) {
- }
+ assertThrows(FlowFileHandlingException.class, () -> session.migrate(secondSession, Collections.singletonList(flowFile)),
+ "Expected a FlowFileHandlingException to be thrown because parent was forked and then migrated without children");
- try {
- session.migrate(secondSession, Arrays.asList(flowFile, children.get(0), children.get(1)));
- Assert.fail("Expected a FlowFileHandlingException to be thrown because parent was forked and then migrated without children");
- } catch (final FlowFileHandlingException expected) {
- }
+ assertThrows(FlowFileHandlingException.class,
+ () -> session.migrate(secondSession, Arrays.asList(flowFile, children.get(0), children.get(1))),
+ "Expected a FlowFileHandlingException to be thrown because parent was forked and then migrated without children");
// Should succeed when migrating all FlowFiles.
final List<FlowFile> allFlowFiles = new ArrayList<>();
@@ -694,12 +689,8 @@ public class StandardProcessSessionIT {
session.transfer(ff1, relationship);
- try {
- session.get();
- Assert.fail("Should not have been able to poll second FlowFile with same ID");
- } catch (final FlowFileAccessException e) {
- // Expected
- }
+ assertThrows(FlowFileAccessException.class, () -> session.get(),
+ "Should not have been able to poll second FlowFile with same ID");
}
@@ -740,13 +731,8 @@ public class StandardProcessSessionIT {
// these will be the same content claim due to how the StandardProcessSession adds multiple FlowFiles' contents to a single claim.
assertSame(updatedContentClaim, childContentClaim);
assertEquals(2, contentRepo.getClaimantCount(childContentClaim));
-
- try {
- session.commit();
- Assert.fail("Expected session commit to fail");
- } catch (final ProcessException pe) {
- // Expected
- }
+ assertThrows(ProcessException.class, () -> session.commit(),
+ "Expected session commit to fail");
// Ensure that if we fail to update teh flowfile repo, that the claimant count of the 'original' flowfile, which was removed, does not get decremented.
assertEquals(1, contentRepo.getClaimantCount(contentClaim));
@@ -828,8 +814,8 @@ public class StandardProcessSessionIT {
StreamUtils.fillBuffer(in, buff2);
}
- Assert.assertArrayEquals(new byte[] {'A', 'B'}, buff1);
- Assert.assertArrayEquals(new byte[] {'C'}, buff2);
+ assertArrayEquals(new byte[] {'A', 'B'}, buff1);
+ assertArrayEquals(new byte[] {'C'}, buff2);
}
@Test
@@ -971,14 +957,10 @@ public class StandardProcessSessionIT {
child = session.append(child, out -> out.write("hello".getBytes()));
// Force an IOException. This will decrement out claim count for the resource claim.
- try {
- child = session.append(child, out -> {
- throw new IOException();
- });
- Assert.fail("append() callback threw IOException but it was not wrapped in ProcessException");
- } catch (final ProcessException pe) {
- // expected
- }
+ final FlowFile finalChild = child;
+ assertThrows(ProcessException.class, () -> session.append(finalChild, out -> {
+ throw new IOException();}),
+ "append() callback threw IOException but it was not wrapped in ProcessException");
session.remove(child);
session.transfer(original);
@@ -1000,17 +982,13 @@ public class StandardProcessSessionIT {
assertNotNull(original);
FlowFile child = session.create(original);
- // Force an IOException. This will decrement out claim count for the resource claim.
- try {
- child = session.write(child, out -> out.write("hello".getBytes()));
+ child = session.write(child, out -> out.write("hello".getBytes()));
+ final FlowFile finalChild = child;
- child = session.write(child, out -> {
- throw new IOException();
- });
- Assert.fail("write() callback threw IOException but it was not wrapped in ProcessException");
- } catch (final ProcessException pe) {
- // expected
- }
+ // Force an IOException. This will decrement out claim count for the resource claim.
+ assertThrows(ProcessException.class, () -> session.write(finalChild, out -> {
+ throw new IOException();}),
+ "write() callback threw IOException but it was not wrapped in ProcessException");
session.remove(child);
session.transfer(original);
@@ -1203,57 +1181,25 @@ public class StandardProcessSessionIT {
}
private void assertDisabled(final OutputStream outputStream) {
- try {
- outputStream.write(new byte[0]);
- Assert.fail("Expected OutputStream to be disabled; was able to call write(byte[])");
- } catch (final Exception ex) {
- assertEquals(FlowFileAccessException.class, ex.getClass());
- }
- try {
- outputStream.write(0);
- Assert.fail("Expected OutputStream to be disabled; was able to call write(int)");
- } catch (final Exception ex) {
- assertEquals(FlowFileAccessException.class, ex.getClass());
- }
- try {
- outputStream.write(new byte[0], 0, 0);
- Assert.fail("Expected OutputStream to be disabled; was able to call write(byte[], int, int)");
- } catch (final Exception ex) {
- assertEquals(FlowFileAccessException.class, ex.getClass());
- }
+ assertThrows(FlowFileAccessException.class, () -> outputStream.write(new byte[0]),
+ "Expected OutputStream to be disabled; was able to call write(byte[])");
+ assertThrows(FlowFileAccessException.class, () -> outputStream.write(0),
+ "Expected OutputStream to be disabled; was able to call write(int)");
+ assertThrows(FlowFileAccessException.class, () -> outputStream.write(new byte[0], 0, 0),
+ "Expected OutputStream to be disabled; was able to call write(byte[], int, int)");
}
private void assertDisabled(final InputStream inputStream) {
- try {
- inputStream.read();
- Assert.fail("Expected InputStream to be disabled; was able to call read()");
- } catch (final Exception ex) {
- assertEquals(FlowFileAccessException.class, ex.getClass());
- }
- try {
- inputStream.read(new byte[0]);
- Assert.fail("Expected InputStream to be disabled; was able to call read(byte[])");
- } catch (final Exception ex) {
- assertEquals(FlowFileAccessException.class, ex.getClass());
- }
- try {
- inputStream.read(new byte[0], 0, 0);
- Assert.fail("Expected InputStream to be disabled; was able to call read(byte[], int, int)");
- } catch (final Exception ex) {
- assertEquals(FlowFileAccessException.class, ex.getClass());
- }
- try {
- inputStream.reset();
- Assert.fail("Expected InputStream to be disabled; was able to call reset()");
- } catch (final Exception ex) {
- assertEquals(FlowFileAccessException.class, ex.getClass());
- }
- try {
- inputStream.skip(1L);
- Assert.fail("Expected InputStream to be disabled; was able to call skip(long)");
- } catch (final Exception ex) {
- assertEquals(FlowFileAccessException.class, ex.getClass());
- }
+ assertThrows(FlowFileAccessException.class, () -> inputStream.read(),
+ "Expected InputStream to be disabled; was able to call read()");
+ assertThrows(FlowFileAccessException.class, () -> inputStream.read(new byte[0]),
+ "Expected InputStream to be disabled; was able to call read(byte[])");
+ assertThrows(FlowFileAccessException.class, () -> inputStream.read(new byte[0], 0, 0),
+ "Expected InputStream to be disabled; was able to call read(byte[], int, int)");
+ assertThrows(FlowFileAccessException.class, () -> inputStream.reset(),
+ "Expected InputStream to be disabled; was able to call reset()");
+ assertThrows(FlowFileAccessException.class, () -> inputStream.skip(1L),
+ "Expected InputStream to be disabled; was able to call skip(long)");
}
@Test
@@ -1305,11 +1251,9 @@ public class StandardProcessSessionIT {
// should throw ProcessException because of IOException (from processor code)
FileOutputStream mock = Mockito.mock(FileOutputStream.class);
doThrow(new IOException()).when(mock).write((byte[]) notNull(), any(Integer.class), any(Integer.class));
- try {
- session.exportTo(flowFile, mock);
- Assert.fail("Expected ProcessException");
- } catch (ProcessException e) {
- }
+
+ final FlowFile finalFlowfile = flowFile;
+ assertThrows(ProcessException.class, () -> session.exportTo(finalFlowfile, mock));
}
@Test
@@ -1579,11 +1523,11 @@ public class StandardProcessSessionIT {
} else if (event.getFlowFileUuid().equals(ff2.getAttribute("uuid"))) {
ff2UpdateCount++;
} else {
- Assert.fail("Got ATTRIBUTE_MODIFIED for wrong FlowFile: " + event.getFlowFileUuid());
+ fail("Got ATTRIBUTE_MODIFIED for wrong FlowFile: " + event.getFlowFileUuid());
}
break;
default:
- Assert.fail("Unexpected event type: " + event);
+ fail("Unexpected event type: " + event);
}
}
@@ -1626,89 +1570,51 @@ public class StandardProcessSessionIT {
@Test
public void testProcessExceptionThrownIfCallbackThrowsInOutputStreamCallback() {
final FlowFile ff1 = session.create();
-
final RuntimeException runtime = new RuntimeException();
- try {
- session.write(ff1, new OutputStreamCallback() {
- @Override
- public void process(final OutputStream out) throws IOException {
+
+ assertThrows(RuntimeException.class,
+ () -> session.write(ff1, out -> {
throw runtime;
- }
- });
- Assert.fail("Should have thrown RuntimeException");
- } catch (final RuntimeException re) {
- assertTrue(runtime == re);
- }
+ }));
final IOException ioe = new IOException();
- try {
- session.write(ff1, new OutputStreamCallback() {
- @Override
- public void process(OutputStream out) throws IOException {
+ ProcessException processException = assertThrows(ProcessException.class,
+ () -> session.write(ff1, out -> {
throw ioe;
- }
- });
- Assert.fail("Should have thrown ProcessException");
- } catch (final ProcessException pe) {
- assertTrue(ioe == pe.getCause());
- }
+ }));
+ assertSame(ioe, processException.getCause());
final ProcessException pe = new ProcessException();
- try {
- session.write(ff1, new OutputStreamCallback() {
- @Override
- public void process(OutputStream out) throws IOException {
+ processException = assertThrows(ProcessException.class,
+ () -> session.write(ff1, out -> {
throw pe;
- }
- });
- Assert.fail("Should have thrown ProcessException");
- } catch (final ProcessException pe2) {
- assertTrue(pe == pe2);
- }
+ }));
+ assertSame(pe, processException);
}
@Test
public void testProcessExceptionThrownIfCallbackThrowsInStreamCallback() {
final FlowFile ff1 = session.create();
-
final RuntimeException runtime = new RuntimeException();
- try {
- session.write(ff1, new StreamCallback() {
- @Override
- public void process(final InputStream in, final OutputStream out) throws IOException {
+
+ assertThrows(RuntimeException.class,
+ () -> session.write(ff1, (in, out) -> {
throw runtime;
- }
- });
- Assert.fail("Should have thrown RuntimeException");
- } catch (final RuntimeException re) {
- assertTrue(runtime == re);
- }
+ }));
final IOException ioe = new IOException();
- try {
- session.write(ff1, new StreamCallback() {
- @Override
- public void process(final InputStream in, OutputStream out) throws IOException {
+ ProcessException processException = assertThrows(ProcessException.class,
+ () -> session.write(ff1, (in, out) -> {
throw ioe;
- }
- });
- Assert.fail("Should have thrown ProcessException");
- } catch (final ProcessException pe) {
- assertTrue(ioe == pe.getCause());
- }
+ }));
+ assertSame(ioe, processException.getCause());
final ProcessException pe = new ProcessException();
- try {
- session.write(ff1, new StreamCallback() {
- @Override
- public void process(final InputStream in, OutputStream out) throws IOException {
+ processException = assertThrows(ProcessException.class,
+ () -> session.write(ff1, (in, out) -> {
throw pe;
- }
- });
- Assert.fail("Should have thrown ProcessException");
- } catch (final ProcessException pe2) {
- assertTrue(pe == pe2);
- }
+ }));
+ assertSame(pe, processException);
}
@Test
@@ -1722,29 +1628,14 @@ public class StandardProcessSessionIT {
flowFileQueue.put(flowFileRecord);
// attempt to read the data.
- try {
- final FlowFile ff1 = session.get();
-
- session.read(ff1, new InputStreamCallback() {
- @Override
- public void process(InputStream in) throws IOException {
- in.read();
- }
- });
- Assert.fail("Expected MissingFlowFileException");
- } catch (final MissingFlowFileException mffe) {
- }
+ final FlowFile ff1 = session.get();
+ assertThrows(MissingFlowFileException.class, () -> session.read(ff1, InputStream::read));
}
@Test
public void testAppend() throws IOException {
FlowFile ff = session.create();
- ff = session.append(ff, new OutputStreamCallback() {
- @Override
- public void process(OutputStream out) throws IOException {
- out.write("Hello".getBytes());
- }
- });
+ ff = session.append(ff, out -> out.write("Hello".getBytes()));
// do not allow the content repo to be read from; this ensures that we are
// not copying the data each time we call append but instead are actually appending to the output stream
@@ -1856,7 +1747,7 @@ public class StandardProcessSessionIT {
}
@Test
- @Ignore
+ @Disabled
public void testManyFilesOpened() throws IOException {
StandardProcessSession[] standardProcessSessions = new StandardProcessSession[100000];
@@ -1901,18 +1792,8 @@ public class StandardProcessSessionIT {
flowFileQueue.put(flowFileRecord);
// attempt to read the data.
- try {
- final FlowFile ff1 = session.get();
-
- session.write(ff1, new StreamCallback() {
- @Override
- public void process(InputStream in, OutputStream out) throws IOException {
- in.read();
- }
- });
- Assert.fail("Expected MissingFlowFileException");
- } catch (final MissingFlowFileException mffe) {
- }
+ final FlowFile ff1 = session.get();
+ assertThrows(MissingFlowFileException.class, () -> session.write(ff1, (in, out) -> in.read()));
}
@Test
@@ -1945,18 +1826,10 @@ public class StandardProcessSessionIT {
flowFileQueue.put(flowFileRecord2);
// attempt to read the data.
- try {
- session.get();
- final FlowFile ff2 = session.get();
- session.write(ff2, new StreamCallback() {
- @Override
- public void process(InputStream in, OutputStream out) throws IOException {
- in.read();
- }
- });
- Assert.fail("Expected ContentNotFoundException");
- } catch (final MissingFlowFileException mffe) {
- }
+ session.get();
+ final FlowFile ff2 = session.get();
+
+ assertThrows(MissingFlowFileException.class, () -> session.write(ff2, (in, out) -> in.read()));
}
@Test
@@ -1988,18 +1861,10 @@ public class StandardProcessSessionIT {
flowFileQueue.put(flowFileRecord2);
// attempt to read the data.
- try {
- session.get();
- final FlowFile ff2 = session.get();
- session.read(ff2, new InputStreamCallback() {
- @Override
- public void process(InputStream in) throws IOException {
- in.read();
- }
- });
- Assert.fail("Expected MissingFlowFileException");
- } catch (final MissingFlowFileException mffe) {
- }
+ session.get();
+ final FlowFile ff2 = session.get();
+
+ assertThrows(MissingFlowFileException.class, () -> session.read(ff2, InputStream::read));
}
@Test
@@ -2007,43 +1872,26 @@ public class StandardProcessSessionIT {
final FlowFile ff1 = session.create();
final RuntimeException runtime = new RuntimeException();
- try {
- session.read(ff1, new InputStreamCallback() {
- @Override
- public void process(final InputStream in) throws IOException {
+ RuntimeException re = assertThrows(RuntimeException.class,
+ () -> session.read(ff1, in -> {
throw runtime;
- }
- });
- Assert.fail("Should have thrown RuntimeException");
- } catch (final RuntimeException re) {
- assertTrue(runtime == re);
- }
+ }));
+ assertSame(runtime, re);
final IOException ioe = new IOException();
- try {
- session.read(ff1, new InputStreamCallback() {
- @Override
- public void process(final InputStream in) throws IOException {
+ ProcessException processException = assertThrows(ProcessException.class,
+ () -> session.read(ff1, in -> {
throw ioe;
- }
- });
- Assert.fail("Should have thrown ProcessException");
- } catch (final ProcessException pe) {
- assertTrue(ioe == pe.getCause());
- }
+ }));
+ assertSame(ioe, processException.getCause());
+
final ProcessException pe = new ProcessException();
- try {
- session.read(ff1, new InputStreamCallback() {
- @Override
- public void process(final InputStream in) throws IOException {
+ processException = assertThrows(ProcessException.class,
+ () -> session.read(ff1, in -> {
throw pe;
- }
- });
- Assert.fail("Should have thrown ProcessException");
- } catch (final ProcessException pe2) {
- assertTrue(pe == pe2);
- }
+ }));
+ assertSame(pe, processException);
}
@Test
@@ -2071,13 +1919,8 @@ public class StandardProcessSessionIT {
// instruct flowfile repo to throw IOException on update
flowFileRepo.setFailOnUpdate(true);
- try {
- session.commit();
- Assert.fail("Session commit completed, even though FlowFile Repo threw IOException");
- } catch (final ProcessException pe) {
- // expected behavior because FlowFile Repo will throw IOException
- }
-
+ // expected behavior because FlowFile Repo will throw IOException
+ assertThrows(ProcessException.class, () -> session.commit());
assertFalse(flowFileQueue.isActiveQueueEmpty());
assertEquals(1, flowFileQueue.size().getObjectCount());
assertFalse(flowFileQueue.isUnacknowledgedFlowFile());
@@ -2236,7 +2079,8 @@ public class StandardProcessSessionIT {
final List<FlowFile> flowFiles = session.get(100);
// FlowFile Queued times should not match yet
- assertNotEquals("Queued times should not be equal.", flowFiles.get(0).getLastQueueDate(), flowFiles.get(99).getLastQueueDate());
+ assertNotEquals(flowFiles.get(0).getLastQueueDate(), flowFiles.get(99).getLastQueueDate(),
+ "Queued times should not be equal.");
session.transfer(flowFiles, new Relationship.Builder().name("A").build());
session.commit();
@@ -2244,7 +2088,8 @@ public class StandardProcessSessionIT {
final List<FlowFile> flowFilesUpdated = session.get(100);
// FlowFile Queued times should match
- assertEquals("Queued times should be equal.", flowFilesUpdated.get(0).getLastQueueDate(), flowFilesUpdated.get(99).getLastQueueDate());
+ assertEquals(flowFilesUpdated.get(0).getLastQueueDate(), flowFilesUpdated.get(99).getLastQueueDate(),
+ "Queued times should be equal.");
}
@Test
@@ -2302,13 +2147,8 @@ public class StandardProcessSessionIT {
final byte[] buffer = new byte[12];
StreamUtils.fillBuffer(in, buffer);
assertEquals("hello, world", new String(buffer));
-
- try {
- session.remove(flowFile);
- Assert.fail("Was able to remove FlowFile while an InputStream is open for it");
- } catch (final IllegalStateException e) {
- // expected
- }
+ final FlowFile finalFlowfile = flowFile;
+ assertThrows(IllegalStateException.class, () -> session.remove(finalFlowfile));
in.close();
@@ -2395,14 +2235,9 @@ public class StandardProcessSessionIT {
final FlowFile flowFile = session.get();
InputStream in = session.read(flowFile);
- try {
- session.write(flowFile);
- Assert.fail("Was able to obtain an OutputStream for a FlowFile while also holding an InputStream for it");
- } catch (final IllegalStateException e) {
- // expected
- } finally {
- in.close();
- }
+ assertThrows(IllegalStateException.class, () -> session.write(flowFile),
+ "Was able to obtain an OutputStream for a FlowFile while also holding an InputStream for it");
+ in.close();
// Should now be okay
try (final OutputStream out = session.write(flowFile)) {
@@ -2422,14 +2257,9 @@ public class StandardProcessSessionIT {
final FlowFile flowFile = session.get();
OutputStream out = session.write(flowFile);
- try {
- session.read(flowFile);
- Assert.fail("Was able to obtain an InputStream for a FlowFile while also holding an OutputStream for it");
- } catch (final IllegalStateException e) {
- // expected
- } finally {
- out.close();
- }
+ assertThrows(IllegalStateException.class, () -> session.read(flowFile),
+ "Was able to obtain an InputStream for a FlowFile while also holding an OutputStream for it");
+ out.close();
// Should now be okay
try (final InputStream in = session.read(flowFile)) {
@@ -2450,20 +2280,14 @@ public class StandardProcessSessionIT {
FlowFile ff1 = session.get();
ff1 = session.putAttribute(ff1, "index", "1");
+ final FlowFile finalFf1 = ff1;
- try {
- session.transfer(ff1, FAKE_RELATIONSHIP);
- Assert.fail("Expected IllegalArgumentException");
- } catch (IllegalArgumentException iae) {
- }
+ assertThrows(IllegalArgumentException.class, () -> session.transfer(finalFf1, FAKE_RELATIONSHIP));
- try {
- final Collection<FlowFile> collection = new HashSet<>();
- collection.add(ff1);
- session.transfer(collection, FAKE_RELATIONSHIP);
- Assert.fail("Expected IllegalArgumentException");
- } catch (IllegalArgumentException iae) {
- }
+ final Collection<FlowFile> collection = new HashSet<>();
+ collection.add(ff1);
+
+ assertThrows(IllegalArgumentException.class, () -> session.transfer(collection, FAKE_RELATIONSHIP));
}
@Test
@@ -2600,28 +2424,27 @@ public class StandardProcessSessionIT {
}
@Test
- public void testMultipleReadCounts() throws IOException {
+ public void testMultipleReadCounts() {
flowFileQueue.put(new MockFlowFile(1L));
- FlowFile flowFile = session.get();
-
- final List<InputStream> streams = new ArrayList<>();
- for (int i = 0; i < 3; i++) {
- streams.add(session.read(flowFile));
- }
-
- for (int i = 0; i < 3; i++) {
- try {
- flowFile = session.putAttribute(flowFile, "counter", String.valueOf(i));
- Assert.fail("Was able to put attribute while reading");
- } catch (final IllegalStateException ise) {
- // expected
- }
-
- streams.get(i).close();
- }
+ final FlowFile flowFile = session.get();
+ final int limit = 3;
+ final List<InputStream> streams =
+ Stream.iterate(0, n -> n + 1)
+ .limit(limit)
+ .map(x -> session.read(flowFile))
+ .collect(Collectors.toList());
+
+ Stream.iterate(0, n -> n + 1)
+ .limit(limit)
+ .forEach(x -> {
+ assertThrows(IllegalStateException.class,
+ () -> session.putAttribute(flowFile, "counter", String.valueOf(x)),
+ "Was able to put attribute while reading");
+ IOUtils.closeQuietly(streams.get(x));
+ });
- flowFile = session.putAttribute(flowFile, "counter", "4");
+ session.putAttribute(flowFile, "counter", "4");
}
@Test
diff --git a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/java/org/apache/nifi/controller/repository/TestFileSystemRepository.java b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/java/org/apache/nifi/controller/repository/TestFileSystemRepository.java
index db762bfa08..a8c685d927 100644
--- a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/java/org/apache/nifi/controller/repository/TestFileSystemRepository.java
+++ b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/java/org/apache/nifi/controller/repository/TestFileSystemRepository.java
@@ -16,7 +16,6 @@
*/
package org.apache.nifi.controller.repository;
-import org.apache.commons.lang3.SystemUtils;
import org.apache.nifi.controller.repository.claim.ContentClaim;
import org.apache.nifi.controller.repository.claim.ResourceClaim;
import org.apache.nifi.controller.repository.claim.StandardContentClaim;
@@ -27,13 +26,12 @@ import org.apache.nifi.events.EventReporter;
import org.apache.nifi.processor.DataUnit;
import org.apache.nifi.stream.io.StreamUtils;
import org.apache.nifi.util.NiFiProperties;
-import org.junit.After;
-import org.junit.Assert;
-import org.junit.Assume;
-import org.junit.Before;
-import org.junit.BeforeClass;
-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.Disabled;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.condition.DisabledOnOs;
+import org.junit.jupiter.api.condition.OS;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
@@ -51,7 +49,6 @@ import java.nio.file.StandardCopyOption;
import java.nio.file.StandardOpenOption;
import java.text.NumberFormat;
import java.util.ArrayList;
-import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.Locale;
@@ -59,13 +56,15 @@ import java.util.Map;
import java.util.Random;
import java.util.concurrent.TimeUnit;
-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.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.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertNotSame;
+import static org.junit.jupiter.api.Assertions.assertThrows;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+@DisabledOnOs(OS.WINDOWS)
public class TestFileSystemRepository {
public static final File helloWorldFile = new File("src/test/resources/hello.txt");
@@ -75,12 +74,7 @@ public class TestFileSystemRepository {
private final File rootFile = new File("target/content_repository");
private NiFiProperties nifiProperties;
- @BeforeClass
- public static void setupClass() {
- Assume.assumeTrue("Test only runs on *nix", !SystemUtils.IS_OS_WINDOWS);
- }
-
- @Before
+ @BeforeEach
public void setup() throws IOException {
nifiProperties = NiFiProperties.createBasicNiFiProperties(TestFileSystemRepository.class.getResource("/conf/nifi.properties").getFile());
if (rootFile.exists()) {
@@ -92,13 +86,13 @@ public class TestFileSystemRepository {
repository.purge();
}
- @After
+ @AfterEach
public void shutdown() throws IOException {
repository.shutdown();
}
@Test
- @Ignore("Intended for manual testing only, in order to judge changes to performance")
+ @Disabled("Intended for manual testing only, in order to judge changes to performance")
public void testWritePerformance() throws IOException {
final long bytesToWrite = 1_000_000_000L;
final int contentSize = 100;
@@ -226,12 +220,7 @@ public class TestFileSystemRepository {
final StandardContentClaim missingContentClaim = new StandardContentClaim(resourceClaim, 12);
missingContentClaim.setLength(1);
- try {
- repository.read(missingContentClaim);
- Assert.fail("Did not throw ContentNotFoundException");
- } catch (final ContentNotFoundException cnfe) {
- // Expected
- }
+ assertThrows(ContentNotFoundException.class, () -> repository.read(missingContentClaim));
}
@Test
@@ -411,7 +400,7 @@ public class TestFileSystemRepository {
m.setAccessible(true);
return (Path) m.invoke(repository, claim);
} catch (final Exception e) {
- throw new RuntimeException("Could not invoke #getPath on FileSystemRepository due to " + e.toString());
+ throw new RuntimeException("Could not invoke #getPath on FileSystemRepository due to " + e);
}
}
@@ -435,14 +424,14 @@ public class TestFileSystemRepository {
final Path path = getPath(claim);
final byte[] data = Files.readAllBytes(path);
final byte[] expected = Files.readAllBytes(testFile.toPath());
- assertTrue(Arrays.equals(expected, data));
+ assertArrayEquals(expected, data);
final ByteArrayOutputStream baos = new ByteArrayOutputStream();
try (final InputStream in = repository.read(claim)) {
StreamUtils.copy(in, baos);
}
- assertTrue(Arrays.equals(expected, baos.toByteArray()));
+ assertArrayEquals(expected, baos.toByteArray());
}
@Test
@@ -453,7 +442,7 @@ public class TestFileSystemRepository {
repository.importFrom(bais, claim);
final Path claimPath = getPath(claim);
- assertTrue(Arrays.equals(data, Files.readAllBytes(claimPath)));
+ assertArrayEquals(data, Files.readAllBytes(claimPath));
}
@Test
@@ -467,7 +456,7 @@ public class TestFileSystemRepository {
final ByteArrayOutputStream baos = new ByteArrayOutputStream();
repository.exportTo(claim, baos);
final byte[] data = baos.toByteArray();
- assertTrue(Arrays.equals(Files.readAllBytes(helloWorldFile.toPath()), data));
+ assertArrayEquals(Files.readAllBytes(helloWorldFile.toPath()), data);
}
@Test
@@ -484,13 +473,13 @@ public class TestFileSystemRepository {
final byte[] expected = Files.readAllBytes(helloWorldFile.toPath());
repository.exportTo(claim, outPath, false);
- assertTrue(Arrays.equals(expected, Files.readAllBytes(outPath)));
+ assertArrayEquals(expected, Files.readAllBytes(outPath));
repository.exportTo(claim, outPath, true);
final byte[] doubleExpected = new byte[expected.length * 2];
System.arraycopy(expected, 0, doubleExpected, 0, expected.length);
System.arraycopy(expected, 0, doubleExpected, expected.length, expected.length);
- assertTrue(Arrays.equals(doubleExpected, Files.readAllBytes(outPath)));
+ assertArrayEquals(doubleExpected, Files.readAllBytes(outPath));
}
@Test
@@ -507,17 +496,21 @@ public class TestFileSystemRepository {
assertEquals(data.length, repository.size(claim));
}
- @Test(expected = ContentNotFoundException.class)
+ @Test
public void testSizeWithNoContent() throws IOException {
- final ContentClaim claim = new StandardContentClaim(new StandardResourceClaim(claimManager, "container1", "section 1", "1", false), 0L);
- assertEquals(0L, repository.size(claim));
+ final ContentClaim claim =
+ new StandardContentClaim(new StandardResourceClaim(claimManager,
+ "container1", "section 1", "1", false), 0L);
+
+ assertThrows(ContentNotFoundException.class, () -> repository.size(claim));
}
- @Test(expected = ContentNotFoundException.class)
+ @Test
public void testReadWithNoContent() throws IOException {
final ContentClaim claim = new StandardContentClaim(new StandardResourceClaim(claimManager, "container1", "section 1", "1", false), 0L);
- final InputStream in = repository.read(claim);
- in.close();
+
+ assertThrows(ContentNotFoundException.class,
+ () -> repository.read(claim));
}
@Test
@@ -534,7 +527,7 @@ public class TestFileSystemRepository {
try (final InputStream inStream = repository.read(claim)) {
assertNotNull(inStream);
final byte[] dataRead = readFully(inStream, data.length);
- assertTrue(Arrays.equals(data, dataRead));
+ assertArrayEquals(data, dataRead);
}
}
@@ -563,7 +556,7 @@ public class TestFileSystemRepository {
return System.getProperty("os.name").toLowerCase().startsWith("windows");
}
- @Test(expected = ContentNotFoundException.class)
+ @Test
public void testReadWithNoContentArchived() throws IOException {
final ContentClaim claim = repository.create(true);
final Path path = getPath(claim);
@@ -571,7 +564,8 @@ public class TestFileSystemRepository {
Path archivePath = FileSystemRepository.getArchivePath(path);
Files.deleteIfExists(archivePath);
- repository.read(claim).close();
+
+ assertThrows(ContentNotFoundException.class, () -> repository.read(claim).close());
}
@Test
@@ -583,7 +577,7 @@ public class TestFileSystemRepository {
}
final Path path = getPath(claim);
- assertTrue(Arrays.equals(data, Files.readAllBytes(path)));
+ assertArrayEquals(data, Files.readAllBytes(path));
}
@Test
@@ -744,7 +738,7 @@ public class TestFileSystemRepository {
public void testMarkDestructableDoesNotArchiveIfStreamOpenAndNotWrittenTo() throws IOException, InterruptedException {
FileSystemRepository repository = null;
try {
- final List<Path> archivedPathsWithOpenStream = Collections.synchronizedList(new ArrayList<Path>());
+ final List<Path> archivedPathsWithOpenStream = Collections.synchronizedList(new ArrayList<>());
// We are creating our own 'local' repository in this test so shut down the one created in the setup() method
shutdown();
@@ -875,7 +869,7 @@ public class TestFileSystemRepository {
StreamUtils.copy(in, baos);
}
final byte[] actual = baos.toByteArray();
- assertTrue(Arrays.equals(expected, actual));
+ assertArrayEquals(expected, actual);
}
private byte[] readFully(final InputStream inStream, final int size) throws IOException {
diff --git a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/java/org/apache/nifi/controller/repository/TestWriteAheadFlowFileRepository.java b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/java/org/apache/nifi/controller/repository/TestWriteAheadFlowFileRepository.java
index 52dc3ec786..402ecfcb77 100644
--- a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/java/org/apache/nifi/controller/repository/TestWriteAheadFlowFileRepository.java
+++ b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/java/org/apache/nifi/controller/repository/TestWriteAheadFlowFileRepository.java
@@ -44,13 +44,11 @@ import org.apache.nifi.processor.FlowFileFilter;
import org.apache.nifi.util.MockFlowFile;
import org.apache.nifi.util.NiFiProperties;
import org.apache.nifi.util.file.FileUtils;
-import org.junit.After;
-import org.junit.Assert;
-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.Disabled;
+import org.junit.jupiter.api.Test;
import org.mockito.Mockito;
-import org.mockito.invocation.InvocationOnMock;
import org.mockito.stubbing.Answer;
import org.wali.MinimalLockingWriteAheadLog;
import org.wali.WriteAheadRepository;
@@ -70,10 +68,12 @@ import java.util.Set;
import java.util.UUID;
import java.util.concurrent.TimeUnit;
-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.assertNull;
+import static org.junit.jupiter.api.Assertions.assertThrows;
+import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Mockito.doAnswer;
import static org.mockito.Mockito.when;
@@ -83,13 +83,13 @@ public class TestWriteAheadFlowFileRepository {
private static NiFiProperties niFiProperties;
- @Before
+ @BeforeEach
public void setUp() throws Exception {
niFiProperties = NiFiProperties.createBasicNiFiProperties(TestWriteAheadFlowFileRepository.class.getResource("/conf/nifi.properties").getFile());
clearRepo();
}
- @After
+ @AfterEach
public void tearDown() throws Exception {
clearRepo();
}
@@ -103,7 +103,7 @@ public class TestWriteAheadFlowFileRepository {
}
@Test
- @Ignore("Intended only for local performance testing before/after making changes")
+ @Disabled("Intended only for local performance testing before/after making changes")
public void testUpdatePerformance() throws IOException, InterruptedException {
final FlowFileQueue queue = new FlowFileQueue() {
private LoadBalanceCompression compression = LoadBalanceCompression.DO_NOT_COMPRESS;
@@ -301,7 +301,7 @@ public class TestWriteAheadFlowFileRepository {
}
@Override
- public FlowFileRecord getFlowFile(String flowFileUuid) throws IOException {
+ public FlowFileRecord getFlowFile(String flowFileUuid) {
return null;
}
@@ -390,12 +390,7 @@ public class TestWriteAheadFlowFileRepository {
records.add(new LiveSerializedRepositoryRecord(record));
}
- try {
- repo.update(records, false);
- } catch (IOException e) {
- e.printStackTrace();
- Assert.fail(e.toString());
- }
+ assertThrows(IOException.class, () -> repo.update(records, false));
}
}
});
@@ -437,7 +432,7 @@ public class TestWriteAheadFlowFileRepository {
public void testNormalizeSwapLocation() {
assertEquals("/", WriteAheadFlowFileRepository.normalizeSwapLocation("/"));
assertEquals("", WriteAheadFlowFileRepository.normalizeSwapLocation(""));
- assertEquals(null, WriteAheadFlowFileRepository.normalizeSwapLocation(null));
+ assertNull(WriteAheadFlowFileRepository.normalizeSwapLocation(null));
assertEquals("test", WriteAheadFlowFileRepository.normalizeSwapLocation("test.txt"));
assertEquals("test", WriteAheadFlowFileRepository.normalizeSwapLocation("/test.txt"));
assertEquals("test", WriteAheadFlowFileRepository.normalizeSwapLocation("/tmp/test.txt"));
@@ -636,12 +631,9 @@ public class TestWriteAheadFlowFileRepository {
final FlowFileQueue queue = Mockito.mock(FlowFileQueue.class);
when(queue.getIdentifier()).thenReturn("1234");
- doAnswer(new Answer<Object>() {
- @Override
- public Object answer(final InvocationOnMock invocation) throws Throwable {
- flowFileCollection.add((FlowFileRecord) invocation.getArguments()[0]);
- return null;
- }
+ doAnswer((Answer<Object>) invocation -> {
+ flowFileCollection.add((FlowFileRecord) invocation.getArguments()[0]);
+ return null;
}).when(queue).put(any(FlowFileRecord.class));
when(connection.getFlowFileQueue()).thenReturn(queue);
@@ -719,7 +711,7 @@ public class TestWriteAheadFlowFileRepository {
}
@Override
- public String swapOut(List<FlowFileRecord> flowFiles, FlowFileQueue flowFileQueue, final String partitionName) throws IOException {
+ public String swapOut(List<FlowFileRecord> flowFiles, FlowFileQueue flowFileQueue, final String partitionName) {
Map<String, List<FlowFileRecord>> swapMap = swappedRecords.get(flowFileQueue);
if (swapMap == null) {
swapMap = new HashMap<>();
@@ -732,7 +724,7 @@ public class TestWriteAheadFlowFileRepository {
}
@Override
- public SwapContents peek(String swapLocation, FlowFileQueue flowFileQueue) throws IOException {
+ public SwapContents peek(String swapLocation, FlowFileQueue flowFileQueue) {
Map<String, List<FlowFileRecord>> swapMap = swappedRecords.get(flowFileQueue);
if (swapMap == null) {
return null;
@@ -744,7 +736,7 @@ public class TestWriteAheadFlowFileRepository {
}
@Override
- public SwapContents swapIn(String swapLocation, FlowFileQueue flowFileQueue) throws IOException {
+ public SwapContents swapIn(String swapLocation, FlowFileQueue flowFileQueue) {
Map<String, List<FlowFileRecord>> swapMap = swappedRecords.get(flowFileQueue);
if (swapMap == null) {
return null;
@@ -756,7 +748,7 @@ public class TestWriteAheadFlowFileRepository {
}
@Override
- public List<String> recoverSwapLocations(FlowFileQueue flowFileQueue, final String partitionName) throws IOException {
+ public List<String> recoverSwapLocations(FlowFileQueue flowFileQueue, final String partitionName) {
Map<String, List<FlowFileRecord>> swapMap = swappedRecords.get(flowFileQueue);
if (swapMap == null) {
return null;
@@ -766,7 +758,7 @@ public class TestWriteAheadFlowFileRepository {
}
@Override
- public SwapSummary getSwapSummary(String swapLocation) throws IOException {
+ public SwapSummary getSwapSummary(String swapLocation) {
List<FlowFileRecord> records = null;
for (final Map<String, List<FlowFileRecord>> swapMap : swappedRecords.values()) {
records = swapMap.get(swapLocation);
@@ -810,12 +802,12 @@ public class TestWriteAheadFlowFileRepository {
}
@Override
- public Set<String> getSwappedPartitionNames(FlowFileQueue queue) throws IOException {
+ public Set<String> getSwappedPartitionNames(FlowFileQueue queue) {
return Collections.emptySet();
}
@Override
- public String changePartitionName(String swapLocation, String newPartitionName) throws IOException {
+ public String changePartitionName(String swapLocation, String newPartitionName) {
return swapLocation;
}
}
diff --git a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/java/org/apache/nifi/controller/repository/claim/TestContentClaimWriteCache.java b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/java/org/apache/nifi/controller/repository/claim/TestContentClaimWriteCache.java
index e3e75c3731..f5863abb15 100644
--- a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/java/org/apache/nifi/controller/repository/claim/TestContentClaimWriteCache.java
+++ b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/java/org/apache/nifi/controller/repository/claim/TestContentClaimWriteCache.java
@@ -25,18 +25,18 @@ import org.apache.nifi.controller.repository.util.DiskUtils;
import org.apache.nifi.events.EventReporter;
import org.apache.nifi.stream.io.StreamUtils;
import org.apache.nifi.util.NiFiProperties;
-import org.junit.After;
-import org.junit.Assert;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertArrayEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
public class TestContentClaimWriteCache {
@@ -45,7 +45,7 @@ public class TestContentClaimWriteCache {
private final File rootFile = new File("target/testContentClaimWriteCache");
private NiFiProperties nifiProperties;
- @Before
+ @BeforeEach
public void setup() throws IOException {
nifiProperties = NiFiProperties.createBasicNiFiProperties(TestFileSystemRepository.class.getResource("/conf/nifi.properties").getFile());
if (rootFile.exists()) {
@@ -57,7 +57,7 @@ public class TestContentClaimWriteCache {
repository.purge();
}
- @After
+ @AfterEach
public void shutdown() throws IOException {
repository.shutdown();
}
@@ -80,7 +80,7 @@ public class TestContentClaimWriteCache {
final InputStream in = repository.read(claim1);
final byte[] buff = new byte[(int) claim1.getLength()];
StreamUtils.fillBuffer(in, buff);
- Assert.assertArrayEquals("hellogood-bye".getBytes(), buff);
+ assertArrayEquals("hellogood-bye".getBytes(), buff);
final ContentClaim claim2 = cache.getContentClaim();
final OutputStream out2 = cache.write(claim2);
@@ -94,7 +94,7 @@ public class TestContentClaimWriteCache {
final InputStream in2 = repository.read(claim2);
final byte[] buff2 = new byte[(int) claim2.getLength()];
StreamUtils.fillBuffer(in2, buff2);
- Assert.assertArrayEquals("good-dayhello".getBytes(), buff2);
+ assertArrayEquals("good-dayhello".getBytes(), buff2);
}
}
diff --git a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/java/org/apache/nifi/controller/repository/io/TestContentClaimInputStream.java b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/java/org/apache/nifi/controller/repository/io/TestContentClaimInputStream.java
index e7d7f559b4..fe4f6b9e99 100644
--- a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/java/org/apache/nifi/controller/repository/io/TestContentClaimInputStream.java
+++ b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/java/org/apache/nifi/controller/repository/io/TestContentClaimInputStream.java
@@ -20,17 +20,17 @@ import org.apache.nifi.controller.repository.ContentRepository;
import org.apache.nifi.controller.repository.claim.ContentClaim;
import org.apache.nifi.controller.repository.metrics.NopPerformanceTracker;
import org.apache.nifi.stream.io.StreamUtils;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
import org.mockito.Mockito;
import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.util.concurrent.atomic.AtomicBoolean;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-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.assertTrue;
import static org.mockito.Mockito.mock;
public class TestContentClaimInputStream {
@@ -39,7 +39,7 @@ public class TestContentClaimInputStream {
private ContentClaim contentClaim;
private AtomicBoolean closed = new AtomicBoolean();
- @Before
+ @BeforeEach
public void setup() throws IOException {
repo = mock(ContentRepository.class);
contentClaim = mock(ContentClaim.class);
diff --git a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/java/org/apache/nifi/controller/repository/io/TestFlowFileAccessInputStream.java b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/java/org/apache/nifi/controller/repository/io/TestFlowFileAccessInputStream.java
index 127962d8e9..db2408dbb1 100644
--- a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/java/org/apache/nifi/controller/repository/io/TestFlowFileAccessInputStream.java
+++ b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/java/org/apache/nifi/controller/repository/io/TestFlowFileAccessInputStream.java
@@ -16,22 +16,22 @@
*/
package org.apache.nifi.controller.repository.io;
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
-import static org.mockito.Mockito.mock;
-
-import java.io.IOException;
-import java.io.InputStream;
-
import org.apache.nifi.controller.repository.ContentNotFoundException;
import org.apache.nifi.controller.repository.claim.ContentClaim;
import org.apache.nifi.flowfile.FlowFile;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
import org.mockito.Mockito;
import org.mockito.invocation.InvocationOnMock;
import org.mockito.stubbing.Answer;
+import java.io.IOException;
+import java.io.InputStream;
+
+import static org.junit.jupiter.api.Assertions.assertThrows;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+import static org.mockito.Mockito.mock;
+
public class TestFlowFileAccessInputStream {
private InputStream in;
@@ -39,7 +39,7 @@ public class TestFlowFileAccessInputStream {
private ContentClaim claim;
private final byte[] data = new byte[16];
- @Before
+ @BeforeEach
public void setup() throws IOException {
in = mock(InputStream.class);
flowFile = mock(FlowFile.class);
@@ -53,7 +53,7 @@ public class TestFlowFileAccessInputStream {
private int count = 0;
@Override
- public Integer answer(InvocationOnMock invocation) throws Throwable {
+ public Integer answer(InvocationOnMock invocation) {
if (count == 0) {
count++;
return 16;
@@ -62,17 +62,17 @@ public class TestFlowFileAccessInputStream {
}
});
// Flow file total size is 32
- Mockito.when(flowFile.getSize()).thenReturn(32l);
+ Mockito.when(flowFile.getSize()).thenReturn(32L);
FlowFileAccessInputStream flowFileAccessInputStream = new FlowFileAccessInputStream(in, flowFile, claim);
- try {
- while (flowFileAccessInputStream.read(data) != -1) {
- }
- fail("Should throw ContentNotFoundException when lesser bytes read from flow file.");
- } catch (ContentNotFoundException e) {
- assertTrue("ContentNotFoundException message not matched.", e.getMessage().contains("Stream contained only 16 bytes but should have contained 32"));
- } finally {
- flowFileAccessInputStream.close();
- }
+
+ ContentNotFoundException contentNotFoundException =
+ assertThrows(ContentNotFoundException.class, () -> {
+ while (flowFileAccessInputStream.read(data) != -1){}
+ });
+
+ assertTrue(contentNotFoundException.getMessage().contains("Stream contained only 16 bytes" +
+ " but should have contained 32"), "ContentNotFoundException message not matched.");
+ flowFileAccessInputStream.close();
}
}
diff --git a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/java/org/apache/nifi/controller/repository/io/TestLimitedInputStream.java b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/java/org/apache/nifi/controller/repository/io/TestLimitedInputStream.java
index 129fed6ab0..e375117b68 100644
--- a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/java/org/apache/nifi/controller/repository/io/TestLimitedInputStream.java
+++ b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/java/org/apache/nifi/controller/repository/io/TestLimitedInputStream.java
@@ -16,14 +16,14 @@
*/
package org.apache.nifi.controller.repository.io;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.InputStream;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.fail;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertDoesNotThrow;
public class TestLimitedInputStream {
@@ -83,11 +83,8 @@ public class TestLimitedInputStream {
@Test
public void testClose() {
final LimitedInputStream lis = new LimitedInputStream(bais, 4);
- try {
- lis.close();
- } catch (IOException e) {
- fail();
- }
+
+ assertDoesNotThrow(lis::close);
}
@Test
diff --git a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/java/org/apache/nifi/controller/scheduling/ProcessorLifecycleIT.java b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/java/org/apache/nifi/controller/scheduling/ProcessorLifecycleIT.java
index 2e1b73c573..274bc771aa 100644
--- a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/java/org/apache/nifi/controller/scheduling/ProcessorLifecycleIT.java
+++ b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/java/org/apache/nifi/controller/scheduling/ProcessorLifecycleIT.java
@@ -49,10 +49,10 @@ import org.apache.nifi.processor.exception.ProcessException;
import org.apache.nifi.provenance.MockProvenanceRepository;
import org.apache.nifi.registry.variable.FileBasedVariableRegistry;
import org.apache.nifi.util.NiFiProperties;
-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.Disabled;
+import org.junit.jupiter.api.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -72,8 +72,8 @@ import java.util.concurrent.TimeUnit;
import java.util.concurrent.locks.LockSupport;
import java.util.function.Supplier;
-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;
/**
@@ -92,12 +92,12 @@ public class ProcessorLifecycleIT {
private volatile String propsFile = "src/test/resources/lifecycletest.nifi.properties";
private ProcessScheduler processScheduler;
- @Before
+ @BeforeEach
public void before() throws Exception {
properties.put("P", "hello");
}
- @After
+ @AfterEach
public void after() throws Exception {
if (processScheduler != null) {
processScheduler.shutdown();
@@ -224,7 +224,7 @@ public class ProcessorLifecycleIT {
* operations can only be @OnScheduled, @OnUnscheduled, @OnStopped.
*/
@Test
- @Ignore
+ @Disabled
public void validateSuccessfulAndOrderlyShutdown() throws Exception {
final FlowManagerAndSystemBundle fcsb = this.buildFlowControllerForTest();
flowManager = fcsb.getFlowManager();
@@ -267,7 +267,7 @@ public class ProcessorLifecycleIT {
* operation validating their idempotency.
*/
@Test
- @Ignore
+ @Disabled
public void validateLifecycleOperationOrderWithConcurrentCallsToStartStop() throws Exception {
final FlowManagerAndSystemBundle fcsb = this.buildFlowControllerForTest();
flowManager = fcsb.getFlowManager();
diff --git a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/java/org/apache/nifi/controller/scheduling/TestStandardProcessScheduler.java b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/java/org/apache/nifi/controller/scheduling/TestStandardProcessScheduler.java
index 63a806df79..7f65207dc6 100644
--- a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/java/org/apache/nifi/controller/scheduling/TestStandardProcessScheduler.java
+++ b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/java/org/apache/nifi/controller/scheduling/TestStandardProcessScheduler.java
@@ -73,13 +73,13 @@ import org.apache.nifi.reporting.ReportingTask;
import org.apache.nifi.scheduling.SchedulingStrategy;
import org.apache.nifi.util.NiFiProperties;
import org.apache.nifi.util.SynchronousValidationTrigger;
-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.Disabled;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.Timeout;
import org.mockito.AdditionalMatchers;
import org.mockito.Mockito;
-import org.mockito.invocation.InvocationOnMock;
import org.mockito.stubbing.Answer;
import java.io.File;
@@ -101,10 +101,10 @@ import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.concurrent.atomic.AtomicInteger;
-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.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 static org.mockito.ArgumentMatchers.isNull;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.anyBoolean;
@@ -131,7 +131,7 @@ public class TestStandardProcessScheduler {
private volatile String propsFile = TestStandardProcessScheduler.class.getResource("/standardprocessschedulertest.nifi.properties").getFile();
- @Before
+ @BeforeEach
public void setup() throws InitializationException {
final Map<String, String> overrideProperties = new HashMap<>();
overrideProperties.put(NiFiProperties.ADMINISTRATIVE_YIELD_DURATION, "2 millis");
@@ -166,21 +166,15 @@ public class TestStandardProcessScheduler {
serviceProvider = new StandardControllerServiceProvider(scheduler, null, flowManager, extensionManager);
final ConcurrentMap<String, ProcessorNode> processorMap = new ConcurrentHashMap<>();
- Mockito.doAnswer(new Answer<ProcessorNode>() {
- @Override
- public ProcessorNode answer(InvocationOnMock invocation) {
- final String id = invocation.getArgument(0);
- return processorMap.get(id);
- }
+ Mockito.doAnswer((Answer<ProcessorNode>) invocation -> {
+ final String id = invocation.getArgument(0);
+ return processorMap.get(id);
}).when(flowManager).getProcessorNode(Mockito.anyString());
- Mockito.doAnswer(new Answer<Object>() {
- @Override
- public Object answer(InvocationOnMock invocation) {
- final ProcessorNode procNode = invocation.getArgument(0);
- processorMap.putIfAbsent(procNode.getIdentifier(), procNode);
- return null;
- }
+ Mockito.doAnswer((Answer<Object>) invocation -> {
+ final ProcessorNode procNode = invocation.getArgument(0);
+ processorMap.putIfAbsent(procNode.getIdentifier(), procNode);
+ return null;
}).when(flowManager).onProcessorAdded(any(ProcessorNode.class));
when(controller.getControllerServiceProvider()).thenReturn(serviceProvider);
@@ -190,35 +184,32 @@ public class TestStandardProcessScheduler {
when(controller.getReloadComponent()).thenReturn(Mockito.mock(ReloadComponent.class));
- doAnswer(new Answer<ControllerServiceNode>() {
- @Override
- public ControllerServiceNode answer(final InvocationOnMock invocation) throws Throwable {
- final String type = invocation.getArgument(0);
- final String id = invocation.getArgument(1);
- final BundleCoordinate bundleCoordinate = invocation.getArgument(2);
-
- final ControllerServiceNode serviceNode = new ExtensionBuilder()
- .identifier(id)
- .type(type)
- .bundleCoordinate(bundleCoordinate)
- .controllerServiceProvider(serviceProvider)
- .processScheduler(Mockito.mock(ProcessScheduler.class))
- .nodeTypeProvider(Mockito.mock(NodeTypeProvider.class))
- .validationTrigger(Mockito.mock(ValidationTrigger.class))
- .reloadComponent(Mockito.mock(ReloadComponent.class))
- .variableRegistry(variableRegistry)
- .stateManagerProvider(Mockito.mock(StateManagerProvider.class))
- .extensionManager(extensionManager)
- .buildControllerService();
-
- serviceProvider.onControllerServiceAdded(serviceNode);
- return serviceNode;
- }
+ doAnswer((Answer<ControllerServiceNode>) invocation -> {
+ final String type = invocation.getArgument(0);
+ final String id = invocation.getArgument(1);
+ final BundleCoordinate bundleCoordinate = invocation.getArgument(2);
+
+ final ControllerServiceNode serviceNode = new ExtensionBuilder()
+ .identifier(id)
+ .type(type)
+ .bundleCoordinate(bundleCoordinate)
+ .controllerServiceProvider(serviceProvider)
+ .processScheduler(Mockito.mock(ProcessScheduler.class))
+ .nodeTypeProvider(Mockito.mock(NodeTypeProvider.class))
+ .validationTrigger(Mockito.mock(ValidationTrigger.class))
+ .reloadComponent(Mockito.mock(ReloadComponent.class))
+ .variableRegistry(variableRegistry)
+ .stateManagerProvider(Mockito.mock(StateManagerProvider.class))
+ .extensionManager(extensionManager)
+ .buildControllerService();
+
+ serviceProvider.onControllerServiceAdded(serviceNode);
+ return serviceNode;
}).when(flowManager).createControllerService(anyString(), anyString(), any(BundleCoordinate.class),
AdditionalMatchers.or(anySet(), isNull()), anyBoolean(), anyBoolean(), nullable(String.class));
}
- @After
+ @AfterEach
public void after() throws Exception {
controller.shutdown(true);
FileUtils.deleteDirectory(new File("./target/standardprocessschedulertest"));
@@ -247,10 +238,12 @@ public class TestStandardProcessScheduler {
final int attemptsAfterStop = reportingTask.onScheduleAttempts.get() - attempts;
// allow 1 extra run, due to timing issues that could call it as it's being stopped.
- assertTrue("After unscheduling Reporting Task, task ran an additional " + attemptsAfterStop + " times", attemptsAfterStop <= 1);
+ assertTrue(attemptsAfterStop <= 1,
+ "After unscheduling Reporting Task, task ran an additional " + attemptsAfterStop + " times");
}
- @Test(timeout = 60000)
+ @Test
+ @Timeout(60)
public void testDisableControllerServiceWithProcessorTryingToStartUsingIt() throws InterruptedException, ExecutionException {
final String uuid = UUID.randomUUID().toString();
final Processor proc = new ServiceReferencingProcessor();
@@ -284,10 +277,10 @@ public class TestStandardProcessScheduler {
scheduler.stopProcessor(procNode);
assertTrue(service.isActive());
- assertSame(service.getState(), ControllerServiceState.ENABLING);
+ assertSame(ControllerServiceState.ENABLING, service.getState());
scheduler.disableControllerService(service).get();
assertFalse(service.isActive());
- assertSame(service.getState(), ControllerServiceState.DISABLED);
+ assertSame(ControllerServiceState.DISABLED, service.getState());
}
public class TestReportingTask extends AbstractReportingTask {
@@ -352,16 +345,12 @@ public class TestStandardProcessScheduler {
final AtomicBoolean asyncFailed = new AtomicBoolean();
for (int i = 0; i < 1000; i++) {
- executor.execute(new Runnable() {
- @Override
- public void run() {
- try {
- scheduler.enableControllerService(serviceNode).get();
- assertTrue(serviceNode.isActive());
- } catch (final Exception e) {
- e.printStackTrace();
- asyncFailed.set(true);
- }
+ executor.execute(() -> {
+ try {
+ scheduler.enableControllerService(serviceNode).get();
+ assertTrue(serviceNode.isActive());
+ } catch (final Exception e) {
+ asyncFailed.set(true);
}
});
}
@@ -390,16 +379,12 @@ public class TestStandardProcessScheduler {
final AtomicBoolean asyncFailed = new AtomicBoolean();
for (int i = 0; i < 1000; i++) {
- executor.execute(new Runnable() {
- @Override
- public void run() {
- try {
- scheduler.disableControllerService(serviceNode);
- assertFalse(serviceNode.isActive());
- } catch (final Exception e) {
- e.printStackTrace();
- asyncFailed.set(true);
- }
+ executor.execute(() -> {
+ try {
+ scheduler.disableControllerService(serviceNode);
+ assertFalse(serviceNode.isActive());
+ } catch (final Exception e) {
+ asyncFailed.set(true);
}
});
}
@@ -431,16 +416,12 @@ public class TestStandardProcessScheduler {
final AtomicBoolean asyncFailed = new AtomicBoolean();
for (int i = 0; i < 1000; i++) {
- executor.execute(new Runnable() {
- @Override
- public void run() {
- try {
- scheduler.disableControllerService(serviceNode);
- assertFalse(serviceNode.isActive());
- } catch (final Exception e) {
- e.printStackTrace();
- asyncFailed.set(true);
- }
+ executor.execute(() -> {
+ try {
+ scheduler.disableControllerService(serviceNode);
+ assertFalse(serviceNode.isActive());
+ } catch (final Exception e) {
+ asyncFailed.set(true);
}
});
}
@@ -453,7 +434,7 @@ public class TestStandardProcessScheduler {
}
@Test
- public void validateDisablingOfTheFailedService() throws Exception {
+ public void validateDisablingOfTheFailedService() {
final StandardProcessScheduler scheduler = createScheduler();
final ControllerServiceNode serviceNode = flowManager.createControllerService(FailingService.class.getName(),
@@ -476,11 +457,11 @@ public class TestStandardProcessScheduler {
* services, shut down processors etc) before shutting down itself
*/
assertTrue(serviceNode.isActive());
- assertSame(serviceNode.getState(), ControllerServiceState.ENABLING);
+ assertSame(ControllerServiceState.ENABLING, serviceNode.getState());
}
/**
- * Validates that in multi threaded environment enabling service can still
+ * Validates that in multithreaded environment enabling service can still
* be disabled. This test is set up in such way that disabling of the
* service could be initiated by both disable and enable methods. In other
* words it tests two conditions in
@@ -492,7 +473,7 @@ public class TestStandardProcessScheduler {
* IN any even the resulting state of the service is DISABLED
*/
@Test
- @Ignore
+ @Disabled
public void validateEnabledDisableMultiThread() throws Exception {
final StandardProcessScheduler scheduler = createScheduler();
final StandardControllerServiceProvider provider = new StandardControllerServiceProvider(scheduler, null, flowManager, extensionManager);
@@ -501,19 +482,9 @@ public class TestStandardProcessScheduler {
final ControllerServiceNode serviceNode = flowManager.createControllerService(RandomShortDelayEnablingService.class.getName(), "1",
systemBundle.getBundleDetails().getCoordinate(), null, false, true, nullable(String.class));
- executor.execute(new Runnable() {
- @Override
- public void run() {
- scheduler.enableControllerService(serviceNode);
- }
- });
+ executor.execute(() -> scheduler.enableControllerService(serviceNode));
Thread.sleep(10); // ensure that enable gets initiated before disable
- executor.execute(new Runnable() {
- @Override
- public void run() {
- scheduler.disableControllerService(serviceNode);
- }
- });
+ executor.execute(() -> scheduler.disableControllerService(serviceNode));
Thread.sleep(100);
assertFalse(serviceNode.isActive());
assertEquals(ControllerServiceState.DISABLED, serviceNode.getState());
@@ -562,7 +533,8 @@ public class TestStandardProcessScheduler {
}
// Test that if processor throws Exception in @OnScheduled, it keeps getting scheduled
- @Test(timeout = 10000)
+ @Test
+ @Timeout(10)
public void testProcessorThrowsExceptionOnScheduledRetry() throws InterruptedException {
final FailOnScheduledProcessor proc = new FailOnScheduledProcessor();
proc.setDesiredFailureCount(3);
@@ -587,7 +559,8 @@ public class TestStandardProcessScheduler {
}
// Test that if processor times out in the @OnScheduled but responds to interrupt, it keeps getting scheduled
- @Test(timeout = 10000)
+ @Test
+ @Timeout(10)
public void testProcessorTimeOutRespondsToInterrupt() throws InterruptedException {
final FailOnScheduledProcessor proc = new FailOnScheduledProcessor();
proc.setDesiredFailureCount(0);
@@ -616,7 +589,8 @@ public class TestStandardProcessScheduler {
}
// Test that if processor times out in the @OnScheduled and does not respond to interrupt, it is not scheduled again
- @Test(timeout = 10000)
+ @Test
+ @Timeout(10)
public void testProcessorTimeOutNoResponseToInterrupt() throws InterruptedException {
final FailOnScheduledProcessor proc = new FailOnScheduledProcessor();
proc.setDesiredFailureCount(0);
diff --git a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/java/org/apache/nifi/controller/serialization/StandardFlowSerializerTest.java b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/java/org/apache/nifi/controller/serialization/StandardFlowSerializerTest.java
index 92d99dcef0..e949df6f5e 100644
--- a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/java/org/apache/nifi/controller/serialization/StandardFlowSerializerTest.java
+++ b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/java/org/apache/nifi/controller/serialization/StandardFlowSerializerTest.java
@@ -41,9 +41,9 @@ import org.apache.nifi.registry.VariableRegistry;
import org.apache.nifi.registry.variable.FileBasedVariableRegistry;
import org.apache.nifi.reporting.BulletinRepository;
import org.apache.nifi.util.NiFiProperties;
-import org.junit.After;
-import org.junit.Before;
-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.Mockito;
import org.w3c.dom.Document;
@@ -56,8 +56,8 @@ import java.util.HashMap;
import java.util.Map;
import java.util.UUID;
-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.assertTrue;
public class StandardFlowSerializerTest {
@@ -79,7 +79,7 @@ public class StandardFlowSerializerTest {
private ExtensionDiscoveringManager extensionManager;
private StandardFlowSerializer serializer;
- @Before
+ @BeforeEach
public void setUp() throws Exception {
final FlowFileEventRepository flowFileEventRepo = Mockito.mock(FlowFileEventRepository.class);
final AuditService auditService = Mockito.mock(AuditService.class);
@@ -105,7 +105,7 @@ public class StandardFlowSerializerTest {
serializer = new StandardFlowSerializer();
}
- @After
+ @AfterEach
public void after() throws Exception {
controller.shutdown(true);
FileUtils.deleteDirectory(new File("./target/standardflowserializertest"));
diff --git a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/java/org/apache/nifi/controller/service/StandardControllerServiceProviderIT.java b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/java/org/apache/nifi/controller/service/StandardControllerServiceProviderIT.java
index 10b44ee688..547f7976a8 100644
--- a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/java/org/apache/nifi/controller/service/StandardControllerServiceProviderIT.java
+++ b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/java/org/apache/nifi/controller/service/StandardControllerServiceProviderIT.java
@@ -48,8 +48,9 @@ import org.apache.nifi.nar.StandardExtensionDiscoveringManager;
import org.apache.nifi.nar.SystemBundle;
import org.apache.nifi.registry.VariableRegistry;
import org.apache.nifi.util.NiFiProperties;
-import org.junit.BeforeClass;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.Timeout;
import org.mockito.Mockito;
public class StandardControllerServiceProviderIT {
@@ -81,7 +82,7 @@ public class StandardControllerServiceProviderIT {
}
};
- @BeforeClass
+ @BeforeAll
public static void setNiFiProps() {
System.setProperty(NiFiProperties.PROPERTIES_FILE_PATH, TestStandardControllerServiceProvider.class.getResource("/conf/nifi.properties").getFile());
niFiProperties = NiFiProperties.createBasicNiFiProperties(null);
@@ -98,7 +99,8 @@ public class StandardControllerServiceProviderIT {
* {@link PropertyDescriptor}.isDependentServiceEnableable() as well as
* https://issues.apache.org/jira/browse/NIFI-1143
*/
- @Test(timeout = 120000)
+ @Test
+ @Timeout(120)
public void testConcurrencyWithEnablingReferencingServicesGraph() throws InterruptedException, ExecutionException {
final StandardProcessScheduler scheduler = new StandardProcessScheduler(new FlowEngine(1, "Unit Test", true), Mockito.mock(FlowController.class),
stateManagerProvider, niFiProperties);
diff --git a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/java/org/apache/nifi/controller/service/StandardControllerServiceProviderTest.java b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/java/org/apache/nifi/controller/service/StandardControllerServiceProviderTest.java
index 887570bb67..1e06197de7 100644
--- a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/java/org/apache/nifi/controller/service/StandardControllerServiceProviderTest.java
+++ b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/java/org/apache/nifi/controller/service/StandardControllerServiceProviderTest.java
@@ -34,14 +34,14 @@ import org.apache.nifi.registry.VariableRegistry;
import org.apache.nifi.registry.variable.FileBasedVariableRegistry;
import org.apache.nifi.reporting.InitializationException;
import org.apache.nifi.util.NiFiProperties;
-import org.junit.Before;
-import org.junit.BeforeClass;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.Test;
import org.mockito.Mockito;
import java.util.Collections;
-
+import static org.junit.jupiter.api.Assertions.assertThrows;
public class StandardControllerServiceProviderTest {
@@ -51,7 +51,7 @@ public class StandardControllerServiceProviderTest {
private static ExtensionDiscoveringManager extensionManager;
private static Bundle systemBundle;
- @BeforeClass
+ @BeforeAll
public static void setupSuite() {
final NiFiProperties nifiProperties = NiFiProperties.createBasicNiFiProperties(StandardControllerServiceProviderTest.class.getResource("/conf/nifi.properties").getFile());
@@ -63,7 +63,7 @@ public class StandardControllerServiceProviderTest {
variableRegistry = new FileBasedVariableRegistry(nifiProperties.getVariableRegistryPropertiesPaths());
}
- @Before
+ @BeforeEach
public void setup() throws Exception {
String id = "id";
String clazz = "org.apache.nifi.controller.service.util.TestControllerService";
@@ -91,9 +91,10 @@ public class StandardControllerServiceProviderTest {
return serviceNode;
}
- @Test(expected = UnsupportedOperationException.class)
+ @Test
public void testCallProxiedOnPropertyModified() {
- proxied.onPropertyModified(null, "oldValue", "newValue");
+ assertThrows(UnsupportedOperationException.class,
+ () -> proxied.onPropertyModified(null, "oldValue", "newValue"));
}
@Test
@@ -101,9 +102,10 @@ public class StandardControllerServiceProviderTest {
implementation.onPropertyModified(null, "oldValue", "newValue");
}
- @Test(expected = UnsupportedOperationException.class)
+ @Test
public void testCallProxiedInitialized() throws InitializationException {
- proxied.initialize(null);
+ assertThrows(UnsupportedOperationException.class,
+ () -> proxied.initialize(null));
}
@Test
diff --git a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/java/org/apache/nifi/controller/service/TestStandardControllerServiceProvider.java b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/java/org/apache/nifi/controller/service/TestStandardControllerServiceProvider.java
index a357bc722c..027310409f 100644
--- a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/java/org/apache/nifi/controller/service/TestStandardControllerServiceProvider.java
+++ b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/java/org/apache/nifi/controller/service/TestStandardControllerServiceProvider.java
@@ -56,12 +56,11 @@ import org.apache.nifi.util.MockProcessContext;
import org.apache.nifi.util.MockProcessorInitializationContext;
import org.apache.nifi.util.NiFiProperties;
import org.apache.nifi.util.SynchronousValidationTrigger;
-import org.junit.Assert;
-import org.junit.Before;
-import org.junit.BeforeClass;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.Timeout;
import org.mockito.Mockito;
-import org.mockito.invocation.InvocationOnMock;
import org.mockito.stubbing.Answer;
import java.io.IOException;
@@ -74,10 +73,11 @@ import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentMap;
import java.util.concurrent.TimeUnit;
-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.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+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 static org.mockito.ArgumentMatchers.any;
public class TestStandardControllerServiceProvider {
@@ -119,7 +119,7 @@ public class TestStandardControllerServiceProvider {
private static Bundle systemBundle;
private FlowManager flowManager;
- @BeforeClass
+ @BeforeAll
public static void setNiFiProps() {
niFiProperties = NiFiProperties.createBasicNiFiProperties(TestStandardControllerServiceProvider.class.getResource("/conf/nifi.properties").getFile());
@@ -129,26 +129,20 @@ public class TestStandardControllerServiceProvider {
extensionManager.discoverExtensions(systemBundle, Collections.emptySet());
}
- @Before
+ @BeforeEach
public void setup() {
flowManager = Mockito.mock(FlowManager.class);
final ConcurrentMap<String, ProcessorNode> processorMap = new ConcurrentHashMap<>();
- Mockito.doAnswer(new Answer<ProcessorNode>() {
- @Override
- public ProcessorNode answer(InvocationOnMock invocation) throws Throwable {
- final String id = invocation.getArgument(0);
- return processorMap.get(id);
- }
+ Mockito.doAnswer((Answer<ProcessorNode>) invocation -> {
+ final String id = invocation.getArgument(0);
+ return processorMap.get(id);
}).when(flowManager).getProcessorNode(Mockito.anyString());
- Mockito.doAnswer(new Answer<Object>() {
- @Override
- public Object answer(InvocationOnMock invocation) throws Throwable {
- final ProcessorNode procNode = invocation.getArgument(0);
- processorMap.putIfAbsent(procNode.getIdentifier(), procNode);
- return null;
- }
+ Mockito.doAnswer((Answer<Object>) invocation -> {
+ final ProcessorNode procNode = invocation.getArgument(0);
+ processorMap.putIfAbsent(procNode.getIdentifier(), procNode);
+ return null;
}).when(flowManager).onProcessorAdded(any(ProcessorNode.class));
}
@@ -202,7 +196,8 @@ public class TestStandardControllerServiceProvider {
provider.disableControllerService(serviceNode);
}
- @Test(timeout = 10000)
+ @Test
+ @Timeout(10)
public void testEnableDisableWithReference() throws InterruptedException {
final ProcessGroup group = new MockProcessGroup(flowManager);
final FlowManager flowManager = Mockito.mock(FlowManager.class);
@@ -238,12 +233,7 @@ public class TestStandardControllerServiceProvider {
Thread.sleep(5L);
}
assertSame(ControllerServiceState.ENABLED, serviceNodeA.getState());
-
- try {
- provider.disableControllerService(serviceNodeB);
- Assert.fail("Was able to disable Service B but Service A is enabled and references B");
- } catch (final IllegalStateException expected) {
- }
+ assertThrows(IllegalStateException.class, () -> provider.disableControllerService(serviceNodeB));
provider.disableControllerService(serviceNodeA);
waitForServiceState(serviceNodeA, ControllerServiceState.DISABLED);
@@ -282,10 +272,10 @@ public class TestStandardControllerServiceProvider {
assertEquals(2, branches.size());
List<ControllerServiceNode> ordered = branches.get(0);
assertEquals(2, ordered.size());
- assertTrue(ordered.get(0) == serviceNode2);
- assertTrue(ordered.get(1) == serviceNode1);
+ assertSame(ordered.get(0), serviceNode2);
+ assertSame(ordered.get(1), serviceNode1);
assertEquals(1, branches.get(1).size());
- assertTrue(branches.get(1).get(0) == serviceNode2);
+ assertSame(branches.get(1).get(0), serviceNode2);
nodeMap.clear();
nodeMap.put("2", serviceNode2);
@@ -295,10 +285,10 @@ public class TestStandardControllerServiceProvider {
assertEquals(2, branches.size());
ordered = branches.get(1);
assertEquals(2, ordered.size());
- assertTrue(ordered.get(0) == serviceNode2);
- assertTrue(ordered.get(1) == serviceNode1);
+ assertSame(ordered.get(0), serviceNode2);
+ assertSame(ordered.get(1), serviceNode1);
assertEquals(1, branches.get(0).size());
- assertTrue(branches.get(0).get(0) == serviceNode2);
+ assertSame(branches.get(0).get(0), serviceNode2);
// add circular dependency on self.
nodeMap.clear();
@@ -310,8 +300,8 @@ public class TestStandardControllerServiceProvider {
assertEquals(2, branches.size());
ordered = branches.get(0);
assertEquals(2, ordered.size());
- assertTrue(ordered.get(0) == serviceNode2);
- assertTrue(ordered.get(1) == serviceNode1);
+ assertSame(ordered.get(0), serviceNode2);
+ assertSame(ordered.get(1), serviceNode1);
nodeMap.clear();
nodeMap.put("2", serviceNode2);
@@ -320,8 +310,8 @@ public class TestStandardControllerServiceProvider {
assertEquals(2, branches.size());
ordered = branches.get(1);
assertEquals(2, ordered.size());
- assertTrue(ordered.get(0) == serviceNode2);
- assertTrue(ordered.get(1) == serviceNode1);
+ assertSame(ordered.get(0), serviceNode2);
+ assertSame(ordered.get(1), serviceNode1);
// add circular dependency once removed. In this case, we won't actually be able to enable these because of the
// circular dependency because they will never be valid because they will always depend on a disabled service.
@@ -337,8 +327,8 @@ public class TestStandardControllerServiceProvider {
assertEquals(2, branches.size());
ordered = branches.get(0);
assertEquals(2, ordered.size());
- assertTrue(ordered.get(0) == serviceNode3);
- assertTrue(ordered.get(1) == serviceNode1);
+ assertSame(ordered.get(0), serviceNode3);
+ assertSame(ordered.get(1), serviceNode1);
nodeMap.clear();
nodeMap.put("3", serviceNode3);
@@ -347,8 +337,8 @@ public class TestStandardControllerServiceProvider {
assertEquals(2, branches.size());
ordered = branches.get(1);
assertEquals(2, ordered.size());
- assertTrue(ordered.get(0) == serviceNode3);
- assertTrue(ordered.get(1) == serviceNode1);
+ assertSame(ordered.get(0), serviceNode3);
+ assertSame(ordered.get(1), serviceNode1);
// Add multiple completely disparate branches.
nodeMap.clear();
@@ -367,22 +357,22 @@ public class TestStandardControllerServiceProvider {
ordered = branches.get(0);
assertEquals(2, ordered.size());
- assertTrue(ordered.get(0) == serviceNode2);
- assertTrue(ordered.get(1) == serviceNode1);
+ assertSame(ordered.get(0), serviceNode2);
+ assertSame(ordered.get(1), serviceNode1);
assertEquals(1, branches.get(1).size());
- assertTrue(branches.get(1).get(0) == serviceNode2);
+ assertSame(branches.get(1).get(0), serviceNode2);
ordered = branches.get(2);
assertEquals(2, ordered.size());
- assertTrue(ordered.get(0) == serviceNode4);
- assertTrue(ordered.get(1) == serviceNode3);
+ assertSame(ordered.get(0), serviceNode4);
+ assertSame(ordered.get(1), serviceNode3);
assertEquals(1, branches.get(3).size());
- assertTrue(branches.get(3).get(0) == serviceNode4);
+ assertSame(branches.get(3).get(0), serviceNode4);
assertEquals(1, branches.get(4).size());
- assertTrue(branches.get(4).get(0) == serviceNode5);
+ assertSame(branches.get(4).get(0), serviceNode5);
// create 2 branches both dependent on the same service
nodeMap.clear();
@@ -397,17 +387,17 @@ public class TestStandardControllerServiceProvider {
ordered = branches.get(0);
assertEquals(2, ordered.size());
- assertTrue(ordered.get(0) == serviceNode2);
- assertTrue(ordered.get(1) == serviceNode1);
+ assertSame(ordered.get(0), serviceNode2);
+ assertSame(ordered.get(1), serviceNode1);
ordered = branches.get(1);
assertEquals(1, ordered.size());
- assertTrue(ordered.get(0) == serviceNode2);
+ assertSame(ordered.get(0), serviceNode2);
ordered = branches.get(2);
assertEquals(2, ordered.size());
- assertTrue(ordered.get(0) == serviceNode2);
- assertTrue(ordered.get(1) == serviceNode3);
+ assertSame(ordered.get(0), serviceNode2);
+ assertSame(ordered.get(1), serviceNode3);
}
private ProcessorNode createProcessor(final StandardProcessScheduler scheduler, final ControllerServiceProvider serviceProvider) {
diff --git a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/java/org/apache/nifi/controller/state/TestStateMapSerDe.java b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/java/org/apache/nifi/controller/state/TestStateMapSerDe.java
index 63bfbade47..9d83707de1 100644
--- a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/java/org/apache/nifi/controller/state/TestStateMapSerDe.java
+++ b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/java/org/apache/nifi/controller/state/TestStateMapSerDe.java
@@ -17,8 +17,9 @@
package org.apache.nifi.controller.state;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
+import org.apache.nifi.components.state.StateMap;
+import org.junit.jupiter.api.Test;
+import org.wali.UpdateType;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
@@ -28,9 +29,8 @@ import java.io.IOException;
import java.util.HashMap;
import java.util.Map;
-import org.apache.nifi.components.state.StateMap;
-import org.junit.Test;
-import org.wali.UpdateType;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
public class TestStateMapSerDe {
diff --git a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/java/org/apache/nifi/controller/state/server/ITZooKeeperStateServerTLS.java b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/java/org/apache/nifi/controller/state/server/ITZooKeeperStateServerTLS.java
index 296edaa0bf..22d43a7cea 100644
--- a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/java/org/apache/nifi/controller/state/server/ITZooKeeperStateServerTLS.java
+++ b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/java/org/apache/nifi/controller/state/server/ITZooKeeperStateServerTLS.java
@@ -31,13 +31,10 @@ import org.apache.zookeeper.KeeperException;
import org.apache.zookeeper.data.Stat;
import org.apache.zookeeper.server.ServerCnxnFactory;
import org.apache.zookeeper.server.quorum.QuorumPeerConfig;
-import org.junit.After;
-import org.junit.Assert;
-import org.junit.Before;
-import org.junit.BeforeClass;
-import org.junit.Rule;
-import org.junit.Test;
-import org.junit.rules.ExpectedException;
+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 java.io.File;
import java.io.IOException;
@@ -48,8 +45,11 @@ import java.util.Map;
import java.util.Properties;
import static org.apache.nifi.leader.election.ITSecureClientZooKeeperFactory.createSecureClientProperties;
-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.assertNotEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertNull;
+import static org.junit.jupiter.api.Assertions.assertThrows;
// Testing setting up a ZooKeeperStateServer with TLS
public class ITZooKeeperStateServerTLS {
@@ -65,10 +65,7 @@ public class ITZooKeeperStateServerTLS {
private static TlsConfiguration tlsConfiguration;
- @Rule
- public ExpectedException expectedException = ExpectedException.none();
-
- @BeforeClass
+ @BeforeAll
public static void setTlsConfiguration() {
tlsConfiguration = new TemporaryKeyStoreBuilder().build();
@@ -108,7 +105,7 @@ public class ITZooKeeperStateServerTLS {
private Properties partialZooKeeperProps;
private ZooKeeperStateServer server;
- @Before
+ @BeforeEach
public void setupWithValidProperties() throws IOException, QuorumPeerConfig.ConfigException {
niFiProps = NiFiProperties.createBasicNiFiProperties(null, SECURE_NIFI_PROPS);
assertNotNull(niFiProps);
@@ -133,21 +130,13 @@ public class ITZooKeeperStateServerTLS {
assertNotNull(partialZooKeeperProps);
}
- @After
- public void clearConnectionProperties() {
- Collections.unmodifiableSet(System.getProperties().stringPropertyNames()).stream()
- .filter(name -> name.startsWith("zookeeper."))
- .forEach(System::clearProperty);
-
- }
-
// This test shows that a ZooKeeperStateServer cannot be created from empty NiFi properties.
@Test
public void testCreateFromEmptyNiFiProperties() throws IOException, QuorumPeerConfig.ConfigException {
final NiFiProperties emptyProps = NiFiProperties.createBasicNiFiProperties(null, new HashMap<>());
assertNotNull(emptyProps);
- Assert.assertNull(ZooKeeperStateServer.create(emptyProps));
+ assertNull(ZooKeeperStateServer.create(emptyProps));
}
// This test shows that a ZooKeeperStateServer can be created from insecure NiFi properties.
@@ -168,7 +157,7 @@ public class ITZooKeeperStateServerTLS {
put(ZOOKEEPER_PROPERTIES_FILE_KEY, PARTIAL_ZOOKEEPER_PROPS);
}});
- Assert.assertThrows(QuorumPeerConfig.ConfigException.class, () ->
+ assertThrows(QuorumPeerConfig.ConfigException.class, () ->
ZooKeeperStateServer.create(partialProps));
}
@@ -202,8 +191,8 @@ public class ITZooKeeperStateServerTLS {
@Test
public void testCreateRemovesInsecureClientPort() {
assertNotNull(insecureZooKeeperProps.getProperty("clientPort"));
- Assert.assertNotEquals(insecureZooKeeperProps.getProperty("clientPort"), "");
- Assert.assertNull(quorumPeerConfig.getClientPortAddress());
+ assertNotEquals("", insecureZooKeeperProps.getProperty("clientPort"));
+ assertNull(quorumPeerConfig.getClientPortAddress());
}
// This test shows that a connection class is set when none is specified (QuorumPeerConfig::parseProperties sets the System property):
@@ -224,8 +213,12 @@ public class ITZooKeeperStateServerTLS {
assertEquals(ZOOKEEPER_CNXN_FACTORY, System.getProperty(ServerCnxnFactory.ZOOKEEPER_SERVER_CNXN_FACTORY));
}
- @After
+ @AfterEach
public void tearDown() throws Exception {
+ Collections.unmodifiableSet(System.getProperties().stringPropertyNames()).stream()
+ .filter(name -> name.startsWith("zookeeper."))
+ .forEach(System::clearProperty);
+
if(server != null) {
File stateDir = server.getQuorumPeerConfig().getDataDir().getParentFile();
deleteRecursively(stateDir);
@@ -296,7 +289,7 @@ public class ITZooKeeperStateServerTLS {
}
// Fail to connect to a secure ZooKeeperStateServer with insecure client configuration
- @Test(expected = KeeperException.ConnectionLossException.class)
+ @Test
public void testSecureZooKeeperStateServerWithInsecureClient() throws Exception {
final int actualPort = Integer.parseInt(secureZooKeeperProps.getProperty("secureClientPort", "0"));
final String connect = "localhost:" + actualPort;
@@ -318,11 +311,12 @@ public class ITZooKeeperStateServerTLS {
final String testPath = "/test";
// Expect this to fail with ConnectionLossException
- client.create().forPath(testPath, new byte[0]);
+ assertThrows(KeeperException.ConnectionLossException.class,
+ () -> client.create().forPath(testPath, new byte[0]));
}
// Fail to connect to a secure ZooKeeperStateServer with missing client configuration
- @Test(expected = KeeperException.ConnectionLossException.class)
+ @Test
public void testSecureZooKeeperStateServerWithMissingClientConfiguration() throws Exception {
final int actualPort = Integer.parseInt(secureZooKeeperProps.getProperty("secureClientPort", "0"));
final String connect = "localhost:" + actualPort;
@@ -344,7 +338,8 @@ public class ITZooKeeperStateServerTLS {
final String testPath = "/test";
// Expect this to fail with ConnectionLossException
- final String createResult = client.create().forPath(testPath, new byte[0]);
+ assertThrows(KeeperException.ConnectionLossException.class,
+ () -> client.create().forPath(testPath, new byte[0]));
}
// Connect to a secure ZooKeeperStateServer
@@ -402,11 +397,7 @@ public class ITZooKeeperStateServerTLS {
}
@Test
- public void testClientSecureFalseWithClientSecurePortAndNoTls() throws Exception {
- expectedException.expect(QuorumPeerConfig.ConfigException.class);
- expectedException.expectMessage("ZooKeeper properties file src/test/resources/TestZooKeeperStateServerConfigurations/secure.zookeeper.properties was " +
- "configured to be secure but there was no valid TLS config present in nifi.properties or nifi.zookeeper.client.secure was set to false. Check the administration guide");
-
+ public void testClientSecureFalseWithClientSecurePortAndNoTls() {
final int actualPort = Integer.parseInt(secureZooKeeperProps.getProperty("secureClientPort"));
final String connect = "localhost:" + actualPort;
final NiFiProperties validZkClientProps = NiFiProperties.createBasicNiFiProperties(null, new HashMap<String, String>() {{
@@ -415,14 +406,16 @@ public class ITZooKeeperStateServerTLS {
put(NiFiProperties.ZOOKEEPER_CONNECT_STRING, connect);
}});
- server = ZooKeeperStateServer.create(validZkClientProps);
+ QuorumPeerConfig.ConfigException configException =
+ assertThrows(QuorumPeerConfig.ConfigException.class, () -> ZooKeeperStateServer.create(validZkClientProps));
+
+ assertEquals("ZooKeeper properties file src/test/resources/TestZooKeeperStateServerConfigurations/secure.zookeeper.properties was " +
+ "configured to be secure but there was no valid TLS config present in nifi.properties or nifi.zookeeper.client.secure was set to false. Check the administration guide",
+ configException.getMessage());
}
@Test
- public void testClientSecureTrueWithInsecureZooKeeperAndTlsSet() throws Exception {
- expectedException.expect(QuorumPeerConfig.ConfigException.class);
- expectedException.expectMessage("NiFi was configured to be secure but secureClientPort could not be retrieved from zookeeper.properties file");
-
+ public void testClientSecureTrueWithInsecureZooKeeperAndTlsSet() {
final int actualPort = Integer.parseInt(insecureZooKeeperProps.getProperty("clientPort"));
final String connect = "localhost:" + actualPort;
final NiFiProperties validZkClientProps = NiFiProperties.createBasicNiFiProperties(null, new HashMap<String, String>() {{
@@ -432,14 +425,14 @@ public class ITZooKeeperStateServerTLS {
put(NiFiProperties.ZOOKEEPER_CONNECT_STRING, connect);
}});
- server = ZooKeeperStateServer.create(validZkClientProps);
+ QuorumPeerConfig.ConfigException configException =
+ assertThrows(QuorumPeerConfig.ConfigException.class, () -> ZooKeeperStateServer.create(validZkClientProps));
+ assertEquals("NiFi was configured to be secure but secureClientPort could not be retrieved from zookeeper.properties file",
+ configException.getMessage());
}
@Test
- public void testClientSecureTrueWithNoTls() throws Exception {
- expectedException.expect(QuorumPeerConfig.ConfigException.class);
- expectedException.expectMessage(NiFiProperties.ZOOKEEPER_CLIENT_SECURE + " is true but no TLS configuration is present in nifi.properties");
-
+ public void testClientSecureTrueWithNoTls() {
final int actualPort = Integer.parseInt(insecureZooKeeperProps.getProperty("clientPort"));
final String connect = "localhost:" + actualPort;
final NiFiProperties validZkClientProps = NiFiProperties.createBasicNiFiProperties(null, new HashMap<String, String>() {{
@@ -449,14 +442,14 @@ public class ITZooKeeperStateServerTLS {
put(NiFiProperties.ZOOKEEPER_CONNECT_STRING, connect);
}});
- server = ZooKeeperStateServer.create(validZkClientProps);
+ QuorumPeerConfig.ConfigException configException =
+ assertThrows(QuorumPeerConfig.ConfigException.class, () -> ZooKeeperStateServer.create(validZkClientProps));
+ assertEquals(NiFiProperties.ZOOKEEPER_CLIENT_SECURE + " is true but no TLS configuration is present in nifi.properties",
+ configException.getMessage());
}
@Test
- public void testZooKeeperMissingPortSettings() throws Exception {
- expectedException.expect(QuorumPeerConfig.ConfigException.class);
- expectedException.expectMessage("No clientAddress or secureClientAddress is set in zookeeper.properties");
-
+ public void testZooKeeperMissingPortSettings() {
final String connect = "localhost:" + 2181;
final NiFiProperties validZkClientProps = NiFiProperties.createBasicNiFiProperties(null, new HashMap<String, String>() {{
putAll(SECURE_NIFI_PROPS);
@@ -465,7 +458,10 @@ public class ITZooKeeperStateServerTLS {
put(NiFiProperties.ZOOKEEPER_CONNECT_STRING, connect);
}});
- server = ZooKeeperStateServer.create(validZkClientProps);
+ QuorumPeerConfig.ConfigException configException =
+ assertThrows(QuorumPeerConfig.ConfigException.class, () -> ZooKeeperStateServer.create(validZkClientProps));
+ assertEquals("No clientAddress or secureClientAddress is set in zookeeper.properties",
+ configException.getMessage());
}
@Test
diff --git a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/java/org/apache/nifi/controller/state/server/TestZooKeeperStateServerConfigurations.java b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/java/org/apache/nifi/controller/state/server/TestZooKeeperStateServerConfigurations.java
index 3abf23ac40..2f54b1a4cb 100644
--- a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/java/org/apache/nifi/controller/state/server/TestZooKeeperStateServerConfigurations.java
+++ b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/java/org/apache/nifi/controller/state/server/TestZooKeeperStateServerConfigurations.java
@@ -22,11 +22,10 @@ import org.apache.nifi.security.util.TlsConfiguration;
import org.apache.nifi.util.NiFiProperties;
import org.apache.zookeeper.server.ServerCnxnFactory;
import org.apache.zookeeper.server.quorum.QuorumPeerConfig;
-import org.junit.After;
-import org.junit.Assert;
-import org.junit.Before;
-import org.junit.BeforeClass;
-import org.junit.Test;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.Test;
import java.io.File;
import java.io.IOException;
@@ -35,6 +34,11 @@ import java.util.HashMap;
import java.util.Map;
import java.util.Properties;
+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.assertNull;
+
// This class tests the behaviors involved with the ZooKeeperStateServer::create method. The servers are not started,
// and TLS connections are not used.
public class TestZooKeeperStateServerConfigurations {
@@ -64,7 +68,7 @@ public class TestZooKeeperStateServerConfigurations {
private static TlsConfiguration tlsConfiguration;
- @BeforeClass
+ @BeforeAll
public static void setTlsConfiguration() {
tlsConfiguration = new TemporaryKeyStoreBuilder().build();
@@ -79,41 +83,41 @@ public class TestZooKeeperStateServerConfigurations {
SECURE_NIFI_PROPS.put(NiFiProperties.ZOOKEEPER_CLIENT_SECURE, "true");
}
- @Before
+ @BeforeEach
public void setupWithValidProperties() throws IOException, QuorumPeerConfig.ConfigException {
// Secure properties setup
secureNiFiProps = NiFiProperties.createBasicNiFiProperties(null, SECURE_NIFI_PROPS);
- Assert.assertNotNull(secureNiFiProps);
+ assertNotNull(secureNiFiProps);
// This shows that a ZooKeeper server is created from valid NiFi properties:
final ZooKeeperStateServer secureZooKeeperStateServer = ZooKeeperStateServer.create(secureNiFiProps);
- Assert.assertNotNull(secureZooKeeperStateServer);
+ assertNotNull(secureZooKeeperStateServer);
secureQuorumPeerConfig = secureZooKeeperStateServer.getQuorumPeerConfig();
- Assert.assertNotNull(secureQuorumPeerConfig);
+ assertNotNull(secureQuorumPeerConfig);
secureZooKeeperProps = new Properties();
secureZooKeeperProps.load( FileUtils.openInputStream(new File(SECURE_ZOOKEEPER_PROPS)));
- Assert.assertNotNull(secureZooKeeperProps);
+ assertNotNull(secureZooKeeperProps);
// Insecure properties setup
insecureNiFiProps = NiFiProperties.createBasicNiFiProperties(null, INSECURE_NIFI_PROPS);
- Assert.assertNotNull(insecureNiFiProps);
+ assertNotNull(insecureNiFiProps);
// This shows that a ZooKeeper server is created from valid NiFi properties:
final ZooKeeperStateServer insecureZooKeeperStateServer = ZooKeeperStateServer.create(insecureNiFiProps);
- Assert.assertNotNull(insecureZooKeeperStateServer);
+ assertNotNull(insecureZooKeeperStateServer);
insecureQuorumPeerConfig = insecureZooKeeperStateServer.getQuorumPeerConfig();
- Assert.assertNotNull(insecureQuorumPeerConfig);
+ assertNotNull(insecureQuorumPeerConfig);
insecureZooKeeperProps = new Properties();
insecureZooKeeperProps.load(FileUtils.openInputStream(new File(INSECURE_ZOOKEEPER_PROPS)));
- Assert.assertNotNull(insecureZooKeeperProps);
+ assertNotNull(insecureZooKeeperProps);
}
- @After
+ @AfterEach
public void clearConnectionProperties() {
Collections.unmodifiableSet(System.getProperties().stringPropertyNames()).stream()
.filter(name -> name.startsWith("zookeeper."))
@@ -125,8 +129,8 @@ public class TestZooKeeperStateServerConfigurations {
public void testCreateFromEmptyNiFiProperties() throws IOException, QuorumPeerConfig.ConfigException {
final NiFiProperties emptyProps = NiFiProperties.createBasicNiFiProperties(null, new HashMap<>());
- Assert.assertNotNull(emptyProps);
- Assert.assertNull(ZooKeeperStateServer.create(emptyProps));
+ assertNotNull(emptyProps);
+ assertNull(ZooKeeperStateServer.create(emptyProps));
}
// This test shows that a ZooKeeperStateServer can be created from insecure NiFi properties.
@@ -135,8 +139,8 @@ public class TestZooKeeperStateServerConfigurations {
final NiFiProperties insecureProps = NiFiProperties.createBasicNiFiProperties(null, INSECURE_PROPS);
final ZooKeeperStateServer server = ZooKeeperStateServer.create(insecureProps);
- Assert.assertNotNull(server);
- Assert.assertNotNull(server.getQuorumPeerConfig().getClientPortAddress());
+ assertNotNull(server);
+ assertNotNull(server.getQuorumPeerConfig().getClientPortAddress());
}
// This test shows that the client can specify a secure port and that port is used:
@@ -148,24 +152,24 @@ public class TestZooKeeperStateServerConfigurations {
}});
final ZooKeeperStateServer server = ZooKeeperStateServer.create(secureProps);
- Assert.assertNotNull(server);
+ assertNotNull(server);
final QuorumPeerConfig config = server.getQuorumPeerConfig();
- Assert.assertEquals(secureZooKeeperProps.getProperty("secureClientPort"), String.valueOf(config.getSecureClientPortAddress().getPort()));
+ assertEquals(secureZooKeeperProps.getProperty("secureClientPort"), String.valueOf(config.getSecureClientPortAddress().getPort()));
}
// This shows that a secure NiFi with an secure ZooKeeper will not have an insecure client address or port:
@Test
public void testCreateRemovesInsecureClientPort() {
- Assert.assertNotNull(secureZooKeeperProps.getProperty("secureClientPort"));
- Assert.assertNotEquals(secureZooKeeperProps.getProperty("clientPort"), "");
- Assert.assertNull(secureQuorumPeerConfig.getClientPortAddress());
+ assertNotNull(secureZooKeeperProps.getProperty("secureClientPort"));
+ assertNotEquals("", secureZooKeeperProps.getProperty("clientPort"));
+ assertNull(secureQuorumPeerConfig.getClientPortAddress());
}
// This test shows that a connection class is set when none is specified (QuorumPeerConfig::parseProperties sets the System property):
@Test
public void testCreateWithUnspecifiedConnectionClass() {
- Assert.assertEquals(org.apache.zookeeper.server.NettyServerCnxnFactory.class.getName(), System.getProperty(ServerCnxnFactory.ZOOKEEPER_SERVER_CNXN_FACTORY));
+ assertEquals(org.apache.zookeeper.server.NettyServerCnxnFactory.class.getName(), System.getProperty(ServerCnxnFactory.ZOOKEEPER_SERVER_CNXN_FACTORY));
}
// This test shows that a specified connection class is honored (QuorumPeerConfig::parseProperties sets the System property):
@@ -176,8 +180,8 @@ public class TestZooKeeperStateServerConfigurations {
put(ZOOKEEPER_PROPERTIES_FILE_KEY, SECURE_ZOOKEEPER_PROPS);
}});
- Assert.assertNotNull(ZooKeeperStateServer.create(secureProps));
- Assert.assertEquals(ZOOKEEPER_CNXN_FACTORY, System.getProperty(ServerCnxnFactory.ZOOKEEPER_SERVER_CNXN_FACTORY));
+ assertNotNull(ZooKeeperStateServer.create(secureProps));
+ assertEquals(ZOOKEEPER_CNXN_FACTORY, System.getProperty(ServerCnxnFactory.ZOOKEEPER_SERVER_CNXN_FACTORY));
}
private static String getPath(String path) {
diff --git a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/java/org/apache/nifi/controller/status/analytics/TestCachingConnectionStatusAnalyticsEngine.java b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/java/org/apache/nifi/controller/status/analytics/TestCachingConnectionStatusAnalyticsEngine.java
index 4df96ae97e..26bff98adb 100644
--- a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/java/org/apache/nifi/controller/status/analytics/TestCachingConnectionStatusAnalyticsEngine.java
+++ b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/java/org/apache/nifi/controller/status/analytics/TestCachingConnectionStatusAnalyticsEngine.java
@@ -16,12 +16,12 @@
*/
package org.apache.nifi.controller.status.analytics;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotEquals;
-
import org.apache.nifi.controller.flow.FlowManager;
import org.apache.nifi.controller.status.history.StatusHistoryRepository;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotEquals;
public class TestCachingConnectionStatusAnalyticsEngine extends TestStatusAnalyticsEngine {
diff --git a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/java/org/apache/nifi/controller/status/analytics/TestConnectionStatusAnalytics.java b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/java/org/apache/nifi/controller/status/analytics/TestConnectionStatusAnalytics.java
index 27d2d6de6c..09362c7683 100644
--- a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/java/org/apache/nifi/controller/status/analytics/TestConnectionStatusAnalytics.java
+++ b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/java/org/apache/nifi/controller/status/analytics/TestConnectionStatusAnalytics.java
@@ -51,7 +51,7 @@ import org.apache.nifi.nar.StandardExtensionDiscoveringManager;
import org.apache.nifi.nar.SystemBundle;
import org.apache.nifi.util.NiFiProperties;
import org.apache.nifi.util.Tuple;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import org.mockito.Mockito;
import org.mockito.invocation.InvocationOnMock;
import org.mockito.stubbing.Answer;
diff --git a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/java/org/apache/nifi/controller/status/analytics/TestStatusAnalyticsEngine.java b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/java/org/apache/nifi/controller/status/analytics/TestStatusAnalyticsEngine.java
index 746b9fbb24..e76f9546fe 100644
--- a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/java/org/apache/nifi/controller/status/analytics/TestStatusAnalyticsEngine.java
+++ b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/java/org/apache/nifi/controller/status/analytics/TestStatusAnalyticsEngine.java
@@ -16,30 +16,28 @@
*/
package org.apache.nifi.controller.status.analytics;
-import static org.junit.Assert.assertNotNull;
-import static org.mockito.ArgumentMatchers.any;
-import static org.mockito.ArgumentMatchers.anyInt;
-import static org.mockito.ArgumentMatchers.anyString;
-import static org.mockito.Mockito.when;
-
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.Map;
-import java.util.stream.Stream;
-
import org.apache.nifi.controller.flow.FlowManager;
-import org.apache.nifi.controller.repository.FlowFileEventRepository;
import org.apache.nifi.controller.status.history.StatusHistory;
import org.apache.nifi.controller.status.history.StatusHistoryRepository;
import org.apache.nifi.controller.status.history.StatusSnapshot;
import org.apache.nifi.groups.ProcessGroup;
import org.apache.nifi.util.Tuple;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
import org.mockito.Mockito;
-import org.mockito.invocation.InvocationOnMock;
import org.mockito.stubbing.Answer;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.stream.Stream;
+
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.ArgumentMatchers.anyInt;
+import static org.mockito.ArgumentMatchers.anyString;
+import static org.mockito.Mockito.when;
+
public abstract class TestStatusAnalyticsEngine {
static final long DEFAULT_PREDICT_INTERVAL_MILLIS = 3L * 60 * 1000;
@@ -49,10 +47,9 @@ public abstract class TestStatusAnalyticsEngine {
protected StatusHistoryRepository statusRepository;
protected FlowManager flowManager;
- protected FlowFileEventRepository flowFileEventRepository;
protected StatusAnalyticsModelMapFactory statusAnalyticsModelMapFactory;
- @Before
+ @BeforeEach
public void setup() {
statusRepository = Mockito.mock(StatusHistoryRepository.class);
@@ -78,12 +75,8 @@ public abstract class TestStatusAnalyticsEngine {
when(statusAnalyticsModelMapFactory.getConnectionStatusModelMap()).thenReturn(modelMap);
- when(extractFunction.extractMetric(anyString(),any(StatusHistory.class))).then(new Answer<Tuple<Stream<Double[]>,Stream<Double>>>() {
- @Override
- public Tuple<Stream<Double[]>, Stream<Double>> answer(InvocationOnMock invocationOnMock) throws Throwable {
- return new Tuple<>(Stream.of(features), Stream.of(target));
- }
- });
+ when(extractFunction.extractMetric(anyString(),any(StatusHistory.class))).then((Answer<Tuple<Stream<Double[]>,
+ Stream<Double>>>) invocationOnMock -> new Tuple<>(Stream.of(features), Stream.of(target)));
when(statusSnapshot.getMetricDescriptors()).thenReturn(Collections.emptySet());
when(flowManager.getRootGroup()).thenReturn(processGroup);
diff --git a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/java/org/apache/nifi/controller/status/analytics/models/TestOrdinaryLeastSquares.java b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/java/org/apache/nifi/controller/status/analytics/models/TestOrdinaryLeastSquares.java
index de466ea07e..eca0179a41 100644
--- a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/java/org/apache/nifi/controller/status/analytics/models/TestOrdinaryLeastSquares.java
+++ b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/java/org/apache/nifi/controller/status/analytics/models/TestOrdinaryLeastSquares.java
@@ -16,16 +16,16 @@
*/
package org.apache.nifi.controller.status.analytics.models;
-import static org.junit.Assert.assertFalse;
+import org.apache.commons.lang3.time.DateUtils;
+import org.apache.commons.math3.linear.SingularMatrixException;
+import org.junit.jupiter.api.Test;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;
import java.util.stream.Stream;
-import org.apache.commons.lang3.time.DateUtils;
-import org.apache.commons.math3.linear.SingularMatrixException;
-import org.junit.Test;
+import static org.junit.jupiter.api.Assertions.assertFalse;
public class TestOrdinaryLeastSquares {
diff --git a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/java/org/apache/nifi/controller/status/analytics/models/TestSimpleRegression.java b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/java/org/apache/nifi/controller/status/analytics/models/TestSimpleRegression.java
index b0ecc08015..700eb50ea7 100644
--- a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/java/org/apache/nifi/controller/status/analytics/models/TestSimpleRegression.java
+++ b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/java/org/apache/nifi/controller/status/analytics/models/TestSimpleRegression.java
@@ -16,10 +16,11 @@
*/
package org.apache.nifi.controller.status.analytics.models;
-import static org.junit.Assert.assertNotNull;
+import org.junit.jupiter.api.Test;
import java.util.stream.Stream;
-import org.junit.Test;
+
+import static org.junit.jupiter.api.Assertions.assertNotNull;
public class TestSimpleRegression {
diff --git a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/java/org/apache/nifi/controller/status/history/AbstractEmbeddedQuestDbStatusHistoryRepositoryTest.java b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/java/org/apache/nifi/controller/status/history/AbstractEmbeddedQuestDbStatusHistoryRepositoryTest.java
index 65e2e4cfba..3e2233ceaf 100644
--- a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/java/org/apache/nifi/controller/status/history/AbstractEmbeddedQuestDbStatusHistoryRepositoryTest.java
+++ b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/java/org/apache/nifi/controller/status/history/AbstractEmbeddedQuestDbStatusHistoryRepositoryTest.java
@@ -18,8 +18,8 @@ package org.apache.nifi.controller.status.history;
import org.apache.nifi.util.FileUtils;
import org.apache.nifi.util.NiFiProperties;
-import org.junit.After;
-import org.junit.Before;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeEach;
import org.mockito.Mockito;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -46,13 +46,13 @@ public abstract class AbstractEmbeddedQuestDbStatusHistoryRepositoryTest extends
protected EmbeddedQuestDbStatusHistoryRepository testSubject;
protected String path;
- @Before
+ @BeforeEach
public void setUp() throws Exception {
path = PATH + System.currentTimeMillis();
testSubject = givenTestSubject();
}
- @After
+ @AfterEach
public void tearDown() throws Exception {
testSubject.shutdown();
diff --git a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/java/org/apache/nifi/controller/status/history/EmbeddedQuestDbRolloverHandlerTest.java b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/java/org/apache/nifi/controller/status/history/EmbeddedQuestDbRolloverHandlerTest.java
deleted file mode 100644
index a12282734b..0000000000
--- a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/java/org/apache/nifi/controller/status/history/EmbeddedQuestDbRolloverHandlerTest.java
+++ /dev/null
@@ -1,306 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.nifi.controller.status.history;
-
-import io.questdb.cairo.CairoConfiguration;
-import io.questdb.cairo.CairoEngine;
-import io.questdb.cairo.DefaultCairoConfiguration;
-import io.questdb.cairo.TableWriter;
-import io.questdb.cairo.sql.Record;
-import io.questdb.cairo.sql.RecordCursor;
-import io.questdb.cairo.sql.RecordCursorFactory;
-import io.questdb.griffin.SqlExecutionContext;
-import org.apache.nifi.controller.status.history.questdb.QuestDbContext;
-import org.apache.nifi.util.FileUtils;
-import org.junit.After;
-import org.junit.Assert;
-import org.junit.Before;
-import org.junit.Ignore;
-import org.junit.Test;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import java.io.File;
-import java.time.ZonedDateTime;
-import java.time.format.DateTimeFormatter;
-import java.util.Collections;
-import java.util.LinkedList;
-import java.util.List;
-import java.util.concurrent.TimeUnit;
-import java.util.function.Supplier;
-
-@Ignore("Buggy tests depend on time of day")
-public class EmbeddedQuestDbRolloverHandlerTest {
- private static final Logger LOGGER = LoggerFactory.getLogger(EmbeddedQuestDbRolloverHandlerTest.class);
-
- private static final String PATH_BASE = "target/questdb";
- private static final String CREATE_TABLE = "CREATE TABLE measurements (capturedAt TIMESTAMP, value INT) TIMESTAMP(capturedAt) PARTITION BY DAY";
-
- private static final String UTC_MAR_1_1200 = "03/01/2021 12:00:00 UTC";
- private static final String UTC_MAR_2_1200 = "03/02/2021 12:00:00 UTC";
- private static final String UTC_MAR_5_1200 = "03/05/2021 12:00:00 UTC";
- private static final String UTC_MAR_6_1200 = "03/06/2021 12:00:00 UTC";
- private static final String UTC_MAR_7_1200 = "03/07/2021 12:00:00 UTC";
- private static final String UTC_MAR_8_1200 = "03/08/2021 12:00:00 UTC";
- private static final String UTC_MAR_8_1700 = "03/08/2021 17:00:00 UTC";
-
- private static final String EST_MAR_5_1200 = "03/05/2021 12:00:00 EST"; // UTC: 03/05/2021 17:00:00
- private static final String EST_MAR_6_1200 = "03/06/2021 12:00:00 EST"; // UTC: 03/06/2021 17:00:00
- private static final String EST_MAR_7_1200 = "03/07/2021 12:00:00 EST"; // UTC: 03/07/2021 17:00:00
- private static final String EST_MAR_8_1200 = "03/08/2021 12:00:00 EST"; // UTC: 03/08/2021 17:00:00
- private static final String EST_MAR_8_1600 = "03/08/2021 16:00:00 EST"; // UTC: 03/08/2021 21:00:00
- private static final String EST_MAR_8_1700 = "03/08/2021 17:00:00 EST"; // UTC: 03/09/2021 22:00:00
- private static final String EST_MAR_8_2200 = "03/08/2021 22:00:00 EST"; // UTC: 03/09/2021 03:00:00
- private static final String EST_MAR_8_2300 = "03/08/2021 23:00:00 EST"; // UTC: 03/09/2021 04:00:00
-
- private static final String SGT_MAR_4_1200 = "03/04/2021 12:00:00 SGT"; // UTC: 03/04/2021 04:00:00
- private static final String SGT_MAR_5_1200 = "03/05/2021 12:00:00 SGT"; // UTC: 03/05/2021 04:00:00
- private static final String SGT_MAR_6_1200 = "03/06/2021 12:00:00 SGT"; // UTC: 03/06/2021 04:00:00
- private static final String SGT_MAR_7_1200 = "03/07/2021 12:00:00 SGT"; // UTC: 03/07/2021 04:00:00
- private static final String SGT_MAR_8_1200 = "03/08/2021 12:00:00 SGT"; // UTC: 03/08/2021 04:00:00
- private static final String SGT_MAR_8_1300 = "03/08/2021 13:00:00 SGT"; // UTC: 03/08/2021 05:00:00
- private static final String SGT_MAR_8_2300 = "03/08/2021 23:00:00 SGT"; // UTC: 03/08/2021 15:00:00
-
- private String path;
- private QuestDbContext dbContext;
-
- @Before
- public void setUp() throws Exception {
- path = PATH_BASE + System.currentTimeMillis();
- FileUtils.ensureDirectoryExistAndCanReadAndWrite(new File(path));
-
- dbContext = givenDbContext();
- }
-
- @After
- public void tearDown() throws Exception {
- try {
- FileUtils.deleteFile(new File(path), true);
- } catch (final Exception e) {
- LOGGER.error("Could not delete database directory", e);
- }
- }
-
- @Test
- public void testNoOffsetTimeZoneWhenPartitionNeedsToBeRolled() throws Exception {
- // given
- givenTableIsCreated(dbContext);
- givenTableIsPopulated(UTC_MAR_5_1200, UTC_MAR_6_1200, UTC_MAR_7_1200, UTC_MAR_8_1200);
-
- // when
- whenRollOverIsExecuted(UTC_MAR_8_1700);
-
- // then
- thenTheRemainingPartitionsAre("2021-03-06", "2021-03-07", "2021-03-08");
- }
-
- @Test
- // This scenario might occur when the NiFi was stopped and the persistent storage remains in place
- public void testNoOffsetTimeZoneAndNonConsecutive() throws Exception {
- // given
- givenTableIsCreated(dbContext);
- givenTableIsPopulated(UTC_MAR_1_1200, UTC_MAR_2_1200, UTC_MAR_7_1200, UTC_MAR_8_1200);
-
- // when
- whenRollOverIsExecuted(UTC_MAR_8_1700);
-
- // then
- thenTheRemainingPartitionsAre("2021-03-07", "2021-03-08");
- }
-
- @Test
- public void testNoOffsetTimeWhenNoPartitionsNeedToBeDropped() throws Exception {
- // given
- givenTableIsCreated(dbContext);
- givenTableIsPopulated(UTC_MAR_6_1200, UTC_MAR_7_1200, UTC_MAR_8_1200);
-
- // when
- whenRollOverIsExecuted(UTC_MAR_8_1700);
-
- // then
- thenTheRemainingPartitionsAre("2021-03-06", "2021-03-07", "2021-03-08");
- }
-
- @Test
- public void testNoOffsetTimeZoneAndLessPartitionThanNeeded() throws Exception {
- // given
- givenTableIsCreated(dbContext);
- givenTableIsPopulated(UTC_MAR_7_1200, UTC_MAR_8_1200);
-
- // when
- whenRollOverIsExecuted(UTC_MAR_8_1700);
-
- // then
- thenTheRemainingPartitionsAre("2021-03-07", "2021-03-08");
- }
-
- @Test
- public void testNoOffsetTimeZoneAndOldPartitionsOnly() throws Exception {
- // given
- givenTableIsCreated(dbContext);
- givenTableIsPopulated(UTC_MAR_1_1200, UTC_MAR_2_1200);
-
- // when
- whenRollOverIsExecuted(UTC_MAR_8_1700);
-
- // then - QuestDB will not remove the active partition if presents
- thenTheRemainingPartitionsAre("2021-03-02");
- }
-
- @Test
- public void testNoOffsetTimeZoneAndEmptyDatabase() throws Exception {
- // given
- givenTableIsCreated(dbContext);
-
- // when
- whenRollOverIsExecuted(UTC_MAR_8_1700);
-
- // then
- thenNoPartitionsExpected();
- }
-
- @Test
- public void testNegativeOffsetTimeZoneWhenOverlaps() throws Exception {
- // given
- givenTableIsCreated(dbContext);
- givenTableIsPopulated(EST_MAR_5_1200, EST_MAR_6_1200, EST_MAR_7_1200, EST_MAR_8_1200, EST_MAR_8_1600);
-
- // when
- whenRollOverIsExecuted(EST_MAR_8_1700);
-
- // then
- thenTheRemainingPartitionsAre("2021-03-06", "2021-03-07", "2021-03-08");
- }
-
- @Test
- public void testNegativeOffsetTimeZoneWhenOverlapsAndRolledLater() throws Exception {
- // given
- givenTableIsCreated(dbContext);
- givenTableIsPopulated(EST_MAR_5_1200, EST_MAR_6_1200, EST_MAR_7_1200, EST_MAR_8_1200, EST_MAR_8_1600);
-
- // when
- whenRollOverIsExecuted(EST_MAR_8_2300);
-
- // then (there is no data inserted into the time range after the partition 2021-03-08, so 2021-03-09 is not created)
- thenTheRemainingPartitionsAre("2021-03-07", "2021-03-08");
- }
-
- @Test
- public void testNegativeOffsetTimeZoneWhenHangsOver() throws Exception {
- // given
- givenTableIsCreated(dbContext);
- givenTableIsPopulated(EST_MAR_6_1200, EST_MAR_7_1200, EST_MAR_8_1200, EST_MAR_8_2200);
-
- // when
- whenRollOverIsExecuted(EST_MAR_8_2300);
-
- // then
- thenTheRemainingPartitionsAre("2021-03-07", "2021-03-08", "2021-03-09");
- }
-
- @Test
- public void testPositiveOffsetTimeZoneWhenOverlaps() throws Exception {
- // given
- givenTableIsCreated(dbContext);
- givenTableIsPopulated(SGT_MAR_4_1200, SGT_MAR_5_1200, SGT_MAR_6_1200, SGT_MAR_7_1200, SGT_MAR_8_1200);
-
- // when
- whenRollOverIsExecuted(SGT_MAR_8_1300);
-
- // then
- thenTheRemainingPartitionsAre("2021-03-06", "2021-03-07", "2021-03-08");
- }
-
- @Test
- public void testPositiveOffsetTimeZoneWhenHangsOver() throws Exception {
- // given
- givenTableIsCreated(dbContext);
- givenTableIsPopulated(SGT_MAR_4_1200, SGT_MAR_5_1200, SGT_MAR_6_1200, SGT_MAR_7_1200, SGT_MAR_8_1200);
-
- // when
- whenRollOverIsExecuted(SGT_MAR_8_2300);
-
- // then
- thenTheRemainingPartitionsAre("2021-03-06", "2021-03-07", "2021-03-08");
- }
-
- private QuestDbContext givenDbContext() {
- final CairoConfiguration configuration = new DefaultCairoConfiguration(path);
- final CairoEngine engine = new CairoEngine(configuration);
- return new QuestDbContext(engine);
- }
-
- private void givenTableIsCreated(final QuestDbContext dbContext) throws Exception {
- dbContext.getCompiler().compile(CREATE_TABLE, dbContext.getSqlExecutionContext());
- }
-
- private void givenTableIsPopulated(final String... dates) {
- int value = 0;
-
- for (final String date : dates) {
- givenTableIsPopulated(date, value++);
- }
- }
-
- private void givenTableIsPopulated(final String date, final int value) {
- final DateTimeFormatter formatter = DateTimeFormatter.ofPattern("MM/dd/yyyy HH:mm:ss z");
- final ZonedDateTime parsedDate = ZonedDateTime.parse(date, formatter);
-
- final SqlExecutionContext executionContext = dbContext.getSqlExecutionContext();
- final TableWriter tableWriter = dbContext.getEngine().getWriter(executionContext.getCairoSecurityContext(), "measurements", "testing");
-
- final TableWriter.Row row = tableWriter.newRow(TimeUnit.MILLISECONDS.toMicros(parsedDate.toInstant().toEpochMilli()));
- row.putInt(1, value);
- row.append();
-
- tableWriter.commit();
- tableWriter.close();
- }
-
- private void whenRollOverIsExecuted(final String executedAt) {
- final DateTimeFormatter formatter = DateTimeFormatter.ofPattern("MM/dd/yyyy HH:mm:ss z");
- final ZonedDateTime executionTime = ZonedDateTime.parse(executedAt, formatter);
-
- final Supplier<ZonedDateTime> timeSource = () -> executionTime;
- final EmbeddedQuestDbRolloverHandler testSubject = new EmbeddedQuestDbRolloverHandler(timeSource, Collections.singletonList("measurements"), 2, dbContext);
- testSubject.run();
- }
-
- private void thenTheRemainingPartitionsAre(final String... expectedPartitions) throws Exception {
- final SqlExecutionContext executionContext = dbContext.getSqlExecutionContext();
- final RecordCursorFactory cursorFactory = dbContext.getCompiler()
- .compile(String.format(EmbeddedQuestDbRolloverHandler.SELECTION_QUERY, "measurements"), executionContext).getRecordCursorFactory();
- final RecordCursor cursor = cursorFactory.getCursor(executionContext);
-
- final List<String> existingPartitions = new LinkedList<>();
-
- while (cursor.hasNext()) {
- final Record record = cursor.getRecord();
- existingPartitions.add(new StringBuilder(record.getStr(0)).toString());
- }
-
- Assert.assertEquals(expectedPartitions.length, existingPartitions.size());
-
- for (final String expectedPartition : expectedPartitions) {
- Assert.assertTrue("Partition " + expectedPartition + " is expected", existingPartitions.contains(expectedPartition));
- }
- }
-
- private void thenNoPartitionsExpected() throws Exception {
- thenTheRemainingPartitionsAre();
- }
-}
diff --git a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/java/org/apache/nifi/controller/status/history/EmbeddedQuestDbStatusHistoryRepositoryForComponentsTest.java b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/java/org/apache/nifi/controller/status/history/EmbeddedQuestDbStatusHistoryRepositoryForComponentsTest.java
index c1a4f8968c..640f7f3cb7 100644
--- a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/java/org/apache/nifi/controller/status/history/EmbeddedQuestDbStatusHistoryRepositoryForComponentsTest.java
+++ b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/java/org/apache/nifi/controller/status/history/EmbeddedQuestDbStatusHistoryRepositoryForComponentsTest.java
@@ -17,13 +17,14 @@
package org.apache.nifi.controller.status.history;
import org.apache.nifi.controller.status.NodeStatus;
-import org.junit.Assert;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import java.util.ArrayList;
import java.util.Date;
import java.util.concurrent.TimeUnit;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+
public class EmbeddedQuestDbStatusHistoryRepositoryForComponentsTest extends AbstractEmbeddedQuestDbStatusHistoryRepositoryTest {
@Test
@@ -94,15 +95,15 @@ public class EmbeddedQuestDbStatusHistoryRepositoryForComponentsTest extends Abs
final StatusHistory result = testSubject.getProcessGroupStatusHistory(ROOT_GROUP_ID, START, END, 3);
// then - in case the value of preferred data points are lower than the number of snapshots available, the latest will added to the result
- Assert.assertEquals(3, result.getStatusSnapshots().size());
- Assert.assertEquals(new Date(INSERTED_AT.getTime() - TimeUnit.MINUTES.toMillis(7)), result.getStatusSnapshots().get(0).getTimestamp());
- Assert.assertEquals(new Date(INSERTED_AT.getTime() - TimeUnit.MINUTES.toMillis(6)), result.getStatusSnapshots().get(1).getTimestamp());
- Assert.assertEquals(new Date(INSERTED_AT.getTime() - TimeUnit.MINUTES.toMillis(5)), result.getStatusSnapshots().get(2).getTimestamp());
+ assertEquals(3, result.getStatusSnapshots().size());
+ assertEquals(new Date(INSERTED_AT.getTime() - TimeUnit.MINUTES.toMillis(7)), result.getStatusSnapshots().get(0).getTimestamp());
+ assertEquals(new Date(INSERTED_AT.getTime() - TimeUnit.MINUTES.toMillis(6)), result.getStatusSnapshots().get(1).getTimestamp());
+ assertEquals(new Date(INSERTED_AT.getTime() - TimeUnit.MINUTES.toMillis(5)), result.getStatusSnapshots().get(2).getTimestamp());
}
private void assertCorrectStatusHistory(final StatusHistory rootGroupStatus, final String id, final String name) {
- Assert.assertEquals(id, rootGroupStatus.getComponentDetails().get("Id"));
- Assert.assertEquals(name, rootGroupStatus.getComponentDetails().get("Name"));
- Assert.assertEquals(1, rootGroupStatus.getStatusSnapshots().size());
+ assertEquals(id, rootGroupStatus.getComponentDetails().get("Id"));
+ assertEquals(name, rootGroupStatus.getComponentDetails().get("Name"));
+ assertEquals(1, rootGroupStatus.getStatusSnapshots().size());
}
}
diff --git a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/java/org/apache/nifi/controller/status/history/EmbeddedQuestDbStatusHistoryRepositoryForNodeTest.java b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/java/org/apache/nifi/controller/status/history/EmbeddedQuestDbStatusHistoryRepositoryForNodeTest.java
index b7b605419f..46ed749b23 100644
--- a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/java/org/apache/nifi/controller/status/history/EmbeddedQuestDbStatusHistoryRepositoryForNodeTest.java
+++ b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/java/org/apache/nifi/controller/status/history/EmbeddedQuestDbStatusHistoryRepositoryForNodeTest.java
@@ -17,8 +17,9 @@
package org.apache.nifi.controller.status.history;
import org.apache.nifi.controller.status.ProcessGroupStatus;
-import org.junit.Assert;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
+
+import static org.junit.jupiter.api.Assertions.assertTrue;
public class EmbeddedQuestDbStatusHistoryRepositoryForNodeTest extends AbstractEmbeddedQuestDbStatusHistoryRepositoryTest {
@@ -29,9 +30,9 @@ public class EmbeddedQuestDbStatusHistoryRepositoryForNodeTest extends AbstractE
final GarbageCollectionHistory garbageCollectionHistory = testSubject.getGarbageCollectionHistory(START, END);
// then
- Assert.assertTrue(nodeStatusHistory.getStatusSnapshots().isEmpty());
- Assert.assertTrue(garbageCollectionHistory.getGarbageCollectionStatuses("gc1").isEmpty());
- Assert.assertTrue(garbageCollectionHistory.getGarbageCollectionStatuses("gc2").isEmpty());
+ assertTrue(nodeStatusHistory.getStatusSnapshots().isEmpty());
+ assertTrue(garbageCollectionHistory.getGarbageCollectionStatuses("gc1").isEmpty());
+ assertTrue(garbageCollectionHistory.getGarbageCollectionStatuses("gc2").isEmpty());
}
@Test
diff --git a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/java/org/apache/nifi/controller/status/history/JsonNodeStatusHistoryDumpFactoryTest.java b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/java/org/apache/nifi/controller/status/history/JsonNodeStatusHistoryDumpFactoryTest.java
index fc331bf082..1c5dccae20 100644
--- a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/java/org/apache/nifi/controller/status/history/JsonNodeStatusHistoryDumpFactoryTest.java
+++ b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/java/org/apache/nifi/controller/status/history/JsonNodeStatusHistoryDumpFactoryTest.java
@@ -16,8 +16,7 @@
*/
package org.apache.nifi.controller.status.history;
-import org.junit.Assert;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import org.mockito.ArgumentCaptor;
import java.time.LocalDateTime;
@@ -25,7 +24,9 @@ import java.time.LocalTime;
import java.time.ZoneId;
import java.util.Date;
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertThrows;
+
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.verify;
@@ -66,13 +67,13 @@ public class JsonNodeStatusHistoryDumpFactoryTest {
JsonNodeStatusHistoryDumpFactory factory = new JsonNodeStatusHistoryDumpFactory();
factory.setStatusHistoryRepository(statusHistoryRepository);
- final IllegalArgumentException zeroDaysException = Assert.assertThrows(IllegalArgumentException.class,
+ final IllegalArgumentException zeroDaysException = assertThrows(IllegalArgumentException.class,
() -> factory.create(zeroDays)
);
assertEquals(String.format(EXPECTED_EXCEPTION_MESSAGE, zeroDays), zeroDaysException.getMessage());
- final IllegalArgumentException negativeDaysException = Assert.assertThrows(IllegalArgumentException.class,
+ final IllegalArgumentException negativeDaysException = assertThrows(IllegalArgumentException.class,
() -> factory.create(negativeDays)
);
diff --git a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/java/org/apache/nifi/controller/status/history/StatusHistoryUtilTest.java b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/java/org/apache/nifi/controller/status/history/StatusHistoryUtilTest.java
index d341c57d20..3df09d0afa 100644
--- a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/java/org/apache/nifi/controller/status/history/StatusHistoryUtilTest.java
+++ b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/java/org/apache/nifi/controller/status/history/StatusHistoryUtilTest.java
@@ -17,14 +17,16 @@
package org.apache.nifi.controller.status.history;
import org.apache.nifi.web.api.dto.status.StatusDescriptorDTO;
-import org.junit.Assert;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.List;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertThrows;
+
public class StatusHistoryUtilTest {
@Test
@@ -44,10 +46,10 @@ public class StatusHistoryUtilTest {
final List<StatusDescriptorDTO> result = StatusHistoryUtil.createFieldDescriptorDtos(metricDescriptors);
// then
- Assert.assertEquals(expected, result);
+ assertEquals(expected, result);
}
- @Test(expected = IndexOutOfBoundsException.class)
+ @Test
public void testCreateFieldDescriptorDtosWhenNotConsecutive() {
// given
final Collection<MetricDescriptor<?>> metricDescriptors = Arrays.asList(
@@ -56,7 +58,8 @@ public class StatusHistoryUtilTest {
);
// when
- StatusHistoryUtil.createFieldDescriptorDtos(metricDescriptors);
+ assertThrows(IndexOutOfBoundsException.class,
+ () -> StatusHistoryUtil.createFieldDescriptorDtos(metricDescriptors));
}
@Test
@@ -69,7 +72,7 @@ public class StatusHistoryUtilTest {
final List<StatusDescriptorDTO> result = StatusHistoryUtil.createFieldDescriptorDtos(metricDescriptors);
// then
- Assert.assertEquals(expected, result);
+ assertEquals(expected, result);
}
@Test
@@ -95,6 +98,6 @@ public class StatusHistoryUtilTest {
final List<StatusDescriptorDTO> result = StatusHistoryUtil.createFieldDescriptorDtos(metricDescriptors);
// then
- Assert.assertEquals(expected, result);
+ assertEquals(expected, result);
}
}
\ No newline at end of file
diff --git a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/java/org/apache/nifi/controller/status/history/TestMetricRollingBuffer.java b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/java/org/apache/nifi/controller/status/history/TestMetricRollingBuffer.java
index 338fc625a6..98099162f3 100644
--- a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/java/org/apache/nifi/controller/status/history/TestMetricRollingBuffer.java
+++ b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/java/org/apache/nifi/controller/status/history/TestMetricRollingBuffer.java
@@ -16,7 +16,7 @@
*/
package org.apache.nifi.controller.status.history;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import java.util.ArrayList;
import java.util.Arrays;
@@ -25,9 +25,9 @@ import java.util.List;
import java.util.Set;
import java.util.stream.Collectors;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-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.assertInstanceOf;
public class TestMetricRollingBuffer {
private static final Set<MetricDescriptor<?>> PROCESSOR_METRICS = Arrays.stream(ProcessorStatusDescriptor.values())
@@ -48,7 +48,7 @@ public class TestMetricRollingBuffer {
snapshot.setTimestamp(new Date(startTime + i * 1000));
timestamps.add(snapshot.getTimestamp());
- snapshot.addStatusMetric(ProcessorStatusDescriptor.BYTES_WRITTEN.getDescriptor(), Long.valueOf(i));
+ snapshot.addStatusMetric(ProcessorStatusDescriptor.BYTES_WRITTEN.getDescriptor(), (long) i);
buffer.update(snapshot);
}
@@ -65,7 +65,8 @@ public class TestMetricRollingBuffer {
for (int i=0; i < iterations; i++) {
final StatusSnapshot snapshot = snapshots.get(i);
if (i < expectedEmptyCount) {
- assertTrue("Snapshot at i=" + i + " is not an EmptyStatusSnapshot", snapshot instanceof EmptyStatusSnapshot);
+ assertInstanceOf(EmptyStatusSnapshot.class, snapshot,
+ "Snapshot at i=" + i + " is not an EmptyStatusSnapshot");
} else {
assertEquals(Long.valueOf(i), snapshot.getStatusMetric(ProcessorStatusDescriptor.BYTES_WRITTEN.getDescriptor()));
assertFalse(snapshot instanceof EmptyStatusSnapshot);
@@ -86,7 +87,7 @@ public class TestMetricRollingBuffer {
final StandardStatusSnapshot snapshot = new StandardStatusSnapshot(PROCESSOR_METRICS);
snapshot.setTimestamp(new Date(startTime + i * 1000));
- snapshot.addStatusMetric(ProcessorStatusDescriptor.BYTES_WRITTEN.getDescriptor(), Long.valueOf(i));
+ snapshot.addStatusMetric(ProcessorStatusDescriptor.BYTES_WRITTEN.getDescriptor(), (long) i);
buffer.update(snapshot);
}
@@ -111,7 +112,7 @@ public class TestMetricRollingBuffer {
snapshot.setTimestamp(new Date(insertStart + i * 1000));
timestamps.add(snapshot.getTimestamp());
- snapshot.addStatusMetric(ProcessorStatusDescriptor.BYTES_WRITTEN.getDescriptor(), Long.valueOf(i));
+ snapshot.addStatusMetric(ProcessorStatusDescriptor.BYTES_WRITTEN.getDescriptor(), (long) i);
buffer.update(snapshot);
}
diff --git a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/java/org/apache/nifi/controller/status/history/VolatileComponentStatusRepositoryForComponentsTest.java b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/java/org/apache/nifi/controller/status/history/VolatileComponentStatusRepositoryForComponentsTest.java
index b700d507a7..08cdbfd33e 100644
--- a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/java/org/apache/nifi/controller/status/history/VolatileComponentStatusRepositoryForComponentsTest.java
+++ b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/java/org/apache/nifi/controller/status/history/VolatileComponentStatusRepositoryForComponentsTest.java
@@ -40,7 +40,7 @@ public class VolatileComponentStatusRepositoryForComponentsTest {
private static VolatileComponentStatusRepository partiallyFilledRepo;
private static VolatileComponentStatusRepository emptyRepo;
private static final int FIVE_MINUTES = 300000;
- private static int BUFSIZE3 = 10;
+ private static final int BUFSIZE3 = 10;
@BeforeAll
public static void createBuffers() {
diff --git a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/java/org/apache/nifi/controller/status/history/VolatileComponentStatusRepositoryForNodeTest.java b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/java/org/apache/nifi/controller/status/history/VolatileComponentStatusRepositoryForNodeTest.java
index 42e73cb9e6..2e11fe9368 100644
--- a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/java/org/apache/nifi/controller/status/history/VolatileComponentStatusRepositoryForNodeTest.java
+++ b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/java/org/apache/nifi/controller/status/history/VolatileComponentStatusRepositoryForNodeTest.java
@@ -17,9 +17,9 @@
package org.apache.nifi.controller.status.history;
import org.apache.nifi.controller.status.NodeStatus;
+import org.apache.nifi.controller.status.StorageStatus;
import org.apache.nifi.util.NiFiProperties;
-import org.junit.Assert;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import org.mockito.Mockito;
import java.util.Arrays;
@@ -27,6 +27,9 @@ import java.util.Date;
import java.util.List;
import java.util.Set;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.fail;
+
public class VolatileComponentStatusRepositoryForNodeTest extends AbstractStatusHistoryRepositoryTest {
@Test
@@ -49,50 +52,50 @@ public class VolatileComponentStatusRepositoryForNodeTest extends AbstractStatus
// then
// checking on snapshots
- Assert.assertEquals(nodeStatuses.size(), result.getStatusSnapshots().size());;
+ assertEquals(nodeStatuses.size(), result.getStatusSnapshots().size());
// metrics based on NodeStatus
for (int i = 0; i < result.getStatusSnapshots().size(); i++) {
final StatusSnapshot snapshot = result.getStatusSnapshots().get(i);
final NodeStatus nodeStatus = nodeStatuses.get(i);
- Assert.assertEquals(nodeStatus.getFreeHeap(), snapshot.getStatusMetric(NodeStatusDescriptor.FREE_HEAP.getDescriptor()).longValue());
- Assert.assertEquals(nodeStatus.getUsedHeap(), snapshot.getStatusMetric(NodeStatusDescriptor.USED_HEAP.getDescriptor()).longValue());
- Assert.assertEquals(nodeStatus.getHeapUtilization(), snapshot.getStatusMetric(NodeStatusDescriptor.HEAP_UTILIZATION.getDescriptor()).longValue());
- Assert.assertEquals(nodeStatus.getFreeNonHeap(), snapshot.getStatusMetric(NodeStatusDescriptor.FREE_NON_HEAP.getDescriptor()).longValue());
- Assert.assertEquals(nodeStatus.getUsedNonHeap(), snapshot.getStatusMetric(NodeStatusDescriptor.USED_NON_HEAP.getDescriptor()).longValue());
- Assert.assertEquals(nodeStatus.getOpenFileHandlers(), snapshot.getStatusMetric(NodeStatusDescriptor.OPEN_FILE_HANDLES.getDescriptor()).longValue());
- Assert.assertEquals(
+ assertEquals(nodeStatus.getFreeHeap(), snapshot.getStatusMetric(NodeStatusDescriptor.FREE_HEAP.getDescriptor()).longValue());
+ assertEquals(nodeStatus.getUsedHeap(), snapshot.getStatusMetric(NodeStatusDescriptor.USED_HEAP.getDescriptor()).longValue());
+ assertEquals(nodeStatus.getHeapUtilization(), snapshot.getStatusMetric(NodeStatusDescriptor.HEAP_UTILIZATION.getDescriptor()).longValue());
+ assertEquals(nodeStatus.getFreeNonHeap(), snapshot.getStatusMetric(NodeStatusDescriptor.FREE_NON_HEAP.getDescriptor()).longValue());
+ assertEquals(nodeStatus.getUsedNonHeap(), snapshot.getStatusMetric(NodeStatusDescriptor.USED_NON_HEAP.getDescriptor()).longValue());
+ assertEquals(nodeStatus.getOpenFileHandlers(), snapshot.getStatusMetric(NodeStatusDescriptor.OPEN_FILE_HANDLES.getDescriptor()).longValue());
+ assertEquals(
Double.valueOf(nodeStatus.getProcessorLoadAverage() * MetricDescriptor.FRACTION_MULTIPLIER).longValue(),
snapshot.getStatusMetric(NodeStatusDescriptor.PROCESSOR_LOAD_AVERAGE.getDescriptor()).longValue());
- Assert.assertEquals(nodeStatus.getTotalThreads(), snapshot.getStatusMetric(NodeStatusDescriptor.TOTAL_THREADS.getDescriptor()).longValue());
- Assert.assertEquals(nodeStatus.getEventDrivenThreads(), snapshot.getStatusMetric(NodeStatusDescriptor.EVENT_DRIVEN_THREADS.getDescriptor()).longValue());
- Assert.assertEquals(nodeStatus.getTimerDrivenThreads(), snapshot.getStatusMetric(NodeStatusDescriptor.TIME_DRIVEN_THREADS.getDescriptor()).longValue());
- Assert.assertEquals(nodeStatus.getFlowFileRepositoryFreeSpace(), snapshot.getStatusMetric(NodeStatusDescriptor.FLOW_FILE_REPOSITORY_FREE_SPACE.getDescriptor()).longValue());
- Assert.assertEquals(nodeStatus.getFlowFileRepositoryUsedSpace(), snapshot.getStatusMetric(NodeStatusDescriptor.FLOW_FILE_REPOSITORY_USED_SPACE.getDescriptor()).longValue());
- Assert.assertEquals(
- nodeStatus.getContentRepositories().stream().map(r -> r.getFreeSpace()).reduce(0L, (a, b) -> a + b).longValue(),
+ assertEquals(nodeStatus.getTotalThreads(), snapshot.getStatusMetric(NodeStatusDescriptor.TOTAL_THREADS.getDescriptor()).longValue());
+ assertEquals(nodeStatus.getEventDrivenThreads(), snapshot.getStatusMetric(NodeStatusDescriptor.EVENT_DRIVEN_THREADS.getDescriptor()).longValue());
+ assertEquals(nodeStatus.getTimerDrivenThreads(), snapshot.getStatusMetric(NodeStatusDescriptor.TIME_DRIVEN_THREADS.getDescriptor()).longValue());
+ assertEquals(nodeStatus.getFlowFileRepositoryFreeSpace(), snapshot.getStatusMetric(NodeStatusDescriptor.FLOW_FILE_REPOSITORY_FREE_SPACE.getDescriptor()).longValue());
+ assertEquals(nodeStatus.getFlowFileRepositoryUsedSpace(), snapshot.getStatusMetric(NodeStatusDescriptor.FLOW_FILE_REPOSITORY_USED_SPACE.getDescriptor()).longValue());
+ assertEquals(
+ nodeStatus.getContentRepositories().stream().map(StorageStatus::getFreeSpace).reduce(0L, Long::sum).longValue(),
snapshot.getStatusMetric(NodeStatusDescriptor.CONTENT_REPOSITORY_FREE_SPACE.getDescriptor()).longValue());
- Assert.assertEquals(
- nodeStatus.getContentRepositories().stream().map(r -> r.getUsedSpace()).reduce(0L, (a, b) -> a + b).longValue(),
+ assertEquals(
+ nodeStatus.getContentRepositories().stream().map(StorageStatus::getUsedSpace).reduce(0L, Long::sum).longValue(),
snapshot.getStatusMetric(NodeStatusDescriptor.CONTENT_REPOSITORY_USED_SPACE.getDescriptor()).longValue());
- Assert.assertEquals(
- nodeStatus.getProvenanceRepositories().stream().map(r -> r.getFreeSpace()).reduce(0L, (a, b) -> a + b).longValue(),
+ assertEquals(
+ nodeStatus.getProvenanceRepositories().stream().map(StorageStatus::getFreeSpace).reduce(0L, Long::sum).longValue(),
snapshot.getStatusMetric(NodeStatusDescriptor.PROVENANCE_REPOSITORY_FREE_SPACE.getDescriptor()).longValue());
- Assert.assertEquals(
- nodeStatus.getProvenanceRepositories().stream().map(r -> r.getUsedSpace()).reduce(0L, (a, b) -> a + b).longValue(),
+ assertEquals(
+ nodeStatus.getProvenanceRepositories().stream().map(StorageStatus::getUsedSpace).reduce(0L, Long::sum).longValue(),
snapshot.getStatusMetric(NodeStatusDescriptor.PROVENANCE_REPOSITORY_USED_SPACE.getDescriptor()).longValue());
// metrics based on repositories
- Assert.assertEquals(12 + i, getMetricAtOrdinal(snapshot, 17)); // c1 used
- Assert.assertEquals(13 + i, getMetricAtOrdinal(snapshot, 16)); // c1 free
- Assert.assertEquals(14 + i, getMetricAtOrdinal(snapshot, 19)); // c2 used
- Assert.assertEquals(15 + i, getMetricAtOrdinal(snapshot, 18)); // c2 free
-
- Assert.assertEquals(16 + i, getMetricAtOrdinal(snapshot, 21)); // p1 used
- Assert.assertEquals(17 + i, getMetricAtOrdinal(snapshot, 20)); // p1 free
- Assert.assertEquals(18 + i, getMetricAtOrdinal(snapshot, 23)); // p2 used
- Assert.assertEquals(19 + i, getMetricAtOrdinal(snapshot, 22)); // p2 free
+ assertEquals(12 + i, getMetricAtOrdinal(snapshot, 17)); // c1 used
+ assertEquals(13 + i, getMetricAtOrdinal(snapshot, 16)); // c1 free
+ assertEquals(14 + i, getMetricAtOrdinal(snapshot, 19)); // c2 used
+ assertEquals(15 + i, getMetricAtOrdinal(snapshot, 18)); // c2 free
+
+ assertEquals(16 + i, getMetricAtOrdinal(snapshot, 21)); // p1 used
+ assertEquals(17 + i, getMetricAtOrdinal(snapshot, 20)); // p1 free
+ assertEquals(18 + i, getMetricAtOrdinal(snapshot, 23)); // p2 used
+ assertEquals(19 + i, getMetricAtOrdinal(snapshot, 22)); // p2 free
}
// metrics based on GarbageCollectionStatus (The ordinal numbers are true for setup, in production it might differ)
@@ -108,23 +111,23 @@ public class VolatileComponentStatusRepositoryForNodeTest extends AbstractStatus
final StatusSnapshot snapshot1 = result.getStatusSnapshots().get(0);
final StatusSnapshot snapshot2 = result.getStatusSnapshots().get(1);
- Assert.assertEquals(100L, getMetricAtOrdinal(snapshot1, g0TimeOrdinal));
- Assert.assertEquals(0L, getMetricAtOrdinal(snapshot1, g0TimeDiffOrdinal));
- Assert.assertEquals(1L, getMetricAtOrdinal(snapshot1, g0CountOrdinal));
- Assert.assertEquals(0L, getMetricAtOrdinal(snapshot1, g0CountDiffOrdinal));
- Assert.assertEquals(300L, getMetricAtOrdinal(snapshot1, g1TimeOrdinal));
- Assert.assertEquals(0L, getMetricAtOrdinal(snapshot1, g1TimeDiffOrdinal));
- Assert.assertEquals(2L, getMetricAtOrdinal(snapshot1, g1CountOrdinal));
- Assert.assertEquals(0L, getMetricAtOrdinal(snapshot1, g1CountDiffOrdinal));
-
- Assert.assertEquals(100L, getMetricAtOrdinal(snapshot2, g0TimeOrdinal));
- Assert.assertEquals(0L, getMetricAtOrdinal(snapshot2, g0TimeDiffOrdinal));
- Assert.assertEquals(1L, getMetricAtOrdinal(snapshot2, g0CountOrdinal));
- Assert.assertEquals(0L, getMetricAtOrdinal(snapshot2, g0CountDiffOrdinal));
- Assert.assertEquals(700L, getMetricAtOrdinal(snapshot2, g1TimeOrdinal));
- Assert.assertEquals(400L, getMetricAtOrdinal(snapshot2, g1TimeDiffOrdinal));
- Assert.assertEquals(5L, getMetricAtOrdinal(snapshot2, g1CountOrdinal));
- Assert.assertEquals(3L, getMetricAtOrdinal(snapshot2, g1CountDiffOrdinal));
+ assertEquals(100L, getMetricAtOrdinal(snapshot1, g0TimeOrdinal));
+ assertEquals(0L, getMetricAtOrdinal(snapshot1, g0TimeDiffOrdinal));
+ assertEquals(1L, getMetricAtOrdinal(snapshot1, g0CountOrdinal));
+ assertEquals(0L, getMetricAtOrdinal(snapshot1, g0CountDiffOrdinal));
+ assertEquals(300L, getMetricAtOrdinal(snapshot1, g1TimeOrdinal));
+ assertEquals(0L, getMetricAtOrdinal(snapshot1, g1TimeDiffOrdinal));
+ assertEquals(2L, getMetricAtOrdinal(snapshot1, g1CountOrdinal));
+ assertEquals(0L, getMetricAtOrdinal(snapshot1, g1CountDiffOrdinal));
+
+ assertEquals(100L, getMetricAtOrdinal(snapshot2, g0TimeOrdinal));
+ assertEquals(0L, getMetricAtOrdinal(snapshot2, g0TimeDiffOrdinal));
+ assertEquals(1L, getMetricAtOrdinal(snapshot2, g0CountOrdinal));
+ assertEquals(0L, getMetricAtOrdinal(snapshot2, g0CountDiffOrdinal));
+ assertEquals(700L, getMetricAtOrdinal(snapshot2, g1TimeOrdinal));
+ assertEquals(400L, getMetricAtOrdinal(snapshot2, g1TimeDiffOrdinal));
+ assertEquals(5L, getMetricAtOrdinal(snapshot2, g1CountOrdinal));
+ assertEquals(3L, getMetricAtOrdinal(snapshot2, g1CountDiffOrdinal));
}
private static long getMetricAtOrdinal(final StatusSnapshot snapshot, final long ordinal) {
@@ -136,7 +139,7 @@ public class VolatileComponentStatusRepositoryForNodeTest extends AbstractStatus
}
}
- Assert.fail();
+ fail();
return Long.MIN_VALUE;
}
}
diff --git a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/java/org/apache/nifi/controller/status/history/storage/BufferedWriterForStatusStorageTest.java b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/java/org/apache/nifi/controller/status/history/storage/BufferedWriterForStatusStorageTest.java
index 54db5075cc..f3e9111ded 100644
--- a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/java/org/apache/nifi/controller/status/history/storage/BufferedWriterForStatusStorageTest.java
+++ b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/java/org/apache/nifi/controller/status/history/storage/BufferedWriterForStatusStorageTest.java
@@ -18,18 +18,19 @@ package org.apache.nifi.controller.status.history.storage;
import org.apache.commons.lang3.tuple.ImmutablePair;
import org.apache.nifi.controller.status.NodeStatus;
-import org.junit.Assert;
-import org.junit.Test;
-import org.junit.runner.RunWith;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.ExtendWith;
import org.mockito.ArgumentCaptor;
import org.mockito.Mock;
import org.mockito.Mockito;
-import org.mockito.junit.MockitoJUnitRunner;
+import org.mockito.junit.jupiter.MockitoExtension;
import java.time.Instant;
import java.util.List;
-@RunWith(MockitoJUnitRunner.class)
+import static org.junit.jupiter.api.Assertions.assertEquals;
+
+@ExtendWith(MockitoExtension.class)
public class BufferedWriterForStatusStorageTest {
private static final int BUFFER_SIZE = 3;
@@ -56,6 +57,6 @@ public class BufferedWriterForStatusStorageTest {
// then
Mockito.verify(payload, Mockito.only()).store(Mockito.anyList());
- Assert.assertEquals(BUFFER_SIZE, statusEntriesCaptor.getValue().size());
+ assertEquals(BUFFER_SIZE, statusEntriesCaptor.getValue().size());
}
}
\ No newline at end of file
diff --git a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/java/org/apache/nifi/controller/swap/TestSchemaSwapSerializerDeserializer.java b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/java/org/apache/nifi/controller/swap/TestSchemaSwapSerializerDeserializer.java
index d489ede97d..618863e331 100644
--- a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/java/org/apache/nifi/controller/swap/TestSchemaSwapSerializerDeserializer.java
+++ b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/java/org/apache/nifi/controller/swap/TestSchemaSwapSerializerDeserializer.java
@@ -17,8 +17,20 @@
package org.apache.nifi.controller.swap;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
+import org.apache.nifi.controller.queue.FlowFileQueue;
+import org.apache.nifi.controller.repository.FlowFileRecord;
+import org.apache.nifi.controller.repository.SwapContents;
+import org.apache.nifi.controller.repository.SwapSummary;
+import org.apache.nifi.controller.repository.claim.ContentClaim;
+import org.apache.nifi.controller.repository.claim.ResourceClaim;
+import org.apache.nifi.controller.repository.claim.ResourceClaimManager;
+import org.apache.nifi.controller.repository.claim.StandardResourceClaimManager;
+import org.apache.nifi.flowfile.FlowFile;
+import org.apache.nifi.stream.io.NullOutputStream;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Disabled;
+import org.junit.jupiter.api.Test;
+import org.mockito.Mockito;
import java.io.BufferedInputStream;
import java.io.BufferedOutputStream;
@@ -39,24 +51,12 @@ import java.util.Set;
import java.util.concurrent.TimeUnit;
import java.util.stream.Collectors;
-import org.apache.nifi.controller.queue.FlowFileQueue;
-import org.apache.nifi.controller.repository.FlowFileRecord;
-import org.apache.nifi.controller.repository.SwapContents;
-import org.apache.nifi.controller.repository.SwapSummary;
-import org.apache.nifi.controller.repository.claim.ContentClaim;
-import org.apache.nifi.controller.repository.claim.ResourceClaim;
-import org.apache.nifi.controller.repository.claim.ResourceClaimManager;
-import org.apache.nifi.controller.repository.claim.StandardResourceClaimManager;
-import org.apache.nifi.flowfile.FlowFile;
-import org.apache.nifi.stream.io.NullOutputStream;
-import org.junit.Before;
-import org.junit.Ignore;
-import org.junit.Test;
-import org.mockito.Mockito;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
public class TestSchemaSwapSerializerDeserializer {
- @Before
+ @BeforeEach
public void setup() {
MockFlowFile.resetIdGenerator();
}
@@ -166,7 +166,7 @@ public class TestSchemaSwapSerializerDeserializer {
}
@Test
- @Ignore("For manual testing, in order to ensure that changes do not negatively impact performance")
+ @Disabled("For manual testing, in order to ensure that changes do not negatively impact performance")
public void testWritePerformance() throws IOException, InterruptedException {
final ResourceClaimManager resourceClaimManager = new StandardResourceClaimManager();
diff --git a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/java/org/apache/nifi/controller/swap/TestSimpleSwapSerializerDeserializer.java b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/java/org/apache/nifi/controller/swap/TestSimpleSwapSerializerDeserializer.java
index 210f165471..5401fe2bd9 100644
--- a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/java/org/apache/nifi/controller/swap/TestSimpleSwapSerializerDeserializer.java
+++ b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/java/org/apache/nifi/controller/swap/TestSimpleSwapSerializerDeserializer.java
@@ -17,7 +17,7 @@
package org.apache.nifi.controller.swap;
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
import java.io.DataInputStream;
import java.io.File;
@@ -37,14 +37,14 @@ import org.apache.nifi.controller.repository.SwapContents;
import org.apache.nifi.controller.repository.claim.ResourceClaimManager;
import org.apache.nifi.controller.repository.claim.StandardResourceClaimManager;
import org.apache.nifi.stream.io.NullOutputStream;
-import org.junit.Before;
-import org.junit.Ignore;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Disabled;
+import org.junit.jupiter.api.Test;
import org.mockito.Mockito;
@SuppressWarnings("deprecation")
public class TestSimpleSwapSerializerDeserializer {
- @Before
+ @BeforeEach
public void setup() {
MockFlowFile.resetIdGenerator();
}
@@ -104,7 +104,7 @@ public class TestSimpleSwapSerializerDeserializer {
}
@Test
- @Ignore("For manual testing only. Not intended to be run as part of the automated unit tests but can "
+ @Disabled("For manual testing only. Not intended to be run as part of the automated unit tests but can "
+ "be convenient for determining a baseline for performance if making modifications.")
public void testWritePerformance() throws IOException, InterruptedException {
final ResourceClaimManager resourceClaimManager = new StandardResourceClaimManager();
diff --git a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/java/org/apache/nifi/controller/tasks/TestConnectableTask.java b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/java/org/apache/nifi/controller/tasks/TestConnectableTask.java
index a01f52756b..585241022c 100644
--- a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/java/org/apache/nifi/controller/tasks/TestConnectableTask.java
+++ b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/java/org/apache/nifi/controller/tasks/TestConnectableTask.java
@@ -33,7 +33,7 @@ import org.apache.nifi.controller.scheduling.RepositoryContextFactory;
import org.apache.nifi.controller.scheduling.SchedulingAgent;
import org.apache.nifi.controller.status.FlowFileAvailability;
import org.apache.nifi.processor.Processor;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import org.mockito.Mockito;
import java.util.Arrays;
@@ -42,8 +42,8 @@ import java.util.HashSet;
import java.util.Set;
import java.util.concurrent.atomic.AtomicLong;
-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.assertTrue;
import static org.mockito.Mockito.when;
public class TestConnectableTask {
@@ -125,7 +125,8 @@ public class TestConnectableTask {
Mockito.when(funnel.getIdentifier()).thenReturn("funnel-1");
final ConnectableTask task = createTask(funnel);
- assertTrue("If there is no incoming connection, it should be yielded.", task.invoke().isYield());
+ assertTrue(task.invoke().isYield(),
+ "If there is no incoming connection, it should be yielded.");
// Test with only a single connection that is self-looping and empty.
// Actually, this self-loop input can not be created for Funnels using NiFi API because an outer layer check condition does not allow it.
@@ -145,7 +146,8 @@ public class TestConnectableTask {
outgoingConnections.add(selfLoopingConnection);
when(funnel.getConnections()).thenReturn(outgoingConnections);
- assertTrue("If there is no incoming connection from other components, it should be yielded.", task.invoke().isYield());
+ assertTrue(task.invoke().isYield(),
+ "If there is no incoming connection from other components, it should be yielded.");
// Add an incoming connection from another component.
final ProcessorNode inputProcessor = Mockito.mock(ProcessorNode.class);
@@ -157,8 +159,8 @@ public class TestConnectableTask {
when(funnel.hasIncomingConnection()).thenReturn(true);
when(funnel.getIncomingConnections()).thenReturn(Arrays.asList(selfLoopingConnection, incomingFromAnotherComponent));
- assertTrue("Even if there is an incoming connection from another component," +
- " it should be yielded because there's no outgoing connections.", task.invoke().isYield());
+ assertTrue(task.invoke().isYield(), "Even if there is an incoming connection from another component," +
+ " it should be yielded because there's no outgoing connections.");
// Add an outgoing connection to another component.
final ProcessorNode outputProcessor = Mockito.mock(ProcessorNode.class);
@@ -167,16 +169,15 @@ public class TestConnectableTask {
when(outgoingToAnotherComponent.getDestination()).thenReturn(outputProcessor);
outgoingConnections.add(outgoingToAnotherComponent);
- assertTrue("Even if there is an incoming connection from another component and an outgoing connection as well," +
- " it should be yielded because there's no incoming FlowFiles to process.", task.invoke().isYield());
+ assertTrue(task.invoke().isYield(),"Even if there is an incoming connection from another component and an outgoing connection as well," +
+ " it should be yielded because there's no incoming FlowFiles to process.");
// Adding input FlowFiles.
final FlowFileQueue nonEmptyQueue = Mockito.mock(FlowFileQueue.class);
when(nonEmptyQueue.getFlowFileAvailability()).thenReturn(FlowFileAvailability.FLOWFILE_AVAILABLE);
when(incomingFromAnotherComponent.getFlowFileQueue()).thenReturn(nonEmptyQueue);
- assertFalse("When a Funnel has both incoming and outgoing connections and FlowFiles to process, then it should be executed.",
- task.invoke().isYield());
-
+ assertFalse(task.invoke().isYield(),
+ "When a Funnel has both incoming and outgoing connections and FlowFiles to process," +
+ " then it should be executed.");
}
-
}
diff --git a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/java/org/apache/nifi/events/TestNodeBulletinProcessingStrategy.java b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/java/org/apache/nifi/events/TestNodeBulletinProcessingStrategy.java
index 394c9404f1..03ab6ea667 100644
--- a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/java/org/apache/nifi/events/TestNodeBulletinProcessingStrategy.java
+++ b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/java/org/apache/nifi/events/TestNodeBulletinProcessingStrategy.java
@@ -17,9 +17,9 @@
package org.apache.nifi.events;
-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 TestNodeBulletinProcessingStrategy {
diff --git a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/java/org/apache/nifi/fingerprint/FingerprintFactoryTest.java b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/java/org/apache/nifi/fingerprint/FingerprintFactoryTest.java
index 5c047b31a3..9936adae32 100644
--- a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/java/org/apache/nifi/fingerprint/FingerprintFactoryTest.java
+++ b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/java/org/apache/nifi/fingerprint/FingerprintFactoryTest.java
@@ -35,8 +35,8 @@ import org.apache.nifi.remote.RemoteGroupPort;
import org.apache.nifi.remote.protocol.SiteToSiteTransportProtocol;
import org.apache.nifi.xml.processing.parsers.DocumentProvider;
import org.apache.nifi.xml.processing.parsers.StandardDocumentProvider;
-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;
import org.w3c.dom.Element;
@@ -48,10 +48,10 @@ import java.util.Collections;
import java.util.Optional;
import static org.apache.nifi.controller.serialization.ScheduledStateLookup.IDENTITY_LOOKUP;
-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.assertTrue;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
@@ -64,7 +64,7 @@ public class FingerprintFactoryTest {
private FingerprintFactory fingerprintFactory;
private SensitiveValueEncoder sensitiveValueEncoder;
- @Before
+ @BeforeEach
public void setup() {
encryptor = createEncryptor();
sensitiveValueEncoder = createSensitiveValueEncoder();
@@ -368,7 +368,8 @@ public class FingerprintFactoryTest {
};
for (final String criticalValue : criticalFingerprintValues) {
- assertTrue("Fingerprint did not contain '" + criticalValue + "'", fingerprint.contains(criticalValue));
+ assertTrue( fingerprint.contains(criticalValue),
+ "Fingerprint did not contain '" + criticalValue + "'");
}
// Ensure that 's1' comes before 's2' in the fingerprint
diff --git a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/java/org/apache/nifi/integration/FrameworkIntegrationTest.java b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/java/org/apache/nifi/integration/FrameworkIntegrationTest.java
index fc8984b270..b369c9aec9 100644
--- a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/java/org/apache/nifi/integration/FrameworkIntegrationTest.java
+++ b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/java/org/apache/nifi/integration/FrameworkIntegrationTest.java
@@ -104,10 +104,8 @@ import org.apache.nifi.services.FlowService;
import org.apache.nifi.util.FileUtils;
import org.apache.nifi.util.NiFiProperties;
import org.apache.nifi.web.revision.RevisionManager;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Rule;
-import org.junit.rules.TestName;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeEach;
import org.junit.rules.Timeout;
import org.mockito.Mockito;
import org.slf4j.Logger;
@@ -140,10 +138,6 @@ public class FrameworkIntegrationTest {
//@Rule
public Timeout globalTimeout = Timeout.seconds(20);
- @Rule
- public TestName name = new TestName();
-
-
private ResourceClaimManager resourceClaimManager;
private StandardProcessScheduler processScheduler;
@@ -162,11 +156,10 @@ public class FrameworkIntegrationTest {
public static final Relationship REL_SUCCESS = new Relationship.Builder().name("success").build();
- @Before
+ @BeforeEach
public void setup() throws IOException {
StandardStateManagerProvider.resetProvider();
- cleanup();
initialize();
flowController.initializeFlow();
@@ -306,8 +299,8 @@ public class FrameworkIntegrationTest {
return clusterCoordinator;
}
- @After
- public final void shutdown() {
+ @AfterEach
+ public final void shutdown() throws IOException {
logger.info("Shutting down...");
if (flowController != null) {
@@ -321,6 +314,8 @@ public class FrameworkIntegrationTest {
if (processScheduler != null) {
processScheduler.shutdown();
}
+
+ deleteDirectory(new File("target/int-tests"));
}
protected void restart() throws IOException, ExecutionException, InterruptedException {
@@ -368,11 +363,6 @@ public class FrameworkIntegrationTest {
flowController.initializeFlow(queueProvider);
}
- @After
- public final void cleanup() throws IOException {
- deleteDirectory(new File("target/int-tests"));
- }
-
private void deleteDirectory(final File dir) throws IOException {
if (!dir.exists()) {
return;
diff --git a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/java/org/apache/nifi/integration/cs/ControllerServiceReferenceIT.java b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/java/org/apache/nifi/integration/cs/ControllerServiceReferenceIT.java
index f3d5dbdbc4..d0aa24da88 100644
--- a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/java/org/apache/nifi/integration/cs/ControllerServiceReferenceIT.java
+++ b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/java/org/apache/nifi/integration/cs/ControllerServiceReferenceIT.java
@@ -66,7 +66,7 @@ public class ControllerServiceReferenceIT extends FrameworkIntegrationTest {
serviceNode.setProperties(Collections.singletonMap(LongValidatingControllerService.DELAY.getName(), "250 millis"));
final ValidationStatus validationStatus = serviceNode.performValidation();
final Collection<ValidationResult> validationErrors = serviceNode.getValidationErrors();
- assertSame(validationStatus, ValidationStatus.VALID);
+ assertSame(ValidationStatus.VALID, validationStatus);
assertEquals(0, validationErrors.size());
}
diff --git a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/java/org/apache/nifi/integration/flowfilerepo/OOMEFlowFileRepoUpdateIT.java b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/java/org/apache/nifi/integration/flowfilerepo/OOMEFlowFileRepoUpdateIT.java
index 64a7657e82..1de2f3094d 100644
--- a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/java/org/apache/nifi/integration/flowfilerepo/OOMEFlowFileRepoUpdateIT.java
+++ b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/java/org/apache/nifi/integration/flowfilerepo/OOMEFlowFileRepoUpdateIT.java
@@ -23,7 +23,7 @@ import org.apache.nifi.flowfile.FlowFile;
import org.apache.nifi.integration.DirectInjectionExtensionManager;
import org.apache.nifi.integration.FrameworkIntegrationTest;
import org.apache.nifi.reporting.Bulletin;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import java.io.IOException;
import java.util.Collections;
@@ -31,7 +31,7 @@ import java.util.List;
import java.util.Map;
import java.util.concurrent.ExecutionException;
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
public class OOMEFlowFileRepoUpdateIT extends FrameworkIntegrationTest {
@Override
diff --git a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/java/org/apache/nifi/integration/lifecycle/ContentCleanupIT.java b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/java/org/apache/nifi/integration/lifecycle/ContentCleanupIT.java
index 90f1f3df3a..cb8717b053 100644
--- a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/java/org/apache/nifi/integration/lifecycle/ContentCleanupIT.java
+++ b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/java/org/apache/nifi/integration/lifecycle/ContentCleanupIT.java
@@ -24,7 +24,7 @@ import org.apache.nifi.controller.repository.claim.ContentClaim;
import org.apache.nifi.flowfile.FlowFile;
import org.apache.nifi.integration.FrameworkIntegrationTest;
import org.apache.nifi.provenance.ProvenanceEventType;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import java.io.IOException;
import java.nio.file.Files;
@@ -32,10 +32,10 @@ import java.nio.file.Path;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.atomic.AtomicReference;
-import static junit.framework.TestCase.assertTrue;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNotEquals;
+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;
public class ContentCleanupIT extends FrameworkIntegrationTest {
diff --git a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/java/org/apache/nifi/integration/parameters/ParametersIT.java b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/java/org/apache/nifi/integration/parameters/ParametersIT.java
index 5545cc846d..53d0d46652 100644
--- a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/java/org/apache/nifi/integration/parameters/ParametersIT.java
+++ b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/java/org/apache/nifi/integration/parameters/ParametersIT.java
@@ -38,8 +38,7 @@ import org.apache.nifi.parameter.StandardParameterReferenceManager;
import org.apache.nifi.processor.ProcessContext;
import org.apache.nifi.processor.Processor;
import org.apache.nifi.processor.StandardProcessContext;
-import org.junit.Assert;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import java.util.Arrays;
import java.util.Collections;
@@ -51,7 +50,8 @@ import java.util.UUID;
import java.util.concurrent.ExecutionException;
import java.util.function.BiConsumer;
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertThrows;
public class ParametersIT extends FrameworkIntegrationTest {
@@ -466,12 +466,8 @@ public class ParametersIT extends FrameworkIntegrationTest {
final Map<String, String> properties = new HashMap<>();
properties.put("username", "${#{pass}}");
- try {
- usernamePassword.setProperties(properties);
- Assert.fail("Was able to set properties when referencing sensitive parameter from within EL");
- } catch (final IllegalArgumentException iae) {
- // Expected. Since the parameter is sensitive, it may referenced by a sensitive property
- }
+ assertThrows(IllegalArgumentException.class, () -> usernamePassword.setProperties(properties),
+ "Was able to set properties when referencing sensitive parameter from within EL");
}
@Test
@@ -487,12 +483,8 @@ public class ParametersIT extends FrameworkIntegrationTest {
final Map<String, String> properties = new HashMap<>();
properties.put("password", "${#{pass}}");
- try {
- usernamePassword.setProperties(properties);
- Assert.fail("Was able to set properties when referencing sensitive parameter from within EL");
- } catch (final IllegalArgumentException iae) {
- // Expected. Since the property is sensitive, it may reference a parameter only if that is the only value.
- }
+ assertThrows(IllegalArgumentException.class, () -> usernamePassword.setProperties(properties),
+ "Was able to set properties when referencing sensitive parameter from within EL");
}
private ParameterContext createParameterContext(final ParameterReferenceManager referenceManager) {
diff --git a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/java/org/apache/nifi/integration/processgroup/StandardProcessGroupIT.java b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/java/org/apache/nifi/integration/processgroup/StandardProcessGroupIT.java
index 53cda12c98..6596196007 100644
--- a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/java/org/apache/nifi/integration/processgroup/StandardProcessGroupIT.java
+++ b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/java/org/apache/nifi/integration/processgroup/StandardProcessGroupIT.java
@@ -35,17 +35,17 @@ import org.apache.nifi.processor.exception.ProcessException;
import org.apache.nifi.processor.util.StandardValidators;
import org.apache.nifi.util.NiFiProperties;
import org.apache.nifi.web.Revision;
-import org.junit.Assert;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import java.util.Collections;
import java.util.List;
import java.util.Set;
import java.util.concurrent.TimeUnit;
-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 static org.junit.jupiter.api.Assertions.assertThrows;
+import static org.junit.jupiter.api.Assertions.assertTrue;
public class StandardProcessGroupIT extends FrameworkIntegrationTest {
@@ -250,12 +250,9 @@ public class StandardProcessGroupIT extends FrameworkIntegrationTest {
getRootGroup().setVariables(Collections.singletonMap("number", "2"));
- try {
- child.setVariables(Collections.singletonMap("number", "10"));
- Assert.fail("Updated variable that is referenced by a running processor");
- } catch (final IllegalStateException ise) {
- // Expected
- }
+ assertThrows(IllegalStateException.class,
+ () -> child.setVariables(Collections.singletonMap("number", "10")),
+ "Updated variable that is referenced by a running processor");
child.stopProcessor(processor);
}
diff --git a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/java/org/apache/nifi/integration/processor/ProcessorParameterTokenIT.java b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/java/org/apache/nifi/integration/processor/ProcessorParameterTokenIT.java
index e241e7974c..dae500dbcc 100644
--- a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/java/org/apache/nifi/integration/processor/ProcessorParameterTokenIT.java
+++ b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/java/org/apache/nifi/integration/processor/ProcessorParameterTokenIT.java
@@ -33,8 +33,7 @@ import org.apache.nifi.processor.ProcessSession;
import org.apache.nifi.processor.Processor;
import org.apache.nifi.processor.Relationship;
import org.apache.nifi.processor.exception.ProcessException;
-import org.junit.Assert;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import java.nio.charset.StandardCharsets;
import java.util.Arrays;
@@ -47,7 +46,8 @@ import java.util.UUID;
import java.util.concurrent.ExecutionException;
import static org.apache.nifi.processor.util.StandardValidators.NON_EMPTY_VALIDATOR;
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertThrows;
public class ProcessorParameterTokenIT extends FrameworkIntegrationTest {
@@ -127,11 +127,8 @@ public class ProcessorParameterTokenIT extends FrameworkIntegrationTest {
properties.put(WriteText.TEXT.getName(), text);
properties.put(WriteText.PASSWORD.getName(), password);
- try {
- procNode.setProperties(properties);
- Assert.fail("Expected to fail when setting properties to " + properties);
- } catch (final IllegalArgumentException expected) {
- }
+ assertThrows(IllegalArgumentException.class, () -> procNode.setProperties(properties),
+ "Expected to fail when setting properties to " + properties);
}
private void verifyText(final ProcessorNode procNode, final String text, final String expectedOutput) throws ExecutionException, InterruptedException {
diff --git a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/java/org/apache/nifi/integration/swap/ClusteredSwapFileIT.java b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/java/org/apache/nifi/integration/swap/ClusteredSwapFileIT.java
deleted file mode 100644
index d725ff0c5b..0000000000
--- a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/java/org/apache/nifi/integration/swap/ClusteredSwapFileIT.java
+++ /dev/null
@@ -1,251 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.nifi.integration.swap;
-
-import org.apache.nifi.cluster.protocol.NodeIdentifier;
-import org.apache.nifi.connectable.Connection;
-import org.apache.nifi.controller.ProcessScheduler;
-import org.apache.nifi.controller.ProcessorNode;
-import org.apache.nifi.controller.queue.ConnectionEventListener;
-import org.apache.nifi.controller.queue.FlowFileQueue;
-import org.apache.nifi.controller.queue.LoadBalanceStrategy;
-import org.apache.nifi.controller.queue.LocalQueuePartitionDiagnostics;
-import org.apache.nifi.controller.queue.QueueDiagnostics;
-import org.apache.nifi.controller.queue.RemoteQueuePartitionDiagnostics;
-import org.apache.nifi.controller.queue.clustered.SocketLoadBalancedFlowFileQueue;
-import org.apache.nifi.controller.queue.clustered.client.async.AsyncLoadBalanceClientRegistry;
-import org.apache.nifi.controller.repository.FlowFileRecord;
-import org.apache.nifi.controller.repository.FlowFileSwapManager;
-import org.apache.nifi.controller.repository.claim.ResourceClaimManager;
-import org.apache.nifi.events.EventReporter;
-import org.apache.nifi.integration.FrameworkIntegrationTest;
-import org.apache.nifi.integration.processors.GenerateProcessor;
-import org.junit.Ignore;
-import org.junit.Test;
-import org.mockito.Mockito;
-
-import java.io.IOException;
-import java.util.Collections;
-import java.util.Set;
-import java.util.concurrent.ExecutionException;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNull;
-
-@Ignore("Tests need to be updated")
-public class ClusteredSwapFileIT extends FrameworkIntegrationTest {
-
- @Test
- public void testSwapOnRestartWithLoadBalancedConnectionDoNotLoadBalanceStrategy() throws ExecutionException, InterruptedException, IOException {
- final ProcessorNode generator = createProcessorNode(GenerateProcessor.class);
- generator.setProperties(Collections.singletonMap(GenerateProcessor.COUNT.getName(), "60000"));
-
- Connection connection = connect(generator, getTerminateAllProcessor(), REL_SUCCESS);
- triggerOnce(generator);
-
- FlowFileQueue queue = connection.getFlowFileQueue();
- QueueDiagnostics diagnostics = queue.getQueueDiagnostics();
- LocalQueuePartitionDiagnostics localPartitionDiagnostics = diagnostics.getLocalQueuePartitionDiagnostics();
-
- assertEquals(20_000, localPartitionDiagnostics.getActiveQueueSize().getObjectCount());
- assertEquals(4, localPartitionDiagnostics.getSwapFileCount());
- assertEquals(40_000, localPartitionDiagnostics.getSwapQueueSize().getObjectCount());
- assertEquals(60_000, queue.size().getObjectCount());
-
- // restart nifi
- restart();
-
- // get the new Connection with the same ID
- connection = getRootGroup().getConnection(connection.getIdentifier());
- queue = connection.getFlowFileQueue();
- diagnostics = queue.getQueueDiagnostics();
- localPartitionDiagnostics = diagnostics.getLocalQueuePartitionDiagnostics();
-
- // Ensure we have the correct queue sizes
- assertEquals(20_000, localPartitionDiagnostics.getActiveQueueSize().getObjectCount());
- assertEquals(4, localPartitionDiagnostics.getSwapFileCount());
- assertEquals(40_000, localPartitionDiagnostics.getSwapQueueSize().getObjectCount());
- assertEquals(60_000, queue.size().getObjectCount());
-
- // Consume all the data
- for (int i=0; i < 60_000; i++) {
- final FlowFileRecord flowFile = queue.poll(Collections.emptySet());
- assertNotNull(flowFile);
-
- queue.acknowledge(flowFile);
- }
-
- assertNull(queue.poll(Collections.emptySet()));
-
- // Check queue sizes again
- diagnostics = queue.getQueueDiagnostics();
- localPartitionDiagnostics = diagnostics.getLocalQueuePartitionDiagnostics();
-
- assertEquals(0, localPartitionDiagnostics.getActiveQueueSize().getObjectCount());
- assertEquals(0, localPartitionDiagnostics.getSwapFileCount());
- assertEquals(0, localPartitionDiagnostics.getSwapQueueSize().getObjectCount());
- assertEquals(0, queue.size().getObjectCount());
- }
-
-
- @Test
- public void testSwapOnRestartWithLoadBalancedConnectionRoundRobinStrategy() throws ExecutionException, InterruptedException, IOException {
- final ProcessorNode generator = createProcessorNode(GenerateProcessor.class);
- generator.setProperties(Collections.singletonMap(GenerateProcessor.COUNT.getName(), "60000"));
-
- Connection connection = connect(generator, getTerminateAllProcessor(), REL_SUCCESS);
- FlowFileQueue queue = connection.getFlowFileQueue();
-
- queue.setLoadBalanceStrategy(LoadBalanceStrategy.ROUND_ROBIN, null);
-
- final Set<NodeIdentifier> nodeIdentifiers = getClusterCoordinator().getNodeIdentifiers();
- ((SocketLoadBalancedFlowFileQueue) queue).setNodeIdentifiers(nodeIdentifiers, false);
-
- triggerOnce(generator);
-
- QueueDiagnostics diagnostics = queue.getQueueDiagnostics();
- LocalQueuePartitionDiagnostics localPartitionDiagnostics = diagnostics.getLocalQueuePartitionDiagnostics();
- RemoteQueuePartitionDiagnostics remotePartitionDiagnostics = diagnostics.getRemoteQueuePartitionDiagnostics().get(0);
-
- assertEquals(20_000, localPartitionDiagnostics.getActiveQueueSize().getObjectCount());
- assertEquals(1, localPartitionDiagnostics.getSwapFileCount());
- assertEquals(10_000, localPartitionDiagnostics.getSwapQueueSize().getObjectCount());
-
- assertEquals(2, remotePartitionDiagnostics.getSwapFileCount());
- assertEquals(29_000, remotePartitionDiagnostics.getSwapQueueSize().getObjectCount());
- assertEquals(1_000, remotePartitionDiagnostics.getActiveQueueSize().getObjectCount());
-
- assertEquals(60_000, queue.size().getObjectCount());
-
- // restart nifi
- restart();
-
- // get the new Connection with the same ID
- connection = getRootGroup().getConnection(connection.getIdentifier());
- queue = connection.getFlowFileQueue();
-
- // Ensure we have the correct queue sizes
- assertEquals(60_000, queue.size().getObjectCount());
-
- while (true) {
- triggerOnce((ProcessorNode) connection.getDestination());
- FlowFileRecord polled = queue.poll(Collections.emptySet());
- if (polled == null) {
- break;
- }
-
- queue.acknowledge(polled);
- }
-
- // Check queue sizes again
- diagnostics = queue.getQueueDiagnostics();
- localPartitionDiagnostics = diagnostics.getLocalQueuePartitionDiagnostics();
- remotePartitionDiagnostics = diagnostics.getRemoteQueuePartitionDiagnostics().get(0);
-
- assertEquals(0, localPartitionDiagnostics.getActiveQueueSize().getObjectCount());
- assertEquals(0, localPartitionDiagnostics.getSwapFileCount());
- assertEquals(0, localPartitionDiagnostics.getSwapQueueSize().getObjectCount());
-
- final int queueCount = remotePartitionDiagnostics.getActiveQueueSize().getObjectCount() + remotePartitionDiagnostics.getSwapQueueSize().getObjectCount()
- + remotePartitionDiagnostics.getUnacknowledgedQueueSize().getObjectCount();
-
- assertEquals(queueCount, queue.size().getObjectCount());
- }
-
-
- @Test(timeout = 60_000)
- public void testChangeLoadBalanceStrategyWhileDataSwapped() throws ExecutionException, InterruptedException, IOException {
- final ProcessorNode generator = createProcessorNode(GenerateProcessor.class);
- generator.setProperties(Collections.singletonMap(GenerateProcessor.COUNT.getName(), "60000"));
-
- Connection connection = connect(generator, getTerminateAllProcessor(), REL_SUCCESS);
- triggerOnce(generator);
-
- FlowFileQueue queue = connection.getFlowFileQueue();
- QueueDiagnostics diagnostics = queue.getQueueDiagnostics();
- LocalQueuePartitionDiagnostics localPartitionDiagnostics = diagnostics.getLocalQueuePartitionDiagnostics();
-
- assertEquals(20_000, localPartitionDiagnostics.getActiveQueueSize().getObjectCount());
- assertEquals(4, localPartitionDiagnostics.getSwapFileCount());
- assertEquals(40_000, localPartitionDiagnostics.getSwapQueueSize().getObjectCount());
- assertEquals(60_000, queue.size().getObjectCount());
-
- queue.setLoadBalanceStrategy(LoadBalanceStrategy.ROUND_ROBIN, null);
-
- // Consume all the data
- int polled = 0;
- while (polled < 30_000) {
- final FlowFileRecord flowFile = queue.poll(Collections.emptySet());
- if (flowFile != null) {
- polled++;
- queue.acknowledge(flowFile);
- }
- }
-
- assertNull(queue.poll(Collections.emptySet()));
-
- // Check queue sizes again
- diagnostics = queue.getQueueDiagnostics();
- localPartitionDiagnostics = diagnostics.getLocalQueuePartitionDiagnostics();
-
- assertEquals(0, localPartitionDiagnostics.getActiveQueueSize().getObjectCount());
- assertEquals(0, localPartitionDiagnostics.getSwapFileCount());
- assertEquals(0, localPartitionDiagnostics.getSwapQueueSize().getObjectCount());
- assertEquals(30_000, queue.size().getObjectCount());
-
- queue.setLoadBalanceStrategy(LoadBalanceStrategy.DO_NOT_LOAD_BALANCE, null);
-
- // Consume all the data
- polled = 0;
- while (polled < 30_000) {
- final FlowFileRecord flowFile = queue.poll(Collections.emptySet());
- if (flowFile != null) {
- polled++;
- queue.acknowledge(flowFile);
- }
- }
-
- assertNull(queue.poll(Collections.emptySet()));
-
- // Check queue sizes again
- diagnostics = queue.getQueueDiagnostics();
- localPartitionDiagnostics = diagnostics.getLocalQueuePartitionDiagnostics();
-
- assertEquals(0, localPartitionDiagnostics.getActiveQueueSize().getObjectCount());
- assertEquals(0, localPartitionDiagnostics.getSwapFileCount());
- assertEquals(0, localPartitionDiagnostics.getSwapQueueSize().getObjectCount());
- assertEquals(0, queue.size().getObjectCount());
- }
-
-
- protected FlowFileQueue createFlowFileQueue(final String uuid) {
- final ProcessScheduler processScheduler = getFlowController().getProcessScheduler();
- final ResourceClaimManager resourceClaimManager = getFlowController().getResourceClaimManager();
- final FlowFileSwapManager swapManager = getFlowController().createSwapManager();
-
- final AsyncLoadBalanceClientRegistry clientRegistry = Mockito.mock(AsyncLoadBalanceClientRegistry.class);
-
- return new SocketLoadBalancedFlowFileQueue(uuid, ConnectionEventListener.NOP_EVENT_LISTENER, processScheduler, getFlowFileRepository(), getProvenanceRepository(),
- getContentRepository(), resourceClaimManager, getClusterCoordinator(), clientRegistry, swapManager, 20000, EventReporter.NO_OP);
- }
-
- @Override
- protected boolean isClusteredTest() {
- return true;
- }
-}
diff --git a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/java/org/apache/nifi/leader/election/ITSecureClientZooKeeperFactory.java b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/java/org/apache/nifi/leader/election/ITSecureClientZooKeeperFactory.java
index dc9f9fc810..f08461b603 100644
--- a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/java/org/apache/nifi/leader/election/ITSecureClientZooKeeperFactory.java
+++ b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/java/org/apache/nifi/leader/election/ITSecureClientZooKeeperFactory.java
@@ -28,9 +28,10 @@ import org.apache.zookeeper.common.ClientX509Util;
import org.apache.zookeeper.data.Stat;
import org.apache.zookeeper.server.ServerCnxnFactory;
import org.apache.zookeeper.server.ZooKeeperServer;
-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.junit.jupiter.api.Timeout;
import java.io.FileOutputStream;
import java.io.IOException;
@@ -51,8 +52,8 @@ import java.util.Arrays;
import java.util.List;
import java.util.Properties;
-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;
public class ITSecureClientZooKeeperFactory {
@@ -74,7 +75,7 @@ public class ITSecureClientZooKeeperFactory {
private static Path clientTrustStore;
private static int clientPort;
- @BeforeClass
+ @BeforeAll
public static void setup() throws IOException, GeneralSecurityException, InterruptedException {
tempDir = Paths.get("target/TestSecureClientZooKeeperFactory");
dataDir = tempDir.resolve("state");
@@ -115,7 +116,7 @@ public class ITSecureClientZooKeeperFactory {
zkServer = serverConnectionFactory.getZooKeeperServer();
}
- @AfterClass
+ @AfterAll
public static void cleanup() {
if (serverConnectionFactory != null) {
try {
@@ -154,7 +155,8 @@ public class ITSecureClientZooKeeperFactory {
assertEquals("org.apache.zookeeper.ClientCnxnSocketNetty", SecureClientZooKeeperFactory.NETTY_CLIENT_CNXN_SOCKET);
}
- @Test(timeout = 30_000)
+ @Test
+ @Timeout(30)
public void testServerCreatePath() throws Exception {
final ZooKeeperClientConfig zkClientConfig =
ZooKeeperClientConfig.createConfig(clientProperties);
diff --git a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/java/org/apache/nifi/persistence/TemplateSerializerTest.java b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/java/org/apache/nifi/persistence/TemplateSerializerTest.java
index a3dbec19a1..2948c55114 100644
--- a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/java/org/apache/nifi/persistence/TemplateSerializerTest.java
+++ b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/java/org/apache/nifi/persistence/TemplateSerializerTest.java
@@ -27,7 +27,7 @@ import org.eclipse.jgit.diff.EditList;
import org.eclipse.jgit.diff.HistogramDiff;
import org.eclipse.jgit.diff.RawText;
import org.eclipse.jgit.diff.RawTextComparator;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import javax.xml.bind.JAXBContext;
import javax.xml.bind.JAXBElement;
@@ -44,7 +44,7 @@ import java.util.List;
import java.util.Set;
import java.util.stream.Collectors;
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
public class TemplateSerializerTest {
diff --git a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/java/org/apache/nifi/registry/flow/mapping/NiFiRegistryFlowMapperTest.java b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/java/org/apache/nifi/registry/flow/mapping/NiFiRegistryFlowMapperTest.java
index fa5152a4a6..02cbd19865 100644
--- a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/java/org/apache/nifi/registry/flow/mapping/NiFiRegistryFlowMapperTest.java
+++ b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/java/org/apache/nifi/registry/flow/mapping/NiFiRegistryFlowMapperTest.java
@@ -81,13 +81,15 @@ import org.apache.nifi.remote.RemoteGroupPort;
import org.apache.nifi.remote.protocol.SiteToSiteTransportProtocol;
import org.apache.nifi.scheduling.ExecutionNode;
import org.apache.nifi.scheduling.SchedulingStrategy;
-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.Answers;
import org.mockito.Mock;
import org.mockito.Mockito;
-import org.mockito.junit.MockitoJUnitRunner;
+import org.mockito.junit.jupiter.MockitoExtension;
+import org.mockito.junit.jupiter.MockitoSettings;
+import org.mockito.quality.Strictness;
import java.util.Arrays;
import java.util.Collection;
@@ -111,7 +113,8 @@ import static org.mockito.ArgumentMatchers.anyString;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
-@RunWith(MockitoJUnitRunner.class)
+@ExtendWith(MockitoExtension.class)
+@MockitoSettings(strictness = Strictness.LENIENT)
public class NiFiRegistryFlowMapperTest {
private static final String PARAMETER_PROVIDER_ID = "id";
@@ -132,7 +135,7 @@ public class NiFiRegistryFlowMapperTest {
private int counter = 1;
- @Before
+ @BeforeEach
public void setup() {
final FlowRegistryClientNode flowRegistry = mock(FlowRegistryClientNode.class);
Mockito.when(flowRegistry.getComponentType()).thenReturn(TestNifiRegistryFlowRegistryClient.class.getName());
diff --git a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/java/org/apache/nifi/util/TestFileBasedVariableRegistry.java b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/java/org/apache/nifi/util/TestFileBasedVariableRegistry.java
index daed0e09df..4e4abc2aea 100644
--- a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/java/org/apache/nifi/util/TestFileBasedVariableRegistry.java
+++ b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/java/org/apache/nifi/util/TestFileBasedVariableRegistry.java
@@ -22,9 +22,9 @@ import java.util.Map;
import org.apache.nifi.registry.VariableDescriptor;
import org.apache.nifi.registry.VariableRegistry;
import org.apache.nifi.registry.variable.FileBasedVariableRegistry;
-import org.junit.Test;
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.assertEquals;
+import org.junit.jupiter.api.Test;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertEquals;
/**
*