NIFI-9041 Replaced JUnit 4 only testing configuration with a combination of JUnit 5 and JUnit Vintage.
- Updated nifi-mock to be exclusively JUnit 5
- Updated a few modules to demonstrate a successful conversion to all JUnit 5
This closes #5304
Signed-off-by: David Handermann <exceptionfactory@apache.org>
diff --git a/nifi-mock/pom.xml b/nifi-mock/pom.xml
index 8688dff..08ea3e2 100644
--- a/nifi-mock/pom.xml
+++ b/nifi-mock/pom.xml
@@ -66,8 +66,8 @@
<dependency>
<!-- Dependency marked as compile, not test, because we have assertion
methods in our MockSession & MockFlowFile -->
- <groupId>junit</groupId>
- <artifactId>junit</artifactId>
+ <groupId>org.junit.jupiter</groupId>
+ <artifactId>junit-jupiter-api</artifactId>
<scope>compile</scope>
</dependency>
</dependencies>
diff --git a/nifi-mock/src/main/java/org/apache/nifi/state/MockStateManager.java b/nifi-mock/src/main/java/org/apache/nifi/state/MockStateManager.java
index 1cc8a39..ad86864 100644
--- a/nifi-mock/src/main/java/org/apache/nifi/state/MockStateManager.java
+++ b/nifi-mock/src/main/java/org/apache/nifi/state/MockStateManager.java
@@ -21,7 +21,7 @@
import org.apache.nifi.components.state.Scope;
import org.apache.nifi.components.state.StateManager;
import org.apache.nifi.components.state.StateMap;
-import org.junit.Assert;
+import org.junit.jupiter.api.Assertions;
import java.io.IOException;
import java.util.Collections;
@@ -170,7 +170,7 @@
// ensure that the @Stateful annotation is present with the appropriate Scope
if ((scope == Scope.LOCAL && !usesLocalState) || (scope == Scope.CLUSTER && !usesClusterState)) {
- Assert.fail("Component is attempting to set or retrieve state with a scope of " + scope + " but does not declare that it will use "
+ Assertions.fail("Component is attempting to set or retrieve state with a scope of " + scope + " but does not declare that it will use "
+ scope + " state. A @Stateful annotation should be added to the component with a scope of " + scope);
}
}
@@ -197,7 +197,7 @@
* @param scope the scope
*/
public void assertStateEquals(final String key, final String value, final Scope scope) {
- Assert.assertEquals(value, getValue(key, scope));
+ Assertions.assertEquals(value, getValue(key, scope));
}
/**
@@ -208,7 +208,7 @@
*/
public void assertStateEquals(final Map<String, String> stateValues, final Scope scope) {
final StateMap stateMap = retrieveState(scope);
- Assert.assertEquals(stateValues, stateMap.toMap());
+ Assertions.assertEquals(stateValues, stateMap.toMap());
}
/**
@@ -219,7 +219,7 @@
*/
public void assertStateNotEquals(final Map<String, String> stateValues, final Scope scope) {
final StateMap stateMap = retrieveState(scope);
- Assert.assertNotSame(stateValues, stateMap.toMap());
+ Assertions.assertNotSame(stateValues, stateMap.toMap());
}
/**
@@ -230,7 +230,7 @@
* @param scope the scope
*/
public void assertStateNotEquals(final String key, final String value, final Scope scope) {
- Assert.assertNotEquals(value, getValue(key, scope));
+ Assertions.assertNotEquals(value, getValue(key, scope));
}
/**
@@ -240,7 +240,7 @@
* @param scope the scope
*/
public void assertStateSet(final String key, final Scope scope) {
- Assert.assertNotNull("Expected state to be set for key " + key + " and scope " + scope + ", but it was not set", getValue(key, scope));
+ Assertions.assertNotNull(getValue(key, scope), "Expected state to be set for key " + key + " and scope " + scope + ", but it was not set");
}
/**
@@ -250,7 +250,7 @@
* @param scope the scope
*/
public void assertStateNotSet(final String key, final Scope scope) {
- Assert.assertNull("Expected state not to be set for key " + key + " and scope " + scope + ", but it was set", getValue(key, scope));
+ Assertions.assertNull(getValue(key, scope), "Expected state not to be set for key " + key + " and scope " + scope + ", but it was set");
}
/**
@@ -260,7 +260,7 @@
*/
public void assertStateSet(final Scope scope) {
final StateMap stateMap = (scope == Scope.CLUSTER) ? clusterStateMap : localStateMap;
- Assert.assertNotSame("Expected state to be set for Scope " + scope + ", but it was not set", -1L, stateMap.getVersion());
+ Assertions.assertNotSame(-1L, stateMap.getVersion(), "Expected state to be set for Scope " + scope + ", but it was not set");
}
/**
@@ -278,7 +278,7 @@
*/
public void assertStateNotSet(final Scope scope) {
final StateMap stateMap = (scope == Scope.CLUSTER) ? clusterStateMap : localStateMap;
- Assert.assertEquals("Expected state not to be set for Scope " + scope + ", but it was set", -1L, stateMap.getVersion());
+ Assertions.assertEquals(-1L, stateMap.getVersion(), "Expected state not to be set for Scope " + scope + ", but it was set");
}
/**
diff --git a/nifi-mock/src/main/java/org/apache/nifi/util/MockFlowFile.java b/nifi-mock/src/main/java/org/apache/nifi/util/MockFlowFile.java
index 254320e..7ee30a7 100644
--- a/nifi-mock/src/main/java/org/apache/nifi/util/MockFlowFile.java
+++ b/nifi-mock/src/main/java/org/apache/nifi/util/MockFlowFile.java
@@ -38,7 +38,7 @@
import org.apache.nifi.controller.repository.claim.ContentClaim;
import org.apache.nifi.flowfile.FlowFile;
import org.apache.nifi.flowfile.attributes.CoreAttributes;
-import org.junit.Assert;
+import org.junit.jupiter.api.Assertions;
public class MockFlowFile implements FlowFileRecord {
@@ -217,21 +217,21 @@
}
public void assertAttributeExists(final String attributeName) {
- Assert.assertTrue("Attribute " + attributeName + " does not exist", attributes.containsKey(attributeName));
+ Assertions.assertTrue(attributes.containsKey(attributeName), "Attribute " + attributeName + " does not exist");
}
public void assertAttributeNotExists(final String attributeName) {
- Assert.assertFalse("Attribute " + attributeName + " should not exist on FlowFile, but exists with value "
- + attributes.get(attributeName), attributes.containsKey(attributeName));
+ Assertions.assertFalse(attributes.containsKey(attributeName), "Attribute " + attributeName + " should not exist on FlowFile, but exists with value "
+ + attributes.get(attributeName));
}
public void assertAttributeEquals(final String attributeName, final String expectedValue) {
- Assert.assertEquals("Expected attribute " + attributeName + " to be " + expectedValue + " but instead it was " + attributes.get(attributeName),
- expectedValue, attributes.get(attributeName));
+ Assertions.assertEquals(expectedValue, attributes.get(attributeName), "Expected attribute " + attributeName + " to be " +
+ expectedValue + " but instead it was " + attributes.get(attributeName));
}
public void assertAttributeNotEquals(final String attributeName, final String expectedValue) {
- Assert.assertNotSame(expectedValue, attributes.get(attributeName));
+ Assertions.assertNotSame(expectedValue, attributes.get(attributeName));
}
/**
@@ -281,7 +281,7 @@
public void assertContentEquals(final String data, final Charset charset) {
final String value = new String(this.data, charset);
- Assert.assertEquals(data, value);
+ Assertions.assertEquals(data, value);
}
/**
@@ -298,11 +298,11 @@
for (int i = 0; i < data.length; i++) {
final int fromStream = buffered.read();
if (fromStream < 0) {
- Assert.fail("FlowFile content is " + data.length + " bytes but provided input is only " + bytesRead + " bytes");
+ Assertions.fail("FlowFile content is " + data.length + " bytes but provided input is only " + bytesRead + " bytes");
}
if ((fromStream & 0xFF) != (data[i] & 0xFF)) {
- Assert.fail("FlowFile content differs from input at byte " + bytesRead + " with input having value "
+ Assertions.fail("FlowFile content differs from input at byte " + bytesRead + " with input having value "
+ (fromStream & 0xFF) + " and FlowFile having value " + (data[i] & 0xFF));
}
@@ -311,7 +311,7 @@
final int nextByte = buffered.read();
if (nextByte >= 0) {
- Assert.fail("Contents of input and FlowFile were the same through byte " + data.length + "; however, FlowFile's content ended at this point, and input has more data");
+ Assertions.fail("Contents of input and FlowFile were the same through byte " + data.length + "; however, FlowFile's content ended at this point, and input has more data");
}
}
}
diff --git a/nifi-mock/src/main/java/org/apache/nifi/util/MockProcessContext.java b/nifi-mock/src/main/java/org/apache/nifi/util/MockProcessContext.java
index e2199f4..5c8a8e8 100644
--- a/nifi-mock/src/main/java/org/apache/nifi/util/MockProcessContext.java
+++ b/nifi-mock/src/main/java/org/apache/nifi/util/MockProcessContext.java
@@ -34,7 +34,7 @@
import org.apache.nifi.registry.VariableRegistry;
import org.apache.nifi.scheduling.ExecutionNode;
import org.apache.nifi.state.MockStateManager;
-import org.junit.Assert;
+import org.junit.jupiter.api.Assertions;
import java.util.ArrayList;
import java.util.Collection;
@@ -412,7 +412,7 @@
}
if (failureCount > 0) {
- Assert.fail("Processor has " + failureCount + " validation failures:\n" + sb.toString());
+ Assertions.fail("Processor has " + failureCount + " validation failures:\n" + sb.toString());
}
}
diff --git a/nifi-mock/src/main/java/org/apache/nifi/util/MockProcessSession.java b/nifi-mock/src/main/java/org/apache/nifi/util/MockProcessSession.java
index a4a967b..163fc78 100644
--- a/nifi-mock/src/main/java/org/apache/nifi/util/MockProcessSession.java
+++ b/nifi-mock/src/main/java/org/apache/nifi/util/MockProcessSession.java
@@ -34,7 +34,7 @@
import org.apache.nifi.processor.io.StreamCallback;
import org.apache.nifi.provenance.ProvenanceReporter;
import org.apache.nifi.state.MockStateManager;
-import org.junit.Assert;
+import org.junit.jupiter.api.Assertions;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
@@ -565,7 +565,7 @@
}
if ("uuid".equals(attrName)) {
- Assert.fail("Should not be attempting to set FlowFile UUID via putAttribute. This will be ignored in production");
+ Assertions.fail("Should not be attempting to set FlowFile UUID via putAttribute. This will be ignored in production");
}
final MockFlowFile mock = (MockFlowFile) flowFile;
@@ -1203,28 +1203,28 @@
* Assert that the session has been committed
*/
public void assertCommitted() {
- Assert.assertTrue("Session was not committed", committed);
+ Assertions.assertTrue(committed, "Session was not committed");
}
/**
* Assert that the session has not been committed
*/
public void assertNotCommitted() {
- Assert.assertFalse("Session was committed", committed);
+ Assertions.assertFalse(committed, "Session was committed");
}
/**
* Assert that {@link #rollback()} has been called
*/
public void assertRolledBack() {
- Assert.assertTrue("Session was not rolled back", rolledback);
+ Assertions.assertTrue(rolledback, "Session was not rolled back");
}
/**
* Assert that {@link #rollback()} has not been called
*/
public void assertNotRolledBack() {
- Assert.assertFalse("Session was rolled back", rolledback);
+ Assertions.assertFalse(rolledback, "Session was rolled back");
}
/**
@@ -1236,8 +1236,8 @@
*/
public void assertTransferCount(final Relationship relationship, final int count) {
final int transferCount = getFlowFilesForRelationship(relationship).size();
- Assert.assertEquals("Expected " + count + " FlowFiles to be transferred to "
- + relationship + " but actual transfer count was " + transferCount, count, transferCount);
+ Assertions.assertEquals(count, transferCount, "Expected " + count + " FlowFiles to be transferred to "
+ + relationship + " but actual transfer count was " + transferCount);
}
/**
@@ -1255,14 +1255,14 @@
* Assert that there are no FlowFiles left on the input queue.
*/
public void assertQueueEmpty() {
- Assert.assertTrue("FlowFile Queue has " + this.processorQueue.size() + " items", this.processorQueue.isEmpty());
+ Assertions.assertTrue(this.processorQueue.isEmpty(), "FlowFile Queue has " + this.processorQueue.size() + " items");
}
/**
* Assert that at least one FlowFile is on the input queue
*/
public void assertQueueNotEmpty() {
- Assert.assertFalse("FlowFile Queue is empty", this.processorQueue.isEmpty());
+ Assertions.assertFalse(this.processorQueue.isEmpty(), "FlowFile Queue is empty");
}
/**
@@ -1287,7 +1287,7 @@
final List<MockFlowFile> flowFiles = entry.getValue();
if (!rel.equals(relationship) && flowFiles != null && !flowFiles.isEmpty()) {
- Assert.fail("Expected all Transferred FlowFiles to go to " + relationship + " but " + flowFiles.size() + " were routed to " + rel);
+ Assertions.fail("Expected all Transferred FlowFiles to go to " + relationship + " but " + flowFiles.size() + " were routed to " + rel);
}
}
}
diff --git a/nifi-mock/src/main/java/org/apache/nifi/util/StandardProcessorTestRunner.java b/nifi-mock/src/main/java/org/apache/nifi/util/StandardProcessorTestRunner.java
index 27de55d..d489177 100644
--- a/nifi-mock/src/main/java/org/apache/nifi/util/StandardProcessorTestRunner.java
+++ b/nifi-mock/src/main/java/org/apache/nifi/util/StandardProcessorTestRunner.java
@@ -43,7 +43,7 @@
import org.apache.nifi.registry.VariableDescriptor;
import org.apache.nifi.reporting.InitializationException;
import org.apache.nifi.state.MockStateManager;
-import org.junit.Assert;
+import org.junit.jupiter.api.Assertions;
import java.io.ByteArrayInputStream;
import java.io.IOException;
@@ -131,7 +131,7 @@
try {
ReflectionUtils.invokeMethodsWithAnnotation(OnAdded.class, processor);
} catch (final Exception e) {
- Assert.fail("Could not invoke methods annotated with @OnAdded annotation due to: " + e);
+ Assertions.fail("Could not invoke methods annotated with @OnAdded annotation due to: " + e);
}
triggerSerially = null != processor.getClass().getAnnotation(TriggerSerially.class);
@@ -201,7 +201,7 @@
ReflectionUtils.invokeMethodsWithAnnotation(OnScheduled.class, processor, context);
} catch (final Exception e) {
e.printStackTrace();
- Assert.fail("Could not invoke methods annotated with @OnScheduled annotation due to: " + e);
+ Assertions.fail("Could not invoke methods annotated with @OnScheduled annotation due to: " + e);
}
}
@@ -252,7 +252,7 @@
try {
ReflectionUtils.invokeMethodsWithAnnotation(OnUnscheduled.class, processor, context);
} catch (final Exception e) {
- Assert.fail("Could not invoke methods annotated with @OnUnscheduled annotation due to: " + e);
+ Assertions.fail("Could not invoke methods annotated with @OnUnscheduled annotation due to: " + e);
}
}
@@ -260,7 +260,7 @@
try {
ReflectionUtils.invokeMethodsWithAnnotation(OnStopped.class, processor, context);
} catch (final Exception e) {
- Assert.fail("Could not invoke methods annotated with @OnStopped annotation due to: " + e);
+ Assertions.fail("Could not invoke methods annotated with @OnStopped annotation due to: " + e);
}
}
@@ -269,7 +269,7 @@
try {
ReflectionUtils.invokeMethodsWithAnnotation(OnShutdown.class, processor);
} catch (final Exception e) {
- Assert.fail("Could not invoke methods annotated with @OnShutdown annotation due to: " + e);
+ Assertions.fail("Could not invoke methods annotated with @OnShutdown annotation due to: " + e);
}
}
@@ -318,7 +318,7 @@
assertAllFlowFiles(new FlowFileValidator() {
@Override
public void assertFlowFile(FlowFile f) {
- Assert.assertTrue(f.getAttribute(attributeName) != null);
+ Assertions.assertTrue(f.getAttribute(attributeName) != null);
}
});
}
@@ -328,7 +328,7 @@
assertAllFlowFiles(relationship, new FlowFileValidator() {
@Override
public void assertFlowFile(FlowFile f) {
- Assert.assertTrue(f.getAttribute(attributeName) != null);
+ Assertions.assertTrue(f.getAttribute(attributeName) != null);
}
});
}
@@ -355,17 +355,17 @@
@Override
public void assertTransferCount(final Relationship relationship, final int count) {
- Assert.assertEquals(count, getFlowFilesForRelationship(relationship).size());
+ Assertions.assertEquals(count, getFlowFilesForRelationship(relationship).size());
}
@Override
public void assertTransferCount(final String relationship, final int count) {
- Assert.assertEquals(count, getFlowFilesForRelationship(relationship).size());
+ Assertions.assertEquals(count, getFlowFilesForRelationship(relationship).size());
}
@Override
public void assertPenalizeCount(final int count) {
- Assert.assertEquals(count, getPenalizedFlowFiles().size());
+ Assertions.assertEquals(count, getPenalizedFlowFiles().size());
}
@Override
@@ -375,7 +375,7 @@
@Override
public void assertNotValid() {
- Assert.assertFalse("Processor appears to be valid but expected it to be invalid", context.isValid());
+ Assertions.assertFalse(context.isValid(), "Processor appears to be valid but expected it to be invalid");
}
@Override
@@ -385,12 +385,12 @@
@Override
public void assertQueueEmpty() {
- Assert.assertTrue(flowFileQueue.isEmpty());
+ Assertions.assertTrue(flowFileQueue.isEmpty());
}
@Override
public void assertQueueNotEmpty() {
- Assert.assertFalse(flowFileQueue.isEmpty());
+ Assertions.assertFalse(flowFileQueue.isEmpty());
}
@Override
@@ -540,7 +540,7 @@
@Override
public void setThreadCount(final int threadCount) {
if (threadCount > 1 && triggerSerially) {
- Assert.fail("Cannot set thread-count higher than 1 because the processor is triggered serially");
+ Assertions.fail("Cannot set thread-count higher than 1 because the processor is triggered serially");
}
this.numThreads = threadCount;
@@ -652,7 +652,7 @@
}
}
- Assert.fail("Expected Controller Service " + service + " to be invalid but it is valid");
+ Assertions.fail("Expected Controller Service " + service + " to be invalid but it is valid");
}
@Override
@@ -667,7 +667,7 @@
for (final ValidationResult result : results) {
if (!result.isValid()) {
- Assert.fail("Expected Controller Service to be valid but it is invalid due to: " + result.toString());
+ Assertions.fail("Expected Controller Service to be valid but it is invalid due to: " + result.toString());
}
}
}
@@ -687,7 +687,7 @@
ReflectionUtils.invokeMethodsWithAnnotation(OnDisabled.class, service);
} catch (final Exception e) {
e.printStackTrace();
- Assert.fail("Failed to disable Controller Service " + service + " due to " + e);
+ Assertions.fail("Failed to disable Controller Service " + service + " due to " + e);
}
configuration.setEnabled(false);
@@ -723,10 +723,10 @@
ReflectionUtils.invokeMethodsWithAnnotation(OnEnabled.class, service, configContext);
} catch (final InvocationTargetException ite) {
ite.getCause().printStackTrace();
- Assert.fail("Failed to enable Controller Service " + service + " due to " + ite.getCause());
+ Assertions.fail("Failed to enable Controller Service " + service + " due to " + ite.getCause());
} catch (final Exception e) {
e.printStackTrace();
- Assert.fail("Failed to enable Controller Service " + service + " due to " + e);
+ Assertions.fail("Failed to enable Controller Service " + service + " due to " + e);
}
configuration.setEnabled(true);
@@ -752,7 +752,7 @@
ReflectionUtils.invokeMethodsWithAnnotation(OnRemoved.class, service);
} catch (final Exception e) {
e.printStackTrace();
- Assert.fail("Failed to remove Controller Service " + service + " due to " + e);
+ Assertions.fail("Failed to remove Controller Service " + service + " due to " + e);
}
context.removeControllerService(service);
@@ -989,18 +989,18 @@
public void assertAllConditionsMet(final Relationship relationship, Predicate<MockFlowFile> predicate) {
if (predicate==null) {
- Assert.fail("predicate cannot be null");
+ Assertions.fail("predicate cannot be null");
}
final List<MockFlowFile> flowFiles = getFlowFilesForRelationship(relationship);
if (flowFiles.isEmpty()) {
- Assert.fail("Relationship " + relationship.getName() + " does not contain any FlowFile");
+ Assertions.fail("Relationship " + relationship.getName() + " does not contain any FlowFile");
}
for (MockFlowFile flowFile : flowFiles) {
if (predicate.test(flowFile)==false) {
- Assert.fail("FlowFile " + flowFile + " does not meet all condition");
+ Assertions.fail("FlowFile " + flowFile + " does not meet all condition");
}
}
}
diff --git a/nifi-mock/src/main/java/org/apache/nifi/util/TestRunner.java b/nifi-mock/src/main/java/org/apache/nifi/util/TestRunner.java
index f16fb79..fde8c6a 100644
--- a/nifi-mock/src/main/java/org/apache/nifi/util/TestRunner.java
+++ b/nifi-mock/src/main/java/org/apache/nifi/util/TestRunner.java
@@ -211,7 +211,7 @@
/**
* Updates the value of the property with the given PropertyDescriptor to
* the specified value IF and ONLY IF the value is valid according to the
- * descriptor's validator. Otherwise, Assert.fail() is called, causing the
+ * descriptor's validator. Otherwise, Assertions.fail() is called, causing the
* unit test to fail
*
* @param propertyName name
@@ -223,7 +223,7 @@
/**
* Updates the value of the property with the given PropertyDescriptor to
* the specified value IF and ONLY IF the value is valid according to the
- * descriptor's validator. Otherwise, Assert.fail() is called, causing the
+ * descriptor's validator. Otherwise, Assertions.fail() is called, causing the
* unit test to fail
*
* @param descriptor descriptor
@@ -235,7 +235,7 @@
/**
* Updates the value of the property with the given PropertyDescriptor to
* the specified value IF and ONLY IF the value is valid according to the
- * descriptor's validator. Otherwise, Assert.fail() is called, causing the
+ * descriptor's validator. Otherwise, Assertions.fail() is called, causing the
* unit test to fail
*
* @param descriptor descriptor
diff --git a/nifi-mock/src/test/java/org/apache/nifi/util/CurrentTestStandardProcessorTestRunner.java b/nifi-mock/src/test/java/org/apache/nifi/util/CurrentTestStandardProcessorTestRunner.java
index 6b403af..cde947e 100644
--- a/nifi-mock/src/test/java/org/apache/nifi/util/CurrentTestStandardProcessorTestRunner.java
+++ b/nifi-mock/src/test/java/org/apache/nifi/util/CurrentTestStandardProcessorTestRunner.java
@@ -21,7 +21,7 @@
import org.apache.nifi.processor.ProcessSession;
import org.apache.nifi.processor.exception.ProcessException;
import org.junit.Assert;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
public class CurrentTestStandardProcessorTestRunner {
diff --git a/nifi-mock/src/test/java/org/apache/nifi/util/TestMockProcessContext.java b/nifi-mock/src/test/java/org/apache/nifi/util/TestMockProcessContext.java
index f83db9f..241394a 100644
--- a/nifi-mock/src/test/java/org/apache/nifi/util/TestMockProcessContext.java
+++ b/nifi-mock/src/test/java/org/apache/nifi/util/TestMockProcessContext.java
@@ -31,7 +31,7 @@
import org.apache.nifi.processor.ProcessSession;
import org.apache.nifi.processor.exception.ProcessException;
import org.apache.nifi.processor.util.StandardValidators;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
public class TestMockProcessContext {
diff --git a/nifi-mock/src/test/java/org/apache/nifi/util/TestMockProcessSession.java b/nifi-mock/src/test/java/org/apache/nifi/util/TestMockProcessSession.java
index 8e64988..eefd4a3 100644
--- a/nifi-mock/src/test/java/org/apache/nifi/util/TestMockProcessSession.java
+++ b/nifi-mock/src/test/java/org/apache/nifi/util/TestMockProcessSession.java
@@ -26,8 +26,7 @@
import org.apache.nifi.processor.exception.ProcessException;
import org.apache.nifi.state.MockStateManager;
import org.apache.nifi.stream.io.StreamUtils;
-import org.junit.Assert;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import java.io.IOException;
import java.io.InputStream;
@@ -35,9 +34,11 @@
import java.util.Set;
import java.util.concurrent.atomic.AtomicLong;
-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.junit.jupiter.api.Assertions.assertThrows;
+import static org.junit.jupiter.api.Assertions.fail;
public class TestMockProcessSession {
@@ -54,7 +55,7 @@
try {
session.commit();
- Assert.fail("Was able to commit session without closing InputStream");
+ fail("Was able to commit session without closing InputStream");
} catch (final FlowFileHandlingException | IllegalStateException e) {
System.out.println(e.toString());
}
@@ -73,7 +74,7 @@
try {
session.commitAsync();
- Assert.fail("Was able to commit session without closing InputStream");
+ fail("Was able to commit session without closing InputStream");
} catch (final FlowFileHandlingException | IllegalStateException e) {
System.out.println(e.toString());
}
@@ -87,26 +88,26 @@
final Relationship fakeRel = new Relationship.Builder().name("FAKE").build();
try {
session.transfer(ff1, fakeRel);
- Assert.fail("Should have thrown IllegalArgumentException");
+ fail("Should have thrown IllegalArgumentException");
} catch (final IllegalArgumentException ie) {
}
try {
session.transfer(Collections.singleton(ff1), fakeRel);
- Assert.fail("Should have thrown IllegalArgumentException");
+ fail("Should have thrown IllegalArgumentException");
} catch (final IllegalArgumentException ie) {
}
}
- @Test(expected = IllegalArgumentException.class)
+ @Test
public void testRejectTransferNewlyCreatedFileToSelf() {
final Processor processor = new PoorlyBehavedProcessor();
final MockProcessSession session = new MockProcessSession(new SharedSessionState(processor, new AtomicLong(0L)), processor, new MockStateManager(processor));
final FlowFile ff1 = session.createFlowFile("hello, world".getBytes());
// this should throw an exception because we shouldn't allow a newly created flowfile to get routed back to self
- session.transfer(ff1);
+ assertThrows(IllegalArgumentException.class, () -> session.transfer(ff1));
}
@Test
diff --git a/nifi-mock/src/test/java/org/apache/nifi/util/TestStandardProcessorTestRunner.java b/nifi-mock/src/test/java/org/apache/nifi/util/TestStandardProcessorTestRunner.java
index f2febb4..b7025f8 100644
--- a/nifi-mock/src/test/java/org/apache/nifi/util/TestStandardProcessorTestRunner.java
+++ b/nifi-mock/src/test/java/org/apache/nifi/util/TestStandardProcessorTestRunner.java
@@ -19,6 +19,7 @@
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertThrows;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
@@ -43,7 +44,7 @@
import org.apache.nifi.processor.Relationship;
import org.apache.nifi.processor.exception.ProcessException;
import org.apache.nifi.reporting.InitializationException;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
public class TestStandardProcessorTestRunner {
@@ -131,27 +132,24 @@
});
}
- @Test(expected = AssertionError.class)
+ @Test
public void testFailFlowFileValidator() {
final AddAttributeProcessor proc = new AddAttributeProcessor();
final TestRunner runner = TestRunners.newTestRunner(proc);
runner.run(5, true);
- runner.assertAllFlowFiles(new FlowFileValidator() {
- @Override
- public void assertFlowFile(FlowFile f) {
- assertEquals("value", f.getAttribute(AddAttributeProcessor.KEY));
- }
+ assertThrows(AssertionError.class, () -> {
+ runner.assertAllFlowFiles(f -> assertEquals("value", f.getAttribute(AddAttributeProcessor.KEY)));
});
}
- @Test(expected = AssertionError.class)
+ @Test
public void testFailAllFlowFilesContainAttribute() {
final AddAttributeProcessor proc = new AddAttributeProcessor();
final TestRunner runner = TestRunners.newTestRunner(proc);
runner.run(5, true);
- runner.assertAllFlowFilesContainAttribute(AddAttributeProcessor.KEY);
+ assertThrows(AssertionError.class, () -> runner.assertAllFlowFilesContainAttribute(AddAttributeProcessor.KEY));
}
@Test
diff --git a/nifi-nar-bundles/nifi-email-bundle/nifi-email-processors/pom.xml b/nifi-nar-bundles/nifi-email-bundle/nifi-email-processors/pom.xml
index cdc936b..75423b9 100644
--- a/nifi-nar-bundles/nifi-email-bundle/nifi-email-processors/pom.xml
+++ b/nifi-nar-bundles/nifi-email-bundle/nifi-email-processors/pom.xml
@@ -121,5 +121,11 @@
<version>1.5.11</version>
<scope>test</scope>
</dependency>
+ <dependency>
+ <groupId>org.hamcrest</groupId>
+ <artifactId>hamcrest-core</artifactId>
+ <version>2.2</version>
+ <scope>test</scope>
+ </dependency>
</dependencies>
</project>
diff --git a/nifi-nar-bundles/nifi-graph-bundle/nifi-graph-processors/src/test/java/org/apache/nifi/processors/graph/ExecuteGraphQueryIT.java b/nifi-nar-bundles/nifi-graph-bundle/nifi-graph-processors/src/test/java/org/apache/nifi/processors/graph/ExecuteGraphQueryIT.java
index 7f9e2ef..769fd4a 100644
--- a/nifi-nar-bundles/nifi-graph-bundle/nifi-graph-processors/src/test/java/org/apache/nifi/processors/graph/ExecuteGraphQueryIT.java
+++ b/nifi-nar-bundles/nifi-graph-bundle/nifi-graph-processors/src/test/java/org/apache/nifi/processors/graph/ExecuteGraphQueryIT.java
@@ -22,8 +22,8 @@
import org.apache.nifi.util.MockFlowFile;
import org.apache.nifi.util.TestRunner;
import org.apache.nifi.util.TestRunners;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
import java.util.List;
import java.util.Map;
@@ -37,7 +37,7 @@
"}\n" +
"g.V().hasLabel(\"test\").count().next()";
- @Before
+ @BeforeEach
public void setUp() throws Exception {
InMemoryJanusGraphClientService service = new InMemoryJanusGraphClientService();
runner = TestRunners.newTestRunner(ExecuteGraphQuery.class);
diff --git a/nifi-nar-bundles/nifi-graph-bundle/nifi-graph-processors/src/test/java/org/apache/nifi/processors/graph/ExecuteGraphQueryRecordTest.java b/nifi-nar-bundles/nifi-graph-bundle/nifi-graph-processors/src/test/java/org/apache/nifi/processors/graph/ExecuteGraphQueryRecordTest.java
index b832423..668da17 100644
--- a/nifi-nar-bundles/nifi-graph-bundle/nifi-graph-processors/src/test/java/org/apache/nifi/processors/graph/ExecuteGraphQueryRecordTest.java
+++ b/nifi-nar-bundles/nifi-graph-bundle/nifi-graph-processors/src/test/java/org/apache/nifi/processors/graph/ExecuteGraphQueryRecordTest.java
@@ -26,8 +26,8 @@
import org.apache.nifi.util.TestRunners;
import org.apache.nifi.json.JsonTreeReader;
import org.apache.nifi.serialization.record.MockRecordWriter;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
import java.io.IOException;
import java.io.InputStream;
@@ -44,7 +44,7 @@
private TestRunner runner;
Map<String, String> enqueProperties = new HashMap<>();
- @Before
+ @BeforeEach
public void setup() throws InitializationException {
MockRecordWriter writer = new MockRecordWriter();
JsonTreeReader reader = new JsonTreeReader();
diff --git a/nifi-nar-bundles/nifi-graph-bundle/nifi-graph-processors/src/test/java/org/apache/nifi/processors/graph/TestExecuteGraphQuery.java b/nifi-nar-bundles/nifi-graph-bundle/nifi-graph-processors/src/test/java/org/apache/nifi/processors/graph/TestExecuteGraphQuery.java
index cdcd112..85be628 100644
--- a/nifi-nar-bundles/nifi-graph-bundle/nifi-graph-processors/src/test/java/org/apache/nifi/processors/graph/TestExecuteGraphQuery.java
+++ b/nifi-nar-bundles/nifi-graph-bundle/nifi-graph-processors/src/test/java/org/apache/nifi/processors/graph/TestExecuteGraphQuery.java
@@ -21,11 +21,8 @@
import org.apache.nifi.util.MockFlowFile;
import org.apache.nifi.util.TestRunner;
import org.apache.nifi.util.TestRunners;
-import org.junit.Before;
-import org.junit.Rule;
-import org.junit.Test;
-import org.mockito.junit.MockitoJUnit;
-import org.mockito.junit.MockitoRule;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
import java.util.HashMap;
import java.util.List;
@@ -41,9 +38,7 @@
public class TestExecuteGraphQuery {
protected TestRunner runner;
- @Rule public MockitoRule mockitoRule = MockitoJUnit.rule();
-
- @Before
+ @BeforeEach
public void setUp() throws Exception {
MockCypherClientService service = new MockCypherClientService();
runner = TestRunners.newTestRunner(ExecuteGraphQuery.class);
diff --git a/nifi-nar-bundles/nifi-graph-bundle/nifi-neo4j-cypher-service/src/test/java/org/apache/nifi/graph/ITNeo4JCypherExecutor.java b/nifi-nar-bundles/nifi-graph-bundle/nifi-neo4j-cypher-service/src/test/java/org/apache/nifi/graph/ITNeo4JCypherExecutor.java
index b2fa2c9..fd3566d 100644
--- a/nifi-nar-bundles/nifi-graph-bundle/nifi-neo4j-cypher-service/src/test/java/org/apache/nifi/graph/ITNeo4JCypherExecutor.java
+++ b/nifi-nar-bundles/nifi-graph-bundle/nifi-neo4j-cypher-service/src/test/java/org/apache/nifi/graph/ITNeo4JCypherExecutor.java
@@ -18,9 +18,9 @@
import org.apache.nifi.util.TestRunner;
import org.apache.nifi.util.TestRunners;
-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.neo4j.driver.v1.AuthTokens;
import org.neo4j.driver.v1.Driver;
import org.neo4j.driver.v1.GraphDatabase;
@@ -47,7 +47,7 @@
private GraphClientService clientService;
private GraphQueryResultCallback EMPTY_CALLBACK = (record, hasMore) -> {};
- @Before
+ @BeforeEach
public void setUp() throws Exception {
clientService = new Neo4JCypherClientService();
runner = TestRunners.newTestRunner(MockProcessor.class);
@@ -70,7 +70,7 @@
}
}
- @After
+ @AfterEach
public void tearDown() {
runner = null;
if (driver != null) {
diff --git a/nifi-nar-bundles/nifi-graph-bundle/nifi-other-graph-services/src/test/java/org/apache/nifi/graph/OpenCypherClientServiceIT.java b/nifi-nar-bundles/nifi-graph-bundle/nifi-other-graph-services/src/test/java/org/apache/nifi/graph/OpenCypherClientServiceIT.java
index 340b81a..6397d3f 100644
--- a/nifi-nar-bundles/nifi-graph-bundle/nifi-other-graph-services/src/test/java/org/apache/nifi/graph/OpenCypherClientServiceIT.java
+++ b/nifi-nar-bundles/nifi-graph-bundle/nifi-other-graph-services/src/test/java/org/apache/nifi/graph/OpenCypherClientServiceIT.java
@@ -23,10 +23,10 @@
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
-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.Assertions;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
import org.neo4j.driver.v1.Driver;
import org.neo4j.driver.v1.Session;
import org.neo4j.driver.v1.StatementResult;
@@ -54,7 +54,7 @@
GraphClientService service;
private Driver driver;
- @Before
+ @BeforeEach
public void before() throws Exception {
service = new OpenCypherClientService();
runner = TestRunners.newTestRunner(MockProcessor.class);
@@ -64,7 +64,7 @@
runner.enableControllerService(service);
runner.assertValid();
- Assert.assertEquals("gremlin://localhost:8182/gremlin", service.getTransitUrl());
+ Assertions.assertEquals("gremlin://localhost:8182/gremlin", service.getTransitUrl());
driver = GremlinDatabase.driver("//localhost:8182");
executeSession("MATCH (n) detach delete n");
@@ -75,7 +75,7 @@
"CREATE (rover)-[:chases]->(fido)");
}
- @After
+ @AfterEach
public void after() {
executeSession("MATCH (n) DETACH DELETE n");
}
diff --git a/nifi-nar-bundles/nifi-mongodb-bundle/nifi-mongodb-processors/src/test/groovy/org/apache/nifi/processors/mongodb/GetMongoRecordIT.groovy b/nifi-nar-bundles/nifi-mongodb-bundle/nifi-mongodb-processors/src/test/groovy/org/apache/nifi/processors/mongodb/GetMongoRecordIT.groovy
index 61a99a9..510222b 100644
--- a/nifi-nar-bundles/nifi-mongodb-bundle/nifi-mongodb-processors/src/test/groovy/org/apache/nifi/processors/mongodb/GetMongoRecordIT.groovy
+++ b/nifi-nar-bundles/nifi-mongodb-bundle/nifi-mongodb-processors/src/test/groovy/org/apache/nifi/processors/mongodb/GetMongoRecordIT.groovy
@@ -31,10 +31,10 @@
import org.apache.nifi.util.TestRunner
import org.apache.nifi.util.TestRunners
import org.bson.Document
-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.Assertions
+import org.junit.jupiter.api.BeforeEach
+import org.junit.jupiter.api.Test
import static groovy.json.JsonOutput.*
@@ -62,7 +62,7 @@
[ name: "John Brown", failedLogins: 4, lastLogin: new Date(Calendar.instance.time.time - 10000) ]
].collect { new Document(it) }
- @Before
+ @BeforeEach
void setup() {
runner = TestRunners.newTestRunner(GetMongoRecord.class)
service = new MongoDBControllerService()
@@ -90,7 +90,7 @@
service.getDatabase(DB_NAME).getCollection(COL_NAME).insertMany(SAMPLES)
}
- @After
+ @AfterEach
void after() {
service.getDatabase(DB_NAME).drop()
}
@@ -99,13 +99,13 @@
void testLookup() {
def ffValidator = { TestRunner runner ->
def ffs = runner.getFlowFilesForRelationship(GetMongoRecord.REL_SUCCESS)
- Assert.assertNotNull(ffs)
- Assert.assertTrue(ffs.size() == 1)
- Assert.assertEquals("3", ffs[0].getAttribute("record.count"))
- Assert.assertEquals("application/json", ffs[0].getAttribute(CoreAttributes.MIME_TYPE.key()))
- Assert.assertEquals(COL_NAME, ffs[0].getAttribute(GetMongoRecord.COL_NAME))
- Assert.assertEquals(DB_NAME, ffs[0].getAttribute(GetMongoRecord.DB_NAME))
- Assert.assertEquals(Document.parse("{}"), Document.parse(ffs[0].getAttribute("executed.query")))
+ Assertions.assertNotNull(ffs)
+ Assertions.assertTrue(ffs.size() == 1)
+ Assertions.assertEquals("3", ffs[0].getAttribute("record.count"))
+ Assertions.assertEquals("application/json", ffs[0].getAttribute(CoreAttributes.MIME_TYPE.key()))
+ Assertions.assertEquals(COL_NAME, ffs[0].getAttribute(GetMongoRecord.COL_NAME))
+ Assertions.assertEquals(DB_NAME, ffs[0].getAttribute(GetMongoRecord.DB_NAME))
+ Assertions.assertEquals(Document.parse("{}"), Document.parse(ffs[0].getAttribute("executed.query")))
}
runner.setProperty(GetMongoRecord.QUERY_ATTRIBUTE, "executed.query")
@@ -141,13 +141,13 @@
runner.run()
def parsed = sharedTest()
- Assert.assertEquals(3, parsed.size())
+ Assertions.assertEquals(3, parsed.size())
def values = [1, 2, 4]
int index = 0
parsed.each {
- Assert.assertEquals(values[index++], it["failedLogins"])
- Assert.assertNull(it["name"])
- Assert.assertNull(it["lastLogin"])
+ Assertions.assertEquals(values[index++], it["failedLogins"])
+ Assertions.assertNull(it["name"])
+ Assertions.assertNull(it["lastLogin"])
}
}
@@ -159,7 +159,7 @@
def raw = runner.getContentAsByteArray(ff)
String content = new String(raw)
def parsed = new JsonSlurper().parseText(content)
- Assert.assertNotNull(parsed)
+ Assertions.assertNotNull(parsed)
parsed
}
@@ -173,7 +173,7 @@
runner.run()
def parsed = sharedTest()
- Assert.assertEquals(1, parsed.size())
+ Assertions.assertEquals(1, parsed.size())
}
}
diff --git a/nifi-nar-bundles/nifi-mongodb-bundle/nifi-mongodb-processors/src/test/java/org/apache/nifi/processors/mongodb/AbstractMongoProcessorTest.java b/nifi-nar-bundles/nifi-mongodb-bundle/nifi-mongodb-processors/src/test/java/org/apache/nifi/processors/mongodb/AbstractMongoProcessorTest.java
index ee4a4ec..32b7899 100644
--- a/nifi-nar-bundles/nifi-mongodb-bundle/nifi-mongodb-processors/src/test/java/org/apache/nifi/processors/mongodb/AbstractMongoProcessorTest.java
+++ b/nifi-nar-bundles/nifi-mongodb-bundle/nifi-mongodb-processors/src/test/java/org/apache/nifi/processors/mongodb/AbstractMongoProcessorTest.java
@@ -25,8 +25,8 @@
import org.apache.nifi.ssl.SSLContextService;
import org.apache.nifi.util.TestRunner;
import org.apache.nifi.util.TestRunners;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
import javax.net.ssl.SSLContext;
@@ -41,7 +41,7 @@
MockAbstractMongoProcessor processor;
private TestRunner testRunner;
- @Before
+ @BeforeEach
public void setUp() throws Exception {
processor = new MockAbstractMongoProcessor();
testRunner = TestRunners.newTestRunner(processor);
diff --git a/nifi-nar-bundles/nifi-mongodb-bundle/nifi-mongodb-processors/src/test/java/org/apache/nifi/processors/mongodb/DeleteMongoIT.java b/nifi-nar-bundles/nifi-mongodb-bundle/nifi-mongodb-processors/src/test/java/org/apache/nifi/processors/mongodb/DeleteMongoIT.java
index 9f3c016..9cd6add 100644
--- a/nifi-nar-bundles/nifi-mongodb-bundle/nifi-mongodb-processors/src/test/java/org/apache/nifi/processors/mongodb/DeleteMongoIT.java
+++ b/nifi-nar-bundles/nifi-mongodb-bundle/nifi-mongodb-processors/src/test/java/org/apache/nifi/processors/mongodb/DeleteMongoIT.java
@@ -23,22 +23,22 @@
import org.apache.nifi.mongodb.MongoDBControllerService;
import org.apache.nifi.util.TestRunner;
import org.bson.Document;
-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.Assertions;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
import java.util.HashMap;
import java.util.Map;
public class DeleteMongoIT extends MongoWriteTestBase {
- @Before
+ @BeforeEach
public void setup() {
super.setup(DeleteMongo.class);
collection.insertMany(DOCUMENTS);
}
- @After
+ @AfterEach
public void teardown() {
super.teardown();
}
@@ -49,8 +49,8 @@
runner.assertTransferCount(DeleteMongo.REL_FAILURE, 0);
runner.assertTransferCount(DeleteMongo.REL_SUCCESS, 1);
- Assert.assertEquals("Found a document that should have been deleted.",
- 0, collection.count(Document.parse(query)));
+ Assertions.assertEquals(0, collection.count(Document.parse(query)),
+ "Found a document that should have been deleted.");
}
@Test
@@ -73,10 +73,8 @@
runner.assertTransferCount(DeleteMongo.REL_FAILURE, 0);
runner.assertTransferCount(DeleteMongo.REL_SUCCESS, 1);
- Assert.assertEquals("Found a document that should have been deleted.",
- 0, collection.count(Document.parse(query)));
- Assert.assertEquals("One document should have been left.",
- 1, collection.count(Document.parse("{}")));
+ Assertions.assertEquals(0, collection.count(Document.parse(query)), "Found a document that should have been deleted.");
+ Assertions.assertEquals(1, collection.count(Document.parse("{}")), "One document should have been left.");
}
@Test
@@ -108,7 +106,7 @@
runner.assertTransferCount(DeleteMongo.REL_FAILURE, 1);
runner.assertTransferCount(DeleteMongo.REL_SUCCESS, 0);
- Assert.assertEquals("A document was deleted", 3, collection.count(Document.parse("{}")));
+ Assertions.assertEquals(3, collection.count(Document.parse("{}")), "A document was deleted");
runner.setProperty(DeleteMongo.FAIL_ON_NO_DELETE, DeleteMongo.NO_FAIL);
runner.clearTransferState();
@@ -119,7 +117,7 @@
runner.assertTransferCount(DeleteMongo.REL_FAILURE, 0);
runner.assertTransferCount(DeleteMongo.REL_SUCCESS, 1);
- Assert.assertEquals("A document was deleted", 3, collection.count(Document.parse("{}")));
+ Assertions.assertEquals(3, collection.count(Document.parse("{}")), "A document was deleted");
}
@Test
@@ -139,6 +137,6 @@
runner.assertTransferCount(DeleteMongo.REL_SUCCESS, 1);
runner.assertTransferCount(DeleteMongo.REL_FAILURE, 0);
- Assert.assertEquals(0, collection.count());
+ Assertions.assertEquals(0, collection.count());
}
}
diff --git a/nifi-nar-bundles/nifi-mongodb-bundle/nifi-mongodb-processors/src/test/java/org/apache/nifi/processors/mongodb/GetMongoIT.java b/nifi-nar-bundles/nifi-mongodb-bundle/nifi-mongodb-processors/src/test/java/org/apache/nifi/processors/mongodb/GetMongoIT.java
index 7ec724c..a304f5a 100644
--- a/nifi-nar-bundles/nifi-mongodb-bundle/nifi-mongodb-processors/src/test/java/org/apache/nifi/processors/mongodb/GetMongoIT.java
+++ b/nifi-nar-bundles/nifi-mongodb-bundle/nifi-mongodb-processors/src/test/java/org/apache/nifi/processors/mongodb/GetMongoIT.java
@@ -35,10 +35,10 @@
import org.apache.nifi.util.TestRunner;
import org.apache.nifi.util.TestRunners;
import org.bson.Document;
-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.Assertions;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
import java.text.SimpleDateFormat;
import java.util.Calendar;
@@ -70,7 +70,7 @@
private TestRunner runner;
private MongoClient mongoClient;
- @Before
+ @BeforeEach
public void setup() {
runner = TestRunners.newTestRunner(GetMongo.class);
runner.setVariable("uri", MONGO_URI);
@@ -88,7 +88,7 @@
collection.insertMany(DOCUMENTS);
}
- @After
+ @AfterEach
public void teardown() {
runner = null;
@@ -109,10 +109,10 @@
if (pc instanceof MockProcessContext) {
results = ((MockProcessContext) pc).validate();
}
- Assert.assertEquals(2, results.size());
+ Assertions.assertEquals(2, results.size());
Iterator<ValidationResult> it = results.iterator();
- Assert.assertTrue(it.next().toString().contains("is invalid because Mongo Database Name is required"));
- Assert.assertTrue(it.next().toString().contains("is invalid because Mongo Collection Name is required"));
+ Assertions.assertTrue(it.next().toString().contains("is invalid because Mongo Database Name is required"));
+ Assertions.assertTrue(it.next().toString().contains("is invalid because Mongo Collection Name is required"));
// missing query - is ok
runner.setProperty(AbstractMongoProcessor.URI, MONGO_URI);
@@ -124,7 +124,7 @@
if (pc instanceof MockProcessContext) {
results = ((MockProcessContext) pc).validate();
}
- Assert.assertEquals(0, results.size());
+ Assertions.assertEquals(0, results.size());
// invalid query
runner.setProperty(GetMongo.QUERY, "{a: x,y,z}");
@@ -134,8 +134,8 @@
if (pc instanceof MockProcessContext) {
results = ((MockProcessContext) pc).validate();
}
- Assert.assertEquals(1, results.size());
- Assert.assertTrue(results.iterator().next().toString().contains("is invalid because"));
+ Assertions.assertEquals(1, results.size());
+ Assertions.assertTrue(results.iterator().next().toString().contains("is invalid because"));
// invalid projection
runner.setVariable("projection", "{a: x,y,z}");
@@ -147,8 +147,8 @@
if (pc instanceof MockProcessContext) {
results = ((MockProcessContext) pc).validate();
}
- Assert.assertEquals(1, results.size());
- Assert.assertTrue(results.iterator().next().toString().contains("is invalid"));
+ Assertions.assertEquals(1, results.size());
+ Assertions.assertTrue(results.iterator().next().toString().contains("is invalid"));
// invalid sort
runner.removeProperty(GetMongo.PROJECTION);
@@ -159,8 +159,8 @@
if (pc instanceof MockProcessContext) {
results = ((MockProcessContext) pc).validate();
}
- Assert.assertEquals(1, results.size());
- Assert.assertTrue(results.iterator().next().toString().contains("is invalid"));
+ Assertions.assertEquals(1, results.size());
+ Assertions.assertTrue(results.iterator().next().toString().contains("is invalid"));
}
@Test
@@ -177,8 +177,8 @@
Map<String, Object> parsed = mapper.readValue(raw, Map.class);
SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");
- Assert.assertTrue(parsed.get("date_field").getClass() == String.class);
- Assert.assertTrue(((String)parsed.get("date_field")).startsWith(format.format(CAL.getTime())));
+ Assertions.assertTrue(parsed.get("date_field").getClass() == String.class);
+ Assertions.assertTrue(((String)parsed.get("date_field")).startsWith(format.format(CAL.getTime())));
}
@Test
@@ -252,8 +252,8 @@
runner.assertTransferCount(GetMongo.REL_SUCCESS, 2);
runner.assertTransferCount(GetMongo.REL_ORIGINAL, 1);
List<MockFlowFile> results = runner.getFlowFilesForRelationship(GetMongo.REL_SUCCESS);
- Assert.assertTrue("Flowfile was empty", results.get(0).getSize() > 0);
- Assert.assertEquals("Wrong mime type", results.get(0).getAttribute(CoreAttributes.MIME_TYPE.key()), "application/json");
+ Assertions.assertTrue(results.get(0).getSize() > 0, "Flowfile was empty");
+ Assertions.assertEquals(results.get(0).getAttribute(CoreAttributes.MIME_TYPE.key()), "application/json", "Wrong mime type");
}
@Test
@@ -267,8 +267,8 @@
runner.assertTransferCount(GetMongo.REL_SUCCESS, 2);
runner.assertTransferCount(GetMongo.REL_ORIGINAL, 1);
List<MockFlowFile> results = runner.getFlowFilesForRelationship(GetMongo.REL_SUCCESS);
- Assert.assertTrue("Flowfile was empty", results.get(0).getSize() > 0);
- Assert.assertEquals("Wrong mime type", results.get(0).getAttribute(CoreAttributes.MIME_TYPE.key()), "application/json");
+ Assertions.assertTrue(results.get(0).getSize() > 0, "Flowfile was empty");
+ Assertions.assertEquals(results.get(0).getAttribute(CoreAttributes.MIME_TYPE.key()), "application/json", "Wrong mime type");
}
@Test
@@ -283,7 +283,7 @@
List<MockFlowFile> flowFiles = runner.getFlowFilesForRelationship(GetMongo.REL_SUCCESS);
byte[] raw = runner.getContentAsByteArray(flowFiles.get(0));
String json = new String(raw);
- Assert.assertTrue("JSON did not have new lines.", json.contains("\n"));
+ Assertions.assertTrue(json.contains("\n"), "JSON did not have new lines.");
runner.clearTransferState();
runner.setProperty(GetMongo.USE_PRETTY_PRINTING, GetMongo.NO_PP);
runner.enqueue("{}");
@@ -293,15 +293,15 @@
flowFiles = runner.getFlowFilesForRelationship(GetMongo.REL_SUCCESS);
raw = runner.getContentAsByteArray(flowFiles.get(0));
json = new String(raw);
- Assert.assertFalse("New lines detected", json.contains("\n"));
+ Assertions.assertFalse(json.contains("\n"), "New lines detected");
}
private void testQueryAttribute(String attr, String expected) {
List<MockFlowFile> flowFiles = runner.getFlowFilesForRelationship(GetMongo.REL_SUCCESS);
for (MockFlowFile mff : flowFiles) {
String val = mff.getAttribute(attr);
- Assert.assertNotNull("Missing query attribute", val);
- Assert.assertEquals("Value was wrong", expected, val);
+ Assertions.assertNotNull(val, "Missing query attribute");
+ Assertions.assertEquals(expected, val, "Value was wrong");
}
}
@@ -426,7 +426,7 @@
ex = pe;
}
- Assert.assertNull("An exception was thrown!", ex);
+ Assertions.assertNull(ex, "An exception was thrown!");
runner.assertTransferCount(GetMongo.REL_FAILURE, 0);
runner.assertTransferCount(GetMongo.REL_ORIGINAL, 0);
runner.assertTransferCount(GetMongo.REL_SUCCESS, 3);
@@ -467,7 +467,7 @@
runner.assertTransferCount(GetMongo.REL_SUCCESS, 1);
MockFlowFile flowFile = runner.getFlowFilesForRelationship(GetMongo.REL_SUCCESS).get(0);
- Assert.assertTrue(flowFile.getAttributes().containsKey("property.1"));
+ Assertions.assertTrue(flowFile.getAttributes().containsKey("property.1"));
flowFile.assertAttributeEquals("property.1", "value-1");
}
/*
@@ -536,8 +536,8 @@
tmpRunner.run();
} catch (Throwable ex) {
Throwable cause = ex.getCause();
- Assert.assertTrue(cause instanceof ProcessException);
- Assert.assertTrue(entry.getKey(), ex.getMessage().contains(entry.getKey()));
+ Assertions.assertTrue(cause instanceof ProcessException);
+ Assertions.assertTrue(ex.getMessage().contains(entry.getKey()), entry.getKey());
}
tmpRunner.clearTransferState();
@@ -553,10 +553,10 @@
for (MockFlowFile ff : ffs) {
String db = ff.getAttribute(GetMongo.DB_NAME);
String col = ff.getAttribute(GetMongo.COL_NAME);
- Assert.assertNotNull(db);
- Assert.assertNotNull(col);
- Assert.assertEquals(DB_NAME, db);
- Assert.assertEquals(COLLECTION_NAME, col);
+ Assertions.assertNotNull(db);
+ Assertions.assertNotNull(col);
+ Assertions.assertEquals(DB_NAME, db);
+ Assertions.assertEquals(COLLECTION_NAME, col);
}
}
@@ -578,8 +578,8 @@
Pattern format = Pattern.compile("([\\d]{4})-([\\d]{2})-([\\d]{2})");
- Assert.assertTrue(result.containsKey("date_field"));
- Assert.assertTrue(format.matcher((String) result.get("date_field")).matches());
+ Assertions.assertTrue(result.containsKey("date_field"));
+ Assertions.assertTrue(format.matcher((String) result.get("date_field")).matches());
}
@Test
@@ -667,6 +667,6 @@
List<MockFlowFile> flowFiles = runner.getFlowFilesForRelationship(GetMongo.REL_SUCCESS);
MockFlowFile flowFile = flowFiles.get(0);
- Assert.assertEquals(0, flowFile.getSize());
+ Assertions.assertEquals(0, flowFile.getSize());
}
}
diff --git a/nifi-nar-bundles/nifi-mongodb-bundle/nifi-mongodb-processors/src/test/java/org/apache/nifi/processors/mongodb/PutMongoIT.java b/nifi-nar-bundles/nifi-mongodb-bundle/nifi-mongodb-processors/src/test/java/org/apache/nifi/processors/mongodb/PutMongoIT.java
index cb78f97..1666a4e 100644
--- a/nifi-nar-bundles/nifi-mongodb-bundle/nifi-mongodb-processors/src/test/java/org/apache/nifi/processors/mongodb/PutMongoIT.java
+++ b/nifi-nar-bundles/nifi-mongodb-bundle/nifi-mongodb-processors/src/test/java/org/apache/nifi/processors/mongodb/PutMongoIT.java
@@ -27,10 +27,10 @@
import org.apache.nifi.util.TestRunners;
import org.bson.Document;
import org.bson.types.ObjectId;
-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.Assertions;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
import java.nio.charset.StandardCharsets;
import java.util.Collection;
@@ -40,16 +40,16 @@
import java.util.List;
import java.util.Map;
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
public class PutMongoIT extends MongoWriteTestBase {
- @Before
+ @BeforeEach
public void setup() {
super.setup(PutMongo.class);
}
@Override
- @After
+ @AfterEach
public void teardown() {
super.teardown();
}
@@ -71,10 +71,10 @@
if (pc instanceof MockProcessContext) {
results = ((MockProcessContext) pc).validate();
}
- Assert.assertEquals(2, results.size());
+ assertEquals(2, results.size());
Iterator<ValidationResult> it = results.iterator();
- Assert.assertTrue(it.next().toString().contains("is invalid because Mongo Database Name is required"));
- Assert.assertTrue(it.next().toString().contains("is invalid because Mongo Collection Name is required"));
+ Assertions.assertTrue(it.next().toString().contains("is invalid because Mongo Database Name is required"));
+ Assertions.assertTrue(it.next().toString().contains("is invalid because Mongo Collection Name is required"));
// invalid write concern
runner.setProperty(AbstractMongoProcessor.URI, MONGO_URI);
@@ -88,8 +88,8 @@
if (pc instanceof MockProcessContext) {
results = ((MockProcessContext) pc).validate();
}
- Assert.assertEquals(1, results.size());
- Assert.assertTrue(results.iterator().next().toString().matches("'Write Concern' .* is invalid because Given value not found in allowed set .*"));
+ assertEquals(1, results.size());
+ Assertions.assertTrue(results.iterator().next().toString().matches("'Write Concern' .* is invalid because Given value not found in allowed set .*"));
// valid write concern
runner.setProperty(PutMongo.WRITE_CONCERN, PutMongo.WRITE_CONCERN_UNACKNOWLEDGED);
@@ -99,7 +99,7 @@
if (pc instanceof MockProcessContext) {
results = ((MockProcessContext) pc).validate();
}
- Assert.assertEquals(0, results.size());
+ assertEquals(0, results.size());
}
@Test
@@ -218,14 +218,14 @@
MongoCursor<Document> cursor = collection.find(document).iterator();
Document found = cursor.next();
- Assert.assertEquals(found.get("name"), document.get("name"));
- Assert.assertEquals(found.get("department"), document.get("department"));
+ assertEquals(found.get("name"), document.get("name"));
+ assertEquals(found.get("department"), document.get("department"));
Document contacts = (Document)found.get("contacts");
- Assert.assertNotNull(contacts);
- Assert.assertEquals(contacts.get("twitter"), "@JohnSmith");
- Assert.assertEquals(contacts.get("email"), "john.smith@test.com");
- Assert.assertEquals(contacts.get("phone"), "555-555-5555");
- Assert.assertEquals(collection.count(document), 1);
+ Assertions.assertNotNull(contacts);
+ assertEquals(contacts.get("twitter"), "@JohnSmith");
+ assertEquals(contacts.get("email"), "john.smith@test.com");
+ assertEquals(contacts.get("phone"), "555-555-5555");
+ assertEquals(collection.count(document), 1);
}
@Test
@@ -257,12 +257,12 @@
runner.assertTransferCount(PutMongo.REL_SUCCESS, 1);
MongoCursor<Document> iterator = collection.find(new Document("name", "John Smith")).iterator();
- Assert.assertTrue("Document did not come back.", iterator.hasNext());
+ Assertions.assertTrue(iterator.hasNext(), "Document did not come back.");
Document val = iterator.next();
Map contacts = (Map)val.get("contacts");
- Assert.assertNotNull(contacts);
- Assert.assertTrue(contacts.containsKey("twitter") && contacts.get("twitter").equals("@JohnSmith"));
- Assert.assertTrue(val.containsKey("writes") && val.get("writes").equals(1));
+ Assertions.assertNotNull(contacts);
+ Assertions.assertTrue(contacts.containsKey("twitter") && contacts.get("twitter").equals("@JohnSmith"));
+ Assertions.assertTrue(val.containsKey("writes") && val.get("writes").equals(1));
}
private void updateTests(TestRunner runner, Document document) {
@@ -271,11 +271,11 @@
runner.assertTransferCount(PutMongo.REL_SUCCESS, 1);
MongoCursor<Document> iterator = collection.find(document).iterator();
- Assert.assertTrue("Document did not come back.", iterator.hasNext());
+ Assertions.assertTrue(iterator.hasNext(), "Document did not come back.");
Document val = iterator.next();
- Assert.assertTrue(val.containsKey("email") && val.get("email").equals("john.smith@test.com"));
- Assert.assertTrue(val.containsKey("grade") && val.get("grade").equals("Sr. Principle Eng."));
- Assert.assertTrue(val.containsKey("writes") && val.get("writes").equals(1));
+ Assertions.assertTrue(val.containsKey("email") && val.get("email").equals("john.smith@test.com"));
+ Assertions.assertTrue(val.containsKey("grade") && val.get("grade").equals("Sr. Principle Eng."));
+ Assertions.assertTrue(val.containsKey("writes") && val.get("writes").equals(1));
}
@Test
@@ -462,13 +462,13 @@
Document query = new Document("_id", "Test");
Document result = collection.find(query).first();
List array = (List)result.get("testArr");
- Assert.assertNotNull("Array was empty", array);
- Assert.assertEquals("Wrong size", array.size(), 3);
+ Assertions.assertNotNull(array, "Array was empty");
+ assertEquals(3, array.size(), "Wrong size");
for (int index = 0; index < array.size(); index++) {
Document doc = (Document)array.get(index);
String msg = doc.getString("msg");
- Assert.assertNotNull("Msg was null", msg);
- Assert.assertEquals("Msg had wrong value", msg, "Hi");
+ Assertions.assertNotNull("Msg was null", msg);
+ assertEquals(msg, "Hi", "Msg had wrong value");
}
}
@@ -517,8 +517,8 @@
Document query = new Document(updateKeyProps[index], updateKeys[index]);
Document result = collection.find(query).first();
- Assert.assertNotNull("Result was null", result);
- Assert.assertEquals("Count was wrong", 1, collection.count(query));
+ Assertions.assertNotNull(result, "Result was null");
+ assertEquals(1, collection.count(query), "Count was wrong");
runner.clearTransferState();
index++;
}
diff --git a/nifi-nar-bundles/nifi-mongodb-bundle/nifi-mongodb-processors/src/test/java/org/apache/nifi/processors/mongodb/PutMongoRecordIT.java b/nifi-nar-bundles/nifi-mongodb-bundle/nifi-mongodb-processors/src/test/java/org/apache/nifi/processors/mongodb/PutMongoRecordIT.java
index 371f38c..a8e3319 100644
--- a/nifi-nar-bundles/nifi-mongodb-bundle/nifi-mongodb-processors/src/test/java/org/apache/nifi/processors/mongodb/PutMongoRecordIT.java
+++ b/nifi-nar-bundles/nifi-mongodb-bundle/nifi-mongodb-processors/src/test/java/org/apache/nifi/processors/mongodb/PutMongoRecordIT.java
@@ -38,10 +38,10 @@
import org.apache.nifi.util.TestRunner;
import org.apache.nifi.util.TestRunners;
import org.bson.Document;
-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.Assertions;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
@@ -52,19 +52,19 @@
import java.util.List;
import java.util.Map;
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
public class PutMongoRecordIT extends MongoWriteTestBase {
private MockRecordParser recordReader;
- @Before
+ @BeforeEach
public void setup() throws Exception {
super.setup(PutMongoRecord.class);
recordReader = new MockRecordParser();
}
- @After
+ @AfterEach
public void teardown() {
super.teardown();
}
@@ -96,11 +96,11 @@
if (pc instanceof MockProcessContext) {
results = ((MockProcessContext) pc).validate();
}
- Assert.assertEquals(3, results.size());
+ assertEquals(3, results.size());
Iterator<ValidationResult> it = results.iterator();
- Assert.assertTrue(it.next().toString().contains("is invalid because Mongo Database Name is required"));
- Assert.assertTrue(it.next().toString().contains("is invalid because Mongo Collection Name is required"));
- Assert.assertTrue(it.next().toString().contains("is invalid because Record Reader is required"));
+ Assertions.assertTrue(it.next().toString().contains("is invalid because Mongo Database Name is required"));
+ Assertions.assertTrue(it.next().toString().contains("is invalid because Mongo Collection Name is required"));
+ Assertions.assertTrue(it.next().toString().contains("is invalid because Record Reader is required"));
// invalid write concern
runner.setProperty(AbstractMongoProcessor.URI, MONGO_URI);
@@ -114,8 +114,8 @@
if (pc instanceof MockProcessContext) {
results = ((MockProcessContext) pc).validate();
}
- Assert.assertEquals(1, results.size());
- Assert.assertTrue(results.iterator().next().toString().matches("'Write Concern' .* is invalid because Given value not found in allowed set .*"));
+ assertEquals(1, results.size());
+ Assertions.assertTrue(results.iterator().next().toString().matches("'Write Concern' .* is invalid because Given value not found in allowed set .*"));
// valid write concern
runner.setProperty(PutMongoRecord.WRITE_CONCERN, PutMongoRecord.WRITE_CONCERN_UNACKNOWLEDGED);
@@ -125,7 +125,7 @@
if (pc instanceof MockProcessContext) {
results = ((MockProcessContext) pc).validate();
}
- Assert.assertEquals(0, results.size());
+ assertEquals(0, results.size());
}
@Test
diff --git a/nifi-nar-bundles/nifi-mongodb-bundle/nifi-mongodb-processors/src/test/java/org/apache/nifi/processors/mongodb/PutMongoTest.java b/nifi-nar-bundles/nifi-mongodb-bundle/nifi-mongodb-processors/src/test/java/org/apache/nifi/processors/mongodb/PutMongoTest.java
index 10e2922..a878d5f 100644
--- a/nifi-nar-bundles/nifi-mongodb-bundle/nifi-mongodb-processors/src/test/java/org/apache/nifi/processors/mongodb/PutMongoTest.java
+++ b/nifi-nar-bundles/nifi-mongodb-bundle/nifi-mongodb-processors/src/test/java/org/apache/nifi/processors/mongodb/PutMongoTest.java
@@ -21,8 +21,8 @@
import org.apache.nifi.util.MockProcessContext;
import org.apache.nifi.util.TestRunner;
import org.apache.nifi.util.TestRunners;
-import org.junit.Assert;
-import org.junit.Test;
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.Test;
import java.util.Collection;
import java.util.Iterator;
@@ -50,10 +50,10 @@
if (runner.getProcessContext() instanceof MockProcessContext) {
results = ((MockProcessContext) runner.getProcessContext()).validate();
}
- Assert.assertNotNull(results);
- Assert.assertEquals(1, results.size());
+ Assertions.assertNotNull(results);
+ Assertions.assertEquals(1, results.size());
Iterator<ValidationResult> it = results.iterator();
- Assert.assertTrue(it.next().toString().endsWith("Both update query key and update query cannot be set at the same time."));
+ Assertions.assertTrue(it.next().toString().endsWith("Both update query key and update query cannot be set at the same time."));
runner.removeProperty(PutMongo.UPDATE_QUERY);
runner.removeProperty(PutMongo.UPDATE_QUERY_KEY);
@@ -65,9 +65,9 @@
results = ((MockProcessContext) runner.getProcessContext()).validate();
}
- Assert.assertNotNull(results);
- Assert.assertEquals(1, results.size());
+ Assertions.assertNotNull(results);
+ Assertions.assertEquals(1, results.size());
it = results.iterator();
- Assert.assertTrue(it.next().toString().endsWith("Either the update query key or the update query field must be set."));
+ Assertions.assertTrue(it.next().toString().endsWith("Either the update query key or the update query field must be set."));
}
}
diff --git a/nifi-nar-bundles/nifi-mongodb-bundle/nifi-mongodb-processors/src/test/java/org/apache/nifi/processors/mongodb/RunMongoAggregationIT.java b/nifi-nar-bundles/nifi-mongodb-bundle/nifi-mongodb-processors/src/test/java/org/apache/nifi/processors/mongodb/RunMongoAggregationIT.java
index 24c130f..9da6395 100644
--- a/nifi-nar-bundles/nifi-mongodb-bundle/nifi-mongodb-processors/src/test/java/org/apache/nifi/processors/mongodb/RunMongoAggregationIT.java
+++ b/nifi-nar-bundles/nifi-mongodb-bundle/nifi-mongodb-processors/src/test/java/org/apache/nifi/processors/mongodb/RunMongoAggregationIT.java
@@ -29,10 +29,10 @@
import org.apache.nifi.util.TestRunner;
import org.apache.nifi.util.TestRunners;
import org.bson.Document;
-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.Assertions;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
import java.io.IOException;
import java.text.SimpleDateFormat;
@@ -54,7 +54,7 @@
private Map<String, Integer> mappings;
private Calendar now = Calendar.getInstance();
- @Before
+ @BeforeEach
public void setup() {
runner = TestRunners.newTestRunner(RunMongoAggregation.class);
runner.setVariable("uri", MONGO_URI);
@@ -80,7 +80,7 @@
}
}
- @After
+ @AfterEach
public void teardown() {
runner = null;
mongoClient.getDatabase(DB_NAME).drop();
@@ -120,8 +120,8 @@
List<MockFlowFile> flowFiles = runner.getFlowFilesForRelationship(RunMongoAggregation.REL_RESULTS);
for (MockFlowFile mff : flowFiles) {
String val = mff.getAttribute(AGG_ATTR);
- Assert.assertNotNull("Missing query attribute", val);
- Assert.assertEquals("Value was wrong", val, queryInput);
+ Assertions.assertNotNull("Missing query attribute", val);
+ Assertions.assertEquals(val, queryInput, "Value was wrong");
}
}
@@ -182,7 +182,7 @@
for (MockFlowFile mockFlowFile : flowFiles) {
byte[] raw = runner.getContentAsByteArray(mockFlowFile);
Map<String, List<String>> read = mapper.readValue(raw, Map.class);
- Assert.assertTrue(read.get("myArray").get(1).equalsIgnoreCase( format.format(now.getTime())));
+ Assertions.assertTrue(read.get("myArray").get(1).equalsIgnoreCase( format.format(now.getTime())));
}
runner.clearTransferState();
@@ -195,7 +195,7 @@
for (MockFlowFile mockFlowFile : flowFiles) {
byte[] raw = runner.getContentAsByteArray(mockFlowFile);
Map<String, List<Long>> read = mapper.readValue(raw, Map.class);
- Assert.assertTrue(read.get("myArray").get(1) == now.getTimeInMillis());
+ Assertions.assertTrue(read.get("myArray").get(1) == now.getTimeInMillis());
}
}
@@ -207,12 +207,12 @@
for (MockFlowFile mockFlowFile : flowFiles) {
byte[] raw = runner.getContentAsByteArray(mockFlowFile);
Map read = mapper.readValue(raw, Map.class);
- Assert.assertTrue("Value was not found", mappings.containsKey(read.get("_id")));
+ Assertions.assertTrue(mappings.containsKey(read.get("_id")), "Value was not found");
String queryAttr = mockFlowFile.getAttribute(AGG_ATTR);
- Assert.assertNotNull("Query attribute was null.", queryAttr);
- Assert.assertTrue("Missing $project", queryAttr.contains("$project"));
- Assert.assertTrue("Missing $group", queryAttr.contains("$group"));
+ Assertions.assertNotNull("Query attribute was null.", queryAttr);
+ Assertions.assertTrue(queryAttr.contains("$project"), "Missing $project");
+ Assertions.assertTrue(queryAttr.contains("$group"), "Missing $group");
}
}
diff --git a/nifi-nar-bundles/nifi-mongodb-bundle/nifi-mongodb-processors/src/test/java/org/apache/nifi/processors/mongodb/gridfs/DeleteGridFSIT.java b/nifi-nar-bundles/nifi-mongodb-bundle/nifi-mongodb-processors/src/test/java/org/apache/nifi/processors/mongodb/gridfs/DeleteGridFSIT.java
index e006ecb..2a7d01d 100644
--- a/nifi-nar-bundles/nifi-mongodb-bundle/nifi-mongodb-processors/src/test/java/org/apache/nifi/processors/mongodb/gridfs/DeleteGridFSIT.java
+++ b/nifi-nar-bundles/nifi-mongodb-bundle/nifi-mongodb-processors/src/test/java/org/apache/nifi/processors/mongodb/gridfs/DeleteGridFSIT.java
@@ -25,10 +25,10 @@
import org.apache.nifi.util.TestRunner;
import org.apache.nifi.util.TestRunners;
import org.bson.types.ObjectId;
-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.Assertions;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
import java.util.HashMap;
import java.util.List;
@@ -38,13 +38,13 @@
private TestRunner runner;
private static final String BUCKET = "delete_test_bucket";
- @Before
+ @BeforeEach
public void setup() throws Exception {
runner = TestRunners.newTestRunner(DeleteGridFS.class);
super.setup(runner, BUCKET, false);
}
- @After
+ @AfterEach
public void tearDown() {
super.tearDown();
}
@@ -83,13 +83,13 @@
private void testForQueryAttribute(String mustContain, String attrName) {
List<MockFlowFile> flowFiles = runner.getFlowFilesForRelationship(DeleteGridFS.REL_SUCCESS);
String attribute = flowFiles.get(0).getAttribute(attrName);
- Assert.assertTrue(attribute.contains(mustContain));
+ Assertions.assertTrue(attribute.contains(mustContain));
}
private String setupTestFile() {
String fileName = "simple-delete-test.txt";
ObjectId id = writeTestFile(fileName, "Hello, world!", BUCKET, new HashMap<>());
- Assert.assertNotNull(id);
+ Assertions.assertNotNull(id);
return fileName;
}
@@ -105,6 +105,6 @@
runner.assertTransferCount(DeleteGridFS.REL_FAILURE, 0);
runner.assertTransferCount(DeleteGridFS.REL_SUCCESS, 1);
- Assert.assertFalse(String.format("File %s still exists.", fileName), fileExists(fileName, BUCKET));
+ Assertions.assertFalse(fileExists(fileName, BUCKET), String.format("File %s still exists.", fileName));
}
}
diff --git a/nifi-nar-bundles/nifi-mongodb-bundle/nifi-mongodb-processors/src/test/java/org/apache/nifi/processors/mongodb/gridfs/FetchGridFSIT.java b/nifi-nar-bundles/nifi-mongodb-bundle/nifi-mongodb-processors/src/test/java/org/apache/nifi/processors/mongodb/gridfs/FetchGridFSIT.java
index 5ce4ff3..8e285f0 100644
--- a/nifi-nar-bundles/nifi-mongodb-bundle/nifi-mongodb-processors/src/test/java/org/apache/nifi/processors/mongodb/gridfs/FetchGridFSIT.java
+++ b/nifi-nar-bundles/nifi-mongodb-bundle/nifi-mongodb-processors/src/test/java/org/apache/nifi/processors/mongodb/gridfs/FetchGridFSIT.java
@@ -26,10 +26,10 @@
import org.apache.nifi.util.TestRunner;
import org.apache.nifi.util.TestRunners;
import org.bson.types.ObjectId;
-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.Assertions;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
import java.util.HashMap;
import java.util.List;
@@ -40,13 +40,13 @@
static final String BUCKET = "get_test_bucket";
- @Before
+ @BeforeEach
public void setup() throws Exception {
runner = TestRunners.newTestRunner(FetchGridFS.class);
super.setup(runner, BUCKET, false);
}
- @After
+ @AfterEach
public void tearDown() {
super.tearDown();
}
@@ -56,7 +56,7 @@
final String fileName = "get_by_name.txt";
final String content = "Hello, world";
ObjectId id = writeTestFile(fileName, content, BUCKET, new HashMap<>());
- Assert.assertNotNull(id);
+ Assertions.assertNotNull(id);
String query = String.format("{\"filename\": \"%s\"}", fileName);
runner.enqueue(query);
@@ -66,7 +66,7 @@
runner.assertTransferCount(FetchGridFS.REL_SUCCESS, 1);
List<MockFlowFile> flowFiles = runner.getFlowFilesForRelationship(FetchGridFS.REL_SUCCESS);
byte[] rawData = runner.getContentAsByteArray(flowFiles.get(0));
- Assert.assertEquals("Data did not match for the file", new String(rawData), content);
+ Assertions.assertEquals(new String(rawData), content, "Data did not match for the file");
runner.clearTransferState();
runner.setProperty(FetchGridFS.QUERY, query);
@@ -78,7 +78,7 @@
runner.assertTransferCount(FetchGridFS.REL_SUCCESS, 1);
flowFiles = runner.getFlowFilesForRelationship(FetchGridFS.REL_SUCCESS);
rawData = runner.getContentAsByteArray(flowFiles.get(0));
- Assert.assertEquals("Data did not match for the file", new String(rawData), content);
+ Assertions.assertEquals(new String(rawData), content, "Data did not match for the file");
}
@Test
@@ -87,7 +87,7 @@
String content = "Hello, world take %d";
for (int index = 0; index < 5; index++) {
ObjectId id = writeTestFile(String.format(baseName, index), String.format(content, index), BUCKET, new HashMap<>());
- Assert.assertNotNull(id);
+ Assertions.assertNotNull(id);
}
AllowableValue[] values = new AllowableValue[] { QueryHelper.MODE_MANY_COMMITS, QueryHelper.MODE_ONE_COMMIT };
@@ -110,7 +110,7 @@
final String fileName = "get_by_name.txt";
final String content = "Hello, world";
ObjectId id = writeTestFile(fileName, content, BUCKET, new HashMap<>());
- Assert.assertNotNull(id);
+ Assertions.assertNotNull(id);
final String queryAttr = "gridfs.query.used";
final Map<String, String> attrs = new HashMap<>();
@@ -125,15 +125,15 @@
runner.assertTransferCount(FetchGridFS.REL_SUCCESS, 1);
MockFlowFile mff = runner.getFlowFilesForRelationship(FetchGridFS.REL_SUCCESS).get(0);
String attr = mff.getAttribute(queryAttr);
- Assert.assertNotNull("Query attribute was null.", attr);
- Assert.assertTrue("Wrong content.", attr.contains("filename"));
+ Assertions.assertNotNull("Query attribute was null.", attr);
+ Assertions.assertTrue(attr.contains("filename"), "Wrong content.");
runner.clearTransferState();
id = writeTestFile(fileName, content, BUCKET, new HashMap<String, Object>(){{
put("lookupKey", "xyz");
}});
- Assert.assertNotNull(id);
+ Assertions.assertNotNull(id);
String query = "{ \"metadata\": { \"lookupKey\": \"xyz\" }}";
@@ -146,8 +146,8 @@
runner.assertTransferCount(FetchGridFS.REL_SUCCESS, 1);
mff = runner.getFlowFilesForRelationship(FetchGridFS.REL_SUCCESS).get(0);
attr = mff.getAttribute(queryAttr);
- Assert.assertNotNull("Query attribute was null.", attr);
- Assert.assertTrue("Wrong content.", attr.contains("metadata"));
+ Assertions.assertNotNull("Query attribute was null.", attr);
+ Assertions.assertTrue(attr.contains("metadata"), "Wrong content.");
}
@Test
@@ -176,7 +176,7 @@
final String fileName = "get_by_name.txt";
final String content = "Hello, world";
ObjectId id = writeTestFile(fileName, content, BUCKET, new HashMap<>());
- Assert.assertNotNull(id);
+ Assertions.assertNotNull(id);
runner.run();
runner.assertTransferCount(FetchGridFS.REL_FAILURE, failure);
diff --git a/nifi-nar-bundles/nifi-mongodb-bundle/nifi-mongodb-processors/src/test/java/org/apache/nifi/processors/mongodb/gridfs/PutGridFSIT.java b/nifi-nar-bundles/nifi-mongodb-bundle/nifi-mongodb-processors/src/test/java/org/apache/nifi/processors/mongodb/gridfs/PutGridFSIT.java
index dfd7ae0..40a95f4 100644
--- a/nifi-nar-bundles/nifi-mongodb-bundle/nifi-mongodb-processors/src/test/java/org/apache/nifi/processors/mongodb/gridfs/PutGridFSIT.java
+++ b/nifi-nar-bundles/nifi-mongodb-bundle/nifi-mongodb-processors/src/test/java/org/apache/nifi/processors/mongodb/gridfs/PutGridFSIT.java
@@ -26,10 +26,10 @@
import org.apache.nifi.util.TestRunner;
import org.apache.nifi.util.TestRunners;
import org.bson.Document;
-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.Assertions;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
import java.util.HashMap;
import java.util.Map;
@@ -39,14 +39,14 @@
static final String BUCKET = "put_test_bucket";
- @Before
+ @BeforeEach
public void setup() throws Exception {
runner = TestRunners.newTestRunner(PutGridFS.class);
runner.setProperty(PutGridFS.FILE_NAME, String.format("${%s}", CoreAttributes.FILENAME.key()));
super.setup(runner, BUCKET);
}
- @After
+ @AfterEach
public void tearDown() {
super.tearDown();
}
@@ -61,7 +61,7 @@
runner.run();
runner.assertAllFlowFilesTransferred(PutGridFS.REL_SUCCESS);
- Assert.assertTrue("File does not exist", fileExists(fileName, BUCKET));
+ Assertions.assertTrue(fileExists(fileName, BUCKET), "File does not exist");
}
@Test
@@ -86,8 +86,8 @@
put("department", "Accounting");
}};
- Assert.assertTrue("File does not exist", fileExists(fileName, BUCKET));
- Assert.assertTrue("File is missing PARENT_PROPERTIES", fileHasProperties(fileName, BUCKET, attrs));
+ Assertions.assertTrue(fileExists(fileName, BUCKET), "File does not exist");
+ Assertions.assertTrue(fileHasProperties(fileName, BUCKET, attrs), "File is missing PARENT_PROPERTIES");
}
@Test
@@ -107,7 +107,7 @@
MongoCollection files = client.getDatabase(DB).getCollection(bucketName);
Document query = Document.parse(String.format("{\"filename\": \"%s\"}", fileName));
long count = files.count(query);
- Assert.assertTrue("Wrong count", count == 10);
+ Assertions.assertTrue(count == 10, "Wrong count");
}
@Test
diff --git a/nifi-nar-bundles/nifi-mongodb-bundle/nifi-mongodb-services/src/main/java/org/apache/nifi/mongodb/MongoDBLookupService.java b/nifi-nar-bundles/nifi-mongodb-bundle/nifi-mongodb-services/src/main/java/org/apache/nifi/mongodb/MongoDBLookupService.java
index be8aa89..d97c5de 100644
--- a/nifi-nar-bundles/nifi-mongodb-bundle/nifi-mongodb-services/src/main/java/org/apache/nifi/mongodb/MongoDBLookupService.java
+++ b/nifi-nar-bundles/nifi-mongodb-bundle/nifi-mongodb-services/src/main/java/org/apache/nifi/mongodb/MongoDBLookupService.java
@@ -31,7 +31,6 @@
import org.apache.nifi.lookup.LookupService;
import org.apache.nifi.processor.util.JsonValidator;
import org.apache.nifi.processor.util.StandardValidators;
-import org.apache.nifi.schema.access.SchemaAccessUtils;
import org.apache.nifi.serialization.JsonInferenceSchemaRegistryService;
import org.apache.nifi.serialization.record.MapRecord;
import org.apache.nifi.serialization.record.Record;
@@ -67,6 +66,10 @@
"then the entire MongoDB result document minus the _id field will be returned as a record."
)
public class MongoDBLookupService extends JsonInferenceSchemaRegistryService implements LookupService<Object> {
+ public static final PropertyDescriptor LOCAL_SCHEMA_NAME = new PropertyDescriptor.Builder()
+ .fromPropertyDescriptor(SCHEMA_NAME)
+ .expressionLanguageSupported(ExpressionLanguageScope.VARIABLE_REGISTRY)
+ .build();
private volatile String databaseName;
private volatile String collection;
@@ -169,7 +172,7 @@
this.lookupValueField = context.getProperty(LOOKUP_VALUE_FIELD).getValue();
this.controllerService = context.getProperty(CONTROLLER_SERVICE).asControllerService(MongoDBClientService.class);
- this.schemaNameProperty = context.getProperty(SchemaAccessUtils.SCHEMA_NAME).getValue();
+ this.schemaNameProperty = context.getProperty(LOCAL_SCHEMA_NAME).evaluateAttributeExpressions().getValue();
this.databaseName = context.getProperty(DATABASE_NAME).evaluateAttributeExpressions().getValue();
this.collection = context.getProperty(COLLECTION_NAME).evaluateAttributeExpressions().getValue();
@@ -207,7 +210,7 @@
.build());
_temp.add(SCHEMA_REGISTRY);
- _temp.add(SCHEMA_NAME);
+ _temp.add(LOCAL_SCHEMA_NAME);
_temp.add(SCHEMA_VERSION);
_temp.add(SCHEMA_BRANCH_NAME);
_temp.add(SCHEMA_TEXT);
diff --git a/nifi-nar-bundles/nifi-mongodb-bundle/nifi-mongodb-services/src/test/java/org/apache/nifi/mongodb/MongoDBControllerServiceIT.java b/nifi-nar-bundles/nifi-mongodb-bundle/nifi-mongodb-services/src/test/java/org/apache/nifi/mongodb/MongoDBControllerServiceIT.java
index cd306f9..32d4e86 100644
--- a/nifi-nar-bundles/nifi-mongodb-bundle/nifi-mongodb-services/src/test/java/org/apache/nifi/mongodb/MongoDBControllerServiceIT.java
+++ b/nifi-nar-bundles/nifi-mongodb-bundle/nifi-mongodb-services/src/test/java/org/apache/nifi/mongodb/MongoDBControllerServiceIT.java
@@ -19,9 +19,9 @@
import org.apache.nifi.util.TestRunner;
import org.apache.nifi.util.TestRunners;
-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.util.Calendar;
@@ -32,7 +32,7 @@
private TestRunner runner;
private MongoDBControllerService service;
- @Before
+ @BeforeEach
public void before() throws Exception {
runner = TestRunners.newTestRunner(TestControllerServiceProcessor.class);
service = new MongoDBControllerService();
@@ -41,7 +41,7 @@
runner.enableControllerService(service);
}
- @After
+ @AfterEach
public void after() throws Exception {
service.onDisable();
}
diff --git a/nifi-nar-bundles/nifi-mongodb-bundle/nifi-mongodb-services/src/test/java/org/apache/nifi/mongodb/MongoDBLookupServiceIT.java b/nifi-nar-bundles/nifi-mongodb-bundle/nifi-mongodb-services/src/test/java/org/apache/nifi/mongodb/MongoDBLookupServiceIT.java
index c3ae905..0944061 100644
--- a/nifi-nar-bundles/nifi-mongodb-bundle/nifi-mongodb-services/src/test/java/org/apache/nifi/mongodb/MongoDBLookupServiceIT.java
+++ b/nifi-nar-bundles/nifi-mongodb-bundle/nifi-mongodb-services/src/test/java/org/apache/nifi/mongodb/MongoDBLookupServiceIT.java
@@ -30,10 +30,10 @@
import org.apache.nifi.util.TestRunner;
import org.apache.nifi.util.TestRunners;
import org.bson.Document;
-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.Assertions;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
import java.sql.Timestamp;
import java.util.Arrays;
@@ -44,6 +44,9 @@
import java.util.Map;
import java.util.Optional;
+import static org.junit.jupiter.api.Assertions.assertDoesNotThrow;
+import static org.junit.jupiter.api.Assertions.assertThrows;
+
public class MongoDBLookupServiceIT {
private static final String DB_NAME = String.format("nifi_test-%d", Calendar.getInstance().getTimeInMillis());
private static final String COL_NAME = String.format("nifi_test-%d", Calendar.getInstance().getTimeInMillis());
@@ -54,7 +57,7 @@
private MongoDatabase db;
private MongoCollection col;
- @Before
+ @BeforeEach
public void before() throws Exception {
runner = TestRunners.newTestRunner(TestLookupServiceProcessor.class);
service = new MongoDBLookupService();
@@ -79,7 +82,7 @@
col = db.getCollection(COL_NAME);
}
- @After
+ @AfterEach
public void after() {
db.drop();
controllerService.onDisable();
@@ -103,8 +106,8 @@
criteria.put("uuid", "x-y-z");
Optional result = service.lookup(criteria);
- Assert.assertNotNull("The value was null.", result.get());
- Assert.assertEquals("The value was wrong.", "Hello, world", result.get());
+ Assertions.assertNotNull(result.get(), "The value was null.");
+ Assertions.assertEquals("Hello, world", result.get(), "The value was wrong.");
Map<String, Object> clean = new HashMap<>();
clean.putAll(criteria);
@@ -113,10 +116,10 @@
try {
result = service.lookup(criteria);
} catch (LookupFailureException ex) {
- Assert.fail();
+ Assertions.fail();
}
- Assert.assertTrue(!result.isPresent());
+ Assertions.assertTrue(!result.isPresent());
}
@Test
@@ -133,23 +136,23 @@
Map<String, String> context = new HashMap<>();
context.put("schema.name", "user");
Optional result = service.lookup(criteria, context);
- Assert.assertTrue(result.isPresent());
- Assert.assertNotNull(result.get());
+ Assertions.assertTrue(result.isPresent());
+ Assertions.assertNotNull(result.get());
MapRecord record = (MapRecord)result.get();
- Assert.assertEquals("john.smith", record.getAsString("username"));
- Assert.assertEquals("testing1234", record.getAsString("password"));
+ Assertions.assertEquals("john.smith", record.getAsString("username"));
+ Assertions.assertEquals("testing1234", record.getAsString("password"));
/*
* Test falling back on schema detection if a user doesn't specify the context argument
*/
result = service.lookup(criteria);
- Assert.assertTrue(result.isPresent());
- Assert.assertNotNull(result.get());
+ Assertions.assertTrue(result.isPresent());
+ Assertions.assertNotNull(result.get());
record = (MapRecord)result.get();
- Assert.assertEquals("john.smith", record.getAsString("username"));
- Assert.assertEquals("testing1234", record.getAsString("password"));
+ Assertions.assertEquals("john.smith", record.getAsString("username"));
+ Assertions.assertEquals("testing1234", record.getAsString("password"));
}
@Test
@@ -172,8 +175,8 @@
attrs.put("schema.text", new String(contents));
Optional results = service.lookup(criteria, attrs);
- Assert.assertNotNull(results);
- Assert.assertTrue(results.isPresent());
+ Assertions.assertNotNull(results);
+ Assertions.assertTrue(results.isPresent());
}
@Test
@@ -204,23 +207,23 @@
criteria.put("uuid", "x-y-z");
Optional result = service.lookup(criteria);
- Assert.assertNotNull("The value was null.", result.get());
- Assert.assertTrue("The value was wrong.", result.get() instanceof MapRecord);
+ Assertions.assertNotNull(result.get(), "The value was null.");
+ Assertions.assertTrue(result.get() instanceof MapRecord, "The value was wrong.");
MapRecord record = (MapRecord)result.get();
RecordSchema subSchema = ((RecordDataType)record.getSchema().getField("subrecordField").get().getDataType()).getChildSchema();
- Assert.assertEquals("The value was wrong.", "Hello, world", record.getValue("stringField"));
- Assert.assertEquals("The value was wrong.", "x-y-z", record.getValue("uuid"));
- Assert.assertEquals(new Long(10000), record.getValue("longField"));
- Assert.assertEquals((Double.MAX_VALUE / 2.0), record.getValue("decimalField"));
- Assert.assertEquals(d, record.getValue("dateField"));
- Assert.assertEquals(ts.getTime(), ((Date)record.getValue("timestampField")).getTime());
+ Assertions.assertEquals("Hello, world", record.getValue("stringField"), "The value was wrong.");
+ Assertions.assertEquals("x-y-z", record.getValue("uuid"), "The value was wrong.");
+ Assertions.assertEquals(new Long(10000), record.getValue("longField"));
+ Assertions.assertEquals((Double.MAX_VALUE / 2.0), record.getValue("decimalField"));
+ Assertions.assertEquals(d, record.getValue("dateField"));
+ Assertions.assertEquals(ts.getTime(), ((Date)record.getValue("timestampField")).getTime());
Record subRecord = record.getAsRecord("subrecordField", subSchema);
- Assert.assertNotNull(subRecord);
- Assert.assertEquals("test", subRecord.getValue("nestedString"));
- Assert.assertEquals(new Long(1000), subRecord.getValue("nestedLong"));
- Assert.assertEquals(list, record.getValue("arrayField"));
+ Assertions.assertNotNull(subRecord);
+ Assertions.assertEquals("test", subRecord.getValue("nestedString"));
+ Assertions.assertEquals(new Long(1000), subRecord.getValue("nestedLong"));
+ Assertions.assertEquals(list, record.getValue("arrayField"));
Map<String, Object> clean = new HashMap<>();
clean.putAll(criteria);
@@ -229,10 +232,10 @@
try {
result = service.lookup(criteria);
} catch (LookupFailureException ex) {
- Assert.fail();
+ Assertions.fail();
}
- Assert.assertTrue(!result.isPresent());
+ Assertions.assertTrue(!result.isPresent());
}
@Test
@@ -243,23 +246,8 @@
Map<String, Object> criteria = new HashMap<>();
criteria.put("uuid", "x-y-z");
- boolean error = false;
- try {
- service.lookup(criteria);
- } catch(Exception ex) {
- error = true;
- }
+ assertDoesNotThrow(() -> service.lookup(criteria));
- Assert.assertFalse("An error was thrown when no error should have been thrown.", error);
- error = false;
-
- try {
- service.lookup(new HashMap());
- } catch (Exception ex) {
- error = true;
- Assert.assertTrue("The exception was the wrong type", ex instanceof LookupFailureException);
- }
-
- Assert.assertTrue("An error was not thrown when the input was empty", error);
+ assertThrows(LookupFailureException.class, () -> service.lookup(new HashMap<>()));
}
}
diff --git a/nifi-registry/nifi-registry-core/nifi-registry-test/pom.xml b/nifi-registry/nifi-registry-core/nifi-registry-test/pom.xml
index e5b1878..4ff4bc5 100644
--- a/nifi-registry/nifi-registry-core/nifi-registry-test/pom.xml
+++ b/nifi-registry/nifi-registry-core/nifi-registry-test/pom.xml
@@ -83,6 +83,7 @@
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.13.1</version>
+ <scope>compile</scope>
</dependency>
</dependencies>
diff --git a/nifi-registry/pom.xml b/nifi-registry/pom.xml
index 255286a..fdf9a12 100644
--- a/nifi-registry/pom.xml
+++ b/nifi-registry/pom.xml
@@ -43,7 +43,7 @@
<flyway.version>6.5.7</flyway.version>
<flyway.tests.version>6.4.0</flyway.tests.version>
<swagger.ui.version>3.12.0</swagger.ui.version>
- <testcontainers.version>1.15.1</testcontainers.version>
+ <testcontainers.version>1.16.0</testcontainers.version>
<h2.version>1.4.199</h2.version>
<groovy.eclipse.compiler.version>3.4.0-01</groovy.eclipse.compiler.version>
<jaxb.version>2.3.2</jaxb.version>
diff --git a/pom.xml b/pom.xml
index 95df3fc..17dc60e 100644
--- a/pom.xml
+++ b/pom.xml
@@ -268,9 +268,17 @@
<!-- These junit/mockito/groovy/spock/hamcrest dependencies are here to encourage consistent unit test library usage -->
<dependency>
+ <groupId>org.junit</groupId>
+ <artifactId>junit-bom</artifactId>
+ <version>5.7.2</version>
+ <type>pom</type>
+ <scope>import</scope>
+ </dependency>
+ <dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.13.2</version>
+ <scope>test</scope>
</dependency>
<dependency>
<groupId>org.mockito</groupId>
@@ -455,8 +463,18 @@
<dependencies>
<dependency>
- <groupId>junit</groupId>
- <artifactId>junit</artifactId>
+ <groupId>org.junit.jupiter</groupId>
+ <artifactId>junit-jupiter-api</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.junit.jupiter</groupId>
+ <artifactId>junit-jupiter-engine</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.junit.vintage</groupId>
+ <artifactId>junit-vintage-engine</artifactId>
<scope>test</scope>
</dependency>
<dependency>
@@ -525,14 +543,6 @@
-Duser.timezone=${user.timezone}
-Dfile.encoding=UTF-8</argLine>
</configuration>
- <dependencies>
- <dependency>
- <!-- Force surefire to use JUnit -->
- <groupId>org.apache.maven.surefire</groupId>
- <artifactId>surefire-junit4</artifactId>
- <version>${surefire.version}</version>
- </dependency>
- </dependencies>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>