http://git-wip-us.apache.org/repos/asf/nifi/blob/3a7ddc6a/nifi-nar-bundles/nifi-aws-bundle/nifi-aws-processors/src/main/java/org/apache/nifi/processors/aws/sqs/PutSQS.java ---------------------------------------------------------------------- diff --git a/nifi-nar-bundles/nifi-aws-bundle/nifi-aws-processors/src/main/java/org/apache/nifi/processors/aws/sqs/PutSQS.java b/nifi-nar-bundles/nifi-aws-bundle/nifi-aws-processors/src/main/java/org/apache/nifi/processors/aws/sqs/PutSQS.java index 18150fc..633af19 100644 --- a/nifi-nar-bundles/nifi-aws-bundle/nifi-aws-processors/src/main/java/org/apache/nifi/processors/aws/sqs/PutSQS.java +++ b/nifi-nar-bundles/nifi-aws-bundle/nifi-aws-processors/src/main/java/org/apache/nifi/processors/aws/sqs/PutSQS.java @@ -1,150 +1,150 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.nifi.processors.aws.sqs; - -import java.io.ByteArrayOutputStream; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Collections; -import java.util.HashMap; -import java.util.HashSet; -import java.util.List; -import java.util.Map; -import java.util.Set; -import java.util.concurrent.TimeUnit; - -import org.apache.nifi.annotation.behavior.DynamicProperty; -import org.apache.nifi.annotation.behavior.InputRequirement; -import org.apache.nifi.annotation.behavior.InputRequirement.Requirement; -import org.apache.nifi.annotation.behavior.SupportsBatching; -import org.apache.nifi.annotation.documentation.CapabilityDescription; -import org.apache.nifi.annotation.documentation.SeeAlso; -import org.apache.nifi.annotation.documentation.Tags; -import org.apache.nifi.annotation.lifecycle.OnScheduled; -import org.apache.nifi.components.PropertyDescriptor; -import org.apache.nifi.flowfile.FlowFile; -import org.apache.nifi.processor.ProcessContext; -import org.apache.nifi.processor.ProcessSession; -import org.apache.nifi.processor.util.StandardValidators; - -import com.amazonaws.services.sqs.AmazonSQSClient; -import com.amazonaws.services.sqs.model.MessageAttributeValue; -import com.amazonaws.services.sqs.model.SendMessageBatchRequest; -import com.amazonaws.services.sqs.model.SendMessageBatchRequestEntry; - -@SupportsBatching -@SeeAlso({ GetSQS.class, DeleteSQS.class }) -@InputRequirement(Requirement.INPUT_REQUIRED) -@Tags({"Amazon", "AWS", "SQS", "Queue", "Put", "Publish"}) -@CapabilityDescription("Publishes a message to an Amazon Simple Queuing Service Queue") -@DynamicProperty(name = "The name of a Message Attribute to add to the message", value = "The value of the Message Attribute", - description = "Allows the user to add key/value pairs as Message Attributes by adding a property whose name will become the name of " - + "the Message Attribute and value will become the value of the Message Attribute", supportsExpressionLanguage = true) -public class PutSQS extends AbstractSQSProcessor { - - public static final PropertyDescriptor DELAY = new PropertyDescriptor.Builder() - .name("Delay") - .description("The amount of time to delay the message before it becomes available to consumers") - .required(true) - .addValidator(StandardValidators.TIME_PERIOD_VALIDATOR) - .defaultValue("0 secs") - .build(); - - public static final List<PropertyDescriptor> properties = Collections.unmodifiableList( - Arrays.asList(QUEUE_URL, ACCESS_KEY, SECRET_KEY, CREDENTIALS_FILE, REGION, DELAY, TIMEOUT)); - - private volatile List<PropertyDescriptor> userDefinedProperties = Collections.emptyList(); - - @Override - protected List<PropertyDescriptor> getSupportedPropertyDescriptors() { - return properties; - } - - @Override - protected PropertyDescriptor getSupportedDynamicPropertyDescriptor(final String propertyDescriptorName) { - return new PropertyDescriptor.Builder() - .name(propertyDescriptorName) - .expressionLanguageSupported(true) - .required(false) - .dynamic(true) - .addValidator(StandardValidators.NON_EMPTY_VALIDATOR) - .build(); - } - - @OnScheduled - public void setup(final ProcessContext context) { - userDefinedProperties = new ArrayList<>(); - for (final PropertyDescriptor descriptor : context.getProperties().keySet()) { - if (descriptor.isDynamic()) { - userDefinedProperties.add(descriptor); - } - } - } - - @Override - public void onTrigger(final ProcessContext context, final ProcessSession session) { - FlowFile flowFile = session.get(); - if (flowFile == null) { - return; - } - - final long startNanos = System.nanoTime(); - final AmazonSQSClient client = getClient(); - final SendMessageBatchRequest request = new SendMessageBatchRequest(); - final String queueUrl = context.getProperty(QUEUE_URL).evaluateAttributeExpressions(flowFile).getValue(); - request.setQueueUrl(queueUrl); - - final Set<SendMessageBatchRequestEntry> entries = new HashSet<>(); - - final SendMessageBatchRequestEntry entry = new SendMessageBatchRequestEntry(); - entry.setId(flowFile.getAttribute("uuid")); - final ByteArrayOutputStream baos = new ByteArrayOutputStream(); - session.exportTo(flowFile, baos); - final String flowFileContent = baos.toString(); - entry.setMessageBody(flowFileContent); - - final Map<String, MessageAttributeValue> messageAttributes = new HashMap<>(); - - for (final PropertyDescriptor descriptor : userDefinedProperties) { - final MessageAttributeValue mav = new MessageAttributeValue(); - mav.setDataType("String"); - mav.setStringValue(context.getProperty(descriptor).evaluateAttributeExpressions(flowFile).getValue()); - messageAttributes.put(descriptor.getName(), mav); - } - - entry.setMessageAttributes(messageAttributes); - entry.setDelaySeconds(context.getProperty(DELAY).asTimePeriod(TimeUnit.SECONDS).intValue()); - entries.add(entry); - - request.setEntries(entries); - - try { - client.sendMessageBatch(request); - } catch (final Exception e) { - getLogger().error("Failed to send messages to Amazon SQS due to {}; routing to failure", new Object[]{e}); - flowFile = session.penalize(flowFile); - session.transfer(flowFile, REL_FAILURE); - return; - } - - getLogger().info("Successfully published message to Amazon SQS for {}", new Object[]{flowFile}); - session.transfer(flowFile, REL_SUCCESS); - final long transmissionMillis = TimeUnit.NANOSECONDS.toMillis(System.nanoTime() - startNanos); - session.getProvenanceReporter().send(flowFile, queueUrl, transmissionMillis); - } - -} +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.nifi.processors.aws.sqs; + +import java.io.ByteArrayOutputStream; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collections; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; +import java.util.concurrent.TimeUnit; + +import org.apache.nifi.annotation.behavior.DynamicProperty; +import org.apache.nifi.annotation.behavior.InputRequirement; +import org.apache.nifi.annotation.behavior.InputRequirement.Requirement; +import org.apache.nifi.annotation.behavior.SupportsBatching; +import org.apache.nifi.annotation.documentation.CapabilityDescription; +import org.apache.nifi.annotation.documentation.SeeAlso; +import org.apache.nifi.annotation.documentation.Tags; +import org.apache.nifi.annotation.lifecycle.OnScheduled; +import org.apache.nifi.components.PropertyDescriptor; +import org.apache.nifi.flowfile.FlowFile; +import org.apache.nifi.processor.ProcessContext; +import org.apache.nifi.processor.ProcessSession; +import org.apache.nifi.processor.util.StandardValidators; + +import com.amazonaws.services.sqs.AmazonSQSClient; +import com.amazonaws.services.sqs.model.MessageAttributeValue; +import com.amazonaws.services.sqs.model.SendMessageBatchRequest; +import com.amazonaws.services.sqs.model.SendMessageBatchRequestEntry; + +@SupportsBatching +@SeeAlso({ GetSQS.class, DeleteSQS.class }) +@InputRequirement(Requirement.INPUT_REQUIRED) +@Tags({"Amazon", "AWS", "SQS", "Queue", "Put", "Publish"}) +@CapabilityDescription("Publishes a message to an Amazon Simple Queuing Service Queue") +@DynamicProperty(name = "The name of a Message Attribute to add to the message", value = "The value of the Message Attribute", + description = "Allows the user to add key/value pairs as Message Attributes by adding a property whose name will become the name of " + + "the Message Attribute and value will become the value of the Message Attribute", supportsExpressionLanguage = true) +public class PutSQS extends AbstractSQSProcessor { + + public static final PropertyDescriptor DELAY = new PropertyDescriptor.Builder() + .name("Delay") + .description("The amount of time to delay the message before it becomes available to consumers") + .required(true) + .addValidator(StandardValidators.TIME_PERIOD_VALIDATOR) + .defaultValue("0 secs") + .build(); + + public static final List<PropertyDescriptor> properties = Collections.unmodifiableList( + Arrays.asList(QUEUE_URL, ACCESS_KEY, SECRET_KEY, CREDENTIALS_FILE, REGION, DELAY, TIMEOUT)); + + private volatile List<PropertyDescriptor> userDefinedProperties = Collections.emptyList(); + + @Override + protected List<PropertyDescriptor> getSupportedPropertyDescriptors() { + return properties; + } + + @Override + protected PropertyDescriptor getSupportedDynamicPropertyDescriptor(final String propertyDescriptorName) { + return new PropertyDescriptor.Builder() + .name(propertyDescriptorName) + .expressionLanguageSupported(true) + .required(false) + .dynamic(true) + .addValidator(StandardValidators.NON_EMPTY_VALIDATOR) + .build(); + } + + @OnScheduled + public void setup(final ProcessContext context) { + userDefinedProperties = new ArrayList<>(); + for (final PropertyDescriptor descriptor : context.getProperties().keySet()) { + if (descriptor.isDynamic()) { + userDefinedProperties.add(descriptor); + } + } + } + + @Override + public void onTrigger(final ProcessContext context, final ProcessSession session) { + FlowFile flowFile = session.get(); + if (flowFile == null) { + return; + } + + final long startNanos = System.nanoTime(); + final AmazonSQSClient client = getClient(); + final SendMessageBatchRequest request = new SendMessageBatchRequest(); + final String queueUrl = context.getProperty(QUEUE_URL).evaluateAttributeExpressions(flowFile).getValue(); + request.setQueueUrl(queueUrl); + + final Set<SendMessageBatchRequestEntry> entries = new HashSet<>(); + + final SendMessageBatchRequestEntry entry = new SendMessageBatchRequestEntry(); + entry.setId(flowFile.getAttribute("uuid")); + final ByteArrayOutputStream baos = new ByteArrayOutputStream(); + session.exportTo(flowFile, baos); + final String flowFileContent = baos.toString(); + entry.setMessageBody(flowFileContent); + + final Map<String, MessageAttributeValue> messageAttributes = new HashMap<>(); + + for (final PropertyDescriptor descriptor : userDefinedProperties) { + final MessageAttributeValue mav = new MessageAttributeValue(); + mav.setDataType("String"); + mav.setStringValue(context.getProperty(descriptor).evaluateAttributeExpressions(flowFile).getValue()); + messageAttributes.put(descriptor.getName(), mav); + } + + entry.setMessageAttributes(messageAttributes); + entry.setDelaySeconds(context.getProperty(DELAY).asTimePeriod(TimeUnit.SECONDS).intValue()); + entries.add(entry); + + request.setEntries(entries); + + try { + client.sendMessageBatch(request); + } catch (final Exception e) { + getLogger().error("Failed to send messages to Amazon SQS due to {}; routing to failure", new Object[]{e}); + flowFile = session.penalize(flowFile); + session.transfer(flowFile, REL_FAILURE); + return; + } + + getLogger().info("Successfully published message to Amazon SQS for {}", new Object[]{flowFile}); + session.transfer(flowFile, REL_SUCCESS); + final long transmissionMillis = TimeUnit.NANOSECONDS.toMillis(System.nanoTime() - startNanos); + session.getProvenanceReporter().send(flowFile, queueUrl, transmissionMillis); + } + +}
http://git-wip-us.apache.org/repos/asf/nifi/blob/3a7ddc6a/nifi-nar-bundles/nifi-aws-bundle/nifi-aws-processors/src/test/java/org/apache/nifi/processors/aws/s3/TestDeleteS3Object.java ---------------------------------------------------------------------- diff --git a/nifi-nar-bundles/nifi-aws-bundle/nifi-aws-processors/src/test/java/org/apache/nifi/processors/aws/s3/TestDeleteS3Object.java b/nifi-nar-bundles/nifi-aws-bundle/nifi-aws-processors/src/test/java/org/apache/nifi/processors/aws/s3/TestDeleteS3Object.java index 777a2eb..a51eddd 100644 --- a/nifi-nar-bundles/nifi-aws-bundle/nifi-aws-processors/src/test/java/org/apache/nifi/processors/aws/s3/TestDeleteS3Object.java +++ b/nifi-nar-bundles/nifi-aws-bundle/nifi-aws-processors/src/test/java/org/apache/nifi/processors/aws/s3/TestDeleteS3Object.java @@ -1,109 +1,109 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.nifi.processors.aws.s3; - -import java.io.IOException; -import java.util.HashMap; -import java.util.Map; - -import org.apache.nifi.util.TestRunner; -import org.apache.nifi.util.TestRunners; -import org.junit.Ignore; -import org.junit.Test; - -@Ignore("For local testing only - interacts with S3 so the credentials file must be configured and all necessary buckets created") -public class TestDeleteS3Object extends AbstractS3Test { - - @Test - public void testSimpleDelete() throws IOException { - // Prepares for this test - putTestFile("delete-me", getFileFromResourceName(SAMPLE_FILE_RESOURCE_NAME)); - - final TestRunner runner = TestRunners.newTestRunner(new DeleteS3Object()); - - runner.setProperty(DeleteS3Object.CREDENTIALS_FILE, CREDENTIALS_FILE); - runner.setProperty(DeleteS3Object.REGION, REGION); - runner.setProperty(DeleteS3Object.BUCKET, BUCKET_NAME); - - final Map<String, String> attrs = new HashMap<>(); - attrs.put("filename", "delete-me"); - runner.enqueue(new byte[0], attrs); - - runner.run(1); - - runner.assertAllFlowFilesTransferred(DeleteS3Object.REL_SUCCESS, 1); - } - - @Test - public void testDeleteFolder() throws IOException { - // Prepares for this test - putTestFile("folder/delete-me", getFileFromResourceName(SAMPLE_FILE_RESOURCE_NAME)); - - final TestRunner runner = TestRunners.newTestRunner(new DeleteS3Object()); - - runner.setProperty(DeleteS3Object.CREDENTIALS_FILE, CREDENTIALS_FILE); - runner.setProperty(DeleteS3Object.REGION, REGION); - runner.setProperty(DeleteS3Object.BUCKET, BUCKET_NAME); - - final Map<String, String> attrs = new HashMap<>(); - attrs.put("filename", "folder/delete-me"); - runner.enqueue(new byte[0], attrs); - - runner.run(1); - - runner.assertAllFlowFilesTransferred(DeleteS3Object.REL_SUCCESS, 1); - } - - @Test - public void testDeleteFolderNoExpressionLanguage() throws IOException { - // Prepares for this test - putTestFile("folder/delete-me", getFileFromResourceName(SAMPLE_FILE_RESOURCE_NAME)); - - final TestRunner runner = TestRunners.newTestRunner(new DeleteS3Object()); - - runner.setProperty(DeleteS3Object.CREDENTIALS_FILE, CREDENTIALS_FILE); - runner.setProperty(DeleteS3Object.REGION, REGION); - runner.setProperty(DeleteS3Object.BUCKET, BUCKET_NAME); - runner.setProperty(DeleteS3Object.KEY, "folder/delete-me"); - - final Map<String, String> attrs = new HashMap<>(); - attrs.put("filename", "a-different-name"); - runner.enqueue(new byte[0], attrs); - - runner.run(1); - - runner.assertAllFlowFilesTransferred(DeleteS3Object.REL_SUCCESS, 1); - } - - @Test - public void testTryToDeleteNotExistingFile() throws IOException { - final TestRunner runner = TestRunners.newTestRunner(new DeleteS3Object()); - - runner.setProperty(DeleteS3Object.CREDENTIALS_FILE, CREDENTIALS_FILE); - runner.setProperty(DeleteS3Object.REGION, REGION); - runner.setProperty(DeleteS3Object.BUCKET, BUCKET_NAME); - - final Map<String, String> attrs = new HashMap<>(); - attrs.put("filename", "no-such-a-file"); - runner.enqueue(new byte[0], attrs); - - runner.run(1); - - runner.assertAllFlowFilesTransferred(DeleteS3Object.REL_SUCCESS, 1); - } - -} +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.nifi.processors.aws.s3; + +import java.io.IOException; +import java.util.HashMap; +import java.util.Map; + +import org.apache.nifi.util.TestRunner; +import org.apache.nifi.util.TestRunners; +import org.junit.Ignore; +import org.junit.Test; + +@Ignore("For local testing only - interacts with S3 so the credentials file must be configured and all necessary buckets created") +public class TestDeleteS3Object extends AbstractS3Test { + + @Test + public void testSimpleDelete() throws IOException { + // Prepares for this test + putTestFile("delete-me", getFileFromResourceName(SAMPLE_FILE_RESOURCE_NAME)); + + final TestRunner runner = TestRunners.newTestRunner(new DeleteS3Object()); + + runner.setProperty(DeleteS3Object.CREDENTIALS_FILE, CREDENTIALS_FILE); + runner.setProperty(DeleteS3Object.REGION, REGION); + runner.setProperty(DeleteS3Object.BUCKET, BUCKET_NAME); + + final Map<String, String> attrs = new HashMap<>(); + attrs.put("filename", "delete-me"); + runner.enqueue(new byte[0], attrs); + + runner.run(1); + + runner.assertAllFlowFilesTransferred(DeleteS3Object.REL_SUCCESS, 1); + } + + @Test + public void testDeleteFolder() throws IOException { + // Prepares for this test + putTestFile("folder/delete-me", getFileFromResourceName(SAMPLE_FILE_RESOURCE_NAME)); + + final TestRunner runner = TestRunners.newTestRunner(new DeleteS3Object()); + + runner.setProperty(DeleteS3Object.CREDENTIALS_FILE, CREDENTIALS_FILE); + runner.setProperty(DeleteS3Object.REGION, REGION); + runner.setProperty(DeleteS3Object.BUCKET, BUCKET_NAME); + + final Map<String, String> attrs = new HashMap<>(); + attrs.put("filename", "folder/delete-me"); + runner.enqueue(new byte[0], attrs); + + runner.run(1); + + runner.assertAllFlowFilesTransferred(DeleteS3Object.REL_SUCCESS, 1); + } + + @Test + public void testDeleteFolderNoExpressionLanguage() throws IOException { + // Prepares for this test + putTestFile("folder/delete-me", getFileFromResourceName(SAMPLE_FILE_RESOURCE_NAME)); + + final TestRunner runner = TestRunners.newTestRunner(new DeleteS3Object()); + + runner.setProperty(DeleteS3Object.CREDENTIALS_FILE, CREDENTIALS_FILE); + runner.setProperty(DeleteS3Object.REGION, REGION); + runner.setProperty(DeleteS3Object.BUCKET, BUCKET_NAME); + runner.setProperty(DeleteS3Object.KEY, "folder/delete-me"); + + final Map<String, String> attrs = new HashMap<>(); + attrs.put("filename", "a-different-name"); + runner.enqueue(new byte[0], attrs); + + runner.run(1); + + runner.assertAllFlowFilesTransferred(DeleteS3Object.REL_SUCCESS, 1); + } + + @Test + public void testTryToDeleteNotExistingFile() throws IOException { + final TestRunner runner = TestRunners.newTestRunner(new DeleteS3Object()); + + runner.setProperty(DeleteS3Object.CREDENTIALS_FILE, CREDENTIALS_FILE); + runner.setProperty(DeleteS3Object.REGION, REGION); + runner.setProperty(DeleteS3Object.BUCKET, BUCKET_NAME); + + final Map<String, String> attrs = new HashMap<>(); + attrs.put("filename", "no-such-a-file"); + runner.enqueue(new byte[0], attrs); + + runner.run(1); + + runner.assertAllFlowFilesTransferred(DeleteS3Object.REL_SUCCESS, 1); + } + +} http://git-wip-us.apache.org/repos/asf/nifi/blob/3a7ddc6a/nifi-nar-bundles/nifi-aws-bundle/nifi-aws-processors/src/test/java/org/apache/nifi/processors/aws/s3/TestFetchS3Object.java ---------------------------------------------------------------------- diff --git a/nifi-nar-bundles/nifi-aws-bundle/nifi-aws-processors/src/test/java/org/apache/nifi/processors/aws/s3/TestFetchS3Object.java b/nifi-nar-bundles/nifi-aws-bundle/nifi-aws-processors/src/test/java/org/apache/nifi/processors/aws/s3/TestFetchS3Object.java index c75cab6..b4ab911 100644 --- a/nifi-nar-bundles/nifi-aws-bundle/nifi-aws-processors/src/test/java/org/apache/nifi/processors/aws/s3/TestFetchS3Object.java +++ b/nifi-nar-bundles/nifi-aws-bundle/nifi-aws-processors/src/test/java/org/apache/nifi/processors/aws/s3/TestFetchS3Object.java @@ -1,98 +1,98 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.nifi.processors.aws.s3; - -import java.io.IOException; -import java.nio.file.Files; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -import org.apache.nifi.util.MockFlowFile; -import org.apache.nifi.util.TestRunner; -import org.apache.nifi.util.TestRunners; -import org.junit.Ignore; -import org.junit.Test; - -@Ignore("For local testing only - interacts with S3 so the credentials file must be configured and all necessary buckets created") -public class TestFetchS3Object extends AbstractS3Test { - @Test - public void testSimpleGet() throws IOException { - putTestFile("test-file", getFileFromResourceName(SAMPLE_FILE_RESOURCE_NAME)); - - final TestRunner runner = TestRunners.newTestRunner(new FetchS3Object()); - - runner.setProperty(FetchS3Object.CREDENTIALS_FILE, CREDENTIALS_FILE); - runner.setProperty(FetchS3Object.REGION, REGION); - runner.setProperty(FetchS3Object.BUCKET, BUCKET_NAME); - - final Map<String, String> attrs = new HashMap<>(); - attrs.put("filename", "test-file"); - runner.enqueue(new byte[0], attrs); - - runner.run(1); - - runner.assertAllFlowFilesTransferred(FetchS3Object.REL_SUCCESS, 1); - } - - @Test - public void testTryToFetchNotExistingFile() throws IOException { - final TestRunner runner = TestRunners.newTestRunner(new FetchS3Object()); - - runner.setProperty(FetchS3Object.CREDENTIALS_FILE, CREDENTIALS_FILE); - runner.setProperty(FetchS3Object.REGION, REGION); - runner.setProperty(FetchS3Object.BUCKET, BUCKET_NAME); - - final Map<String, String> attrs = new HashMap<>(); - attrs.put("filename", "no-such-a-file"); - runner.enqueue(new byte[0], attrs); - - runner.run(1); - - runner.assertAllFlowFilesTransferred(FetchS3Object.REL_FAILURE, 1); - } - - @Test - public void testContentsOfFileRetrieved() throws IOException { - String key = "folder/1.txt"; - putTestFile(key, getFileFromResourceName(SAMPLE_FILE_RESOURCE_NAME)); - - final TestRunner runner = TestRunners.newTestRunner(new FetchS3Object()); - - runner.setProperty(FetchS3Object.CREDENTIALS_FILE, CREDENTIALS_FILE); - runner.setProperty(FetchS3Object.REGION, REGION); - runner.setProperty(FetchS3Object.BUCKET, BUCKET_NAME); - - final Map<String, String> attrs = new HashMap<>(); - attrs.put("filename", key); - runner.enqueue(new byte[0], attrs); - - runner.run(1); - - runner.assertAllFlowFilesTransferred(FetchS3Object.REL_SUCCESS, 1); - - final List<MockFlowFile> ffs = runner.getFlowFilesForRelationship(FetchS3Object.REL_SUCCESS); - final MockFlowFile out = ffs.iterator().next(); - - final byte[] expectedBytes = Files.readAllBytes(getResourcePath(SAMPLE_FILE_RESOURCE_NAME)); - out.assertContentEquals(new String(expectedBytes)); - - for (final Map.Entry<String, String> entry : out.getAttributes().entrySet()) { - System.out.println(entry.getKey() + " : " + entry.getValue()); - } - } -} +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.nifi.processors.aws.s3; + +import java.io.IOException; +import java.nio.file.Files; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import org.apache.nifi.util.MockFlowFile; +import org.apache.nifi.util.TestRunner; +import org.apache.nifi.util.TestRunners; +import org.junit.Ignore; +import org.junit.Test; + +@Ignore("For local testing only - interacts with S3 so the credentials file must be configured and all necessary buckets created") +public class TestFetchS3Object extends AbstractS3Test { + @Test + public void testSimpleGet() throws IOException { + putTestFile("test-file", getFileFromResourceName(SAMPLE_FILE_RESOURCE_NAME)); + + final TestRunner runner = TestRunners.newTestRunner(new FetchS3Object()); + + runner.setProperty(FetchS3Object.CREDENTIALS_FILE, CREDENTIALS_FILE); + runner.setProperty(FetchS3Object.REGION, REGION); + runner.setProperty(FetchS3Object.BUCKET, BUCKET_NAME); + + final Map<String, String> attrs = new HashMap<>(); + attrs.put("filename", "test-file"); + runner.enqueue(new byte[0], attrs); + + runner.run(1); + + runner.assertAllFlowFilesTransferred(FetchS3Object.REL_SUCCESS, 1); + } + + @Test + public void testTryToFetchNotExistingFile() throws IOException { + final TestRunner runner = TestRunners.newTestRunner(new FetchS3Object()); + + runner.setProperty(FetchS3Object.CREDENTIALS_FILE, CREDENTIALS_FILE); + runner.setProperty(FetchS3Object.REGION, REGION); + runner.setProperty(FetchS3Object.BUCKET, BUCKET_NAME); + + final Map<String, String> attrs = new HashMap<>(); + attrs.put("filename", "no-such-a-file"); + runner.enqueue(new byte[0], attrs); + + runner.run(1); + + runner.assertAllFlowFilesTransferred(FetchS3Object.REL_FAILURE, 1); + } + + @Test + public void testContentsOfFileRetrieved() throws IOException { + String key = "folder/1.txt"; + putTestFile(key, getFileFromResourceName(SAMPLE_FILE_RESOURCE_NAME)); + + final TestRunner runner = TestRunners.newTestRunner(new FetchS3Object()); + + runner.setProperty(FetchS3Object.CREDENTIALS_FILE, CREDENTIALS_FILE); + runner.setProperty(FetchS3Object.REGION, REGION); + runner.setProperty(FetchS3Object.BUCKET, BUCKET_NAME); + + final Map<String, String> attrs = new HashMap<>(); + attrs.put("filename", key); + runner.enqueue(new byte[0], attrs); + + runner.run(1); + + runner.assertAllFlowFilesTransferred(FetchS3Object.REL_SUCCESS, 1); + + final List<MockFlowFile> ffs = runner.getFlowFilesForRelationship(FetchS3Object.REL_SUCCESS); + final MockFlowFile out = ffs.iterator().next(); + + final byte[] expectedBytes = Files.readAllBytes(getResourcePath(SAMPLE_FILE_RESOURCE_NAME)); + out.assertContentEquals(new String(expectedBytes)); + + for (final Map.Entry<String, String> entry : out.getAttributes().entrySet()) { + System.out.println(entry.getKey() + " : " + entry.getValue()); + } + } +} http://git-wip-us.apache.org/repos/asf/nifi/blob/3a7ddc6a/nifi-nar-bundles/nifi-aws-bundle/nifi-aws-processors/src/test/java/org/apache/nifi/processors/aws/s3/TestPutS3Object.java ---------------------------------------------------------------------- diff --git a/nifi-nar-bundles/nifi-aws-bundle/nifi-aws-processors/src/test/java/org/apache/nifi/processors/aws/s3/TestPutS3Object.java b/nifi-nar-bundles/nifi-aws-bundle/nifi-aws-processors/src/test/java/org/apache/nifi/processors/aws/s3/TestPutS3Object.java index 82e51ce..a65bda3 100644 --- a/nifi-nar-bundles/nifi-aws-bundle/nifi-aws-processors/src/test/java/org/apache/nifi/processors/aws/s3/TestPutS3Object.java +++ b/nifi-nar-bundles/nifi-aws-bundle/nifi-aws-processors/src/test/java/org/apache/nifi/processors/aws/s3/TestPutS3Object.java @@ -1,140 +1,140 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.nifi.processors.aws.s3; - -import java.io.IOException; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -import org.apache.nifi.components.PropertyDescriptor; -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.Ignore; -import org.junit.Test; - -import com.amazonaws.services.s3.model.StorageClass; - -@Ignore("For local testing only - interacts with S3 so the credentials file must be configured and all necessary buckets created") -public class TestPutS3Object extends AbstractS3Test { - - @Test - public void testSimplePut() throws IOException { - final TestRunner runner = TestRunners.newTestRunner(new PutS3Object()); - - runner.setProperty(PutS3Object.CREDENTIALS_FILE, CREDENTIALS_FILE); - runner.setProperty(PutS3Object.REGION, REGION); - runner.setProperty(PutS3Object.BUCKET, BUCKET_NAME); - - Assert.assertTrue(runner.setProperty("x-custom-prop", "hello").isValid()); - - for (int i = 0; i < 3; i++) { - final Map<String, String> attrs = new HashMap<>(); - attrs.put("filename", String.valueOf(i) + ".txt"); - runner.enqueue(getResourcePath(SAMPLE_FILE_RESOURCE_NAME), attrs); - } - runner.run(3); - - runner.assertAllFlowFilesTransferred(PutS3Object.REL_SUCCESS, 3); - } - - @Test - public void testMetaData() throws IOException { - PutS3Object processor = new PutS3Object(); - final TestRunner runner = TestRunners.newTestRunner(processor); - - runner.setProperty(PutS3Object.CREDENTIALS_FILE, CREDENTIALS_FILE); - runner.setProperty(PutS3Object.REGION, REGION); - runner.setProperty(PutS3Object.BUCKET, BUCKET_NAME); - PropertyDescriptor prop1 = processor.getSupportedDynamicPropertyDescriptor("TEST-PROP-1"); - runner.setProperty(prop1, "TESTING-1-2-3"); - PropertyDescriptor prop2 = processor.getSupportedDynamicPropertyDescriptor("TEST-PROP-2"); - runner.setProperty(prop2, "TESTING-4-5-6"); - - final Map<String, String> attrs = new HashMap<>(); - attrs.put("filename", "meta.txt"); - runner.enqueue(getResourcePath(SAMPLE_FILE_RESOURCE_NAME), attrs); - - runner.run(); - - runner.assertAllFlowFilesTransferred(PutS3Object.REL_SUCCESS, 1); - List<MockFlowFile> flowFiles = runner.getFlowFilesForRelationship(PutS3Object.REL_SUCCESS); - MockFlowFile ff1 = flowFiles.get(0); - for (Map.Entry attrib : ff1.getAttributes().entrySet()) { - System.out.println(attrib.getKey() + " = " + attrib.getValue()); - } - } - - @Test - public void testPutInFolder() throws IOException { - final TestRunner runner = TestRunners.newTestRunner(new PutS3Object()); - - runner.setProperty(PutS3Object.CREDENTIALS_FILE, CREDENTIALS_FILE); - runner.setProperty(PutS3Object.REGION, REGION); - runner.setProperty(PutS3Object.BUCKET, BUCKET_NAME); - - Assert.assertTrue(runner.setProperty("x-custom-prop", "hello").isValid()); - - final Map<String, String> attrs = new HashMap<>(); - attrs.put("filename", "folder/1.txt"); - runner.enqueue(getResourcePath(SAMPLE_FILE_RESOURCE_NAME), attrs); - - runner.run(); - - runner.assertAllFlowFilesTransferred(PutS3Object.REL_SUCCESS, 1); - } - - @Test - public void testStorageClass() throws IOException { - final TestRunner runner = TestRunners.newTestRunner(new PutS3Object()); - - runner.setProperty(PutS3Object.CREDENTIALS_FILE, CREDENTIALS_FILE); - runner.setProperty(PutS3Object.REGION, REGION); - runner.setProperty(PutS3Object.BUCKET, BUCKET_NAME); - runner.setProperty(PutS3Object.STORAGE_CLASS, StorageClass.ReducedRedundancy.name()); - - Assert.assertTrue(runner.setProperty("x-custom-prop", "hello").isValid()); - - final Map<String, String> attrs = new HashMap<>(); - attrs.put("filename", "folder/2.txt"); - runner.enqueue(getResourcePath(SAMPLE_FILE_RESOURCE_NAME), attrs); - - runner.run(); - - runner.assertAllFlowFilesTransferred(PutS3Object.REL_SUCCESS, 1); - } - - @Test - public void testPermissions() throws IOException { - final TestRunner runner = TestRunners.newTestRunner(new PutS3Object()); - - runner.setProperty(PutS3Object.CREDENTIALS_FILE, CREDENTIALS_FILE); - runner.setProperty(PutS3Object.BUCKET, BUCKET_NAME); - runner.setProperty(PutS3Object.FULL_CONTROL_USER_LIST,"28545acd76c35c7e91f8409b95fd1aa0c0914bfa1ac60975d9f48bc3c5e090b5"); - runner.setProperty(PutS3Object.REGION, REGION); - - final Map<String, String> attrs = new HashMap<>(); - attrs.put("filename", "folder/4.txt"); - runner.enqueue(getResourcePath(SAMPLE_FILE_RESOURCE_NAME), attrs); - - runner.run(); - - runner.assertAllFlowFilesTransferred(PutS3Object.REL_SUCCESS, 1); - } +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.nifi.processors.aws.s3; + +import java.io.IOException; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import org.apache.nifi.components.PropertyDescriptor; +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.Ignore; +import org.junit.Test; + +import com.amazonaws.services.s3.model.StorageClass; + +@Ignore("For local testing only - interacts with S3 so the credentials file must be configured and all necessary buckets created") +public class TestPutS3Object extends AbstractS3Test { + + @Test + public void testSimplePut() throws IOException { + final TestRunner runner = TestRunners.newTestRunner(new PutS3Object()); + + runner.setProperty(PutS3Object.CREDENTIALS_FILE, CREDENTIALS_FILE); + runner.setProperty(PutS3Object.REGION, REGION); + runner.setProperty(PutS3Object.BUCKET, BUCKET_NAME); + + Assert.assertTrue(runner.setProperty("x-custom-prop", "hello").isValid()); + + for (int i = 0; i < 3; i++) { + final Map<String, String> attrs = new HashMap<>(); + attrs.put("filename", String.valueOf(i) + ".txt"); + runner.enqueue(getResourcePath(SAMPLE_FILE_RESOURCE_NAME), attrs); + } + runner.run(3); + + runner.assertAllFlowFilesTransferred(PutS3Object.REL_SUCCESS, 3); + } + + @Test + public void testMetaData() throws IOException { + PutS3Object processor = new PutS3Object(); + final TestRunner runner = TestRunners.newTestRunner(processor); + + runner.setProperty(PutS3Object.CREDENTIALS_FILE, CREDENTIALS_FILE); + runner.setProperty(PutS3Object.REGION, REGION); + runner.setProperty(PutS3Object.BUCKET, BUCKET_NAME); + PropertyDescriptor prop1 = processor.getSupportedDynamicPropertyDescriptor("TEST-PROP-1"); + runner.setProperty(prop1, "TESTING-1-2-3"); + PropertyDescriptor prop2 = processor.getSupportedDynamicPropertyDescriptor("TEST-PROP-2"); + runner.setProperty(prop2, "TESTING-4-5-6"); + + final Map<String, String> attrs = new HashMap<>(); + attrs.put("filename", "meta.txt"); + runner.enqueue(getResourcePath(SAMPLE_FILE_RESOURCE_NAME), attrs); + + runner.run(); + + runner.assertAllFlowFilesTransferred(PutS3Object.REL_SUCCESS, 1); + List<MockFlowFile> flowFiles = runner.getFlowFilesForRelationship(PutS3Object.REL_SUCCESS); + MockFlowFile ff1 = flowFiles.get(0); + for (Map.Entry attrib : ff1.getAttributes().entrySet()) { + System.out.println(attrib.getKey() + " = " + attrib.getValue()); + } + } + + @Test + public void testPutInFolder() throws IOException { + final TestRunner runner = TestRunners.newTestRunner(new PutS3Object()); + + runner.setProperty(PutS3Object.CREDENTIALS_FILE, CREDENTIALS_FILE); + runner.setProperty(PutS3Object.REGION, REGION); + runner.setProperty(PutS3Object.BUCKET, BUCKET_NAME); + + Assert.assertTrue(runner.setProperty("x-custom-prop", "hello").isValid()); + + final Map<String, String> attrs = new HashMap<>(); + attrs.put("filename", "folder/1.txt"); + runner.enqueue(getResourcePath(SAMPLE_FILE_RESOURCE_NAME), attrs); + + runner.run(); + + runner.assertAllFlowFilesTransferred(PutS3Object.REL_SUCCESS, 1); + } + + @Test + public void testStorageClass() throws IOException { + final TestRunner runner = TestRunners.newTestRunner(new PutS3Object()); + + runner.setProperty(PutS3Object.CREDENTIALS_FILE, CREDENTIALS_FILE); + runner.setProperty(PutS3Object.REGION, REGION); + runner.setProperty(PutS3Object.BUCKET, BUCKET_NAME); + runner.setProperty(PutS3Object.STORAGE_CLASS, StorageClass.ReducedRedundancy.name()); + + Assert.assertTrue(runner.setProperty("x-custom-prop", "hello").isValid()); + + final Map<String, String> attrs = new HashMap<>(); + attrs.put("filename", "folder/2.txt"); + runner.enqueue(getResourcePath(SAMPLE_FILE_RESOURCE_NAME), attrs); + + runner.run(); + + runner.assertAllFlowFilesTransferred(PutS3Object.REL_SUCCESS, 1); + } + + @Test + public void testPermissions() throws IOException { + final TestRunner runner = TestRunners.newTestRunner(new PutS3Object()); + + runner.setProperty(PutS3Object.CREDENTIALS_FILE, CREDENTIALS_FILE); + runner.setProperty(PutS3Object.BUCKET, BUCKET_NAME); + runner.setProperty(PutS3Object.FULL_CONTROL_USER_LIST,"28545acd76c35c7e91f8409b95fd1aa0c0914bfa1ac60975d9f48bc3c5e090b5"); + runner.setProperty(PutS3Object.REGION, REGION); + + final Map<String, String> attrs = new HashMap<>(); + attrs.put("filename", "folder/4.txt"); + runner.enqueue(getResourcePath(SAMPLE_FILE_RESOURCE_NAME), attrs); + + runner.run(); + + runner.assertAllFlowFilesTransferred(PutS3Object.REL_SUCCESS, 1); + } } \ No newline at end of file http://git-wip-us.apache.org/repos/asf/nifi/blob/3a7ddc6a/nifi-nar-bundles/nifi-aws-bundle/nifi-aws-processors/src/test/java/org/apache/nifi/processors/aws/sns/TestPutSNS.java ---------------------------------------------------------------------- diff --git a/nifi-nar-bundles/nifi-aws-bundle/nifi-aws-processors/src/test/java/org/apache/nifi/processors/aws/sns/TestPutSNS.java b/nifi-nar-bundles/nifi-aws-bundle/nifi-aws-processors/src/test/java/org/apache/nifi/processors/aws/sns/TestPutSNS.java index 72d9e07..b1b7643 100644 --- a/nifi-nar-bundles/nifi-aws-bundle/nifi-aws-processors/src/test/java/org/apache/nifi/processors/aws/sns/TestPutSNS.java +++ b/nifi-nar-bundles/nifi-aws-bundle/nifi-aws-processors/src/test/java/org/apache/nifi/processors/aws/sns/TestPutSNS.java @@ -1,51 +1,51 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.nifi.processors.aws.sns; - -import static org.junit.Assert.assertTrue; - -import java.io.IOException; -import java.nio.file.Paths; -import java.util.HashMap; -import java.util.Map; - -import org.apache.nifi.util.TestRunner; -import org.apache.nifi.util.TestRunners; -import org.junit.Ignore; -import org.junit.Test; - -@Ignore("For local testing only - interacts with S3 so the credentials file must be configured and all necessary buckets created") -public class TestPutSNS { - - private final String CREDENTIALS_FILE = System.getProperty("user.home") + "/aws-credentials.properties"; - - @Test - public void testPublish() throws IOException { - final TestRunner runner = TestRunners.newTestRunner(new PutSNS()); - runner.setProperty(PutSNS.CREDENTIALS_FILE, CREDENTIALS_FILE); - runner.setProperty(PutSNS.ARN, "arn:aws:sns:us-west-2:100515378163:test-topic-1"); - assertTrue(runner.setProperty("DynamicProperty", "hello!").isValid()); - - final Map<String, String> attrs = new HashMap<>(); - attrs.put("filename", "1.txt"); - runner.enqueue(Paths.get("src/test/resources/hello.txt"), attrs); - runner.run(); - - runner.assertAllFlowFilesTransferred(PutSNS.REL_SUCCESS, 1); - } - -} +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.nifi.processors.aws.sns; + +import static org.junit.Assert.assertTrue; + +import java.io.IOException; +import java.nio.file.Paths; +import java.util.HashMap; +import java.util.Map; + +import org.apache.nifi.util.TestRunner; +import org.apache.nifi.util.TestRunners; +import org.junit.Ignore; +import org.junit.Test; + +@Ignore("For local testing only - interacts with S3 so the credentials file must be configured and all necessary buckets created") +public class TestPutSNS { + + private final String CREDENTIALS_FILE = System.getProperty("user.home") + "/aws-credentials.properties"; + + @Test + public void testPublish() throws IOException { + final TestRunner runner = TestRunners.newTestRunner(new PutSNS()); + runner.setProperty(PutSNS.CREDENTIALS_FILE, CREDENTIALS_FILE); + runner.setProperty(PutSNS.ARN, "arn:aws:sns:us-west-2:100515378163:test-topic-1"); + assertTrue(runner.setProperty("DynamicProperty", "hello!").isValid()); + + final Map<String, String> attrs = new HashMap<>(); + attrs.put("filename", "1.txt"); + runner.enqueue(Paths.get("src/test/resources/hello.txt"), attrs); + runner.run(); + + runner.assertAllFlowFilesTransferred(PutSNS.REL_SUCCESS, 1); + } + +} http://git-wip-us.apache.org/repos/asf/nifi/blob/3a7ddc6a/nifi-nar-bundles/nifi-aws-bundle/nifi-aws-processors/src/test/java/org/apache/nifi/processors/aws/sqs/TestGetSQS.java ---------------------------------------------------------------------- diff --git a/nifi-nar-bundles/nifi-aws-bundle/nifi-aws-processors/src/test/java/org/apache/nifi/processors/aws/sqs/TestGetSQS.java b/nifi-nar-bundles/nifi-aws-bundle/nifi-aws-processors/src/test/java/org/apache/nifi/processors/aws/sqs/TestGetSQS.java index 3a00db4..e11528e 100644 --- a/nifi-nar-bundles/nifi-aws-bundle/nifi-aws-processors/src/test/java/org/apache/nifi/processors/aws/sqs/TestGetSQS.java +++ b/nifi-nar-bundles/nifi-aws-bundle/nifi-aws-processors/src/test/java/org/apache/nifi/processors/aws/sqs/TestGetSQS.java @@ -1,49 +1,49 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.nifi.processors.aws.sqs; - -import java.util.List; - -import org.apache.nifi.processors.aws.sns.PutSNS; -import org.apache.nifi.util.MockFlowFile; -import org.apache.nifi.util.TestRunner; -import org.apache.nifi.util.TestRunners; -import org.junit.Ignore; -import org.junit.Test; - -@Ignore("For local testing only - interacts with S3 so the credentials file must be configured and all necessary buckets created") -public class TestGetSQS { - - private final String CREDENTIALS_FILE = System.getProperty("user.home") + "/aws-credentials.properties"; - - @Test - public void testSimpleGet() { - final TestRunner runner = TestRunners.newTestRunner(new GetSQS()); - runner.setProperty(PutSNS.CREDENTIALS_FILE, CREDENTIALS_FILE); - runner.setProperty(GetSQS.TIMEOUT, "30 secs"); - runner.setProperty(GetSQS.QUEUE_URL, "https://sqs.us-west-2.amazonaws.com/100515378163/test-queue-000000000"); - - runner.run(1); - - final List<MockFlowFile> flowFiles = runner.getFlowFilesForRelationship(GetSQS.REL_SUCCESS); - for (final MockFlowFile mff : flowFiles) { - System.out.println(mff.getAttributes()); - System.out.println(new String(mff.toByteArray())); - } - } - -} +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.nifi.processors.aws.sqs; + +import java.util.List; + +import org.apache.nifi.processors.aws.sns.PutSNS; +import org.apache.nifi.util.MockFlowFile; +import org.apache.nifi.util.TestRunner; +import org.apache.nifi.util.TestRunners; +import org.junit.Ignore; +import org.junit.Test; + +@Ignore("For local testing only - interacts with S3 so the credentials file must be configured and all necessary buckets created") +public class TestGetSQS { + + private final String CREDENTIALS_FILE = System.getProperty("user.home") + "/aws-credentials.properties"; + + @Test + public void testSimpleGet() { + final TestRunner runner = TestRunners.newTestRunner(new GetSQS()); + runner.setProperty(PutSNS.CREDENTIALS_FILE, CREDENTIALS_FILE); + runner.setProperty(GetSQS.TIMEOUT, "30 secs"); + runner.setProperty(GetSQS.QUEUE_URL, "https://sqs.us-west-2.amazonaws.com/100515378163/test-queue-000000000"); + + runner.run(1); + + final List<MockFlowFile> flowFiles = runner.getFlowFilesForRelationship(GetSQS.REL_SUCCESS); + for (final MockFlowFile mff : flowFiles) { + System.out.println(mff.getAttributes()); + System.out.println(new String(mff.toByteArray())); + } + } + +} http://git-wip-us.apache.org/repos/asf/nifi/blob/3a7ddc6a/nifi-nar-bundles/nifi-aws-bundle/nifi-aws-processors/src/test/java/org/apache/nifi/processors/aws/sqs/TestPutSQS.java ---------------------------------------------------------------------- diff --git a/nifi-nar-bundles/nifi-aws-bundle/nifi-aws-processors/src/test/java/org/apache/nifi/processors/aws/sqs/TestPutSQS.java b/nifi-nar-bundles/nifi-aws-bundle/nifi-aws-processors/src/test/java/org/apache/nifi/processors/aws/sqs/TestPutSQS.java index 3db4f38..712f706 100644 --- a/nifi-nar-bundles/nifi-aws-bundle/nifi-aws-processors/src/test/java/org/apache/nifi/processors/aws/sqs/TestPutSQS.java +++ b/nifi-nar-bundles/nifi-aws-bundle/nifi-aws-processors/src/test/java/org/apache/nifi/processors/aws/sqs/TestPutSQS.java @@ -1,52 +1,52 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.nifi.processors.aws.sqs; - -import java.io.IOException; -import java.nio.file.Paths; -import java.util.HashMap; -import java.util.Map; - -import org.apache.nifi.processors.aws.sns.PutSNS; -import org.apache.nifi.util.TestRunner; -import org.apache.nifi.util.TestRunners; -import org.junit.Assert; -import org.junit.Ignore; -import org.junit.Test; - -@Ignore("For local testing only - interacts with S3 so the credentials file must be configured and all necessary buckets created") -public class TestPutSQS { - - private final String CREDENTIALS_FILE = System.getProperty("user.home") + "/aws-credentials.properties"; - - @Test - public void testSimplePut() throws IOException { - final TestRunner runner = TestRunners.newTestRunner(new PutSQS()); - runner.setProperty(PutSNS.CREDENTIALS_FILE, CREDENTIALS_FILE); - runner.setProperty(PutSQS.TIMEOUT, "30 secs"); - runner.setProperty(PutSQS.QUEUE_URL, "https://sqs.us-west-2.amazonaws.com/100515378163/test-queue-000000000"); - Assert.assertTrue(runner.setProperty("x-custom-prop", "hello").isValid()); - - final Map<String, String> attrs = new HashMap<>(); - attrs.put("filename", "1.txt"); - runner.enqueue(Paths.get("src/test/resources/hello.txt"), attrs); - runner.run(1); - - runner.assertAllFlowFilesTransferred(PutSQS.REL_SUCCESS, 1); - } - -} +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.nifi.processors.aws.sqs; + +import java.io.IOException; +import java.nio.file.Paths; +import java.util.HashMap; +import java.util.Map; + +import org.apache.nifi.processors.aws.sns.PutSNS; +import org.apache.nifi.util.TestRunner; +import org.apache.nifi.util.TestRunners; +import org.junit.Assert; +import org.junit.Ignore; +import org.junit.Test; + +@Ignore("For local testing only - interacts with S3 so the credentials file must be configured and all necessary buckets created") +public class TestPutSQS { + + private final String CREDENTIALS_FILE = System.getProperty("user.home") + "/aws-credentials.properties"; + + @Test + public void testSimplePut() throws IOException { + final TestRunner runner = TestRunners.newTestRunner(new PutSQS()); + runner.setProperty(PutSNS.CREDENTIALS_FILE, CREDENTIALS_FILE); + runner.setProperty(PutSQS.TIMEOUT, "30 secs"); + runner.setProperty(PutSQS.QUEUE_URL, "https://sqs.us-west-2.amazonaws.com/100515378163/test-queue-000000000"); + Assert.assertTrue(runner.setProperty("x-custom-prop", "hello").isValid()); + + final Map<String, String> attrs = new HashMap<>(); + attrs.put("filename", "1.txt"); + runner.enqueue(Paths.get("src/test/resources/hello.txt"), attrs); + runner.run(1); + + runner.assertAllFlowFilesTransferred(PutSQS.REL_SUCCESS, 1); + } + +} http://git-wip-us.apache.org/repos/asf/nifi/blob/3a7ddc6a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/dto/ReportingTaskDTO.java ---------------------------------------------------------------------- diff --git a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/dto/ReportingTaskDTO.java b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/dto/ReportingTaskDTO.java index cdc834c..b826829 100644 --- a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/dto/ReportingTaskDTO.java +++ b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/dto/ReportingTaskDTO.java @@ -1,253 +1,253 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.nifi.web.api.dto; - -import com.wordnik.swagger.annotations.ApiModelProperty; -import java.util.Collection; -import java.util.Map; - -import javax.xml.bind.annotation.XmlType; - -/** - * Component that is capable of reporting internal NiFi state to an external service - */ -@XmlType(name = "reportingTask") -public class ReportingTaskDTO extends NiFiComponentDTO { - - private String name; - private String type; - private String state; - private String availability; - private String comments; - - private String schedulingPeriod; - private String schedulingStrategy; - private Map<String, String> defaultSchedulingPeriod; - - private Map<String, String> properties; - private Map<String, PropertyDescriptorDTO> descriptors; - - private String customUiUrl; - private String annotationData; - - private Collection<String> validationErrors; - private Integer activeThreadCount; - - /** - * @return user-defined name of the reporting task - */ - @ApiModelProperty( - value = "The name of the reporting task." - ) - public String getName() { - return name; - } - - public void setName(String name) { - this.name = name; - } - - /** - * @return user-defined comments for the reporting task - */ - @ApiModelProperty( - value = "The comments of the reporting task." - ) - public String getComments() { - return comments; - } - - public void setComments(String comments) { - this.comments = comments; - } - - /** - * @return type of reporting task - */ - @ApiModelProperty( - value = "The fully qualified type of the reporting task." - ) - public String getType() { - return type; - } - - public void setType(String type) { - this.type = type; - } - - /** - * The frequency with which to schedule the reporting task. The format of the value will depend on the value of {@link #getSchedulingStrategy()}. - * - * @return The scheduling period - */ - @ApiModelProperty( - value = "The frequency with which to schedule the reporting task. The format of the value willd epend on the valud of the schedulingStrategy." - ) - public String getSchedulingPeriod() { - return schedulingPeriod; - } - - public void setSchedulingPeriod(String schedulingPeriod) { - this.schedulingPeriod = schedulingPeriod; - } - - /** - * @return current scheduling state of the reporting task - */ - @ApiModelProperty( - value = "The state of the reporting task.", - allowableValues = "RUNNING, STOPPED, DISABLED" - ) - public String getState() { - return state; - } - - public void setState(String state) { - this.state = state; - } - - /** - * @return The scheduling strategy that determines how the {@link #getSchedulingPeriod()} value should be interpreted - */ - @ApiModelProperty( - value = "The scheduling strategy that determines how the schedulingPeriod value should be interpreted." - ) - public String getSchedulingStrategy() { - return schedulingStrategy; - } - - public void setSchedulingStrategy(String schedulingStrategy) { - this.schedulingStrategy = schedulingStrategy; - } - - /** - * @return Where this service is available. Possible values are NCM, NODE - */ - @ApiModelProperty( - value = "Where the reporting task is available.", - allowableValues = "NCM, NODE" - ) - public String getAvailability() { - return availability; - } - - public void setAvailability(String availability) { - this.availability = availability; - } - - /** - * @return reporting task's properties - */ - @ApiModelProperty( - value = "The properties of the reporting task." - ) - public Map<String, String> getProperties() { - return properties; - } - - public void setProperties(Map<String, String> properties) { - this.properties = properties; - } - - /** - * @return Map of property name to descriptor - */ - @ApiModelProperty( - value = "The descriptors for the reporting tasks properties." - ) - public Map<String, PropertyDescriptorDTO> getDescriptors() { - return descriptors; - } - - public void setDescriptors(Map<String, PropertyDescriptorDTO> descriptors) { - this.descriptors = descriptors; - } - - /** - * @return the URL for this reporting task custom configuration UI if applicable. Null otherwise - */ - @ApiModelProperty( - value = "The URL for the custom configuration UI for the reporting task." - ) - public String getCustomUiUrl() { - return customUiUrl; - } - - public void setCustomUiUrl(String customUiUrl) { - this.customUiUrl = customUiUrl; - } - - /** - * @return currently configured annotation data for the reporting task - */ - @ApiModelProperty( - value = "The anntation data for the repoting task. This is how the custom UI relays configuration to the reporting task." - ) - public String getAnnotationData() { - return annotationData; - } - - public void setAnnotationData(String annotationData) { - this.annotationData = annotationData; - } - - /** - * Gets the validation errors from this reporting task. These validation errors represent the problems with the reporting task that must be resolved before it can be scheduled to run. - * - * @return The validation errors - */ - @ApiModelProperty( - value = "Gets the validation errors from the reporting task. These validation errors represent the problems with the reporting task that must be resolved before " - + "it can be scheduled to run." - ) - public Collection<String> getValidationErrors() { - return validationErrors; - } - - public void setValidationErrors(Collection<String> validationErrors) { - this.validationErrors = validationErrors; - } - - /** - * @return default scheduling period for the different scheduling strategies - */ - @ApiModelProperty( - value = "The default scheduling period for the different scheduling strategies." - ) - public Map<String, String> getDefaultSchedulingPeriod() { - return defaultSchedulingPeriod; - } - - public void setDefaultSchedulingPeriod(Map<String, String> defaultSchedulingPeriod) { - this.defaultSchedulingPeriod = defaultSchedulingPeriod; - } - - /** - * @return number of active threads for this reporting task - */ - @ApiModelProperty( - value = "The number of active threads for the reporting task." - ) - public Integer getActiveThreadCount() { - return activeThreadCount; - } - - public void setActiveThreadCount(Integer activeThreadCount) { - this.activeThreadCount = activeThreadCount; - } - -} +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.nifi.web.api.dto; + +import com.wordnik.swagger.annotations.ApiModelProperty; +import java.util.Collection; +import java.util.Map; + +import javax.xml.bind.annotation.XmlType; + +/** + * Component that is capable of reporting internal NiFi state to an external service + */ +@XmlType(name = "reportingTask") +public class ReportingTaskDTO extends NiFiComponentDTO { + + private String name; + private String type; + private String state; + private String availability; + private String comments; + + private String schedulingPeriod; + private String schedulingStrategy; + private Map<String, String> defaultSchedulingPeriod; + + private Map<String, String> properties; + private Map<String, PropertyDescriptorDTO> descriptors; + + private String customUiUrl; + private String annotationData; + + private Collection<String> validationErrors; + private Integer activeThreadCount; + + /** + * @return user-defined name of the reporting task + */ + @ApiModelProperty( + value = "The name of the reporting task." + ) + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + /** + * @return user-defined comments for the reporting task + */ + @ApiModelProperty( + value = "The comments of the reporting task." + ) + public String getComments() { + return comments; + } + + public void setComments(String comments) { + this.comments = comments; + } + + /** + * @return type of reporting task + */ + @ApiModelProperty( + value = "The fully qualified type of the reporting task." + ) + public String getType() { + return type; + } + + public void setType(String type) { + this.type = type; + } + + /** + * The frequency with which to schedule the reporting task. The format of the value will depend on the value of {@link #getSchedulingStrategy()}. + * + * @return The scheduling period + */ + @ApiModelProperty( + value = "The frequency with which to schedule the reporting task. The format of the value willd epend on the valud of the schedulingStrategy." + ) + public String getSchedulingPeriod() { + return schedulingPeriod; + } + + public void setSchedulingPeriod(String schedulingPeriod) { + this.schedulingPeriod = schedulingPeriod; + } + + /** + * @return current scheduling state of the reporting task + */ + @ApiModelProperty( + value = "The state of the reporting task.", + allowableValues = "RUNNING, STOPPED, DISABLED" + ) + public String getState() { + return state; + } + + public void setState(String state) { + this.state = state; + } + + /** + * @return The scheduling strategy that determines how the {@link #getSchedulingPeriod()} value should be interpreted + */ + @ApiModelProperty( + value = "The scheduling strategy that determines how the schedulingPeriod value should be interpreted." + ) + public String getSchedulingStrategy() { + return schedulingStrategy; + } + + public void setSchedulingStrategy(String schedulingStrategy) { + this.schedulingStrategy = schedulingStrategy; + } + + /** + * @return Where this service is available. Possible values are NCM, NODE + */ + @ApiModelProperty( + value = "Where the reporting task is available.", + allowableValues = "NCM, NODE" + ) + public String getAvailability() { + return availability; + } + + public void setAvailability(String availability) { + this.availability = availability; + } + + /** + * @return reporting task's properties + */ + @ApiModelProperty( + value = "The properties of the reporting task." + ) + public Map<String, String> getProperties() { + return properties; + } + + public void setProperties(Map<String, String> properties) { + this.properties = properties; + } + + /** + * @return Map of property name to descriptor + */ + @ApiModelProperty( + value = "The descriptors for the reporting tasks properties." + ) + public Map<String, PropertyDescriptorDTO> getDescriptors() { + return descriptors; + } + + public void setDescriptors(Map<String, PropertyDescriptorDTO> descriptors) { + this.descriptors = descriptors; + } + + /** + * @return the URL for this reporting task custom configuration UI if applicable. Null otherwise + */ + @ApiModelProperty( + value = "The URL for the custom configuration UI for the reporting task." + ) + public String getCustomUiUrl() { + return customUiUrl; + } + + public void setCustomUiUrl(String customUiUrl) { + this.customUiUrl = customUiUrl; + } + + /** + * @return currently configured annotation data for the reporting task + */ + @ApiModelProperty( + value = "The anntation data for the repoting task. This is how the custom UI relays configuration to the reporting task." + ) + public String getAnnotationData() { + return annotationData; + } + + public void setAnnotationData(String annotationData) { + this.annotationData = annotationData; + } + + /** + * Gets the validation errors from this reporting task. These validation errors represent the problems with the reporting task that must be resolved before it can be scheduled to run. + * + * @return The validation errors + */ + @ApiModelProperty( + value = "Gets the validation errors from the reporting task. These validation errors represent the problems with the reporting task that must be resolved before " + + "it can be scheduled to run." + ) + public Collection<String> getValidationErrors() { + return validationErrors; + } + + public void setValidationErrors(Collection<String> validationErrors) { + this.validationErrors = validationErrors; + } + + /** + * @return default scheduling period for the different scheduling strategies + */ + @ApiModelProperty( + value = "The default scheduling period for the different scheduling strategies." + ) + public Map<String, String> getDefaultSchedulingPeriod() { + return defaultSchedulingPeriod; + } + + public void setDefaultSchedulingPeriod(Map<String, String> defaultSchedulingPeriod) { + this.defaultSchedulingPeriod = defaultSchedulingPeriod; + } + + /** + * @return number of active threads for this reporting task + */ + @ApiModelProperty( + value = "The number of active threads for the reporting task." + ) + public Integer getActiveThreadCount() { + return activeThreadCount; + } + + public void setActiveThreadCount(Integer activeThreadCount) { + this.activeThreadCount = activeThreadCount; + } + +} http://git-wip-us.apache.org/repos/asf/nifi/blob/3a7ddc6a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-documentation/src/main/java/org/apache/nifi/documentation/ConfigurableComponentInitializer.java ---------------------------------------------------------------------- diff --git a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-documentation/src/main/java/org/apache/nifi/documentation/ConfigurableComponentInitializer.java b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-documentation/src/main/java/org/apache/nifi/documentation/ConfigurableComponentInitializer.java index ad21f21..361d3d1 100644 --- a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-documentation/src/main/java/org/apache/nifi/documentation/ConfigurableComponentInitializer.java +++ b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-documentation/src/main/java/org/apache/nifi/documentation/ConfigurableComponentInitializer.java @@ -1,45 +1,45 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.nifi.documentation; - -import org.apache.nifi.components.ConfigurableComponent; -import org.apache.nifi.reporting.InitializationException; - -/** - * An interface for initializing and tearing down a ConfigurableComponent. It is up to the - * implementer to call "init" so that you can call - * ConfigurableComponent.getPropertyDescriptors() - * - */ -public interface ConfigurableComponentInitializer { - - /** - * Initializes a configurable component to the point that you can call - * getPropertyDescriptors() on it - * - * @param component the component to initialize - * @throws InitializationException if the component could not be initialized - */ - void initialize(ConfigurableComponent component) throws InitializationException; - - /** - * Calls the lifecycle methods that should be called when a flow is shutdown. - * - * @param component the component to initialize - */ - void teardown(ConfigurableComponent component); -} +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.nifi.documentation; + +import org.apache.nifi.components.ConfigurableComponent; +import org.apache.nifi.reporting.InitializationException; + +/** + * An interface for initializing and tearing down a ConfigurableComponent. It is up to the + * implementer to call "init" so that you can call + * ConfigurableComponent.getPropertyDescriptors() + * + */ +public interface ConfigurableComponentInitializer { + + /** + * Initializes a configurable component to the point that you can call + * getPropertyDescriptors() on it + * + * @param component the component to initialize + * @throws InitializationException if the component could not be initialized + */ + void initialize(ConfigurableComponent component) throws InitializationException; + + /** + * Calls the lifecycle methods that should be called when a flow is shutdown. + * + * @param component the component to initialize + */ + void teardown(ConfigurableComponent component); +}
