NIFI-9113 Refactored nifi-grpc-bundle to use JUnit 5

- NIFI-9111 Refactored nifi-gcp-bundle to use JUnit 5
- NIFI-9110 Refactored nifi-flume-bundle to use JUnit 5
- NIFI-9108 Refactored nifi-evtx-bundle to use JUnit 5
- NIFI-9106 Refactored nifi-email-bundle to use JUnit 5
- NIFI-9105 Refactored nifi-easyrules-bundle to use JUnit 5
- NIFI-9104 Refactored nifi-druid-bundle to use JUnit 5

This closes #5790

Signed-off-by: David Handermann <exceptionfactory@apache.org>
This commit is contained in:
Mike Thomsen 2021-08-25 16:13:06 -04:00 committed by exceptionfactory
parent c453d2ba8f
commit 13be48cfe3
No known key found for this signature in database
GPG Key ID: 29B6A52D2AAE8DBA
90 changed files with 525 additions and 514 deletions

View File

@ -27,8 +27,8 @@ import org.apache.nifi.processor.ProcessSession;
import org.apache.nifi.processor.exception.ProcessException;
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.ArrayList;
import java.util.List;
@ -40,7 +40,7 @@ public class DruidTranquilityControllerTest {
private TestRunner runner;
private MockDruidTranquilityController service;
@Before
@BeforeEach
public void setup() throws Exception {
runner = TestRunners.newTestRunner(TestControllerServiceProcessor.class);
service = new MockDruidTranquilityController();

View File

@ -17,9 +17,9 @@
package org.apache.nifi.processors.druid;
import org.apache.nifi.controller.api.druid.DruidTranquilityService;
import org.apache.nifi.controller.druid.DruidTranquilityController;
import org.apache.nifi.controller.druid.MockDruidTranquilityController;
import org.apache.nifi.controller.api.druid.DruidTranquilityService;
import org.apache.nifi.provenance.ProvenanceEventType;
import org.apache.nifi.serialization.record.MockRecordParser;
import org.apache.nifi.serialization.record.MockRecordWriter;
@ -27,10 +27,10 @@ import org.apache.nifi.serialization.record.RecordFieldType;
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 static org.junit.Assert.assertEquals;
import static org.junit.jupiter.api.Assertions.assertEquals;
public class PutDruidRecordTest {
@ -40,7 +40,7 @@ public class PutDruidRecordTest {
private MockRecordParser recordReader;
private MockRecordWriter recordWriter;
@Before
@BeforeEach
public void setUp() throws Exception {
runner = TestRunners.newTestRunner(PutDruidRecord.class);
druidTranquilityController = new MockDruidTranquilityController(2,3);

View File

@ -18,11 +18,11 @@ package org.apache.nifi.rules;
import org.jeasy.rules.api.Condition;
import org.jeasy.rules.api.Facts;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertThrows;
import static org.junit.jupiter.api.Assertions.assertTrue;
public class TestRulesCondition {
@ -54,11 +54,7 @@ public class TestRulesCondition {
Facts facts = new Facts();
facts.put("predictedQueued",100);
Condition condition = new RulesMVELCondition(expression, false);
try {
condition.evaluate(facts);
fail();
}catch (Exception ignored){
}
assertThrows(Exception.class, () -> condition.evaluate(facts));
}
@Test
@ -89,12 +85,6 @@ public class TestRulesCondition {
Facts facts = new Facts();
facts.put("predictedQueuedCount",100);
Condition condition = new RulesSPELCondition(expression, false);
try {
condition.evaluate(facts);
fail();
}catch (Exception ignored){
}
assertThrows(Exception.class, () -> condition.evaluate(facts));
}
}
}

View File

@ -16,92 +16,81 @@
*/
package org.apache.nifi.rules;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import java.util.List;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertSame;
import static org.junit.Assert.fail;
import static org.junit.jupiter.api.Assertions.assertDoesNotThrow;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertSame;
import static org.junit.jupiter.api.Assertions.assertThrows;
public class TestRulesFactory {
@Test
public void testCreateRulesFromNiFiYaml(){
try {
assertDoesNotThrow(() -> {
String testYamlFile = "src/test/resources/test_nifi_rules.yml";
List<Rule> rules = RulesFactory.createRulesFromFile(testYamlFile,"YAML", "NIFI");
List<Rule> rules = RulesFactory.createRulesFromFile(testYamlFile, "YAML", "NIFI");
assertEquals(2, rules.size());
assert confirmEntries(rules);
}catch (Exception ex){
fail("Unexpected exception occurred: "+ex.getMessage());
}
});
}
@Test
public void testCreateRulesFromMvelYaml(){
try {
assertDoesNotThrow(() -> {
String testYamlFile = "src/test/resources/test_mvel_rules.yml";
List<Rule> rules = RulesFactory.createRulesFromFile(testYamlFile,"YAML", "MVEL");
List<Rule> rules = RulesFactory.createRulesFromFile(testYamlFile, "YAML", "MVEL");
assertEquals(2, rules.size());
assert confirmEntries(rules);
assertSame("EXPRESSION", rules.get(0).getActions().get(0).getType());
}catch (Exception ex){
fail("Unexpected exception occurred: "+ex.getMessage());
}
});
}
@Test
public void testCreateRulesFromSpelYaml(){
try {
assertDoesNotThrow(() -> {
String testYamlFile = "src/test/resources/test_spel_rules.yml";
List<Rule> rules = RulesFactory.createRulesFromFile(testYamlFile,"YAML", "SPEL");
List<Rule> rules = RulesFactory.createRulesFromFile(testYamlFile, "YAML", "SPEL");
assertEquals(2, rules.size());
assertSame("EXPRESSION", rules.get(0).getActions().get(0).getType());
}catch (Exception ex){
fail("Unexpected exception occurred: "+ex.getMessage());
}
});
}
@Test
public void testCreateRulesFromNiFiJson(){
try {
assertDoesNotThrow(() -> {
String testJsonFile = "src/test/resources/test_nifi_rules.json";
List<Rule> rules = RulesFactory.createRulesFromFile(testJsonFile,"JSON", "NIFI");
List<Rule> rules = RulesFactory.createRulesFromFile(testJsonFile, "JSON", "NIFI");
assertEquals(2, rules.size());
assert confirmEntries(rules);
}catch (Exception ex){
fail("Unexpected exception occurred: "+ex.getMessage());
}
});
}
@Test
public void testCreateRulesFromMvelJson(){
try {
assertDoesNotThrow(() -> {
String testJsonFile = "src/test/resources/test_mvel_rules.json";
List<Rule> rules = RulesFactory.createRulesFromFile(testJsonFile,"JSON", "MVEL");
List<Rule> rules = RulesFactory.createRulesFromFile(testJsonFile, "JSON", "MVEL");
assertEquals(2, rules.size());
assertSame("EXPRESSION", rules.get(0).getActions().get(0).getType());
assert confirmEntries(rules);
}catch (Exception ex){
fail("Unexpected exception occurred: "+ex.getMessage());
}
});
}
@Test
public void testCreateRulesFromSpelJson(){
try {
assertDoesNotThrow(() -> {
String testJsonFile = "src/test/resources/test_spel_rules.json";
List<Rule> rules = RulesFactory.createRulesFromFile(testJsonFile,"JSON", "SPEL");
List<Rule> rules = RulesFactory.createRulesFromFile(testJsonFile, "JSON", "SPEL");
assertEquals(2, rules.size());
assertSame("EXPRESSION", rules.get(0).getActions().get(0).getType());
}catch (Exception ex){
fail("Unexpected exception occurred: "+ex.getMessage());
}
});
}
@Test
public void testCreateRulesFromStringSpelJson(){
try {
assertDoesNotThrow(() -> {
String testJson = "[\n" +
" {\n" +
" \"name\": \"Queue Size\",\n" +
@ -118,17 +107,15 @@ public class TestRulesFactory {
" \"actions\": [\"'System is approaching backpressure! Predicted time left: ' + #predictedTimeToBytesBackpressureMillis\"]\n" +
" }\n" +
"]";
List<Rule> rules = RulesFactory.createRulesFromString(testJson,"JSON", "SPEL");
List<Rule> rules = RulesFactory.createRulesFromString(testJson, "JSON", "SPEL");
assertEquals(2, rules.size());
assertSame("EXPRESSION", rules.get(0).getActions().get(0).getType());
}catch (Exception ex){
fail("Unexpected exception occurred: "+ex.getMessage());
}
});
}
@Test
public void testCreateRulesFromStringSpelYaml(){
try {
assertDoesNotThrow(() -> {
String testYaml = "---\n" +
"name: \"Queue Size\"\n" +
"description: \"Queue size check greater than 50\"\n" +
@ -143,32 +130,22 @@ public class TestRulesFactory {
"condition: \"#predictedTimeToBytesBackpressureMillis < 300000 && #predictedTimeToBytesBackpressureMillis >= 0\"\n" +
"actions:\n" +
" - \"System.out.println(\\\"Back Pressure prediction less than 5 minutes!\\\")\"";
List<Rule> rules = RulesFactory.createRulesFromString(testYaml,"YAML", "SPEL");
List<Rule> rules = RulesFactory.createRulesFromString(testYaml, "YAML", "SPEL");
assertEquals(2, rules.size());
assertSame("EXPRESSION", rules.get(0).getActions().get(0).getType());
}catch (Exception ex){
fail("Unexpected exception occurred: "+ex.getMessage());
}
});
}
@Test
public void testFakeTypeNotSupported(){
try {
RulesFactory.createRulesFromFile("FAKEFILE", "FAKE", "NIFI");
}catch (Exception ex){
return;
}
fail("Exception should have been thrown for unexpected type");
assertThrows(Exception.class,
() -> RulesFactory.createRulesFromFile("FAKEFILE", "FAKE", "NIFI"));
}
@Test
public void testFakeFormatNotSupported(){
try {
RulesFactory.createRulesFromFile("FAKEFILE", "JSON", "FAKE");
}catch (Exception ex){
return;
}
fail("Exception should have been thrown for unexpected type");
assertThrows(Exception.class,
() -> RulesFactory.createRulesFromFile("FAKEFILE", "JSON", "FAKE"));
}

View File

@ -15,19 +15,19 @@
* limitations under the License.
*/
package org.apache.nifi.rules.engine;
import org.apache.nifi.rules.Action;
import org.apache.nifi.rules.Rule;
import org.apache.nifi.rules.RulesFactory;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.fail;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertThrows;
public class TestEasyRulesEngine {
@ -65,12 +65,7 @@ public class TestEasyRulesEngine {
Map<String, Object> facts = new HashMap<>();
facts.put("predictedQueuedCount",60);
facts.put("predictedTimeToBytesBackpressure",311111);
try {
service.fireRules(facts);
fail("Error condition exception was not thrown");
}catch (Exception ignored){
}
assertThrows(Exception.class, () -> service.fireRules(facts));
}
@Test

View File

@ -20,15 +20,15 @@ import org.apache.nifi.reporting.InitializationException;
import org.apache.nifi.rules.Action;
import org.apache.nifi.util.TestRunner;
import org.apache.nifi.util.TestRunners;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import java.io.IOException;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNotNull;
public class TestEasyRulesEngineProvider {

View File

@ -20,17 +20,17 @@ import org.apache.nifi.reporting.InitializationException;
import org.apache.nifi.rules.Action;
import org.apache.nifi.util.TestRunner;
import org.apache.nifi.util.TestRunners;
import org.junit.Test;
import org.mvel2.PropertyAccessException;
import org.junit.jupiter.api.Test;
import java.io.IOException;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.fail;
import static org.junit.jupiter.api.Assertions.assertDoesNotThrow;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertThrows;
public class TestEasyRulesEngineService {
@ -225,12 +225,7 @@ public class TestEasyRulesEngineService {
Map<String, Object> facts = new HashMap<>();
facts.put("fakeMetric",60);
facts.put("predictedTimeToBytesBackpressureMillis",299999);
try {
service.fireRules(facts);
fail("Expected exception to be thrown");
}catch (Exception pae){
assert true;
}
assertThrows(Exception.class, () -> service.fireRules(facts));
}
@Test
@ -247,13 +242,11 @@ public class TestEasyRulesEngineService {
Map<String, Object> facts = new HashMap<>();
facts.put("fakeMetric",60);
facts.put("predictedTimeToBytesBackpressureMillis",299999);
try {
assertDoesNotThrow(() -> {
List<Action> actions = service.fireRules(facts);
assertNotNull(actions);
assertEquals(actions.size(), 1);
}catch (PropertyAccessException pae){
fail();
}
});
}
@Test
@ -270,12 +263,7 @@ public class TestEasyRulesEngineService {
Map<String, Object> facts = new HashMap<>();
facts.put("fakeMetric",60);
facts.put("predictedTimeToBytesBackpressureMillis",299999);
try {
service.fireRules(facts);
fail("Expected exception to be thrown");
}catch (Exception pae){
assert true;
}
assertThrows(Exception.class, () -> service.fireRules(facts));
}
@Test
@ -292,13 +280,11 @@ public class TestEasyRulesEngineService {
Map<String, Object> facts = new HashMap<>();
facts.put("fakeMetric",60);
facts.put("predictedTimeToBytesBackpressureMillis",299999);
try {
assertDoesNotThrow(() -> {
List<Action> actions = service.fireRules(facts);
assertNotNull(actions);
assertEquals(actions.size(), 1);
}catch (PropertyAccessException pae){
fail();
}
});
}
@Test
@ -315,12 +301,7 @@ public class TestEasyRulesEngineService {
Map<String, Object> facts = new HashMap<>();
facts.put("fakeMetric",60);
facts.put("fakeMetric2",299999);
try {
service.fireRules(facts);
fail("Expected exception to be thrown");
}catch (Exception pae){
assert true;
}
assertThrows(Exception.class, () -> service.fireRules(facts));
}
@Test
@ -337,13 +318,12 @@ public class TestEasyRulesEngineService {
Map<String, Object> facts = new HashMap<>();
facts.put("predictedQueuedCount",60);
facts.put("predictedTimeToBytesBackpressureMillis",299999);
try {
assertDoesNotThrow(() -> {
List<Action> actions = service.fireRules(facts);
assertNotNull(actions);
assertEquals(actions.size(), 1);
}catch (Exception pae){
fail();
}
});
}
@Test

View File

@ -23,10 +23,9 @@ import com.icegreen.greenmail.util.ServerSetupTest;
import org.apache.nifi.util.MockFlowFile;
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.Assert;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.springframework.integration.mail.AbstractMailReceiver;
import javax.mail.Message;
@ -38,7 +37,8 @@ import java.lang.reflect.Field;
import java.util.List;
import java.util.Properties;
import static org.junit.Assert.assertEquals;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertTrue;
public class ITestConsumeEmail {
@ -49,7 +49,7 @@ public class ITestConsumeEmail {
private GreenMailUser popUser;
// Setup mock imap server
@Before
@BeforeEach
public void setUp() {
mockIMAP4Server = new GreenMail(ServerSetupTest.IMAP);
mockIMAP4Server.start();
@ -60,7 +60,7 @@ public class ITestConsumeEmail {
popUser = mockPOP3Server.setUser("test@nifi.org", "nifiUserPop", "nifiPassword");
}
@After
@AfterEach
public void cleanUp() {
mockIMAP4Server.stop();
mockPOP3Server.stop();
@ -99,13 +99,13 @@ public class ITestConsumeEmail {
String result = new String(runner.getContentAsByteArray(messages.get(0)));
// Verify body
Assert.assertTrue(result.contains("test test test chocolate"));
assertTrue(result.contains("test test test chocolate"));
// Verify sender
Assert.assertTrue(result.contains("alice@nifi.org"));
assertTrue(result.contains("alice@nifi.org"));
// Verify subject
Assert.assertTrue(result.contains("testConsumeImap1"));
assertTrue(result.contains("testConsumeImap1"));
}
@ -130,13 +130,13 @@ public class ITestConsumeEmail {
String result = new String(runner.getContentAsByteArray(messages.get(0)));
// Verify body
Assert.assertTrue(result.contains("test test test chocolate"));
assertTrue(result.contains("test test test chocolate"));
// Verify sender
Assert.assertTrue(result.contains("alice@nifi.org"));
assertTrue(result.contains("alice@nifi.org"));
// Verify subject
Assert.assertTrue(result.contains("Pop1"));
assertTrue(result.contains("Pop1"));
}

View File

@ -20,14 +20,15 @@ package org.apache.nifi.processors.email;
import org.apache.nifi.util.MockFlowFile;
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.Test;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Random;
import static org.junit.jupiter.api.Assertions.assertTrue;
public class TestExtractEmailAttachments {
// Setups the fields to be used...
@ -81,7 +82,7 @@ public class TestExtractEmailAttachments {
filenames.add(splits.get(a).getAttribute("filename").toString());
}
Assert.assertTrue(filenames.containsAll(Arrays.asList("pom.xml1", "pom.xml" + amount)));
assertTrue(filenames.containsAll(Arrays.asList("pom.xml1", "pom.xml" + amount)));
}
@Test

View File

@ -17,15 +17,16 @@
package org.apache.nifi.processors.email;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.util.List;
import javax.mail.MessagingException;
import javax.mail.internet.MimeMessage;
import org.apache.nifi.util.MockFlowFile;
import org.apache.nifi.util.TestRunner;
import org.apache.nifi.util.TestRunners;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import javax.mail.MessagingException;
import javax.mail.internet.MimeMessage;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.util.List;
public class TestExtractEmailHeaders {

View File

@ -20,14 +20,16 @@ package org.apache.nifi.processors.email;
import org.apache.nifi.util.MockFlowFile;
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.Test;
import java.nio.file.Paths;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertTrue;
public class TestExtractTNEFAttachments {
@Test
@ -42,7 +44,7 @@ public class TestExtractTNEFAttachments {
runner.assertTransferCount(ExtractEmailAttachments.REL_ATTACHMENTS, 0);
// Have a look at the attachments...
final List<MockFlowFile> splits = runner.getFlowFilesForRelationship(ExtractEmailAttachments.REL_ATTACHMENTS);
Assert.assertEquals(0, splits.size());
assertEquals(0, splits.size());
}
@Test
@ -63,7 +65,7 @@ public class TestExtractTNEFAttachments {
filenames.add(flowFile.getAttribute("filename"));
}
Assert.assertTrue(filenames.containsAll(Arrays.asList("nifiDrop.svg", "MINIFI~1.PNG")));
assertTrue(filenames.containsAll(Arrays.asList("nifiDrop.svg", "MINIFI~1.PNG")));
}
@Test
@ -84,7 +86,7 @@ public class TestExtractTNEFAttachments {
filenames.add(flowFile.getAttribute("filename"));
}
Assert.assertTrue(filenames.contains("nifiDrop.svg"));
assertTrue(filenames.contains("nifiDrop.svg"));
}
@Test

View File

@ -16,22 +16,6 @@
*/
package org.apache.nifi.processors.email;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertThrows;
import static org.junit.Assert.assertTrue;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
import java.security.GeneralSecurityException;
import java.util.Properties;
import javax.mail.Message;
import javax.mail.MessagingException;
import javax.mail.Session;
import javax.mail.Transport;
import javax.mail.internet.InternetAddress;
import javax.mail.internet.MimeMessage;
import javax.net.ssl.SSLContext;
import org.apache.nifi.remote.io.socket.NetworkUtils;
import org.apache.nifi.reporting.InitializationException;
import org.apache.nifi.security.util.ClientAuth;
@ -43,8 +27,24 @@ import org.apache.nifi.ssl.RestrictedSSLContextService;
import org.apache.nifi.ssl.SSLContextService;
import org.apache.nifi.util.TestRunner;
import org.apache.nifi.util.TestRunners;
import org.junit.BeforeClass;
import org.junit.Test;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Test;
import javax.mail.Message;
import javax.mail.MessagingException;
import javax.mail.Session;
import javax.mail.Transport;
import javax.mail.internet.InternetAddress;
import javax.mail.internet.MimeMessage;
import javax.net.ssl.SSLContext;
import java.security.GeneralSecurityException;
import java.util.Properties;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertThrows;
import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
public class TestListenSMTP {
private static final String SSL_SERVICE_IDENTIFIER = "ssl-context";
@ -55,7 +55,7 @@ public class TestListenSMTP {
private static final int MESSAGES = 2;
@BeforeClass
@BeforeAll
public static void setTlsConfiguration() throws GeneralSecurityException {
final TlsConfiguration testTlsConfiguration = new TemporaryKeyStoreBuilder().build();
@ -80,7 +80,7 @@ public class TestListenSMTP {
}
@Test
public void testListenSMTP() throws Exception {
public void testListenSMTP() throws MessagingException {
final int port = NetworkUtils.availablePort();
final TestRunner runner = newTestRunner(port);
@ -165,7 +165,7 @@ public class TestListenSMTP {
}
private void assertPortListening(final int port) {
assertTrue(String.format("expected server listening on %s:%d", "localhost", port), NetworkUtils.isListening("localhost", port, 5000));
assertTrue(NetworkUtils.isListening("localhost", port, 5000), String.format("expected server listening on %s:%d", "localhost", port));
}
private Session getSession(final int port) {

View File

@ -58,5 +58,11 @@
<version>1.16.0-SNAPSHOT</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-junit-jupiter</artifactId>
<version>3.9.0</version>
<scope>test</scope>
</dependency>
</dependencies>
</project>

View File

@ -23,10 +23,10 @@ import org.apache.nifi.flowfile.attributes.CoreAttributes;
import org.apache.nifi.processor.ProcessSession;
import org.apache.nifi.processor.Relationship;
import org.apache.nifi.processor.io.OutputStreamCallback;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.junit.MockitoJUnitRunner;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.mockito.junit.jupiter.MockitoExtension;
import java.io.ByteArrayOutputStream;
@ -37,13 +37,13 @@ import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
@RunWith(MockitoJUnitRunner.class)
@ExtendWith(MockitoExtension.class)
public class MalformedChunkHandlerTest {
Relationship badChunkRelationship;
MalformedChunkHandler malformedChunkHandler;
@Before
@BeforeEach
public void setup() {
badChunkRelationship = new Relationship.Builder().build();
malformedChunkHandler = new MalformedChunkHandler(badChunkRelationship);

View File

@ -17,28 +17,6 @@
package org.apache.nifi.processors.evtx;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import static org.mockito.Mockito.any;
import static org.mockito.Mockito.eq;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.verifyNoMoreInteractions;
import static org.mockito.Mockito.when;
import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.util.Arrays;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.concurrent.atomic.AtomicReference;
import javax.xml.parsers.ParserConfigurationException;
import javax.xml.stream.XMLStreamException;
import org.apache.nifi.flowfile.FlowFile;
import org.apache.nifi.flowfile.attributes.CoreAttributes;
import org.apache.nifi.logging.ComponentLog;
@ -54,18 +32,44 @@ import org.apache.nifi.security.xml.XmlUtils;
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.runner.RunWith;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.mockito.Mock;
import org.mockito.junit.MockitoJUnitRunner;
import org.mockito.junit.jupiter.MockitoExtension;
import org.mockito.junit.jupiter.MockitoSettings;
import org.mockito.quality.Strictness;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
import org.xml.sax.SAXException;
@RunWith(MockitoJUnitRunner.class)
import javax.xml.parsers.ParserConfigurationException;
import javax.xml.stream.XMLStreamException;
import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.util.Arrays;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.concurrent.atomic.AtomicReference;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import static org.mockito.Mockito.any;
import static org.mockito.Mockito.eq;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.verifyNoMoreInteractions;
import static org.mockito.Mockito.when;
@ExtendWith(MockitoExtension.class)
@MockitoSettings(strictness = Strictness.LENIENT)
public class ParseEvtxTest {
public static final String USER_DATA = "UserData";
public static final String EVENT_DATA = "EventData";
@ -98,7 +102,7 @@ public class ParseEvtxTest {
ParseEvtx parseEvtx;
@Before
@BeforeEach
public void setup() throws XMLStreamException, IOException {
parseEvtx = new ParseEvtx(fileHeaderFactory, malformedChunkHandler, rootNodeHandlerFactory, resultProcessor);
when(fileHeaderFactory.create(in, componentLog)).thenReturn(fileHeader);

View File

@ -23,10 +23,10 @@ import org.apache.nifi.flowfile.attributes.CoreAttributes;
import org.apache.nifi.logging.ComponentLog;
import org.apache.nifi.processor.ProcessSession;
import org.apache.nifi.processor.Relationship;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.junit.MockitoJUnitRunner;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.mockito.junit.jupiter.MockitoExtension;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.anyString;
@ -36,14 +36,14 @@ import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.verifyNoMoreInteractions;
import static org.mockito.Mockito.when;
@RunWith(MockitoJUnitRunner.class)
@ExtendWith(MockitoExtension.class)
public class ResultProcessorTest {
Relationship successRelationship;
Relationship failureRelationship;
ResultProcessor resultProcessor;
@Before
@BeforeEach
public void setup() {
successRelationship = new Relationship.Builder().build();
failureRelationship = new Relationship.Builder().build();

View File

@ -31,13 +31,13 @@ import org.apache.nifi.processors.evtx.parser.bxml.TemplateNode;
import org.apache.nifi.processors.evtx.parser.bxml.ValueNode;
import org.apache.nifi.processors.evtx.parser.bxml.value.BXmlTypeNode;
import org.apache.nifi.processors.evtx.parser.bxml.value.VariantTypeNode;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.mockito.ArgumentCaptor;
import org.mockito.InOrder;
import org.mockito.Mock;
import org.mockito.junit.MockitoJUnitRunner;
import org.mockito.junit.jupiter.MockitoExtension;
import javax.xml.stream.XMLStreamException;
import javax.xml.stream.XMLStreamWriter;
@ -55,7 +55,7 @@ import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
@RunWith(MockitoJUnitRunner.class)
@ExtendWith(MockitoExtension.class)
public class XmlBxmlNodeVisitorTest {
@Mock
private XMLStreamWriter xmlStreamWriter;
@ -69,7 +69,7 @@ public class XmlBxmlNodeVisitorTest {
private List<BxmlNode> children;
private XmlBxmlNodeVisitor xmlBxmlNodeVisitor;
@Before
@BeforeEach
public void setup() throws IOException {
substitutions = new ArrayList<>();
children = new ArrayList<>(Arrays.asList(bxmlNode));

View File

@ -17,21 +17,22 @@
package org.apache.nifi.processors.evtx;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.mockito.Mock;
import org.mockito.junit.MockitoJUnitRunner;
import org.mockito.junit.jupiter.MockitoExtension;
import javax.xml.stream.XMLStreamException;
import javax.xml.stream.XMLStreamWriter;
import java.io.IOException;
import static org.junit.jupiter.api.Assertions.assertThrows;
import static org.mockito.Mockito.doThrow;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.verify;
@RunWith(MockitoJUnitRunner.class)
@ExtendWith(MockitoExtension.class)
public class XmlRootNodeHandlerTest {
@Mock
XMLStreamWriter xmlStreamWriter;
@ -41,7 +42,7 @@ public class XmlRootNodeHandlerTest {
XmlRootNodeHandler xmlRootNodeHandler;
@Before
@BeforeEach
public void setup() throws IOException {
xmlRootNodeHandler = new XmlRootNodeHandler(xmlStreamWriter, xmlBxmlNodeVisitorFactory);
}
@ -52,11 +53,11 @@ public class XmlRootNodeHandlerTest {
verify(xmlStreamWriter).writeStartElement(XmlRootNodeHandler.EVENTS);
}
@Test(expected = IOException.class)
public void testConstructorException() throws XMLStreamException, IOException {
@Test
public void testConstructorException() throws XMLStreamException {
xmlStreamWriter = mock(XMLStreamWriter.class);
doThrow(new XMLStreamException()).when(xmlStreamWriter).writeStartElement(XmlRootNodeHandler.EVENTS);
new XmlRootNodeHandler(xmlStreamWriter, xmlBxmlNodeVisitorFactory);
assertThrows(IOException.class, () -> new XmlRootNodeHandler(xmlStreamWriter, xmlBxmlNodeVisitorFactory));
}
@Test
@ -66,9 +67,9 @@ public class XmlRootNodeHandlerTest {
verify(xmlStreamWriter).close();
}
@Test(expected = IOException.class)
public void testCloseException() throws IOException, XMLStreamException {
@Test
public void testCloseException() throws XMLStreamException {
doThrow(new XMLStreamException()).when(xmlStreamWriter).close();
xmlRootNodeHandler.close();
assertThrows(IOException.class, () -> xmlRootNodeHandler.close());
}
}

View File

@ -20,8 +20,8 @@ package org.apache.nifi.processors.evtx.parser;
import com.google.common.base.Charsets;
import com.google.common.primitives.UnsignedInteger;
import com.google.common.primitives.UnsignedLong;
import org.junit.Before;
import org.junit.Test;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import java.io.ByteArrayInputStream;
import java.io.IOException;
@ -31,11 +31,12 @@ import java.util.Date;
import static org.junit.Assert.assertArrayEquals;
import static org.junit.Assert.assertEquals;
import static org.junit.jupiter.api.Assertions.assertThrows;
public class BinaryReaderTest {
private TestBinaryReaderBuilder testBinaryReaderBuilder;
@Before
@BeforeEach
public void setup() {
testBinaryReaderBuilder = new TestBinaryReaderBuilder();
}
@ -91,12 +92,12 @@ public class BinaryReaderTest {
assertEquals(16, binaryReader.getPosition());
}
@Test(expected = IOException.class)
@Test
public void testReadStringNotNullTerminated() throws IOException {
String value = "Hello world";
BinaryReader binaryReader = testBinaryReaderBuilder.put(value.getBytes(Charsets.US_ASCII)).build();
binaryReader.readString(value.length());
assertThrows(IOException.class, () -> binaryReader.readString(value.length()));
}
@Test

View File

@ -26,8 +26,8 @@ import org.apache.nifi.processors.evtx.parser.bxml.NameStringNodeTest;
import org.apache.nifi.processors.evtx.parser.bxml.RootNode;
import org.apache.nifi.processors.evtx.parser.bxml.TemplateNode;
import org.apache.nifi.processors.evtx.parser.bxml.TemplateNodeTest;
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.util.ArrayList;
@ -59,7 +59,7 @@ public class ChunkHeaderTest {
private int dataChecksum = 1111;
private List<String> guids;
@Before
@BeforeEach
public void setup() throws IOException {
TestBinaryReaderBuilder testBinaryReaderBuilder = new TestBinaryReaderBuilder();
testBinaryReaderBuilder.putString(ChunkHeader.ELF_CHNK);

View File

@ -19,8 +19,8 @@ package org.apache.nifi.processors.evtx.parser;
import com.google.common.primitives.UnsignedInteger;
import org.apache.nifi.logging.ComponentLog;
import org.junit.Before;
import org.junit.Test;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import java.io.ByteArrayInputStream;
import java.io.IOException;
@ -43,7 +43,7 @@ public class FileHeaderTest {
private int chunkCount = 0;
private int flags = 340942;
@Before
@BeforeEach
public void setup() throws IOException {
TestBinaryReaderBuilder testBinaryReaderBuilder = new TestBinaryReaderBuilder();
testBinaryReaderBuilder.putString(FileHeader.ELF_FILE);

View File

@ -20,11 +20,11 @@ package org.apache.nifi.processors.evtx.parser;
import org.apache.nifi.processors.evtx.parser.bxml.BxmlNode;
import org.apache.nifi.processors.evtx.parser.bxml.EndOfStreamNode;
import org.apache.nifi.processors.evtx.parser.bxml.RootNode;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.mockito.Mock;
import org.mockito.junit.MockitoJUnitRunner;
import org.mockito.junit.jupiter.MockitoExtension;
import java.io.IOException;
import java.util.Date;
@ -33,7 +33,7 @@ import java.util.List;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
@RunWith(MockitoJUnitRunner.class)
@ExtendWith(MockitoExtension.class)
public class RecordTest {
@Mock
ChunkHeader chunkHeader;
@ -53,7 +53,7 @@ public class RecordTest {
testBinaryReaderBuilder.putDWord(size);
}
@Before
@BeforeEach
public void setup() throws IOException {
TestBinaryReaderBuilder testBinaryReaderBuilder = new TestBinaryReaderBuilder();
putNode(testBinaryReaderBuilder, recordNum, new Date());

View File

@ -20,7 +20,8 @@ package org.apache.nifi.processors.evtx.parser.bxml;
import org.apache.nifi.processors.evtx.parser.BinaryReader;
import org.apache.nifi.processors.evtx.parser.BxmlNodeVisitor;
import org.apache.nifi.processors.evtx.parser.bxml.value.NullTypeNode;
import org.junit.Test;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import java.io.IOException;
import java.util.List;
@ -37,6 +38,7 @@ public class AttributeNodeTest extends BxmlNodeWithTokenAndStringTestBase {
private AttributeNode attributeNode;
@Override
@BeforeEach
public void setup() throws IOException {
super.setup();
testBinaryReaderBuilder.put((byte) BxmlNode.VALUE_TOKEN);

View File

@ -19,14 +19,14 @@ package org.apache.nifi.processors.evtx.parser.bxml;
import org.apache.nifi.processors.evtx.parser.ChunkHeader;
import org.apache.nifi.processors.evtx.parser.TestBinaryReaderBuilder;
import org.junit.Before;
import org.junit.runner.RunWith;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.extension.ExtendWith;
import org.mockito.Mock;
import org.mockito.junit.MockitoJUnitRunner;
import org.mockito.junit.jupiter.MockitoExtension;
import java.io.IOException;
@RunWith(MockitoJUnitRunner.class)
@ExtendWith(MockitoExtension.class)
public abstract class BxmlNodeTestBase {
public TestBinaryReaderBuilder testBinaryReaderBuilder;
@ -36,7 +36,7 @@ public abstract class BxmlNodeTestBase {
@Mock
public BxmlNode parent;
@Before
@BeforeEach
public void setup() throws IOException {
testBinaryReaderBuilder = new TestBinaryReaderBuilder();
}

View File

@ -18,7 +18,8 @@
package org.apache.nifi.processors.evtx.parser.bxml;
import org.apache.nifi.processors.evtx.parser.BxmlNodeVisitor;
import org.junit.Test;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import java.io.IOException;
@ -32,6 +33,7 @@ public class CDataSectionNodeTest extends BxmlNodeWithTokenTestBase {
private CDataSectionNode cDataSectionNode;
@Override
@BeforeEach
public void setup() throws IOException {
super.setup();
content = "cdata content";

View File

@ -18,7 +18,8 @@
package org.apache.nifi.processors.evtx.parser.bxml;
import org.apache.nifi.processors.evtx.parser.BxmlNodeVisitor;
import org.junit.Test;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import java.io.IOException;
@ -30,6 +31,7 @@ public class CloseElementNodeTest extends BxmlNodeWithTokenTestBase {
private CloseElementNode closeElementNode;
@Override
@BeforeEach
public void setup() throws IOException {
super.setup();
closeElementNode = new CloseElementNode(testBinaryReaderBuilder.build(), chunkHeader, parent);

View File

@ -18,7 +18,8 @@
package org.apache.nifi.processors.evtx.parser.bxml;
import org.apache.nifi.processors.evtx.parser.BxmlNodeVisitor;
import org.junit.Test;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import java.io.IOException;
@ -31,6 +32,7 @@ public class CloseEmptyElementNodeTest extends BxmlNodeWithTokenTestBase {
private CloseEmptyElementNode closeEmptyElementNode;
@Override
@BeforeEach
public void setup() throws IOException {
super.setup();
closeEmptyElementNode = new CloseEmptyElementNode(testBinaryReaderBuilder.build(), chunkHeader, parent);

View File

@ -18,7 +18,8 @@
package org.apache.nifi.processors.evtx.parser.bxml;
import org.apache.nifi.processors.evtx.parser.BxmlNodeVisitor;
import org.junit.Test;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import java.io.IOException;
@ -31,6 +32,7 @@ public class CloseStartElementNodeTest extends BxmlNodeWithTokenTestBase {
private CloseStartElementNode closeStartElementNode;
@Override
@BeforeEach
public void setup() throws IOException {
super.setup();
closeStartElementNode = new CloseStartElementNode(testBinaryReaderBuilder.build(), chunkHeader, parent);

View File

@ -18,7 +18,8 @@
package org.apache.nifi.processors.evtx.parser.bxml;
import org.apache.nifi.processors.evtx.parser.BxmlNodeVisitor;
import org.junit.Test;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import java.io.IOException;
@ -33,6 +34,7 @@ public class ConditionalSubstitutionNodeTest extends BxmlNodeWithTokenTestBase {
private byte type;
@Override
@BeforeEach
public void setup() throws IOException {
super.setup();
index = 10;

View File

@ -18,7 +18,8 @@
package org.apache.nifi.processors.evtx.parser.bxml;
import org.apache.nifi.processors.evtx.parser.BxmlNodeVisitor;
import org.junit.Test;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import java.io.IOException;
@ -31,6 +32,7 @@ public class EndOfStreamNodeTest extends BxmlNodeWithTokenTestBase {
private EndOfStreamNode endOfStreamNode;
@Override
@BeforeEach
public void setup() throws IOException {
super.setup();
endOfStreamNode = new EndOfStreamNode(testBinaryReaderBuilder.build(), chunkHeader, parent);

View File

@ -18,7 +18,8 @@
package org.apache.nifi.processors.evtx.parser.bxml;
import org.apache.nifi.processors.evtx.parser.BxmlNodeVisitor;
import org.junit.Test;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import java.io.IOException;
@ -32,6 +33,7 @@ public class EntityReferenceNodeTest extends BxmlNodeWithTokenAndStringTestBase
private EntityReferenceNode entityReferenceNode;
@Override
@BeforeEach
public void setup() throws IOException {
super.setup();
entityReferenceNode = new EntityReferenceNode(testBinaryReaderBuilder.build(), chunkHeader, parent);

View File

@ -20,7 +20,8 @@ package org.apache.nifi.processors.evtx.parser.bxml;
import com.google.common.primitives.UnsignedInteger;
import org.apache.nifi.processors.evtx.parser.BxmlNodeVisitor;
import org.apache.nifi.processors.evtx.parser.TestBinaryReaderBuilder;
import org.junit.Test;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import java.io.IOException;
@ -44,6 +45,7 @@ public class NameStringNodeTest extends BxmlNodeTestBase {
}
@Override
@BeforeEach
public void setup() throws IOException {
super.setup();
putNode(testBinaryReaderBuilder, nextOffset, hash, string);

View File

@ -18,7 +18,8 @@
package org.apache.nifi.processors.evtx.parser.bxml;
import org.apache.nifi.processors.evtx.parser.BxmlNodeVisitor;
import org.junit.Test;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import java.io.IOException;
@ -33,6 +34,7 @@ public class NormalSubstitutionNodeTest extends BxmlNodeWithTokenTestBase {
private NormalSubstitutionNode normalSubstitutionNode;
@Override
@BeforeEach
public void setup() throws IOException {
super.setup();
testBinaryReaderBuilder.putWord(index);

View File

@ -20,7 +20,8 @@ package org.apache.nifi.processors.evtx.parser.bxml;
import org.apache.nifi.processors.evtx.parser.BinaryReader;
import org.apache.nifi.processors.evtx.parser.BxmlNodeVisitor;
import org.apache.nifi.processors.evtx.parser.TestBinaryReaderBuilder;
import org.junit.Test;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import java.io.IOException;
import java.util.List;
@ -40,6 +41,7 @@ public class OpenStartElementNodeTest extends BxmlNodeWithTokenTestBase {
private OpenStartElementNode openStartElementNode;
@Override
@BeforeEach
public void setup() throws IOException {
super.setup();
testBinaryReaderBuilder.putWord(unknown);

View File

@ -18,7 +18,8 @@
package org.apache.nifi.processors.evtx.parser.bxml;
import org.apache.nifi.processors.evtx.parser.BxmlNodeVisitor;
import org.junit.Test;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import java.io.IOException;
@ -32,6 +33,7 @@ public class ProcessingInstructionDataNodeTest extends BxmlNodeWithTokenTestBase
private ProcessingInstructionDataNode processingInstructionDataNode;
@Override
@BeforeEach
public void setup() throws IOException {
super.setup();
testBinaryReaderBuilder.putWord(data.length());

View File

@ -18,7 +18,8 @@
package org.apache.nifi.processors.evtx.parser.bxml;
import org.apache.nifi.processors.evtx.parser.BxmlNodeVisitor;
import org.junit.Test;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import java.io.IOException;
@ -32,6 +33,7 @@ public class ProcessingInstructionTargetNodeTest extends BxmlNodeWithTokenAndStr
private ProcessingInstructionTargetNode processingInstructionTargetNode;
@Override
@BeforeEach
public void setup() throws IOException {
super.setup();
processingInstructionTargetNode = new ProcessingInstructionTargetNode(testBinaryReaderBuilder.build(), chunkHeader, parent);

View File

@ -19,7 +19,8 @@ package org.apache.nifi.processors.evtx.parser.bxml;
import org.apache.nifi.processors.evtx.parser.BxmlNodeVisitor;
import org.apache.nifi.processors.evtx.parser.bxml.value.VariantTypeNode;
import org.junit.Test;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import java.io.IOException;
import java.util.List;
@ -36,6 +37,7 @@ public class RootNodeTest extends BxmlNodeTestBase {
private RootNode rootNode;
@Override
@BeforeEach
public void setup() throws IOException {
super.setup();
testBinaryReaderBuilder.put((byte) BxmlNode.END_OF_STREAM_TOKEN);

View File

@ -18,7 +18,8 @@
package org.apache.nifi.processors.evtx.parser.bxml;
import org.apache.nifi.processors.evtx.parser.BxmlNodeVisitor;
import org.junit.Test;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import java.io.IOException;
@ -32,6 +33,7 @@ public class StreamStartNodeTest extends BxmlNodeWithTokenTestBase {
private StreamStartNode streamStartNode;
@Override
@BeforeEach
public void setup() throws IOException {
super.setup();
testBinaryReaderBuilder.put((byte) 1);

View File

@ -20,7 +20,8 @@ package org.apache.nifi.processors.evtx.parser.bxml;
import com.google.common.primitives.UnsignedInteger;
import org.apache.nifi.processors.evtx.parser.BinaryReader;
import org.apache.nifi.processors.evtx.parser.BxmlNodeVisitor;
import org.junit.Test;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import java.io.IOException;
@ -40,6 +41,7 @@ public class TemplateInstanceNodeTest extends BxmlNodeWithTokenTestBase {
private TemplateInstanceNode templateInstanceNode;
@Override
@BeforeEach
public void setup() throws IOException {
super.setup();
testBinaryReaderBuilder.put(unknown);

View File

@ -20,7 +20,8 @@ package org.apache.nifi.processors.evtx.parser.bxml;
import com.google.common.primitives.UnsignedInteger;
import org.apache.nifi.processors.evtx.parser.BxmlNodeVisitor;
import org.apache.nifi.processors.evtx.parser.TestBinaryReaderBuilder;
import org.junit.Test;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import java.io.IOException;
@ -45,6 +46,7 @@ public class TemplateNodeTest extends BxmlNodeTestBase {
}
@Override
@BeforeEach
public void setup() throws IOException {
super.setup();
putNode(testBinaryReaderBuilder, nextOffset, guid, dataLength);

View File

@ -19,7 +19,8 @@ package org.apache.nifi.processors.evtx.parser.bxml;
import org.apache.nifi.processors.evtx.parser.BxmlNodeVisitor;
import org.apache.nifi.processors.evtx.parser.bxml.value.NullTypeNode;
import org.junit.Test;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import java.io.IOException;
import java.util.List;
@ -34,6 +35,7 @@ public class ValueNodeTest extends BxmlNodeWithTokenTestBase {
private ValueNode valueNode;
@Override
@BeforeEach
public void setup() throws IOException {
super.setup();
testBinaryReaderBuilder.put((byte) 0);

View File

@ -21,18 +21,20 @@ import org.apache.nifi.processors.evtx.parser.bxml.BxmlNode;
import org.apache.nifi.processors.evtx.parser.bxml.BxmlNodeTestBase;
import org.apache.nifi.processors.evtx.parser.bxml.EndOfStreamNode;
import org.apache.nifi.processors.evtx.parser.bxml.RootNode;
import org.junit.Test;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import java.io.IOException;
import java.util.List;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertTrue;
public class BXmlTypeNodeTest extends BxmlNodeTestBase {
private BXmlTypeNode bXmlTypeNode;
@Override
@BeforeEach
public void setup() throws IOException {
super.setup();
testBinaryReaderBuilder.put((byte) BxmlNode.END_OF_STREAM_TOKEN);

View File

@ -21,12 +21,13 @@ import com.google.common.base.Charsets;
import com.google.common.primitives.UnsignedInteger;
import org.apache.nifi.processors.evtx.parser.BinaryReader;
import org.apache.nifi.processors.evtx.parser.bxml.BxmlNodeTestBase;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import java.io.IOException;
import java.util.Base64;
import static org.junit.Assert.assertEquals;
import static org.junit.jupiter.api.Assertions.assertThrows;
public class BinaryTypeNodeTest extends BxmlNodeTestBase {
@Test
@ -36,11 +37,11 @@ public class BinaryTypeNodeTest extends BxmlNodeTestBase {
assertEquals(Base64.getEncoder().encodeToString(val.getBytes(Charsets.US_ASCII)), new BinaryTypeNode(binaryReader, chunkHeader, parent, -1).getValue());
}
@Test(expected = IOException.class)
@Test
public void testInvalidStringLength() throws IOException {
String val = "Test String";
BinaryReader binaryReader = testBinaryReaderBuilder.putDWord(UnsignedInteger.fromIntBits(Integer.MAX_VALUE + 1)).putString(val).build();
assertEquals(Base64.getEncoder().encodeToString(val.getBytes(Charsets.US_ASCII)), new BinaryTypeNode(binaryReader, chunkHeader, parent, -1).getValue());
assertThrows(IOException.class, () -> assertEquals(Base64.getEncoder().encodeToString(val.getBytes(Charsets.US_ASCII)), new BinaryTypeNode(binaryReader, chunkHeader, parent, -1).getValue()));
}
@Test

View File

@ -18,12 +18,12 @@
package org.apache.nifi.processors.evtx.parser.bxml.value;
import org.apache.nifi.processors.evtx.parser.bxml.BxmlNodeTestBase;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import java.io.IOException;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertTrue;
public class BooleanTypeNodeTest extends BxmlNodeTestBase {
@Test

View File

@ -18,11 +18,11 @@
package org.apache.nifi.processors.evtx.parser.bxml.value;
import org.apache.nifi.processors.evtx.parser.bxml.BxmlNodeTestBase;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import java.io.IOException;
import static org.junit.Assert.assertEquals;
import static org.junit.jupiter.api.Assertions.assertEquals;
public class DoubleTypeNodeTest extends BxmlNodeTestBase {
@Test

View File

@ -18,12 +18,12 @@
package org.apache.nifi.processors.evtx.parser.bxml.value;
import org.apache.nifi.processors.evtx.parser.bxml.BxmlNodeTestBase;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import java.io.IOException;
import java.util.Date;
import static org.junit.Assert.assertEquals;
import static org.junit.jupiter.api.Assertions.assertEquals;
public class FiletimeTypeNodeTest extends BxmlNodeTestBase {
@Test

View File

@ -18,11 +18,11 @@
package org.apache.nifi.processors.evtx.parser.bxml.value;
import org.apache.nifi.processors.evtx.parser.bxml.BxmlNodeTestBase;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import java.io.IOException;
import static org.junit.Assert.assertEquals;
import static org.junit.jupiter.api.Assertions.assertEquals;
public class FloatTypeNodeTest extends BxmlNodeTestBase {
@Test

View File

@ -18,11 +18,11 @@
package org.apache.nifi.processors.evtx.parser.bxml.value;
import org.apache.nifi.processors.evtx.parser.bxml.BxmlNodeTestBase;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import java.io.IOException;
import static org.junit.Assert.assertEquals;
import static org.junit.jupiter.api.Assertions.assertEquals;
public class GuidTypeNodeTest extends BxmlNodeTestBase {
@Test

View File

@ -19,7 +19,7 @@ package org.apache.nifi.processors.evtx.parser.bxml.value;
import com.google.common.primitives.UnsignedInteger;
import org.apache.nifi.processors.evtx.parser.bxml.BxmlNodeTestBase;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import java.io.IOException;

View File

@ -19,7 +19,7 @@ package org.apache.nifi.processors.evtx.parser.bxml.value;
import com.google.common.primitives.UnsignedLong;
import org.apache.nifi.processors.evtx.parser.bxml.BxmlNodeTestBase;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import java.io.IOException;

View File

@ -18,7 +18,7 @@
package org.apache.nifi.processors.evtx.parser.bxml.value;
import org.apache.nifi.processors.evtx.parser.bxml.BxmlNodeTestBase;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import java.io.IOException;

View File

@ -18,7 +18,7 @@
package org.apache.nifi.processors.evtx.parser.bxml.value;
import org.apache.nifi.processors.evtx.parser.bxml.BxmlNodeTestBase;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import java.io.IOException;

View File

@ -18,7 +18,7 @@
package org.apache.nifi.processors.evtx.parser.bxml.value;
import org.apache.nifi.processors.evtx.parser.bxml.BxmlNodeTestBase;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import java.io.IOException;

View File

@ -18,7 +18,7 @@
package org.apache.nifi.processors.evtx.parser.bxml.value;
import org.apache.nifi.processors.evtx.parser.bxml.BxmlNodeTestBase;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import java.io.IOException;

View File

@ -18,7 +18,7 @@
package org.apache.nifi.processors.evtx.parser.bxml.value;
import org.apache.nifi.processors.evtx.parser.bxml.BxmlNodeTestBase;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import java.io.IOException;

View File

@ -18,7 +18,7 @@
package org.apache.nifi.processors.evtx.parser.bxml.value;
import org.apache.nifi.processors.evtx.parser.bxml.BxmlNodeTestBase;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import java.io.IOException;

View File

@ -20,7 +20,7 @@ package org.apache.nifi.processors.evtx.parser.bxml.value;
import com.google.common.primitives.UnsignedInteger;
import com.google.common.primitives.UnsignedLong;
import org.apache.nifi.processors.evtx.parser.bxml.BxmlNodeTestBase;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import java.io.IOException;

View File

@ -19,7 +19,7 @@ package org.apache.nifi.processors.evtx.parser.bxml.value;
import org.apache.nifi.processors.evtx.parser.BinaryReader;
import org.apache.nifi.processors.evtx.parser.bxml.BxmlNodeTestBase;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import java.io.IOException;

View File

@ -18,7 +18,7 @@
package org.apache.nifi.processors.evtx.parser.bxml.value;
import org.apache.nifi.processors.evtx.parser.bxml.BxmlNodeTestBase;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import java.io.IOException;
import java.util.Calendar;

View File

@ -18,7 +18,7 @@
package org.apache.nifi.processors.evtx.parser.bxml.value;
import org.apache.nifi.processors.evtx.parser.bxml.BxmlNodeTestBase;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import java.io.IOException;

View File

@ -19,7 +19,7 @@ package org.apache.nifi.processors.evtx.parser.bxml.value;
import com.google.common.primitives.UnsignedInteger;
import org.apache.nifi.processors.evtx.parser.bxml.BxmlNodeTestBase;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import java.io.IOException;

View File

@ -19,7 +19,7 @@ package org.apache.nifi.processors.evtx.parser.bxml.value;
import com.google.common.primitives.UnsignedLong;
import org.apache.nifi.processors.evtx.parser.bxml.BxmlNodeTestBase;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import java.io.IOException;

View File

@ -18,7 +18,7 @@
package org.apache.nifi.processors.evtx.parser.bxml.value;
import org.apache.nifi.processors.evtx.parser.bxml.BxmlNodeTestBase;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import java.io.IOException;

View File

@ -18,7 +18,7 @@
package org.apache.nifi.processors.evtx.parser.bxml.value;
import org.apache.nifi.processors.evtx.parser.bxml.BxmlNodeTestBase;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import java.io.IOException;

View File

@ -18,7 +18,7 @@
package org.apache.nifi.processors.evtx.parser.bxml.value;
import org.apache.nifi.processors.evtx.parser.bxml.BxmlNodeTestBase;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import java.io.IOException;

View File

@ -16,18 +16,6 @@
*/
package org.apache.nifi.processors.flume;
import java.io.File;
import static org.junit.Assert.assertEquals;
import java.io.FilenameFilter;
import java.io.IOException;
import java.io.InputStream;
import java.util.Collection;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import org.apache.commons.io.filefilter.HiddenFileFilter;
import org.apache.flume.sink.NullSink;
import org.apache.flume.source.AvroSource;
@ -39,22 +27,31 @@ import org.apache.nifi.util.TestRunner;
import org.apache.nifi.util.TestRunners;
import org.apache.nifi.util.file.FileUtils;
import org.apache.nifi.util.security.MessageDigestUtils;
import org.junit.Assert;
import org.junit.Ignore;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.TemporaryFolder;
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.io.TempDir;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.io.File;
import java.io.FilenameFilter;
import java.io.IOException;
import java.io.InputStream;
import java.nio.file.Path;
import java.util.Collection;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import static org.junit.jupiter.api.Assertions.assertArrayEquals;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertTrue;
public class ExecuteFlumeSinkTest {
private static final Logger logger =
LoggerFactory.getLogger(ExecuteFlumeSinkTest.class);
@Rule
public final TemporaryFolder temp = new TemporaryFolder();
@Test
public void testValidators() {
TestRunner runner = TestRunners.newTestRunner(ExecuteFlumeSink.class);
@ -67,10 +64,10 @@ public class ExecuteFlumeSinkTest {
if (pc instanceof MockProcessContext) {
results = ((MockProcessContext) pc).validate();
}
Assert.assertEquals(1, results.size());
assertEquals(1, results.size());
for (ValidationResult vr : results) {
logger.debug(vr.toString());
Assert.assertTrue(vr.toString().contains("is invalid because Sink Type is required"));
assertTrue(vr.toString().contains("is invalid because Sink Type is required"));
}
// non-existent class
@ -81,10 +78,10 @@ public class ExecuteFlumeSinkTest {
if (pc instanceof MockProcessContext) {
results = ((MockProcessContext) pc).validate();
}
Assert.assertEquals(1, results.size());
assertEquals(1, results.size());
for (ValidationResult vr : results) {
logger.debug(vr.toString());
Assert.assertTrue(vr.toString().contains("is invalid because unable to load sink"));
assertTrue(vr.toString().contains("is invalid because unable to load sink"));
}
// class doesn't implement Sink
@ -95,10 +92,10 @@ public class ExecuteFlumeSinkTest {
if (pc instanceof MockProcessContext) {
results = ((MockProcessContext) pc).validate();
}
Assert.assertEquals(1, results.size());
assertEquals(1, results.size());
for (ValidationResult vr : results) {
logger.debug(vr.toString());
Assert.assertTrue(vr.toString().contains("is invalid because unable to create sink"));
assertTrue(vr.toString().contains("is invalid because unable to create sink"));
}
results = new HashSet<>();
@ -108,7 +105,7 @@ public class ExecuteFlumeSinkTest {
if (pc instanceof MockProcessContext) {
results = ((MockProcessContext) pc).validate();
}
Assert.assertEquals(0, results.size());
assertEquals(0, results.size());
}
@ -137,9 +134,10 @@ public class ExecuteFlumeSinkTest {
}
@Test
@Ignore("Does not work on Windows")
public void testHdfsSink() throws IOException {
File destDir = temp.newFolder("hdfs");
@Disabled("Does not work on Windows")
public void testHdfsSink(@TempDir Path temp) throws IOException {
File destDir = temp.resolve("hdfs").toFile();
destDir.mkdirs();
TestRunner runner = TestRunners.newTestRunner(ExecuteFlumeSink.class);
runner.setProperty(ExecuteFlumeSink.SINK_TYPE, "hdfs");
@ -157,14 +155,14 @@ public class ExecuteFlumeSinkTest {
}
File[] files = destDir.listFiles((FilenameFilter)HiddenFileFilter.VISIBLE);
assertEquals("Unexpected number of destination files.", 1, files.length);
assertEquals(1, files.length, "Unexpected number of destination files.");
File dst = files[0];
byte[] expectedDigest;
try (InputStream resourceStream = getClass().getResourceAsStream("/testdata/records.txt")) {
expectedDigest = MessageDigestUtils.getDigest(resourceStream);
}
byte[] actualDigest = FileUtils.computeDigest(dst);
Assert.assertArrayEquals("Destination file doesn't match source data", expectedDigest, actualDigest);
assertArrayEquals(expectedDigest, actualDigest, "Destination file doesn't match source data");
}
}

View File

@ -17,13 +17,6 @@
package org.apache.nifi.processors.flume;
import java.io.File;
import java.io.IOException;
import java.util.Collection;
import java.util.HashSet;
import java.util.List;
import java.util.concurrent.TimeUnit;
import org.apache.flume.sink.NullSink;
import org.apache.flume.source.AvroSource;
import org.apache.nifi.components.ValidationResult;
@ -33,21 +26,27 @@ import org.apache.nifi.util.MockProcessContext;
import org.apache.nifi.util.TestRunner;
import org.apache.nifi.util.TestRunners;
import org.apache.nifi.util.file.FileUtils;
import org.junit.Assert;
import org.junit.Ignore;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.TemporaryFolder;
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.io.TempDir;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.io.File;
import java.io.IOException;
import java.nio.file.Path;
import java.util.Collection;
import java.util.HashSet;
import java.util.List;
import java.util.concurrent.TimeUnit;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertTrue;
public class ExecuteFlumeSourceTest {
private static final Logger logger = LoggerFactory.getLogger(ExecuteFlumeSourceTest.class);
@Rule
public final TemporaryFolder temp = new TemporaryFolder();
@Test
public void testValidators() {
TestRunner runner = TestRunners.newTestRunner(ExecuteFlumeSource.class);
@ -60,10 +59,10 @@ public class ExecuteFlumeSourceTest {
if (pc instanceof MockProcessContext) {
results = ((MockProcessContext) pc).validate();
}
Assert.assertEquals(1, results.size());
assertEquals(1, results.size());
for (ValidationResult vr : results) {
logger.debug(vr.toString());
Assert.assertTrue(vr.toString().contains("is invalid because Source Type is required"));
assertTrue(vr.toString().contains("is invalid because Source Type is required"));
}
// non-existent class
@ -74,10 +73,10 @@ public class ExecuteFlumeSourceTest {
if (pc instanceof MockProcessContext) {
results = ((MockProcessContext) pc).validate();
}
Assert.assertEquals(1, results.size());
assertEquals(1, results.size());
for (ValidationResult vr : results) {
logger.debug(vr.toString());
Assert.assertTrue(vr.toString().contains("is invalid because unable to load source"));
assertTrue(vr.toString().contains("is invalid because unable to load source"));
}
// class doesn't implement Source
@ -88,10 +87,10 @@ public class ExecuteFlumeSourceTest {
if (pc instanceof MockProcessContext) {
results = ((MockProcessContext) pc).validate();
}
Assert.assertEquals(1, results.size());
assertEquals(1, results.size());
for (ValidationResult vr : results) {
logger.debug(vr.toString());
Assert.assertTrue(vr.toString().contains("is invalid because unable to create source"));
assertTrue(vr.toString().contains("is invalid because unable to create source"));
}
results = new HashSet<>();
@ -101,7 +100,7 @@ public class ExecuteFlumeSourceTest {
if (pc instanceof MockProcessContext) {
results = ((MockProcessContext) pc).validate();
}
Assert.assertEquals(0, results.size());
assertEquals(0, results.size());
}
@Test
@ -110,17 +109,18 @@ public class ExecuteFlumeSourceTest {
runner.setProperty(ExecuteFlumeSource.SOURCE_TYPE, "seq");
runner.run();
List<MockFlowFile> flowFiles = runner.getFlowFilesForRelationship(ExecuteFlumeSource.SUCCESS);
Assert.assertEquals(1, flowFiles.size());
assertEquals(1, flowFiles.size());
for (MockFlowFile flowFile : flowFiles) {
logger.debug(flowFile.toString());
Assert.assertEquals(1, flowFile.getSize());
assertEquals(1, flowFile.getSize());
}
}
@Test
@Ignore("Does not work on Windows")
public void testSourceWithConfig() throws IOException {
File spoolDirectory = temp.newFolder("spooldir");
@Disabled("Does not work on Windows")
public void testSourceWithConfig(@TempDir Path temp) throws IOException {
File spoolDirectory = temp.resolve("spooldir").toFile();
spoolDirectory.mkdirs();
File dst = new File(spoolDirectory, "records.txt");
FileUtils.copyFile(getClass().getResourceAsStream("/testdata/records.txt"), dst, true, false);

View File

@ -171,7 +171,6 @@
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-failsafe-plugin</artifactId>
<configuration>
<groups>org.apache.nifi.processors.gcp.GCPIntegrationTests</groups>
<skipITs>${skipGCPIntegrationTests}</skipITs>
</configuration>
</plugin>
@ -179,7 +178,6 @@
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<excludedGroups>org.apache.nifi.processors.gcp.GCPIntegrationTests</excludedGroups>
<environmentVariables>
<GOOGLE_APPLICATION_CREDENTIALS>${project.basedir}/src/test/resources/mock-gcp-application-default-credentials.json</GOOGLE_APPLICATION_CREDENTIALS>
</environmentVariables>

View File

@ -26,8 +26,8 @@ import org.apache.nifi.processor.Processor;
import org.apache.nifi.processors.gcp.credentials.service.GCPCredentialsControllerService;
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 org.mockito.Mock;
import org.mockito.MockitoAnnotations;
@ -45,7 +45,7 @@ public abstract class AbstractBQTest {
static final String DATASET = RemoteBigQueryHelper.generateDatasetName();
@Before
@BeforeEach
public void setup() throws Exception {
MockitoAnnotations.initMocks(this);
}

View File

@ -17,33 +17,29 @@
package org.apache.nifi.processors.gcp.bigquery;
import static org.junit.Assert.assertNull;
import java.io.IOException;
import java.util.HashMap;
import java.util.Map;
import org.apache.nifi.components.PropertyDescriptor;
import org.apache.nifi.flowfile.FlowFile;
import org.apache.nifi.processors.gcp.GCPIntegrationTests;
import org.apache.nifi.processors.gcp.ProxyAwareTransportFactory;
import org.apache.nifi.processors.gcp.credentials.factory.CredentialPropertyDescriptors;
import org.apache.nifi.processors.gcp.credentials.factory.CredentialsFactory;
import org.apache.nifi.processors.gcp.credentials.service.GCPCredentialsControllerService;
import org.apache.nifi.reporting.InitializationException;
import org.apache.nifi.util.TestRunner;
import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.experimental.categories.Category;
import com.google.auth.Credentials;
import com.google.cloud.bigquery.BigQuery;
import com.google.cloud.bigquery.BigQueryOptions;
import com.google.cloud.bigquery.Dataset;
import com.google.cloud.bigquery.DatasetInfo;
import com.google.cloud.bigquery.testing.RemoteBigQueryHelper;
import org.apache.nifi.components.PropertyDescriptor;
import org.apache.nifi.flowfile.FlowFile;
import org.apache.nifi.processors.gcp.ProxyAwareTransportFactory;
import org.apache.nifi.processors.gcp.credentials.factory.CredentialPropertyDescriptors;
import org.apache.nifi.processors.gcp.credentials.factory.CredentialsFactory;
import org.apache.nifi.processors.gcp.credentials.service.GCPCredentialsControllerService;
import org.apache.nifi.reporting.InitializationException;
import org.apache.nifi.util.TestRunner;
import org.junit.jupiter.api.AfterAll;
import org.junit.jupiter.api.BeforeAll;
import java.io.IOException;
import java.util.HashMap;
import java.util.Map;
import static org.junit.Assert.assertNull;
@Category(GCPIntegrationTests.class)
public abstract class AbstractBigQueryIT {
protected static final String CONTROLLER_SERVICE = "GCPCredentialsService";
@ -56,7 +52,7 @@ public abstract class AbstractBigQueryIT {
private static final CredentialsFactory credentialsProviderFactory = new CredentialsFactory();
@BeforeClass
@BeforeAll
public static void beforeClass() throws IOException {
final Map<PropertyDescriptor, String> propertiesMap = new HashMap<>();
propertiesMap.put(CredentialPropertyDescriptors.SERVICE_ACCOUNT_JSON_FILE, SERVICE_ACCOUNT_JSON);
@ -73,7 +69,7 @@ public abstract class AbstractBigQueryIT {
dataset = bigquery.create(datasetInfo);
}
@AfterClass
@AfterAll
public static void afterClass() {
bigquery.delete(dataset.getDatasetId(), BigQuery.DatasetDeleteOption.deleteContents());
}

View File

@ -17,6 +17,14 @@
package org.apache.nifi.processors.gcp.bigquery;
import com.google.cloud.bigquery.FormatOptions;
import org.apache.nifi.processors.gcp.AbstractGCPProcessor;
import org.apache.nifi.reporting.InitializationException;
import org.apache.nifi.util.MockFlowFile;
import org.apache.nifi.util.TestRunners;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import java.io.BufferedWriter;
import java.io.ByteArrayInputStream;
import java.io.IOException;
@ -24,15 +32,6 @@ import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.nio.file.Path;
import org.apache.nifi.processors.gcp.AbstractGCPProcessor;
import org.apache.nifi.reporting.InitializationException;
import org.apache.nifi.util.MockFlowFile;
import org.apache.nifi.util.TestRunners;
import org.junit.Before;
import org.junit.Test;
import com.google.cloud.bigquery.FormatOptions;
public class PutBigQueryBatchIT extends AbstractBigQueryIT {
private static final String TABLE_SCHEMA_STRING = "[\n" +
@ -56,7 +55,7 @@ public class PutBigQueryBatchIT extends AbstractBigQueryIT {
" }\n" +
"]";
@Before
@BeforeEach
public void setup() {
runner = TestRunners.newTestRunner(PutBigQueryBatch.class);
runner.setProperty(AbstractBigQueryProcessor.PROJECT_ID, PROJECT_ID);

View File

@ -32,8 +32,8 @@ import org.apache.nifi.components.ConfigVerificationResult;
import org.apache.nifi.processor.ProcessContext;
import org.apache.nifi.processor.VerifiableProcessor;
import org.apache.nifi.util.TestRunner;
import org.junit.Before;
import org.junit.Test;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.mockito.ArgumentMatchers;
import org.mockito.Mock;
@ -79,7 +79,7 @@ public class PutBigQueryBatchTest extends AbstractBQTest {
@Mock
TableDataWriteChannel tableDataWriteChannel;
@Before
@BeforeEach
public void setup() throws Exception {
super.setup();
reset(bq);

View File

@ -17,26 +17,6 @@
package org.apache.nifi.processors.gcp.bigquery;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.time.LocalDateTime;
import java.time.ZoneOffset;
import java.time.format.DateTimeFormatter;
import java.util.Iterator;
import org.apache.nifi.json.JsonTreeReader;
import org.apache.nifi.processors.gcp.AbstractGCPProcessor;
import org.apache.nifi.reporting.InitializationException;
import org.apache.nifi.schema.access.SchemaAccessUtils;
import org.apache.nifi.serialization.DateTimeUtils;
import org.apache.nifi.util.TestRunners;
import org.junit.Before;
import org.junit.Test;
import com.google.cloud.bigquery.Field;
import com.google.cloud.bigquery.Field.Mode;
import com.google.cloud.bigquery.FieldValueList;
@ -47,12 +27,31 @@ import com.google.cloud.bigquery.TableDefinition;
import com.google.cloud.bigquery.TableId;
import com.google.cloud.bigquery.TableInfo;
import com.google.cloud.bigquery.TableResult;
import org.apache.nifi.json.JsonTreeReader;
import org.apache.nifi.processors.gcp.AbstractGCPProcessor;
import org.apache.nifi.reporting.InitializationException;
import org.apache.nifi.schema.access.SchemaAccessUtils;
import org.apache.nifi.serialization.DateTimeUtils;
import org.apache.nifi.util.TestRunners;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.time.LocalDateTime;
import java.time.ZoneOffset;
import java.time.format.DateTimeFormatter;
import java.util.Iterator;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
public class PutBigQueryStreamingIT extends AbstractBigQueryIT {
private Schema schema;
@Before
@BeforeEach
public void setup() throws InitializationException {
runner = TestRunners.newTestRunner(PutBigQueryStreaming.class);
runner = setCredentialsControllerService(runner);

View File

@ -25,7 +25,7 @@ import com.google.auth.oauth2.ServiceAccountCredentials;
import org.apache.nifi.components.PropertyDescriptor;
import org.apache.nifi.util.TestRunner;
import org.apache.nifi.util.TestRunners;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import java.lang.reflect.Constructor;
import java.lang.reflect.Modifier;

View File

@ -18,13 +18,13 @@ package org.apache.nifi.processors.gcp.credentials.service;
import com.google.auth.oauth2.GoogleCredentials;
import com.google.auth.oauth2.ServiceAccountCredentials;
import org.apache.nifi.gcp.credentials.service.GCPCredentialsService;
import org.apache.nifi.util.TestRunner;
import org.apache.nifi.util.TestRunners;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import java.nio.file.Files;
import java.nio.file.Paths;
import org.apache.nifi.gcp.credentials.service.GCPCredentialsService;
import static org.apache.nifi.processors.gcp.credentials.factory.CredentialPropertyDescriptors.SERVICE_ACCOUNT_JSON;
import static org.apache.nifi.processors.gcp.credentials.factory.CredentialPropertyDescriptors.SERVICE_ACCOUNT_JSON_FILE;

View File

@ -18,8 +18,8 @@ package org.apache.nifi.processors.gcp.pubsub;
import org.apache.nifi.reporting.InitializationException;
import org.apache.nifi.util.TestRunners;
import org.junit.BeforeClass;
import org.junit.Test;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Test;
import static org.apache.nifi.processors.gcp.pubsub.PubSubAttributes.ACK_ID_ATTRIBUTE;
import static org.apache.nifi.processors.gcp.pubsub.PubSubAttributes.MSG_ATTRIBUTES_COUNT_ATTRIBUTE;
@ -27,7 +27,7 @@ import static org.apache.nifi.processors.gcp.pubsub.PubSubAttributes.MSG_PUBLISH
public class ConsumeGCPubSubIT extends AbstractGCPubSubIT{
@BeforeClass
@BeforeAll
public static void setup() throws InitializationException {
runner = TestRunners.newTestRunner(ConsumeGCPubSub.class);
}

View File

@ -18,15 +18,15 @@ package org.apache.nifi.processors.gcp.pubsub;
import org.apache.nifi.reporting.InitializationException;
import org.apache.nifi.util.TestRunners;
import org.junit.BeforeClass;
import org.junit.Test;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Test;
import static org.apache.nifi.processors.gcp.pubsub.PubSubAttributes.MESSAGE_ID_ATTRIBUTE;
import static org.apache.nifi.processors.gcp.pubsub.PubSubAttributes.TOPIC_NAME_ATTRIBUTE;
public class PublishGCPubSubIT extends AbstractGCPubSubIT{
@BeforeClass
@BeforeAll
public static void setup() throws InitializationException {
runner = TestRunners.newTestRunner(PublishGCPubSub.class);
}

View File

@ -24,13 +24,11 @@ import com.google.cloud.storage.Storage;
import com.google.cloud.storage.StorageException;
import com.google.cloud.storage.testing.RemoteStorageHelper;
import org.apache.nifi.processor.Processor;
import org.apache.nifi.processors.gcp.GCPIntegrationTests;
import org.apache.nifi.processors.gcp.credentials.service.GCPCredentialsControllerService;
import org.apache.nifi.util.TestRunner;
import org.apache.nifi.util.TestRunners;
import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.experimental.categories.Category;
import org.junit.jupiter.api.AfterAll;
import org.junit.jupiter.api.BeforeAll;
import java.util.Arrays;
@ -41,7 +39,6 @@ import static org.junit.Assert.fail;
* Assumes use of <a href=https://developers.google.com/identity/protocols/application-default-credentials">Application Default</a>
* credentials for running tests.
*/
@Category(GCPIntegrationTests.class)
public abstract class AbstractGCSIT {
private static final String PROJECT_ID = System.getProperty("test.gcp.project.id", "nifi-test-gcp-project");
protected static final String BUCKET = RemoteStorageHelper.generateBucketName();
@ -51,7 +48,7 @@ public abstract class AbstractGCSIT {
protected static RemoteStorageHelper helper;
protected static Storage storage;
@BeforeClass
@BeforeAll
public static void setUp() {
try {
helper = RemoteStorageHelper.create();
@ -73,7 +70,7 @@ public abstract class AbstractGCSIT {
}
}
@AfterClass
@AfterAll
public static void tearDown() {
try {
// Empty the bucket before deleting it.

View File

@ -26,9 +26,12 @@ import org.apache.nifi.processor.Processor;
import org.apache.nifi.processors.gcp.credentials.service.GCPCredentialsControllerService;
import org.apache.nifi.util.TestRunner;
import org.apache.nifi.util.TestRunners;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.mockito.Mock;
import org.mockito.MockitoAnnotations;
import org.mockito.junit.jupiter.MockitoExtension;
import static org.junit.jupiter.api.Assertions.assertEquals;
@ -46,6 +49,11 @@ public abstract class AbstractGCSTest {
static final String BUCKET = RemoteStorageHelper.generateBucketName();
@BeforeEach
public void setup() throws Exception {
MockitoAnnotations.initMocks(this);
}
public static TestRunner buildNewRunner(Processor processor) throws Exception {
final GCPCredentialsService credentialsService = new GCPCredentialsControllerService();

View File

@ -18,7 +18,7 @@ package org.apache.nifi.processors.gcp.storage;
import org.apache.nifi.flowfile.attributes.CoreAttributes;
import org.apache.nifi.util.TestRunner;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import java.util.Collections;

View File

@ -20,9 +20,12 @@ import com.google.cloud.storage.BlobId;
import com.google.cloud.storage.Storage;
import com.google.cloud.storage.StorageException;
import org.apache.nifi.util.TestRunner;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.mockito.Mock;
import org.mockito.MockitoAnnotations;
import org.mockito.junit.jupiter.MockitoExtension;
import java.util.LinkedHashMap;
@ -50,6 +53,11 @@ public class DeleteGCSObjectTest extends AbstractGCSTest {
@Mock
Storage storage;
@BeforeEach
public void setup() throws Exception {
MockitoAnnotations.initMocks(this);
}
@Override
protected void addRequiredPropertiesToRunner(TestRunner runner) {
runner.setProperty(DeleteGCSObject.BUCKET, BUCKET);

View File

@ -19,7 +19,7 @@ package org.apache.nifi.processors.gcp.storage;
import org.apache.nifi.components.ConfigVerificationResult;
import org.apache.nifi.util.MockFlowFile;
import org.apache.nifi.util.TestRunner;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import java.util.Collections;
import java.util.HashMap;

View File

@ -28,10 +28,13 @@ import org.apache.nifi.flowfile.attributes.CoreAttributes;
import org.apache.nifi.processor.ProcessContext;
import org.apache.nifi.util.MockFlowFile;
import org.apache.nifi.util.TestRunner;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.mockito.ArgumentCaptor;
import org.mockito.Mock;
import org.mockito.MockitoAnnotations;
import org.mockito.junit.jupiter.MockitoExtension;
import java.io.IOException;
@ -106,6 +109,11 @@ public class FetchGCSObjectTest extends AbstractGCSTest {
@Mock
Storage storage;
@BeforeEach
public void setup() throws Exception {
MockitoAnnotations.initMocks(this);
}
@Override
public AbstractGCSProcessor getProcessor() {
return new FetchGCSObject() {

View File

@ -19,7 +19,7 @@ package org.apache.nifi.processors.gcp.storage;
import com.google.cloud.storage.BucketInfo;
import org.apache.nifi.util.MockFlowFile;
import org.apache.nifi.util.TestRunner;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import java.util.List;

View File

@ -21,7 +21,7 @@ import com.google.cloud.storage.Blob;
import com.google.cloud.storage.BlobId;
import org.apache.nifi.util.MockFlowFile;
import org.apache.nifi.util.TestRunner;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import java.util.Map;

View File

@ -16,6 +16,26 @@
*/
package org.apache.nifi.processors.gcp.storage;
import com.google.cloud.storage.Acl;
import com.google.cloud.storage.Blob;
import com.google.cloud.storage.BlobInfo;
import com.google.cloud.storage.Storage;
import com.google.cloud.storage.StorageException;
import org.apache.nifi.flowfile.attributes.CoreAttributes;
import org.apache.nifi.util.MockFlowFile;
import org.apache.nifi.util.TestRunner;
import org.junit.jupiter.api.Test;
import org.mockito.ArgumentCaptor;
import org.mockito.Captor;
import org.mockito.Mock;
import java.io.InputStream;
import java.util.Collections;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import static com.google.cloud.storage.Storage.PredefinedAcl.BUCKET_OWNER_READ;
import static org.apache.nifi.processors.gcp.storage.StorageAttributes.BUCKET_ATTR;
import static org.apache.nifi.processors.gcp.storage.StorageAttributes.CACHE_CONTROL_ATTR;
@ -48,25 +68,6 @@ import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.reset;
import static org.mockito.Mockito.when;
import com.google.cloud.storage.Acl;
import com.google.cloud.storage.Blob;
import com.google.cloud.storage.BlobInfo;
import com.google.cloud.storage.Storage;
import com.google.cloud.storage.StorageException;
import java.io.InputStream;
import java.util.Collections;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import org.apache.nifi.flowfile.attributes.CoreAttributes;
import org.apache.nifi.util.MockFlowFile;
import org.apache.nifi.util.TestRunner;
import org.junit.jupiter.api.Test;
import org.mockito.ArgumentCaptor;
import org.mockito.Captor;
import org.mockito.Mock;
/**
* Unit tests for {@link PutGCSObject} which do not use Google Cloud resources.
*/

View File

@ -16,7 +16,7 @@
*/
package org.apache.nifi.processors.gcp.storage;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import java.lang.reflect.Constructor;
import java.lang.reflect.Modifier;

View File

@ -16,7 +16,7 @@
*/
package org.apache.nifi.processors.gcp.storage;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;

View File

@ -25,13 +25,14 @@ import org.apache.nifi.processor.ProcessSessionFactory;
import org.apache.nifi.util.MockFlowFile;
import org.apache.nifi.util.TestRunner;
import org.apache.nifi.util.TestRunners;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import java.util.List;
import static org.hamcrest.CoreMatchers.equalTo;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.core.StringContains.containsString;
import static org.junit.jupiter.api.Assertions.assertThrows;
import static org.mockito.Mockito.spy;
import static org.mockito.Mockito.when;
@ -119,49 +120,51 @@ public class ITListenGRPC {
}
}
@Test(expected = io.grpc.StatusRuntimeException.class)
public void testExceedMaxMessageSize() throws Exception {
final int randPort = TestGRPCClient.randomPort();
final ManagedChannel channel = TestGRPCClient.buildChannel(HOST, randPort);
final FlowFileServiceGrpc.FlowFileServiceBlockingStub stub = FlowFileServiceGrpc.newBlockingStub(channel);
@Test
public void testExceedMaxMessageSize() {
assertThrows(io.grpc.StatusRuntimeException.class, () -> {
final int randPort = TestGRPCClient.randomPort();
final ManagedChannel channel = TestGRPCClient.buildChannel(HOST, randPort);
final FlowFileServiceGrpc.FlowFileServiceBlockingStub stub = FlowFileServiceGrpc.newBlockingStub(channel);
final ListenGRPC listenGRPC = new ListenGRPC();
final TestRunner runner = TestRunners.newTestRunner(listenGRPC);
runner.setProperty(ListenGRPC.PROP_SERVICE_PORT, String.valueOf(randPort));
// set max message size to 1 byte to force exception to be thrown.
runner.setProperty(ListenGRPC.PROP_MAX_MESSAGE_SIZE, "1B");
final ListenGRPC listenGRPC = new ListenGRPC();
final TestRunner runner = TestRunners.newTestRunner(listenGRPC);
runner.setProperty(ListenGRPC.PROP_SERVICE_PORT, String.valueOf(randPort));
// set max message size to 1 byte to force exception to be thrown.
runner.setProperty(ListenGRPC.PROP_MAX_MESSAGE_SIZE, "1B");
final ProcessContext processContext = runner.getProcessContext();
final ProcessSessionFactory processSessionFactory = runner.getProcessSessionFactory();
final ProcessContext processContext = runner.getProcessContext();
final ProcessSessionFactory processSessionFactory = runner.getProcessSessionFactory();
try {
// start the server. The order of the following statements shouldn't matter, because the
// startServer() method waits for a processSessionFactory to be available to it.
listenGRPC.startServer(processContext);
listenGRPC.onTrigger(processContext, processSessionFactory);
try {
// start the server. The order of the following statements shouldn't matter, because the
// startServer() method waits for a processSessionFactory to be available to it.
listenGRPC.startServer(processContext);
listenGRPC.onTrigger(processContext, processSessionFactory);
final FlowFileRequest ingestFile = FlowFileRequest.newBuilder()
.putAttributes("FOO", "BAR")
.putAttributes(CoreAttributes.UUID.key(), SOURCE_SYSTEM_UUID)
.setContent(ByteString.copyFrom("content".getBytes()))
.build();
// this should throw a runtime exception
final FlowFileReply reply = stub.send(ingestFile);
assertThat(reply.getResponseCode(), equalTo(FlowFileReply.ResponseCode.SUCCESS));
assertThat(reply.getBody(), equalTo("FlowFile successfully received."));
final FlowFileRequest ingestFile = FlowFileRequest.newBuilder()
.putAttributes("FOO", "BAR")
.putAttributes(CoreAttributes.UUID.key(), SOURCE_SYSTEM_UUID)
.setContent(ByteString.copyFrom("content".getBytes()))
.build();
// this should throw a runtime exception
final FlowFileReply reply = stub.send(ingestFile);
assertThat(reply.getResponseCode(), equalTo(FlowFileReply.ResponseCode.SUCCESS));
assertThat(reply.getBody(), equalTo("FlowFile successfully received."));
runner.assertTransferCount(ListenGRPC.REL_SUCCESS, 1);
final List<MockFlowFile> successFiles = runner.getFlowFilesForRelationship(ListenGRPC.REL_SUCCESS);
assertThat(successFiles.size(), equalTo(1));
final MockFlowFile mockFlowFile = successFiles.get(0);
assertThat(mockFlowFile.getAttribute("FOO"), equalTo("BAR"));
assertThat(mockFlowFile.getAttribute(ListenGRPC.REMOTE_HOST), equalTo("127.0.0.1"));
assertThat(mockFlowFile.getAttribute(ListenGRPC.REMOTE_USER_DN), equalTo(FlowFileIngestServiceInterceptor.DEFAULT_FOUND_SUBJECT));
runner.assertTransferCount(ListenGRPC.REL_SUCCESS, 1);
final List<MockFlowFile> successFiles = runner.getFlowFilesForRelationship(ListenGRPC.REL_SUCCESS);
assertThat(successFiles.size(), equalTo(1));
final MockFlowFile mockFlowFile = successFiles.get(0);
assertThat(mockFlowFile.getAttribute("FOO"), equalTo("BAR"));
assertThat(mockFlowFile.getAttribute(ListenGRPC.REMOTE_HOST), equalTo("127.0.0.1"));
assertThat(mockFlowFile.getAttribute(ListenGRPC.REMOTE_USER_DN), equalTo(FlowFileIngestServiceInterceptor.DEFAULT_FOUND_SUBJECT));
} finally {
// stop the server
listenGRPC.stopServer(processContext);
channel.shutdown();
}
} finally {
// stop the server
listenGRPC.stopServer(processContext);
channel.shutdown();
}
});
}
}
}

View File

@ -16,15 +16,14 @@
*/
package org.apache.nifi.processors.grpc;
import io.grpc.stub.StreamObserver;
import org.apache.nifi.util.MockFlowFile;
import org.apache.nifi.util.TestRunner;
import org.apache.nifi.util.TestRunners;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import java.util.List;
import io.grpc.stub.StreamObserver;
import static org.hamcrest.CoreMatchers.equalTo;
import static org.hamcrest.MatcherAssert.assertThat;