From 4417b9d64a48b52927c67e42a7bb278e92403e9c Mon Sep 17 00:00:00 2001 From: Joe Witt Date: Wed, 12 Aug 2020 17:11:29 -0700 Subject: [PATCH] NIFI-6666 removing all modifications to the nifi-api and the newly created builder class This closes #4475. Signed-off-by: Andy LoPresto --- nifi-api/pom.xml | 95 ------------------- .../NifiBuildProperties.java.template | 93 ------------------ .../nifi/registry/VariableRegistry.java | 10 -- .../nifi/build/TestBuildProperties.java | 39 -------- .../util/StandardProcessorTestRunner.java | 32 ------- .../processors/standard/TestInvokeHTTP.java | 7 +- .../text/TestFreeFormTextRecordSetWriter.java | 4 +- 7 files changed, 4 insertions(+), 276 deletions(-) delete mode 100644 nifi-api/src/main/code-gen/NifiBuildProperties.java.template delete mode 100644 nifi-api/src/test/java/org/apache/nifi/build/TestBuildProperties.java diff --git a/nifi-api/pom.xml b/nifi-api/pom.xml index 50bb79d56e..c710f97129 100644 --- a/nifi-api/pom.xml +++ b/nifi-api/pom.xml @@ -23,99 +23,4 @@ nifi-api jar - - - - - - pl.project13.maven - git-commit-id-plugin - 4.0.0 - - - generate-sources - - revision - - - - - - - yyyy-MM-dd'T'HH:mm:ssZ - - - - - com.google.code.maven-replacer-plugin - replacer - 1.5.3 - - - Generate NifiBuildProperties Java class - generate-sources - - replace - - - ${project.basedir}/src/main/code-gen/NifiBuildProperties.java.template - ${project.build.directory}/generated-sources/java/org/apache/nifi/build/NifiBuildProperties.java - - - - - - - #maven.build.timestamp# - ${maven.build.timestamp} - - - - #project.version# - ${project.version} - - - #git.branch#${git.branch} - #git.build.number#${git.build.number} - #git.build.number.unique#${git.build.number.unique} - #git.build.time#${git.build.time} - #git.build.version#${git.build.version} - #git.closest.tag.commit.count#${git.closest.tag.commit.count} - #git.closest.tag.name#${git.closest.tag.name} - #git.commit.id#${git.commit.id} - #git.commit.id.abbrev#${git.commit.id.abbrev} - #git.commit.id.describe#${git.commit.id.describe} - #git.commit.id.describe-short#${git.commit.id.describe-short} - #git.commit.time#${git.commit.time} - #git.dirty#${git.dirty} - #git.total.commit.count#${git.total.commit.count} - - - - - - - org.codehaus.mojo - build-helper-maven-plugin - 3.0.0 - - - add-source - generate-sources - - add-source - - - - ${project.build.directory}/generated-sources/java/ - - - - - - - - - - diff --git a/nifi-api/src/main/code-gen/NifiBuildProperties.java.template b/nifi-api/src/main/code-gen/NifiBuildProperties.java.template deleted file mode 100644 index 050bd98dfa..0000000000 --- a/nifi-api/src/main/code-gen/NifiBuildProperties.java.template +++ /dev/null @@ -1,93 +0,0 @@ -/* - * 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.build; - -import java.time.Instant; -import java.time.ZoneId; -import java.time.format.DateTimeFormatter; -import java.time.format.DateTimeParseException; -import java.util.Properties; - -public final class NifiBuildProperties { - - private static final String MAVEN_TIMESTAMP_FORMAT = "yyyy-MM-dd'T'HH:mm:ssX"; - private static final String GIT_TIMESTAMP_FORMAT = "yyyy-MM-dd'T'HH:mm:ssZ"; - - public static final String NIFI_VERSION = "#project.version#"; - public static final Instant BUILD_TIMESTAMP = parseDateTime("#maven.build.timestamp#", MAVEN_TIMESTAMP_FORMAT); - public static final String BUILD_TIMESTAMP_STR = instantToString(BUILD_TIMESTAMP); - - public static final String BUILD_GIT_BRANCH = "#git.branch#"; - public static final String BUILD_GIT_BUILD_NUMBER = "#git.build.number#"; - public static final String BUILD_GIT_BUILD_NUMBER_UNIQUE = "#git.build.number.unique#"; - public static final Instant BUILD_GIT_BUILD_TIME = parseDateTime("#git.build.time#", GIT_TIMESTAMP_FORMAT); - public static final String BUILD_GIT_BUILD_TIME_STR = instantToString(BUILD_GIT_BUILD_TIME); - public static final String BUILD_GIT_BUILD_VERSION = "#git.build.version#"; - public static final String BUILD_GIT_CLOSEST_TAG_COMMIT_COUNT = "#git.closest.tag.commit.count#"; - public static final String BUILD_GIT_CLOSEST_TAG_NAME = "#git.closest.tag.name#"; - public static final String BUILD_GIT_COMMIT_ID = "#git.commit.id#"; - public static final String BUILD_GIT_COMMIT_ID_ABBREV = "#git.commit.id.abbrev#"; - public static final String BUILD_GIT_COMMIT_ID_DESCRIBE = "#git.commit.id.describe#"; - public static final String BUILD_GIT_COMMIT_ID_DESCRIBE_SHORT = "#git.commit.id.describe-short#"; - public static final Instant BUILD_GIT_COMMIT_TIME = parseDateTime("#git.commit.time#", GIT_TIMESTAMP_FORMAT); - public static final String BUILD_GIT_COMMIT_TIME_STR = instantToString(BUILD_GIT_COMMIT_TIME); - public static final String BUILD_GIT_DIRTY = "#git.dirty#"; - public static final String BUILD_GIT_TOTAL_COMMIT_COUNT = "#git.total.commit.count#"; - - private static Instant parseDateTime(String dateTime, String pattern) { - // This is to reliably parse the datetime format configured in the git-commit-id-plugin - try { - return DateTimeFormatter.ofPattern(pattern).parse(dateTime, Instant::from); - } catch (DateTimeParseException dtpe) { - return Instant.EPOCH; - } - } - - private static String instantToString(Instant dateTime) { - // Default zone to format the build time in. - try { - return DateTimeFormatter.ISO_OFFSET_DATE_TIME.withZone(ZoneId.of("Europe/Amsterdam")).format(dateTime); - } catch (DateTimeParseException dtpe) { - return "1970-01-01T00:00:00+0000"; - } - } - - public static final Properties getBuildProperties() { - Properties properties = new Properties(); - properties.setProperty("nifi.version", NIFI_VERSION ); - properties.setProperty("nifi.build.timestamp", BUILD_TIMESTAMP_STR ); - - properties.setProperty("nifi.build.git.branch", BUILD_GIT_BRANCH ); - properties.setProperty("nifi.build.git.build.number", BUILD_GIT_BUILD_NUMBER ); - properties.setProperty("nifi.build.git.build.number.unique", BUILD_GIT_BUILD_NUMBER_UNIQUE ); - properties.setProperty("nifi.build.git.build.time", BUILD_GIT_BUILD_TIME_STR ); - properties.setProperty("nifi.build.git.build.version", BUILD_GIT_BUILD_VERSION ); - properties.setProperty("nifi.build.git.closest.tag.commit.count", BUILD_GIT_CLOSEST_TAG_COMMIT_COUNT ); - properties.setProperty("nifi.build.git.closest.tag.name", BUILD_GIT_CLOSEST_TAG_NAME ); - properties.setProperty("nifi.build.git.commit.id", BUILD_GIT_COMMIT_ID ); - properties.setProperty("nifi.build.git.commit.id.abbrev", BUILD_GIT_COMMIT_ID_ABBREV ); - properties.setProperty("nifi.build.git.commit.id.describe", BUILD_GIT_COMMIT_ID_DESCRIBE ); - properties.setProperty("nifi.build.git.commit.id.describe-short", BUILD_GIT_COMMIT_ID_DESCRIBE_SHORT ); - properties.setProperty("nifi.build.git.commit.time", BUILD_GIT_COMMIT_TIME_STR ); - properties.setProperty("nifi.build.git.dirty", BUILD_GIT_DIRTY ); - properties.setProperty("nifi.build.git.total.commit.count", BUILD_GIT_TOTAL_COMMIT_COUNT ); - - return properties; - } - -} diff --git a/nifi-api/src/main/java/org/apache/nifi/registry/VariableRegistry.java b/nifi-api/src/main/java/org/apache/nifi/registry/VariableRegistry.java index cb9b444160..31e017ffab 100644 --- a/nifi-api/src/main/java/org/apache/nifi/registry/VariableRegistry.java +++ b/nifi-api/src/main/java/org/apache/nifi/registry/VariableRegistry.java @@ -16,8 +16,6 @@ */ package org.apache.nifi.registry; -import org.apache.nifi.build.NifiBuildProperties; - import java.util.Collections; import java.util.HashMap; import java.util.Map; @@ -58,14 +56,6 @@ public interface VariableRegistry { .build(); map.put(desc, entry.getValue().toString()); }); - NifiBuildProperties.getBuildProperties().entrySet().stream().forEach((entry) -> { - final VariableDescriptor desc = new VariableDescriptor.Builder(entry.getKey().toString()) - .description("Build Property") - .sensitive(false) - .build(); - map.put(desc, entry.getValue().toString()); - }); - } @Override diff --git a/nifi-api/src/test/java/org/apache/nifi/build/TestBuildProperties.java b/nifi-api/src/test/java/org/apache/nifi/build/TestBuildProperties.java deleted file mode 100644 index 478ef9a432..0000000000 --- a/nifi-api/src/test/java/org/apache/nifi/build/TestBuildProperties.java +++ /dev/null @@ -1,39 +0,0 @@ -/* - * 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.build; - -import org.junit.Test; - -import java.time.Instant; - -import static org.junit.Assert.assertNotEquals; - -public class TestBuildProperties { - - @Test - public void testCheckGeneratedBuildProperties() { - assertNotEquals("An error occurred in the parsed Maven build time", - Instant.EPOCH, NifiBuildProperties.BUILD_TIMESTAMP); - - assertNotEquals("An error occurred in the parsed Git build time", - Instant.EPOCH, NifiBuildProperties.BUILD_GIT_BUILD_TIME); - - assertNotEquals("An error occurred in the parsed Git commit time", - Instant.EPOCH, NifiBuildProperties.BUILD_GIT_COMMIT_TIME); - } - -} diff --git a/nifi-mock/src/main/java/org/apache/nifi/util/StandardProcessorTestRunner.java b/nifi-mock/src/main/java/org/apache/nifi/util/StandardProcessorTestRunner.java index 4258e914dd..297791679d 100644 --- a/nifi-mock/src/main/java/org/apache/nifi/util/StandardProcessorTestRunner.java +++ b/nifi-mock/src/main/java/org/apache/nifi/util/StandardProcessorTestRunner.java @@ -16,35 +16,6 @@ */ package org.apache.nifi.util; -import static java.util.Objects.requireNonNull; -import static org.apache.nifi.registry.VariableRegistry.ENVIRONMENT_SYSTEM_REGISTRY; - -import java.io.ByteArrayInputStream; -import java.io.IOException; -import java.io.InputStream; -import java.lang.reflect.InvocationTargetException; -import java.nio.charset.StandardCharsets; -import java.nio.file.Files; -import java.nio.file.Path; -import java.util.ArrayList; -import java.util.Collection; -import java.util.Collections; -import java.util.Comparator; -import java.util.HashMap; -import java.util.HashSet; -import java.util.List; -import java.util.Map; -import java.util.Objects; -import java.util.Set; -import java.util.concurrent.Callable; -import java.util.concurrent.Executors; -import java.util.concurrent.Future; -import java.util.concurrent.ScheduledExecutorService; -import java.util.concurrent.TimeUnit; -import java.util.concurrent.atomic.AtomicInteger; -import java.util.concurrent.atomic.AtomicLong; -import java.util.function.Predicate; - import org.apache.nifi.annotation.behavior.TriggerSerially; import org.apache.nifi.annotation.lifecycle.OnAdded; import org.apache.nifi.annotation.lifecycle.OnConfigurationRestored; @@ -150,9 +121,6 @@ public class StandardProcessorTestRunner implements TestRunner { this.processorStateManager = new MockStateManager(processor); this.variableRegistry = new MockVariableRegistry(); - // Ensure the test runner has the environment and build variables - ENVIRONMENT_SYSTEM_REGISTRY.getVariableMap().forEach(this.variableRegistry::setVariable); - this.context = new MockProcessContext(processor, processorName, processorStateManager, variableRegistry); this.kerberosContext = kerberosContext; diff --git a/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/test/java/org/apache/nifi/processors/standard/TestInvokeHTTP.java b/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/test/java/org/apache/nifi/processors/standard/TestInvokeHTTP.java index 3d9a528580..860b68f6f2 100644 --- a/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/test/java/org/apache/nifi/processors/standard/TestInvokeHTTP.java +++ b/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/test/java/org/apache/nifi/processors/standard/TestInvokeHTTP.java @@ -18,7 +18,6 @@ package org.apache.nifi.processors.standard; import static java.nio.charset.StandardCharsets.UTF_8; import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertNull; import static org.junit.Assert.assertTrue; @@ -33,7 +32,6 @@ import java.util.Map; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import org.apache.commons.lang3.SystemUtils; -import org.apache.nifi.build.NifiBuildProperties; import org.apache.nifi.processors.standard.util.TestInvokeHttpCommon; import org.apache.nifi.ssl.StandardSSLContextService; import org.apache.nifi.util.MockFlowFile; @@ -379,7 +377,7 @@ public class TestInvokeHTTP extends TestInvokeHttpCommon { public void testShouldSetUserAgentExplicitly() throws Exception { addHandler(new EchoUserAgentHandler()); - runner.setProperty(InvokeHTTP.PROP_USERAGENT, "Apache NiFi/${nifi.version} (git:${nifi.build.git.commit.id.describe}; https://nifi.apache.org/)"); + runner.setProperty(InvokeHTTP.PROP_USERAGENT, "Apache NiFi For The Win"); runner.setProperty(InvokeHTTP.PROP_URL, url); createFlowFiles(runner); @@ -395,8 +393,7 @@ public class TestInvokeHTTP extends TestInvokeHttpCommon { final MockFlowFile response = runner.getFlowFilesForRelationship(InvokeHTTP.REL_RESPONSE).get(0); String content = new String(response.toByteArray(), UTF_8); - assertTrue(content.startsWith("Apache NiFi/" + NifiBuildProperties.NIFI_VERSION + " (")); - assertFalse("Missing expression language variables: " + content, content.contains("; ;")); + assertTrue(content.startsWith("Apache NiFi For The Win")); response.assertAttributeEquals(InvokeHTTP.STATUS_CODE, "200"); response.assertAttributeEquals(InvokeHTTP.STATUS_MESSAGE, "OK"); diff --git a/nifi-nar-bundles/nifi-standard-services/nifi-record-serialization-services-bundle/nifi-record-serialization-services/src/test/java/org/apache/nifi/text/TestFreeFormTextRecordSetWriter.java b/nifi-nar-bundles/nifi-standard-services/nifi-record-serialization-services-bundle/nifi-record-serialization-services/src/test/java/org/apache/nifi/text/TestFreeFormTextRecordSetWriter.java index a58d7547dc..581a0db0b7 100644 --- a/nifi-nar-bundles/nifi-standard-services/nifi-record-serialization-services-bundle/nifi-record-serialization-services/src/test/java/org/apache/nifi/text/TestFreeFormTextRecordSetWriter.java +++ b/nifi-nar-bundles/nifi-standard-services/nifi-record-serialization-services-bundle/nifi-record-serialization-services/src/test/java/org/apache/nifi/text/TestFreeFormTextRecordSetWriter.java @@ -42,7 +42,7 @@ public class TestFreeFormTextRecordSetWriter { runner.setProperty(writer, SchemaAccessUtils.SCHEMA_ACCESS_STRATEGY, SchemaAccessUtils.SCHEMA_TEXT_PROPERTY); runner.setProperty(writer, SchemaAccessUtils.SCHEMA_TEXT, outputSchemaText); - runner.setProperty(writer, FreeFormTextRecordSetWriter.TEXT, "ID: ${ID}, Name: ${NAME}, Age: ${AGE}, Country: ${COUNTRY}, Username: ${login.name}"); + runner.setProperty(writer, FreeFormTextRecordSetWriter.TEXT, "ID: ${ID}, Name: ${NAME}, Age: ${AGE}, Country: ${COUNTRY}, Username: ${user.name}"); return runner; } @@ -54,7 +54,7 @@ public class TestFreeFormTextRecordSetWriter { runner.enableControllerService(writer); Map attributes = new HashMap<>(); - attributes.put("login.name", "jdoe64"); + attributes.put("user.name", "jdoe64"); runner.enqueue("", attributes); runner.run(); // In addition to making sure a flow file was output successfully, also check nothing got rolled back into the incoming queue. May be a moot point as there is a