NIFI-7482 Changed InvokeHTTP to be extensible.

Added unit test.

This closes #4291.

Signed-off-by: Arpad Boda <aboda@apache.org>
This commit is contained in:
Andy LoPresto 2020-05-22 10:55:48 -07:00
parent b6ef7e13bf
commit 97a919a3be
No known key found for this signature in database
GPG Key ID: 6EC293152D90B61D
2 changed files with 28 additions and 1 deletions

View File

@ -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";

View File

@ -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