You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nifi.apache.org by tk...@apache.org on 2015/11/19 07:20:57 UTC
[14/24] nifi git commit: NIFI-1054: Fixing Line endings of source code
http://git-wip-us.apache.org/repos/asf/nifi/blob/e2d3d1b7/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-documentation/src/test/java/org/apache/nifi/documentation/html/HtmlDocumentationWriterTest.java
----------------------------------------------------------------------
diff --git a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-documentation/src/test/java/org/apache/nifi/documentation/html/HtmlDocumentationWriterTest.java b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-documentation/src/test/java/org/apache/nifi/documentation/html/HtmlDocumentationWriterTest.java
index ae04f46..2bd9def 100644
--- a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-documentation/src/test/java/org/apache/nifi/documentation/html/HtmlDocumentationWriterTest.java
+++ b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-documentation/src/test/java/org/apache/nifi/documentation/html/HtmlDocumentationWriterTest.java
@@ -1,156 +1,156 @@
-/*
- * 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.html;
-
-import static org.apache.nifi.documentation.html.XmlValidator.assertContains;
-import static org.junit.Assert.assertEquals;
-
-import java.io.ByteArrayOutputStream;
-import java.io.IOException;
-
-import org.apache.nifi.controller.ControllerService;
-import org.apache.nifi.documentation.DocumentationWriter;
-import org.apache.nifi.documentation.example.ControllerServiceWithLogger;
-import org.apache.nifi.documentation.example.FullyDocumentedControllerService;
-import org.apache.nifi.documentation.example.FullyDocumentedReportingTask;
-import org.apache.nifi.documentation.example.ReportingTaskWithLogger;
-import org.apache.nifi.documentation.init.ControllerServiceInitializer;
-import org.apache.nifi.documentation.init.ReportingTaskingInitializer;
-import org.apache.nifi.documentation.mock.MockControllerServiceInitializationContext;
-import org.apache.nifi.documentation.mock.MockReportingInitializationContext;
-import org.apache.nifi.reporting.InitializationException;
-import org.apache.nifi.reporting.ReportingTask;
-import org.junit.Assert;
-import org.junit.Test;
-
-public class HtmlDocumentationWriterTest {
-
- @Test
- public void testJoin() {
- assertEquals("a, b, c", HtmlDocumentationWriter.join(new String[] { "a", "b", "c" }, ", "));
- assertEquals("a, b", HtmlDocumentationWriter.join(new String[] { "a", "b" }, ", "));
- assertEquals("a", HtmlDocumentationWriter.join(new String[] { "a" }, ", "));
- }
-
- @Test
- public void testDocumentControllerService() throws InitializationException, IOException {
-
- FullyDocumentedControllerService controllerService = new FullyDocumentedControllerService();
- ControllerServiceInitializer initializer = new ControllerServiceInitializer();
- initializer.initialize(controllerService);
-
- DocumentationWriter writer = new HtmlDocumentationWriter();
-
- ByteArrayOutputStream baos = new ByteArrayOutputStream();
-
- writer.write(controllerService, baos, false);
- initializer.teardown(controllerService);
-
- String results = new String(baos.toByteArray());
- XmlValidator.assertXmlValid(results);
-
- // description
- assertContains(results, "A documented controller service that can help you do things");
-
- // tags
- assertContains(results, "one, two, three");
-
- // properties
- assertContains(results, "Keystore Filename");
- assertContains(results, "The fully-qualified filename of the Keystore");
- assertContains(results, "Keystore Type");
- assertContains(results, "JKS");
- assertContains(results, "PKCS12");
- assertContains(results, "Sensitive Property: true");
-
- // verify the right OnRemoved and OnShutdown methods were called
- Assert.assertEquals(0, controllerService.getOnRemovedArgs());
- Assert.assertEquals(0, controllerService.getOnRemovedNoArgs());
-
- Assert.assertEquals(1, controllerService.getOnShutdownArgs());
- Assert.assertEquals(1, controllerService.getOnShutdownNoArgs());
- }
-
- @Test
- public void testDocumentReportingTask() throws InitializationException, IOException {
-
- FullyDocumentedReportingTask reportingTask = new FullyDocumentedReportingTask();
- ReportingTaskingInitializer initializer = new ReportingTaskingInitializer();
- initializer.initialize(reportingTask);
-
- DocumentationWriter writer = new HtmlDocumentationWriter();
-
- ByteArrayOutputStream baos = new ByteArrayOutputStream();
-
- writer.write(reportingTask, baos, false);
- initializer.teardown(reportingTask);
-
- String results = new String(baos.toByteArray());
- XmlValidator.assertXmlValid(results);
-
- // description
- assertContains(results, "A helper reporting task to do...");
-
- // tags
- assertContains(results, "first, second, third");
-
- // properties
- assertContains(results, "Show Deltas");
- assertContains(results, "Specifies whether or not to show the difference in values between the current status and the previous status");
- assertContains(results, "true");
- assertContains(results, "false");
-
- // verify the right OnRemoved and OnShutdown methods were called
- Assert.assertEquals(0, reportingTask.getOnRemovedArgs());
- Assert.assertEquals(0, reportingTask.getOnRemovedNoArgs());
-
- Assert.assertEquals(1, reportingTask.getOnShutdownArgs());
- Assert.assertEquals(1, reportingTask.getOnShutdownNoArgs());
- }
-
- @Test
- public void testControllerServiceWithLogger() throws InitializationException, IOException {
-
- ControllerService controllerService = new ControllerServiceWithLogger();
- controllerService.initialize(new MockControllerServiceInitializationContext());
-
- DocumentationWriter writer = new HtmlDocumentationWriter();
-
- ByteArrayOutputStream baos = new ByteArrayOutputStream();
-
- writer.write(controllerService, baos, false);
-
- String results = new String(baos.toByteArray());
- XmlValidator.assertXmlValid(results);
- }
-
- @Test
- public void testReportingTaskWithLogger() throws InitializationException, IOException {
-
- ReportingTask controllerService = new ReportingTaskWithLogger();
- controllerService.initialize(new MockReportingInitializationContext());
-
- DocumentationWriter writer = new HtmlDocumentationWriter();
-
- ByteArrayOutputStream baos = new ByteArrayOutputStream();
-
- writer.write(controllerService, baos, false);
-
- String results = new String(baos.toByteArray());
- XmlValidator.assertXmlValid(results);
- }
-}
+/*
+ * 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.html;
+
+import static org.apache.nifi.documentation.html.XmlValidator.assertContains;
+import static org.junit.Assert.assertEquals;
+
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+
+import org.apache.nifi.controller.ControllerService;
+import org.apache.nifi.documentation.DocumentationWriter;
+import org.apache.nifi.documentation.example.ControllerServiceWithLogger;
+import org.apache.nifi.documentation.example.FullyDocumentedControllerService;
+import org.apache.nifi.documentation.example.FullyDocumentedReportingTask;
+import org.apache.nifi.documentation.example.ReportingTaskWithLogger;
+import org.apache.nifi.documentation.init.ControllerServiceInitializer;
+import org.apache.nifi.documentation.init.ReportingTaskingInitializer;
+import org.apache.nifi.documentation.mock.MockControllerServiceInitializationContext;
+import org.apache.nifi.documentation.mock.MockReportingInitializationContext;
+import org.apache.nifi.reporting.InitializationException;
+import org.apache.nifi.reporting.ReportingTask;
+import org.junit.Assert;
+import org.junit.Test;
+
+public class HtmlDocumentationWriterTest {
+
+ @Test
+ public void testJoin() {
+ assertEquals("a, b, c", HtmlDocumentationWriter.join(new String[] { "a", "b", "c" }, ", "));
+ assertEquals("a, b", HtmlDocumentationWriter.join(new String[] { "a", "b" }, ", "));
+ assertEquals("a", HtmlDocumentationWriter.join(new String[] { "a" }, ", "));
+ }
+
+ @Test
+ public void testDocumentControllerService() throws InitializationException, IOException {
+
+ FullyDocumentedControllerService controllerService = new FullyDocumentedControllerService();
+ ControllerServiceInitializer initializer = new ControllerServiceInitializer();
+ initializer.initialize(controllerService);
+
+ DocumentationWriter writer = new HtmlDocumentationWriter();
+
+ ByteArrayOutputStream baos = new ByteArrayOutputStream();
+
+ writer.write(controllerService, baos, false);
+ initializer.teardown(controllerService);
+
+ String results = new String(baos.toByteArray());
+ XmlValidator.assertXmlValid(results);
+
+ // description
+ assertContains(results, "A documented controller service that can help you do things");
+
+ // tags
+ assertContains(results, "one, two, three");
+
+ // properties
+ assertContains(results, "Keystore Filename");
+ assertContains(results, "The fully-qualified filename of the Keystore");
+ assertContains(results, "Keystore Type");
+ assertContains(results, "JKS");
+ assertContains(results, "PKCS12");
+ assertContains(results, "Sensitive Property: true");
+
+ // verify the right OnRemoved and OnShutdown methods were called
+ Assert.assertEquals(0, controllerService.getOnRemovedArgs());
+ Assert.assertEquals(0, controllerService.getOnRemovedNoArgs());
+
+ Assert.assertEquals(1, controllerService.getOnShutdownArgs());
+ Assert.assertEquals(1, controllerService.getOnShutdownNoArgs());
+ }
+
+ @Test
+ public void testDocumentReportingTask() throws InitializationException, IOException {
+
+ FullyDocumentedReportingTask reportingTask = new FullyDocumentedReportingTask();
+ ReportingTaskingInitializer initializer = new ReportingTaskingInitializer();
+ initializer.initialize(reportingTask);
+
+ DocumentationWriter writer = new HtmlDocumentationWriter();
+
+ ByteArrayOutputStream baos = new ByteArrayOutputStream();
+
+ writer.write(reportingTask, baos, false);
+ initializer.teardown(reportingTask);
+
+ String results = new String(baos.toByteArray());
+ XmlValidator.assertXmlValid(results);
+
+ // description
+ assertContains(results, "A helper reporting task to do...");
+
+ // tags
+ assertContains(results, "first, second, third");
+
+ // properties
+ assertContains(results, "Show Deltas");
+ assertContains(results, "Specifies whether or not to show the difference in values between the current status and the previous status");
+ assertContains(results, "true");
+ assertContains(results, "false");
+
+ // verify the right OnRemoved and OnShutdown methods were called
+ Assert.assertEquals(0, reportingTask.getOnRemovedArgs());
+ Assert.assertEquals(0, reportingTask.getOnRemovedNoArgs());
+
+ Assert.assertEquals(1, reportingTask.getOnShutdownArgs());
+ Assert.assertEquals(1, reportingTask.getOnShutdownNoArgs());
+ }
+
+ @Test
+ public void testControllerServiceWithLogger() throws InitializationException, IOException {
+
+ ControllerService controllerService = new ControllerServiceWithLogger();
+ controllerService.initialize(new MockControllerServiceInitializationContext());
+
+ DocumentationWriter writer = new HtmlDocumentationWriter();
+
+ ByteArrayOutputStream baos = new ByteArrayOutputStream();
+
+ writer.write(controllerService, baos, false);
+
+ String results = new String(baos.toByteArray());
+ XmlValidator.assertXmlValid(results);
+ }
+
+ @Test
+ public void testReportingTaskWithLogger() throws InitializationException, IOException {
+
+ ReportingTask controllerService = new ReportingTaskWithLogger();
+ controllerService.initialize(new MockReportingInitializationContext());
+
+ DocumentationWriter writer = new HtmlDocumentationWriter();
+
+ ByteArrayOutputStream baos = new ByteArrayOutputStream();
+
+ writer.write(controllerService, baos, false);
+
+ String results = new String(baos.toByteArray());
+ XmlValidator.assertXmlValid(results);
+ }
+}
http://git-wip-us.apache.org/repos/asf/nifi/blob/e2d3d1b7/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-documentation/src/test/java/org/apache/nifi/documentation/html/ProcessorDocumentationWriterTest.java
----------------------------------------------------------------------
diff --git a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-documentation/src/test/java/org/apache/nifi/documentation/html/ProcessorDocumentationWriterTest.java b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-documentation/src/test/java/org/apache/nifi/documentation/html/ProcessorDocumentationWriterTest.java
index 447e2e9..a4a8dcd 100644
--- a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-documentation/src/test/java/org/apache/nifi/documentation/html/ProcessorDocumentationWriterTest.java
+++ b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-documentation/src/test/java/org/apache/nifi/documentation/html/ProcessorDocumentationWriterTest.java
@@ -1,132 +1,132 @@
-/*
- * 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.html;
-
-import static org.apache.nifi.documentation.html.XmlValidator.assertContains;
-import static org.apache.nifi.documentation.html.XmlValidator.assertNotContains;
-
-import java.io.ByteArrayOutputStream;
-import java.io.IOException;
-
-import org.apache.nifi.annotation.documentation.CapabilityDescription;
-import org.apache.nifi.documentation.DocumentationWriter;
-import org.apache.nifi.documentation.example.FullyDocumentedProcessor;
-import org.apache.nifi.documentation.example.NakedProcessor;
-import org.apache.nifi.documentation.example.ProcessorWithLogger;
-import org.apache.nifi.documentation.init.ProcessorInitializer;
-import org.junit.Assert;
-import org.junit.Test;
-
-public class ProcessorDocumentationWriterTest {
-
- @Test
- public void testFullyDocumentedProcessor() throws IOException {
- FullyDocumentedProcessor processor = new FullyDocumentedProcessor();
- ProcessorInitializer initializer = new ProcessorInitializer();
- initializer.initialize(processor);
-
- DocumentationWriter writer = new HtmlProcessorDocumentationWriter();
-
- ByteArrayOutputStream baos = new ByteArrayOutputStream();
-
- writer.write(processor, baos, false);
- initializer.teardown(processor);
-
- String results = new String(baos.toByteArray());
- XmlValidator.assertXmlValid(results);
-
- assertContains(results, FullyDocumentedProcessor.DIRECTORY.getDisplayName());
- assertContains(results, FullyDocumentedProcessor.DIRECTORY.getDescription());
- assertContains(results, FullyDocumentedProcessor.OPTIONAL_PROPERTY.getDisplayName());
- assertContains(results, FullyDocumentedProcessor.OPTIONAL_PROPERTY.getDescription());
- assertContains(results, FullyDocumentedProcessor.POLLING_INTERVAL.getDisplayName());
- assertContains(results, FullyDocumentedProcessor.POLLING_INTERVAL.getDescription());
- assertContains(results, FullyDocumentedProcessor.POLLING_INTERVAL.getDefaultValue());
- assertContains(results, FullyDocumentedProcessor.RECURSE.getDisplayName());
- assertContains(results, FullyDocumentedProcessor.RECURSE.getDescription());
-
- assertContains(results, FullyDocumentedProcessor.REL_SUCCESS.getName());
- assertContains(results, FullyDocumentedProcessor.REL_SUCCESS.getDescription());
- assertContains(results, FullyDocumentedProcessor.REL_FAILURE.getName());
- assertContains(results, FullyDocumentedProcessor.REL_FAILURE.getDescription());
- assertContains(results, "Controller Service API: ");
- assertContains(results, "SampleService");
-
- assertNotContains(results, "iconSecure.png");
- assertContains(results, FullyDocumentedProcessor.class.getAnnotation(CapabilityDescription.class)
- .value());
- assertNotContains(results, "This component has no required or optional properties.");
- assertNotContains(results, "No description provided.");
- assertNotContains(results, "No Tags provided.");
- assertNotContains(results, "Additional Details...");
-
- // verify the right OnRemoved and OnShutdown methods were called
- Assert.assertEquals(0, processor.getOnRemovedArgs());
- Assert.assertEquals(0, processor.getOnRemovedNoArgs());
-
- Assert.assertEquals(1, processor.getOnShutdownArgs());
- Assert.assertEquals(1, processor.getOnShutdownNoArgs());
- }
-
- @Test
- public void testNakedProcessor() throws IOException {
- NakedProcessor processor = new NakedProcessor();
- ProcessorInitializer initializer = new ProcessorInitializer();
- initializer.initialize(processor);
-
- DocumentationWriter writer = new HtmlProcessorDocumentationWriter();
-
- ByteArrayOutputStream baos = new ByteArrayOutputStream();
-
- writer.write(processor, baos, false);
- initializer.teardown(processor);
-
- String results = new String(baos.toByteArray());
- XmlValidator.assertXmlValid(results);
-
- // no description
- assertContains(results, "No description provided.");
-
- // no tags
- assertContains(results, "None.");
-
- // properties
- assertContains(results, "This component has no required or optional properties.");
-
- // relationships
- assertContains(results, "This processor has no relationships.");
-
- }
-
- @Test
- public void testProcessorWithLoggerInitialization() throws IOException {
- ProcessorWithLogger processor = new ProcessorWithLogger();
- ProcessorInitializer initializer = new ProcessorInitializer();
- initializer.initialize(processor);
-
- DocumentationWriter writer = new HtmlProcessorDocumentationWriter();
-
- ByteArrayOutputStream baos = new ByteArrayOutputStream();
-
- writer.write(processor, baos, false);
- initializer.teardown(processor);
-
- String results = new String(baos.toByteArray());
- XmlValidator.assertXmlValid(results);
-
- }
-}
+/*
+ * 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.html;
+
+import static org.apache.nifi.documentation.html.XmlValidator.assertContains;
+import static org.apache.nifi.documentation.html.XmlValidator.assertNotContains;
+
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+
+import org.apache.nifi.annotation.documentation.CapabilityDescription;
+import org.apache.nifi.documentation.DocumentationWriter;
+import org.apache.nifi.documentation.example.FullyDocumentedProcessor;
+import org.apache.nifi.documentation.example.NakedProcessor;
+import org.apache.nifi.documentation.example.ProcessorWithLogger;
+import org.apache.nifi.documentation.init.ProcessorInitializer;
+import org.junit.Assert;
+import org.junit.Test;
+
+public class ProcessorDocumentationWriterTest {
+
+ @Test
+ public void testFullyDocumentedProcessor() throws IOException {
+ FullyDocumentedProcessor processor = new FullyDocumentedProcessor();
+ ProcessorInitializer initializer = new ProcessorInitializer();
+ initializer.initialize(processor);
+
+ DocumentationWriter writer = new HtmlProcessorDocumentationWriter();
+
+ ByteArrayOutputStream baos = new ByteArrayOutputStream();
+
+ writer.write(processor, baos, false);
+ initializer.teardown(processor);
+
+ String results = new String(baos.toByteArray());
+ XmlValidator.assertXmlValid(results);
+
+ assertContains(results, FullyDocumentedProcessor.DIRECTORY.getDisplayName());
+ assertContains(results, FullyDocumentedProcessor.DIRECTORY.getDescription());
+ assertContains(results, FullyDocumentedProcessor.OPTIONAL_PROPERTY.getDisplayName());
+ assertContains(results, FullyDocumentedProcessor.OPTIONAL_PROPERTY.getDescription());
+ assertContains(results, FullyDocumentedProcessor.POLLING_INTERVAL.getDisplayName());
+ assertContains(results, FullyDocumentedProcessor.POLLING_INTERVAL.getDescription());
+ assertContains(results, FullyDocumentedProcessor.POLLING_INTERVAL.getDefaultValue());
+ assertContains(results, FullyDocumentedProcessor.RECURSE.getDisplayName());
+ assertContains(results, FullyDocumentedProcessor.RECURSE.getDescription());
+
+ assertContains(results, FullyDocumentedProcessor.REL_SUCCESS.getName());
+ assertContains(results, FullyDocumentedProcessor.REL_SUCCESS.getDescription());
+ assertContains(results, FullyDocumentedProcessor.REL_FAILURE.getName());
+ assertContains(results, FullyDocumentedProcessor.REL_FAILURE.getDescription());
+ assertContains(results, "Controller Service API: ");
+ assertContains(results, "SampleService");
+
+ assertNotContains(results, "iconSecure.png");
+ assertContains(results, FullyDocumentedProcessor.class.getAnnotation(CapabilityDescription.class)
+ .value());
+ assertNotContains(results, "This component has no required or optional properties.");
+ assertNotContains(results, "No description provided.");
+ assertNotContains(results, "No Tags provided.");
+ assertNotContains(results, "Additional Details...");
+
+ // verify the right OnRemoved and OnShutdown methods were called
+ Assert.assertEquals(0, processor.getOnRemovedArgs());
+ Assert.assertEquals(0, processor.getOnRemovedNoArgs());
+
+ Assert.assertEquals(1, processor.getOnShutdownArgs());
+ Assert.assertEquals(1, processor.getOnShutdownNoArgs());
+ }
+
+ @Test
+ public void testNakedProcessor() throws IOException {
+ NakedProcessor processor = new NakedProcessor();
+ ProcessorInitializer initializer = new ProcessorInitializer();
+ initializer.initialize(processor);
+
+ DocumentationWriter writer = new HtmlProcessorDocumentationWriter();
+
+ ByteArrayOutputStream baos = new ByteArrayOutputStream();
+
+ writer.write(processor, baos, false);
+ initializer.teardown(processor);
+
+ String results = new String(baos.toByteArray());
+ XmlValidator.assertXmlValid(results);
+
+ // no description
+ assertContains(results, "No description provided.");
+
+ // no tags
+ assertContains(results, "None.");
+
+ // properties
+ assertContains(results, "This component has no required or optional properties.");
+
+ // relationships
+ assertContains(results, "This processor has no relationships.");
+
+ }
+
+ @Test
+ public void testProcessorWithLoggerInitialization() throws IOException {
+ ProcessorWithLogger processor = new ProcessorWithLogger();
+ ProcessorInitializer initializer = new ProcessorInitializer();
+ initializer.initialize(processor);
+
+ DocumentationWriter writer = new HtmlProcessorDocumentationWriter();
+
+ ByteArrayOutputStream baos = new ByteArrayOutputStream();
+
+ writer.write(processor, baos, false);
+ initializer.teardown(processor);
+
+ String results = new String(baos.toByteArray());
+ XmlValidator.assertXmlValid(results);
+
+ }
+}
http://git-wip-us.apache.org/repos/asf/nifi/blob/e2d3d1b7/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-documentation/src/test/java/org/apache/nifi/documentation/html/XmlValidator.java
----------------------------------------------------------------------
diff --git a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-documentation/src/test/java/org/apache/nifi/documentation/html/XmlValidator.java b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-documentation/src/test/java/org/apache/nifi/documentation/html/XmlValidator.java
index 713c9de..8481536 100644
--- a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-documentation/src/test/java/org/apache/nifi/documentation/html/XmlValidator.java
+++ b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-documentation/src/test/java/org/apache/nifi/documentation/html/XmlValidator.java
@@ -1,53 +1,53 @@
-/*
- * 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.html;
-
-import java.io.IOException;
-import java.io.StringReader;
-
-import javax.xml.parsers.DocumentBuilderFactory;
-import javax.xml.parsers.ParserConfigurationException;
-
-import org.junit.Assert;
-import org.xml.sax.InputSource;
-import org.xml.sax.SAXException;
-
-/**
- * A helper class to validate xml documents.
- *
- *
- */
-public class XmlValidator {
-
- public static void assertXmlValid(String xml) {
- try {
- final DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
- dbf.setNamespaceAware(true);
- dbf.newDocumentBuilder().parse(new InputSource(new StringReader(xml)));
- } catch (SAXException | IOException | ParserConfigurationException e) {
- Assert.fail(e.getMessage());
- }
- }
-
- public static void assertContains(String original, String subword) {
- Assert.assertTrue(original + " did not contain: " + subword, original.contains(subword));
- }
-
- public static void assertNotContains(String original, String subword) {
- Assert.assertFalse(original + " did contain: " + subword, original.contains(subword));
- }
-}
+/*
+ * 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.html;
+
+import java.io.IOException;
+import java.io.StringReader;
+
+import javax.xml.parsers.DocumentBuilderFactory;
+import javax.xml.parsers.ParserConfigurationException;
+
+import org.junit.Assert;
+import org.xml.sax.InputSource;
+import org.xml.sax.SAXException;
+
+/**
+ * A helper class to validate xml documents.
+ *
+ *
+ */
+public class XmlValidator {
+
+ public static void assertXmlValid(String xml) {
+ try {
+ final DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
+ dbf.setNamespaceAware(true);
+ dbf.newDocumentBuilder().parse(new InputSource(new StringReader(xml)));
+ } catch (SAXException | IOException | ParserConfigurationException e) {
+ Assert.fail(e.getMessage());
+ }
+ }
+
+ public static void assertContains(String original, String subword) {
+ Assert.assertTrue(original + " did not contain: " + subword, original.contains(subword));
+ }
+
+ public static void assertNotContains(String original, String subword) {
+ Assert.assertFalse(original + " did contain: " + subword, original.contains(subword));
+ }
+}
http://git-wip-us.apache.org/repos/asf/nifi/blob/e2d3d1b7/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core-api/src/main/java/org/apache/nifi/controller/reporting/ReportingTaskProvider.java
----------------------------------------------------------------------
diff --git a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core-api/src/main/java/org/apache/nifi/controller/reporting/ReportingTaskProvider.java b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core-api/src/main/java/org/apache/nifi/controller/reporting/ReportingTaskProvider.java
index 9f16798..ee0bf50 100644
--- a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core-api/src/main/java/org/apache/nifi/controller/reporting/ReportingTaskProvider.java
+++ b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core-api/src/main/java/org/apache/nifi/controller/reporting/ReportingTaskProvider.java
@@ -1,111 +1,111 @@
-/*
- * 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.controller.reporting;
-
-import java.util.Set;
-import org.apache.nifi.controller.ReportingTaskNode;
-
-/**
- * A ReportingTaskProvider is responsible for providing management of, and
- * access to, Reporting Tasks
- */
-public interface ReportingTaskProvider {
-
- /**
- * Creates a new instance of a reporting task
- *
- * @param type the type (fully qualified class name) of the reporting task
- * to instantiate
- * @param id the identifier for the Reporting Task
- * @param firstTimeAdded whether or not this is the first time that the
- * reporting task is being added to the flow. I.e., this will be true only
- * when the user adds the reporting task to the flow, not when the flow is
- * being restored after a restart of the software
- *
- * @return the ReportingTaskNode that is used to manage the reporting task
- *
- * @throws ReportingTaskInstantiationException if unable to create the
- * Reporting Task
- */
- ReportingTaskNode createReportingTask(String type, String id, boolean firstTimeAdded) throws ReportingTaskInstantiationException;
-
- /**
- * @param identifier of node
- * @return the reporting task that has the given identifier, or
- * <code>null</code> if no reporting task exists with that ID
- */
- ReportingTaskNode getReportingTaskNode(String identifier);
-
- /**
- * @return a Set of all Reporting Tasks that exist for this service
- * provider
- */
- Set<ReportingTaskNode> getAllReportingTasks();
-
- /**
- * Removes the given reporting task from the flow
- *
- * @param reportingTask
- *
- * @throws IllegalStateException if the reporting task cannot be removed
- * because it is not stopped, or if the reporting task is not known in the
- * flow
- */
- void removeReportingTask(ReportingTaskNode reportingTask);
-
- /**
- * Begins scheduling the reporting task to run and invokes appropriate
- * lifecycle methods
- *
- * @param reportingTask
- *
- * @throws IllegalStateException if the ReportingTask's state is not
- * STOPPED, or if the Reporting Task has active threads, or if the
- * ReportingTask is not valid
- */
- void startReportingTask(ReportingTaskNode reportingTask);
-
- /**
- * Stops scheduling the reporting task to run and invokes appropriate
- * lifecycle methods
- *
- * @param reportingTask
- *
- * @throws IllegalStateException if the ReportingTask's state is not RUNNING
- */
- void stopReportingTask(ReportingTaskNode reportingTask);
-
- /**
- * Enables the reporting task to be scheduled to run
- *
- * @param reportingTask
- *
- * @throws IllegalStateException if the ReportingTask's state is not
- * DISABLED
- */
- void enableReportingTask(ReportingTaskNode reportingTask);
-
- /**
- * Disables the ability to schedul the reporting task to run
- *
- * @param reportingTask
- *
- * @throws IllegalStateException if the ReportingTask's state is not
- * STOPPED, or if the Reporting Task has active threads
- */
- void disableReportingTask(ReportingTaskNode reportingTask);
-}
+/*
+ * 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.controller.reporting;
+
+import java.util.Set;
+import org.apache.nifi.controller.ReportingTaskNode;
+
+/**
+ * A ReportingTaskProvider is responsible for providing management of, and
+ * access to, Reporting Tasks
+ */
+public interface ReportingTaskProvider {
+
+ /**
+ * Creates a new instance of a reporting task
+ *
+ * @param type the type (fully qualified class name) of the reporting task
+ * to instantiate
+ * @param id the identifier for the Reporting Task
+ * @param firstTimeAdded whether or not this is the first time that the
+ * reporting task is being added to the flow. I.e., this will be true only
+ * when the user adds the reporting task to the flow, not when the flow is
+ * being restored after a restart of the software
+ *
+ * @return the ReportingTaskNode that is used to manage the reporting task
+ *
+ * @throws ReportingTaskInstantiationException if unable to create the
+ * Reporting Task
+ */
+ ReportingTaskNode createReportingTask(String type, String id, boolean firstTimeAdded) throws ReportingTaskInstantiationException;
+
+ /**
+ * @param identifier of node
+ * @return the reporting task that has the given identifier, or
+ * <code>null</code> if no reporting task exists with that ID
+ */
+ ReportingTaskNode getReportingTaskNode(String identifier);
+
+ /**
+ * @return a Set of all Reporting Tasks that exist for this service
+ * provider
+ */
+ Set<ReportingTaskNode> getAllReportingTasks();
+
+ /**
+ * Removes the given reporting task from the flow
+ *
+ * @param reportingTask
+ *
+ * @throws IllegalStateException if the reporting task cannot be removed
+ * because it is not stopped, or if the reporting task is not known in the
+ * flow
+ */
+ void removeReportingTask(ReportingTaskNode reportingTask);
+
+ /**
+ * Begins scheduling the reporting task to run and invokes appropriate
+ * lifecycle methods
+ *
+ * @param reportingTask
+ *
+ * @throws IllegalStateException if the ReportingTask's state is not
+ * STOPPED, or if the Reporting Task has active threads, or if the
+ * ReportingTask is not valid
+ */
+ void startReportingTask(ReportingTaskNode reportingTask);
+
+ /**
+ * Stops scheduling the reporting task to run and invokes appropriate
+ * lifecycle methods
+ *
+ * @param reportingTask
+ *
+ * @throws IllegalStateException if the ReportingTask's state is not RUNNING
+ */
+ void stopReportingTask(ReportingTaskNode reportingTask);
+
+ /**
+ * Enables the reporting task to be scheduled to run
+ *
+ * @param reportingTask
+ *
+ * @throws IllegalStateException if the ReportingTask's state is not
+ * DISABLED
+ */
+ void enableReportingTask(ReportingTaskNode reportingTask);
+
+ /**
+ * Disables the ability to schedul the reporting task to run
+ *
+ * @param reportingTask
+ *
+ * @throws IllegalStateException if the ReportingTask's state is not
+ * STOPPED, or if the Reporting Task has active threads
+ */
+ void disableReportingTask(ReportingTaskNode reportingTask);
+}
http://git-wip-us.apache.org/repos/asf/nifi/blob/e2d3d1b7/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core-api/src/main/java/org/apache/nifi/controller/service/ControllerServiceState.java
----------------------------------------------------------------------
diff --git a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core-api/src/main/java/org/apache/nifi/controller/service/ControllerServiceState.java b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core-api/src/main/java/org/apache/nifi/controller/service/ControllerServiceState.java
index 63840e7..4afd826 100644
--- a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core-api/src/main/java/org/apache/nifi/controller/service/ControllerServiceState.java
+++ b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core-api/src/main/java/org/apache/nifi/controller/service/ControllerServiceState.java
@@ -1,43 +1,43 @@
-/*
- * 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.controller.service;
-
-/**
- * Represents the valid states for a Controller Service.
- */
-public enum ControllerServiceState {
-
- /**
- * Controller Service is disabled and cannot be used.
- */
- DISABLED,
- /**
- * Controller Service has been disabled but has not yet finished its
- * lifecycle methods.
- */
- DISABLING,
- /**
- * Controller Service has been enabled but has not yet finished its
- * lifecycle methods.
- */
- ENABLING,
- /**
- * Controller Service has been enabled and has finished its lifecycle
- * methods. The Controller SErvice is ready to be used.
- */
- ENABLED;
-}
+/*
+ * 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.controller.service;
+
+/**
+ * Represents the valid states for a Controller Service.
+ */
+public enum ControllerServiceState {
+
+ /**
+ * Controller Service is disabled and cannot be used.
+ */
+ DISABLED,
+ /**
+ * Controller Service has been disabled but has not yet finished its
+ * lifecycle methods.
+ */
+ DISABLING,
+ /**
+ * Controller Service has been enabled but has not yet finished its
+ * lifecycle methods.
+ */
+ ENABLING,
+ /**
+ * Controller Service has been enabled and has finished its lifecycle
+ * methods. The Controller SErvice is ready to be used.
+ */
+ ENABLED;
+}
http://git-wip-us.apache.org/repos/asf/nifi/blob/e2d3d1b7/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/main/java/org/apache/nifi/controller/repository/claim/StandardResourceClaim.java
----------------------------------------------------------------------
diff --git a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/main/java/org/apache/nifi/controller/repository/claim/StandardResourceClaim.java b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/main/java/org/apache/nifi/controller/repository/claim/StandardResourceClaim.java
index bd3ed5a..4b27eae 100644
--- a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/main/java/org/apache/nifi/controller/repository/claim/StandardResourceClaim.java
+++ b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/main/java/org/apache/nifi/controller/repository/claim/StandardResourceClaim.java
@@ -1,134 +1,134 @@
-/*
- * 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.controller.repository.claim;
-
-import java.util.concurrent.atomic.AtomicInteger;
-
-public class StandardResourceClaim implements ResourceClaim, Comparable<ResourceClaim> {
- private final String id;
- private final String container;
- private final String section;
- private final boolean lossTolerant;
- private final AtomicInteger claimantCount = new AtomicInteger(0);
- private final int hashCode;
-
- public StandardResourceClaim(final String container, final String section, final String id, final boolean lossTolerant) {
- this.container = container.intern();
- this.section = section.intern();
- this.id = id;
- this.lossTolerant = lossTolerant;
-
- hashCode = 17 + 19 * id.hashCode() + 19 * container.hashCode() + 19 * section.hashCode();
- }
-
- @Override
- public boolean isLossTolerant() {
- return lossTolerant;
- }
-
- /**
- * @return the unique identifier for this claim
- */
- @Override
- public String getId() {
- return id;
- }
-
- /**
- * @return the container identifier in which this claim is held
- */
- @Override
- public String getContainer() {
- return container;
- }
-
- /**
- * @return the section within a given container the claim is held
- */
- @Override
- public String getSection() {
- return section;
- }
-
- int getClaimantCount() {
- return claimantCount.get();
- }
-
- int decrementClaimantCount() {
- return claimantCount.decrementAndGet();
- }
-
- int incrementClaimantCount() {
- return claimantCount.incrementAndGet();
- }
-
- /**
- * Provides the natural ordering for ResourceClaim objects. By default they are sorted by their id, then container, then section
- *
- * @param other other claim
- * @return x such that x <=1 if this is less than other;
- * x=0 if this.equals(other);
- * x >= 1 if this is greater than other
- */
- @Override
- public int compareTo(final ResourceClaim other) {
- final int idComparison = id.compareTo(other.getId());
- if (idComparison != 0) {
- return idComparison;
- }
-
- final int containerComparison = container.compareTo(other.getContainer());
- if (containerComparison != 0) {
- return containerComparison;
- }
-
- return section.compareTo(other.getSection());
- }
-
- @Override
- public boolean equals(final Object other) {
- if (this == other) {
- return true;
- }
-
- if (other == null) {
- return false;
- }
- if (hashCode != other.hashCode()) {
- // We check hash code before instanceof because instanceof is fairly expensive and for
- // StandardResourceClaim, calling hashCode() simply returns a pre-calculated value.
- return false;
- }
-
- if (!(other instanceof ResourceClaim)) {
- return false;
- }
- final ResourceClaim otherClaim = (ResourceClaim) other;
- return id.equals(otherClaim.getId()) && container.equals(otherClaim.getContainer()) && section.equals(otherClaim.getSection());
- }
-
- @Override
- public int hashCode() {
- return hashCode;
- }
-
- @Override
- public String toString() {
- return "StandardResourceClaim[id=" + id + ", container=" + container + ", section=" + section + "]";
- }
-
-}
+/*
+ * 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.controller.repository.claim;
+
+import java.util.concurrent.atomic.AtomicInteger;
+
+public class StandardResourceClaim implements ResourceClaim, Comparable<ResourceClaim> {
+ private final String id;
+ private final String container;
+ private final String section;
+ private final boolean lossTolerant;
+ private final AtomicInteger claimantCount = new AtomicInteger(0);
+ private final int hashCode;
+
+ public StandardResourceClaim(final String container, final String section, final String id, final boolean lossTolerant) {
+ this.container = container.intern();
+ this.section = section.intern();
+ this.id = id;
+ this.lossTolerant = lossTolerant;
+
+ hashCode = 17 + 19 * id.hashCode() + 19 * container.hashCode() + 19 * section.hashCode();
+ }
+
+ @Override
+ public boolean isLossTolerant() {
+ return lossTolerant;
+ }
+
+ /**
+ * @return the unique identifier for this claim
+ */
+ @Override
+ public String getId() {
+ return id;
+ }
+
+ /**
+ * @return the container identifier in which this claim is held
+ */
+ @Override
+ public String getContainer() {
+ return container;
+ }
+
+ /**
+ * @return the section within a given container the claim is held
+ */
+ @Override
+ public String getSection() {
+ return section;
+ }
+
+ int getClaimantCount() {
+ return claimantCount.get();
+ }
+
+ int decrementClaimantCount() {
+ return claimantCount.decrementAndGet();
+ }
+
+ int incrementClaimantCount() {
+ return claimantCount.incrementAndGet();
+ }
+
+ /**
+ * Provides the natural ordering for ResourceClaim objects. By default they are sorted by their id, then container, then section
+ *
+ * @param other other claim
+ * @return x such that x <=1 if this is less than other;
+ * x=0 if this.equals(other);
+ * x >= 1 if this is greater than other
+ */
+ @Override
+ public int compareTo(final ResourceClaim other) {
+ final int idComparison = id.compareTo(other.getId());
+ if (idComparison != 0) {
+ return idComparison;
+ }
+
+ final int containerComparison = container.compareTo(other.getContainer());
+ if (containerComparison != 0) {
+ return containerComparison;
+ }
+
+ return section.compareTo(other.getSection());
+ }
+
+ @Override
+ public boolean equals(final Object other) {
+ if (this == other) {
+ return true;
+ }
+
+ if (other == null) {
+ return false;
+ }
+ if (hashCode != other.hashCode()) {
+ // We check hash code before instanceof because instanceof is fairly expensive and for
+ // StandardResourceClaim, calling hashCode() simply returns a pre-calculated value.
+ return false;
+ }
+
+ if (!(other instanceof ResourceClaim)) {
+ return false;
+ }
+ final ResourceClaim otherClaim = (ResourceClaim) other;
+ return id.equals(otherClaim.getId()) && container.equals(otherClaim.getContainer()) && section.equals(otherClaim.getSection());
+ }
+
+ @Override
+ public int hashCode() {
+ return hashCode;
+ }
+
+ @Override
+ public String toString() {
+ return "StandardResourceClaim[id=" + id + ", container=" + container + ", section=" + section + "]";
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/nifi/blob/e2d3d1b7/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/main/java/org/apache/nifi/logging/ControllerServiceLogObserver.java
----------------------------------------------------------------------
diff --git a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/main/java/org/apache/nifi/logging/ControllerServiceLogObserver.java b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/main/java/org/apache/nifi/logging/ControllerServiceLogObserver.java
index d9eaa12..3ea432d 100644
--- a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/main/java/org/apache/nifi/logging/ControllerServiceLogObserver.java
+++ b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/main/java/org/apache/nifi/logging/ControllerServiceLogObserver.java
@@ -1,46 +1,46 @@
-/*
- * 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.logging;
-
-import org.apache.nifi.controller.service.ControllerServiceNode;
-import org.apache.nifi.events.BulletinFactory;
-import org.apache.nifi.reporting.Bulletin;
-import org.apache.nifi.reporting.BulletinRepository;
-import org.apache.nifi.reporting.ComponentType;
-import org.apache.nifi.reporting.Severity;
-
-public class ControllerServiceLogObserver implements LogObserver {
-
- private final BulletinRepository bulletinRepository;
- private final ControllerServiceNode serviceNode;
-
- public ControllerServiceLogObserver(final BulletinRepository bulletinRepository, final ControllerServiceNode serviceNode) {
- this.bulletinRepository = bulletinRepository;
- this.serviceNode = serviceNode;
- }
-
- @Override
- public void onLogMessage(final LogMessage message) {
- // Map LogLevel.WARN to Severity.WARNING so that we are consistent with the Severity enumeration. Else, just use whatever
- // the LogLevel is (INFO and ERROR map directly and all others we will just accept as they are).
- final String bulletinLevel = message.getLevel() == LogLevel.WARN ? Severity.WARNING.name() : message.getLevel().toString();
-
- final Bulletin bulletin = BulletinFactory.createBulletin(null, serviceNode.getIdentifier(), ComponentType.CONTROLLER_SERVICE,
- serviceNode.getName(), "Log Message", bulletinLevel, message.getMessage());
- bulletinRepository.addBulletin(bulletin);
- }
-}
+/*
+ * 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.logging;
+
+import org.apache.nifi.controller.service.ControllerServiceNode;
+import org.apache.nifi.events.BulletinFactory;
+import org.apache.nifi.reporting.Bulletin;
+import org.apache.nifi.reporting.BulletinRepository;
+import org.apache.nifi.reporting.ComponentType;
+import org.apache.nifi.reporting.Severity;
+
+public class ControllerServiceLogObserver implements LogObserver {
+
+ private final BulletinRepository bulletinRepository;
+ private final ControllerServiceNode serviceNode;
+
+ public ControllerServiceLogObserver(final BulletinRepository bulletinRepository, final ControllerServiceNode serviceNode) {
+ this.bulletinRepository = bulletinRepository;
+ this.serviceNode = serviceNode;
+ }
+
+ @Override
+ public void onLogMessage(final LogMessage message) {
+ // Map LogLevel.WARN to Severity.WARNING so that we are consistent with the Severity enumeration. Else, just use whatever
+ // the LogLevel is (INFO and ERROR map directly and all others we will just accept as they are).
+ final String bulletinLevel = message.getLevel() == LogLevel.WARN ? Severity.WARNING.name() : message.getLevel().toString();
+
+ final Bulletin bulletin = BulletinFactory.createBulletin(null, serviceNode.getIdentifier(), ComponentType.CONTROLLER_SERVICE,
+ serviceNode.getName(), "Log Message", bulletinLevel, message.getMessage());
+ bulletinRepository.addBulletin(bulletin);
+ }
+}
http://git-wip-us.apache.org/repos/asf/nifi/blob/e2d3d1b7/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/main/java/org/apache/nifi/logging/ReportingTaskLogObserver.java
----------------------------------------------------------------------
diff --git a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/main/java/org/apache/nifi/logging/ReportingTaskLogObserver.java b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/main/java/org/apache/nifi/logging/ReportingTaskLogObserver.java
index e5638d6..f52bc1c 100644
--- a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/main/java/org/apache/nifi/logging/ReportingTaskLogObserver.java
+++ b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/main/java/org/apache/nifi/logging/ReportingTaskLogObserver.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.logging;
-
-import org.apache.nifi.controller.ReportingTaskNode;
-import org.apache.nifi.events.BulletinFactory;
-import org.apache.nifi.reporting.Bulletin;
-import org.apache.nifi.reporting.BulletinRepository;
-import org.apache.nifi.reporting.ComponentType;
-import org.apache.nifi.reporting.Severity;
-
-public class ReportingTaskLogObserver implements LogObserver {
- private final BulletinRepository bulletinRepository;
- private final ReportingTaskNode taskNode;
-
- public ReportingTaskLogObserver(final BulletinRepository bulletinRepository, final ReportingTaskNode taskNode) {
- this.bulletinRepository = bulletinRepository;
- this.taskNode = taskNode;
- }
-
- @Override
- public void onLogMessage(final LogMessage message) {
- // Map LogLevel.WARN to Severity.WARNING so that we are consistent with the Severity enumeration. Else, just use whatever
- // the LogLevel is (INFO and ERROR map directly and all others we will just accept as they are).
- final String bulletinLevel = message.getLevel() == LogLevel.WARN ? Severity.WARNING.name() : message.getLevel().toString();
-
- final Bulletin bulletin = BulletinFactory.createBulletin(null, taskNode.getIdentifier(), ComponentType.REPORTING_TASK,
- taskNode.getName(), "Log Message", bulletinLevel, message.getMessage());
- bulletinRepository.addBulletin(bulletin);
- }
-}
+/*
+ * 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.logging;
+
+import org.apache.nifi.controller.ReportingTaskNode;
+import org.apache.nifi.events.BulletinFactory;
+import org.apache.nifi.reporting.Bulletin;
+import org.apache.nifi.reporting.BulletinRepository;
+import org.apache.nifi.reporting.ComponentType;
+import org.apache.nifi.reporting.Severity;
+
+public class ReportingTaskLogObserver implements LogObserver {
+ private final BulletinRepository bulletinRepository;
+ private final ReportingTaskNode taskNode;
+
+ public ReportingTaskLogObserver(final BulletinRepository bulletinRepository, final ReportingTaskNode taskNode) {
+ this.bulletinRepository = bulletinRepository;
+ this.taskNode = taskNode;
+ }
+
+ @Override
+ public void onLogMessage(final LogMessage message) {
+ // Map LogLevel.WARN to Severity.WARNING so that we are consistent with the Severity enumeration. Else, just use whatever
+ // the LogLevel is (INFO and ERROR map directly and all others we will just accept as they are).
+ final String bulletinLevel = message.getLevel() == LogLevel.WARN ? Severity.WARNING.name() : message.getLevel().toString();
+
+ final Bulletin bulletin = BulletinFactory.createBulletin(null, taskNode.getIdentifier(), ComponentType.REPORTING_TASK,
+ taskNode.getName(), "Log Message", bulletinLevel, message.getMessage());
+ bulletinRepository.addBulletin(bulletin);
+ }
+}
http://git-wip-us.apache.org/repos/asf/nifi/blob/e2d3d1b7/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/java/org/apache/nifi/controller/scheduling/NoStartService.java
----------------------------------------------------------------------
diff --git a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/java/org/apache/nifi/controller/scheduling/NoStartService.java b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/java/org/apache/nifi/controller/scheduling/NoStartService.java
index fac5531..bbec70e 100644
--- a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/java/org/apache/nifi/controller/scheduling/NoStartService.java
+++ b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/java/org/apache/nifi/controller/scheduling/NoStartService.java
@@ -1,23 +1,23 @@
-/*
- * 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.controller.scheduling;
-
-import org.apache.nifi.controller.ControllerService;
-
-public interface NoStartService extends ControllerService {
-
-}
+/*
+ * 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.controller.scheduling;
+
+import org.apache.nifi.controller.ControllerService;
+
+public interface NoStartService extends ControllerService {
+
+}
http://git-wip-us.apache.org/repos/asf/nifi/blob/e2d3d1b7/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/java/org/apache/nifi/controller/scheduling/NoStartServiceImpl.java
----------------------------------------------------------------------
diff --git a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/java/org/apache/nifi/controller/scheduling/NoStartServiceImpl.java b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/java/org/apache/nifi/controller/scheduling/NoStartServiceImpl.java
index d6a47be..0aee90b 100644
--- a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/java/org/apache/nifi/controller/scheduling/NoStartServiceImpl.java
+++ b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/java/org/apache/nifi/controller/scheduling/NoStartServiceImpl.java
@@ -1,29 +1,29 @@
-/*
- * 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.controller.scheduling;
-
-import org.apache.nifi.annotation.lifecycle.OnEnabled;
-import org.apache.nifi.controller.AbstractControllerService;
-
-public class NoStartServiceImpl extends AbstractControllerService implements NoStartService {
-
- @OnEnabled
- public void failIntentionally() {
- throw new RuntimeException("Failed intentionally for unit test");
- }
-
-}
+/*
+ * 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.controller.scheduling;
+
+import org.apache.nifi.annotation.lifecycle.OnEnabled;
+import org.apache.nifi.controller.AbstractControllerService;
+
+public class NoStartServiceImpl extends AbstractControllerService implements NoStartService {
+
+ @OnEnabled
+ public void failIntentionally() {
+ throw new RuntimeException("Failed intentionally for unit test");
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/nifi/blob/e2d3d1b7/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/java/org/apache/nifi/controller/scheduling/TestStandardProcessScheduler.java
----------------------------------------------------------------------
diff --git a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/java/org/apache/nifi/controller/scheduling/TestStandardProcessScheduler.java b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/java/org/apache/nifi/controller/scheduling/TestStandardProcessScheduler.java
index d8c5d08..bed1c06 100644
--- a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/java/org/apache/nifi/controller/scheduling/TestStandardProcessScheduler.java
+++ b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/java/org/apache/nifi/controller/scheduling/TestStandardProcessScheduler.java
@@ -1,159 +1,159 @@
-/*
- * 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.controller.scheduling;
-
-import static org.junit.Assert.assertTrue;
-
-import java.util.ArrayList;
-import java.util.List;
-import java.util.UUID;
-import java.util.concurrent.atomic.AtomicBoolean;
-import java.util.concurrent.atomic.AtomicInteger;
-
-import org.apache.nifi.annotation.lifecycle.OnScheduled;
-import org.apache.nifi.components.PropertyDescriptor;
-import org.apache.nifi.controller.Heartbeater;
-import org.apache.nifi.controller.ProcessorNode;
-import org.apache.nifi.controller.ReportingTaskNode;
-import org.apache.nifi.controller.StandardProcessorNode;
-import org.apache.nifi.controller.ValidationContextFactory;
-import org.apache.nifi.controller.reporting.StandardReportingInitializationContext;
-import org.apache.nifi.controller.reporting.StandardReportingTaskNode;
-import org.apache.nifi.controller.service.ControllerServiceNode;
-import org.apache.nifi.controller.service.ControllerServiceProvider;
-import org.apache.nifi.controller.service.StandardControllerServiceProvider;
-import org.apache.nifi.logging.ComponentLog;
-import org.apache.nifi.processor.AbstractProcessor;
-import org.apache.nifi.processor.ProcessContext;
-import org.apache.nifi.processor.ProcessSession;
-import org.apache.nifi.processor.Processor;
-import org.apache.nifi.processor.StandardValidationContextFactory;
-import org.apache.nifi.processor.exception.ProcessException;
-import org.apache.nifi.reporting.AbstractReportingTask;
-import org.apache.nifi.reporting.InitializationException;
-import org.apache.nifi.reporting.ReportingContext;
-import org.apache.nifi.reporting.ReportingInitializationContext;
-import org.apache.nifi.scheduling.SchedulingStrategy;
-import org.junit.Before;
-import org.junit.Test;
-import org.mockito.Mockito;
-
-public class TestStandardProcessScheduler {
- private StandardProcessScheduler scheduler = null;
- private ReportingTaskNode taskNode = null;
- private TestReportingTask reportingTask = null;
-
- @Before
- public void setup() throws InitializationException {
- System.setProperty("nifi.properties.file.path", "src/test/resources/nifi.properties");
- scheduler = new StandardProcessScheduler(Mockito.mock(Heartbeater.class), Mockito.mock(ControllerServiceProvider.class), null);
- scheduler.setSchedulingAgent(SchedulingStrategy.TIMER_DRIVEN, Mockito.mock(SchedulingAgent.class));
-
- reportingTask = new TestReportingTask();
- final ReportingInitializationContext config = new StandardReportingInitializationContext(UUID.randomUUID().toString(), "Test", SchedulingStrategy.TIMER_DRIVEN, "5 secs",
- Mockito.mock(ComponentLog.class), null);
- reportingTask.initialize(config);
-
- final ValidationContextFactory validationContextFactory = new StandardValidationContextFactory(null);
- taskNode = new StandardReportingTaskNode(reportingTask, UUID.randomUUID().toString(), null, scheduler, validationContextFactory);
- }
-
- /**
- * We have run into an issue where a Reporting Task is scheduled to run but throws an Exception
- * from a method with the @OnScheduled annotation. User stops Reporting Task, updates configuration
- * to fix the issue. Reporting Task then finishes running @OnSchedule method and is then scheduled to run.
- * This unit test is intended to verify that we have this resolved.
- */
- @Test
- public void testReportingTaskDoesntKeepRunningAfterStop() throws InterruptedException, InitializationException {
- scheduler.schedule(taskNode);
-
- // Let it try to run a few times.
- Thread.sleep(1000L);
-
- scheduler.unschedule(taskNode);
-
- final int attempts = reportingTask.onScheduleAttempts.get();
- // give it a sec to make sure that it's finished running.
- Thread.sleep(1500L);
- final int attemptsAfterStop = reportingTask.onScheduleAttempts.get() - attempts;
-
- // allow 1 extra run, due to timing issues that could call it as it's being stopped.
- assertTrue("After unscheduling Reporting Task, task ran an additional " + attemptsAfterStop + " times", attemptsAfterStop <= 1);
- }
-
- @Test(timeout = 6000)
- public void testDisableControllerServiceWithProcessorTryingToStartUsingIt() throws InterruptedException {
- final Processor proc = new ServiceReferencingProcessor();
-
- final ControllerServiceProvider serviceProvider = new StandardControllerServiceProvider(scheduler, null);
- final ControllerServiceNode service = serviceProvider.createControllerService(NoStartServiceImpl.class.getName(), "service", true);
- final ProcessorNode procNode = new StandardProcessorNode(proc, UUID.randomUUID().toString(),
- new StandardValidationContextFactory(serviceProvider), scheduler, serviceProvider);
-
- procNode.setProperty(ServiceReferencingProcessor.SERVICE_DESC.getName(), service.getIdentifier());
-
- scheduler.enableControllerService(service);
- scheduler.startProcessor(procNode);
-
- Thread.sleep(1000L);
-
- scheduler.stopProcessor(procNode);
- scheduler.disableControllerService(service);
- }
-
-
- private class TestReportingTask extends AbstractReportingTask {
- private final AtomicBoolean failOnScheduled = new AtomicBoolean(true);
- private final AtomicInteger onScheduleAttempts = new AtomicInteger(0);
- private final AtomicInteger triggerCount = new AtomicInteger(0);
-
- @OnScheduled
- public void onScheduled() {
- onScheduleAttempts.incrementAndGet();
-
- if (failOnScheduled.get()) {
- throw new RuntimeException("Intentional Exception for testing purposes");
- }
- }
-
- @Override
- public void onTrigger(final ReportingContext context) {
- triggerCount.getAndIncrement();
- }
- }
-
-
- private static class ServiceReferencingProcessor extends AbstractProcessor {
- static final PropertyDescriptor SERVICE_DESC = new PropertyDescriptor.Builder()
- .name("service")
- .identifiesControllerService(NoStartService.class)
- .required(true)
- .build();
-
- @Override
- protected List<PropertyDescriptor> getSupportedPropertyDescriptors() {
- final List<PropertyDescriptor> properties = new ArrayList<>();
- properties.add(SERVICE_DESC);
- return properties;
- }
-
- @Override
- public void onTrigger(ProcessContext context, ProcessSession session) throws ProcessException {
- }
- }
-}
+/*
+ * 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.controller.scheduling;
+
+import static org.junit.Assert.assertTrue;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.UUID;
+import java.util.concurrent.atomic.AtomicBoolean;
+import java.util.concurrent.atomic.AtomicInteger;
+
+import org.apache.nifi.annotation.lifecycle.OnScheduled;
+import org.apache.nifi.components.PropertyDescriptor;
+import org.apache.nifi.controller.Heartbeater;
+import org.apache.nifi.controller.ProcessorNode;
+import org.apache.nifi.controller.ReportingTaskNode;
+import org.apache.nifi.controller.StandardProcessorNode;
+import org.apache.nifi.controller.ValidationContextFactory;
+import org.apache.nifi.controller.reporting.StandardReportingInitializationContext;
+import org.apache.nifi.controller.reporting.StandardReportingTaskNode;
+import org.apache.nifi.controller.service.ControllerServiceNode;
+import org.apache.nifi.controller.service.ControllerServiceProvider;
+import org.apache.nifi.controller.service.StandardControllerServiceProvider;
+import org.apache.nifi.logging.ComponentLog;
+import org.apache.nifi.processor.AbstractProcessor;
+import org.apache.nifi.processor.ProcessContext;
+import org.apache.nifi.processor.ProcessSession;
+import org.apache.nifi.processor.Processor;
+import org.apache.nifi.processor.StandardValidationContextFactory;
+import org.apache.nifi.processor.exception.ProcessException;
+import org.apache.nifi.reporting.AbstractReportingTask;
+import org.apache.nifi.reporting.InitializationException;
+import org.apache.nifi.reporting.ReportingContext;
+import org.apache.nifi.reporting.ReportingInitializationContext;
+import org.apache.nifi.scheduling.SchedulingStrategy;
+import org.junit.Before;
+import org.junit.Test;
+import org.mockito.Mockito;
+
+public class TestStandardProcessScheduler {
+ private StandardProcessScheduler scheduler = null;
+ private ReportingTaskNode taskNode = null;
+ private TestReportingTask reportingTask = null;
+
+ @Before
+ public void setup() throws InitializationException {
+ System.setProperty("nifi.properties.file.path", "src/test/resources/nifi.properties");
+ scheduler = new StandardProcessScheduler(Mockito.mock(Heartbeater.class), Mockito.mock(ControllerServiceProvider.class), null);
+ scheduler.setSchedulingAgent(SchedulingStrategy.TIMER_DRIVEN, Mockito.mock(SchedulingAgent.class));
+
+ reportingTask = new TestReportingTask();
+ final ReportingInitializationContext config = new StandardReportingInitializationContext(UUID.randomUUID().toString(), "Test", SchedulingStrategy.TIMER_DRIVEN, "5 secs",
+ Mockito.mock(ComponentLog.class), null);
+ reportingTask.initialize(config);
+
+ final ValidationContextFactory validationContextFactory = new StandardValidationContextFactory(null);
+ taskNode = new StandardReportingTaskNode(reportingTask, UUID.randomUUID().toString(), null, scheduler, validationContextFactory);
+ }
+
+ /**
+ * We have run into an issue where a Reporting Task is scheduled to run but throws an Exception
+ * from a method with the @OnScheduled annotation. User stops Reporting Task, updates configuration
+ * to fix the issue. Reporting Task then finishes running @OnSchedule method and is then scheduled to run.
+ * This unit test is intended to verify that we have this resolved.
+ */
+ @Test
+ public void testReportingTaskDoesntKeepRunningAfterStop() throws InterruptedException, InitializationException {
+ scheduler.schedule(taskNode);
+
+ // Let it try to run a few times.
+ Thread.sleep(1000L);
+
+ scheduler.unschedule(taskNode);
+
+ final int attempts = reportingTask.onScheduleAttempts.get();
+ // give it a sec to make sure that it's finished running.
+ Thread.sleep(1500L);
+ final int attemptsAfterStop = reportingTask.onScheduleAttempts.get() - attempts;
+
+ // allow 1 extra run, due to timing issues that could call it as it's being stopped.
+ assertTrue("After unscheduling Reporting Task, task ran an additional " + attemptsAfterStop + " times", attemptsAfterStop <= 1);
+ }
+
+ @Test(timeout = 6000)
+ public void testDisableControllerServiceWithProcessorTryingToStartUsingIt() throws InterruptedException {
+ final Processor proc = new ServiceReferencingProcessor();
+
+ final ControllerServiceProvider serviceProvider = new StandardControllerServiceProvider(scheduler, null);
+ final ControllerServiceNode service = serviceProvider.createControllerService(NoStartServiceImpl.class.getName(), "service", true);
+ final ProcessorNode procNode = new StandardProcessorNode(proc, UUID.randomUUID().toString(),
+ new StandardValidationContextFactory(serviceProvider), scheduler, serviceProvider);
+
+ procNode.setProperty(ServiceReferencingProcessor.SERVICE_DESC.getName(), service.getIdentifier());
+
+ scheduler.enableControllerService(service);
+ scheduler.startProcessor(procNode);
+
+ Thread.sleep(1000L);
+
+ scheduler.stopProcessor(procNode);
+ scheduler.disableControllerService(service);
+ }
+
+
+ private class TestReportingTask extends AbstractReportingTask {
+ private final AtomicBoolean failOnScheduled = new AtomicBoolean(true);
+ private final AtomicInteger onScheduleAttempts = new AtomicInteger(0);
+ private final AtomicInteger triggerCount = new AtomicInteger(0);
+
+ @OnScheduled
+ public void onScheduled() {
+ onScheduleAttempts.incrementAndGet();
+
+ if (failOnScheduled.get()) {
+ throw new RuntimeException("Intentional Exception for testing purposes");
+ }
+ }
+
+ @Override
+ public void onTrigger(final ReportingContext context) {
+ triggerCount.getAndIncrement();
+ }
+ }
+
+
+ private static class ServiceReferencingProcessor extends AbstractProcessor {
+ static final PropertyDescriptor SERVICE_DESC = new PropertyDescriptor.Builder()
+ .name("service")
+ .identifiesControllerService(NoStartService.class)
+ .required(true)
+ .build();
+
+ @Override
+ protected List<PropertyDescriptor> getSupportedPropertyDescriptors() {
+ final List<PropertyDescriptor> properties = new ArrayList<>();
+ properties.add(SERVICE_DESC);
+ return properties;
+ }
+
+ @Override
+ public void onTrigger(ProcessContext context, ProcessSession session) throws ProcessException {
+ }
+ }
+}