You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nifi.apache.org by al...@apache.org on 2020/05/22 18:45:35 UTC
[nifi] branch master updated: NIFI-7482 Changed InvokeHTTP to be
extensible. Added unit test.
This is an automated email from the ASF dual-hosted git repository.
alopresto pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/nifi.git
The following commit(s) were added to refs/heads/master by this push:
new 97a919a NIFI-7482 Changed InvokeHTTP to be extensible. Added unit test.
97a919a is described below
commit 97a919a3be37c8e78b623ffacf9b1f22db534644
Author: Andy LoPresto <al...@apache.org>
AuthorDate: Fri May 22 10:55:48 2020 -0700
NIFI-7482 Changed InvokeHTTP to be extensible.
Added unit test.
This closes #4291.
Signed-off-by: Arpad Boda <ab...@apache.org>
---
.../nifi/processors/standard/InvokeHTTP.java | 2 +-
.../nifi/processors/standard/TestInvokeHTTP.java | 27 ++++++++++++++++++++++
2 files changed, 28 insertions(+), 1 deletion(-)
diff --git a/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/main/java/org/apache/nifi/processors/standard/InvokeHTTP.java b/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/main/java/org/apache/nifi/processors/standard/InvokeHTTP.java
index 249fb8e..d0cd858 100644
--- a/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/main/java/org/apache/nifi/processors/standard/InvokeHTTP.java
+++ b/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/main/java/org/apache/nifi/processors/standard/InvokeHTTP.java
@@ -134,7 +134,7 @@ import org.joda.time.format.DateTimeFormatter;
+ " where the <NAME> will be the form data name, will be used to fill out the multipart form parts."
+ " If send message body is false, the flowfile will not be sent, but any other form data will be.")
})
-public final class InvokeHTTP extends AbstractProcessor {
+public class InvokeHTTP extends AbstractProcessor {
// flowfile attribute keys returned after reading the response
public final static String STATUS_CODE = "invokehttp.status.code";
public final static String STATUS_MESSAGE = "invokehttp.status.message";
diff --git a/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/test/java/org/apache/nifi/processors/standard/TestInvokeHTTP.java b/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/test/java/org/apache/nifi/processors/standard/TestInvokeHTTP.java
index c2a68dd..9cabae0 100644
--- a/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/test/java/org/apache/nifi/processors/standard/TestInvokeHTTP.java
+++ b/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/test/java/org/apache/nifi/processors/standard/TestInvokeHTTP.java
@@ -16,6 +16,7 @@
*/
package org.apache.nifi.processors.standard;
+import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
@@ -273,6 +274,7 @@ public class TestInvokeHTTP extends TestInvokeHttpCommon {
assertNull(regexAttributesToSendField.get(processor));
}
+
@Test
public void testEmptyGzipHttpReponse() throws Exception {
addHandler(new EmptyGzipResponseHandler());
@@ -300,6 +302,31 @@ public class TestInvokeHTTP extends TestInvokeHttpCommon {
bundle.assertAttributeEquals("Content-Type", "text/plain");
}
+ @Test
+ public void testShouldAllowExtension() {
+ // Arrange
+ class ExtendedInvokeHTTP extends InvokeHTTP {
+ private int extendedNumber = -1;
+
+ public ExtendedInvokeHTTP(int num) {
+ super();
+ this.extendedNumber = num;
+ }
+
+ public int extendedMethod() {
+ return this.extendedNumber;
+ }
+ }
+
+ int num = Double.valueOf(Math.random() * 100).intValue();
+
+ // Act
+ ExtendedInvokeHTTP eih = new ExtendedInvokeHTTP(num);
+
+ // Assert
+ assertEquals(num, eih.extendedMethod());
+ }
+
public static class EmptyGzipResponseHandler extends AbstractHandler {
@Override