mirror of https://github.com/apache/nifi.git
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:
parent
b6ef7e13bf
commit
97a919a3be
|
@ -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";
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue