use of org.apache.nifi.reporting.InitializationException in project nifi by apache.
the class SSLContextServiceTest method testGoodTrustOnly.
@Test
public void testGoodTrustOnly() {
try {
TestRunner runner = TestRunners.newTestRunner(TestProcessor.class);
SSLContextService service = new StandardSSLContextService();
HashMap<String, String> properties = new HashMap<String, String>();
properties.put(StandardSSLContextService.TRUSTSTORE.getName(), "src/test/resources/localhost-ts.jks");
properties.put(StandardSSLContextService.TRUSTSTORE_PASSWORD.getName(), "localtest");
properties.put(StandardSSLContextService.TRUSTSTORE_TYPE.getName(), "JKS");
runner.addControllerService("test-good2", service, properties);
runner.enableControllerService(service);
runner.setProperty("SSL Context Svc ID", "test-good2");
runner.assertValid();
Assert.assertNotNull(service);
assertTrue(service instanceof StandardSSLContextService);
service.createSSLContext(ClientAuth.NONE);
} catch (InitializationException e) {
}
}
use of org.apache.nifi.reporting.InitializationException in project nifi by apache.
the class TestListenTCP method testTLSClientAuthRequiredAndClientCertNotProvided.
@Test
public void testTLSClientAuthRequiredAndClientCertNotProvided() throws InitializationException, IOException, InterruptedException, UnrecoverableKeyException, CertificateException, NoSuchAlgorithmException, KeyStoreException, KeyManagementException {
runner.setProperty(ListenTCP.CLIENT_AUTH, SSLContextService.ClientAuth.REQUIRED.name());
configureProcessorSslContextService();
final List<String> messages = new ArrayList<>();
messages.add("This is message 1\n");
messages.add("This is message 2\n");
messages.add("This is message 3\n");
messages.add("This is message 4\n");
messages.add("This is message 5\n");
// Make an SSLContext that only has the trust store, this should not work since the processor has client auth REQUIRED
final SSLContext clientSslContext = SslContextFactory.createTrustSslContext("src/test/resources/localhost-ts.jks", "localtest".toCharArray(), "jks", "TLS");
try {
runTCP(messages, messages.size(), clientSslContext);
Assert.fail("Should have thrown exception");
} catch (Exception e) {
}
}
use of org.apache.nifi.reporting.InitializationException in project nifi by apache.
the class TestSplitRecord method testMultipleRecordsPerSplit.
@Test
public void testMultipleRecordsPerSplit() throws InitializationException {
final MockRecordParser readerService = new MockRecordParser();
final MockRecordWriter writerService = new MockRecordWriter("header", false);
final TestRunner runner = TestRunners.newTestRunner(SplitRecord.class);
runner.addControllerService("reader", readerService);
runner.enableControllerService(readerService);
runner.addControllerService("writer", writerService);
runner.enableControllerService(writerService);
runner.setProperty(SplitRecord.RECORD_READER, "reader");
runner.setProperty(SplitRecord.RECORD_WRITER, "writer");
runner.setProperty(SplitRecord.RECORDS_PER_SPLIT, "2");
readerService.addSchemaField("name", RecordFieldType.STRING);
readerService.addSchemaField("age", RecordFieldType.INT);
readerService.addRecord("John Doe", 48);
readerService.addRecord("Jane Doe", 47);
readerService.addRecord("Jimmy Doe", 14);
runner.enqueue("");
runner.run();
runner.assertTransferCount(SplitRecord.REL_SPLITS, 2);
runner.assertTransferCount(SplitRecord.REL_ORIGINAL, 1);
runner.assertTransferCount(SplitRecord.REL_FAILURE, 0);
final List<MockFlowFile> out = runner.getFlowFilesForRelationship(SplitRecord.REL_SPLITS);
assertEquals(1, out.stream().filter(mff -> mff.getAttribute("record.count").equals("1")).count());
assertTrue(out.stream().allMatch(mff -> mff.getAttribute("mime.type").equals("text/plain")));
assertEquals(1, out.stream().filter(mff -> mff.isContentEqual("header\nJohn Doe,48\nJane Doe,47\n")).count());
assertEquals(1, out.stream().filter(mff -> mff.isContentEqual("header\nJimmy Doe,14\n")).count());
}
use of org.apache.nifi.reporting.InitializationException in project nifi by apache.
the class TestPutHBaseRecord method generateTestData.
private void generateTestData(TestRunner runner) throws IOException {
final MockRecordParser parser = new MockRecordParser();
try {
runner.addControllerService("parser", parser);
} catch (InitializationException e) {
throw new IOException(e);
}
runner.enableControllerService(parser);
runner.setProperty(PutHBaseRecord.RECORD_READER_FACTORY, "parser");
parser.addSchemaField("id", RecordFieldType.INT);
parser.addSchemaField("name", RecordFieldType.STRING);
parser.addSchemaField("code", RecordFieldType.LONG);
for (int x = 0; x < KEYS.size(); x++) {
parser.addRecord(KEYS.get(x), NAMES.get(x), CODES.get(x));
}
}
use of org.apache.nifi.reporting.InitializationException in project nifi by apache.
the class ITListenGRPC method useSSLContextService.
private static void useSSLContextService(final TestRunner controller, final Map<String, String> sslProperties) {
final SSLContextService service = new StandardSSLContextService();
try {
controller.addControllerService("ssl-service", service, sslProperties);
controller.enableControllerService(service);
} catch (InitializationException ex) {
ex.printStackTrace();
Assert.fail("Could not create SSL Context Service");
}
controller.setProperty(InvokeGRPC.PROP_SSL_CONTEXT_SERVICE, "ssl-service");
}
Aggregations