You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@geode.apache.org by jb...@apache.org on 2018/08/23 20:36:21 UTC
[geode] branch develop updated: GEODE-5597 verify geode-dependency
jar ClassPath (#2369)
This is an automated email from the ASF dual-hosted git repository.
jbarrett pushed a commit to branch develop
in repository https://gitbox.apache.org/repos/asf/geode.git
The following commit(s) were added to refs/heads/develop by this push:
new 6ee86d6 GEODE-5597 verify geode-dependency jar ClassPath (#2369)
6ee86d6 is described below
commit 6ee86d6d3befbe721034148adc87eebc6708fb32
Author: FSOUTHERLAND <39...@users.noreply.github.com>
AuthorDate: Thu Aug 23 13:36:15 2018 -0700
GEODE-5597 verify geode-dependency jar ClassPath (#2369)
Co-authored-by: Finn Southerland <fs...@pivotal.io>
Co-authored-by: Jacob Barrett <jb...@pivotal.io>
---
.../geode/GeodeDependencyJarIntegrationTest.java | 93 ++++++++++++++++++++++
.../resources/dependency_classpath.txt | 67 ++++++++++++++++
2 files changed, 160 insertions(+)
diff --git a/geode-assembly/src/integrationTest/java/org/apache/geode/GeodeDependencyJarIntegrationTest.java b/geode-assembly/src/integrationTest/java/org/apache/geode/GeodeDependencyJarIntegrationTest.java
new file mode 100644
index 0000000..5950063
--- /dev/null
+++ b/geode-assembly/src/integrationTest/java/org/apache/geode/GeodeDependencyJarIntegrationTest.java
@@ -0,0 +1,93 @@
+/*
+ * 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.geode;
+
+import static org.junit.Assert.assertTrue;
+
+import org.apache.geode.test.junit.categories.RestAPITest;
+import org.apache.geode.util.test.TestUtil;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.experimental.categories.Category;
+
+import java.io.File;
+import java.io.IOException;
+import java.nio.file.Files;
+import java.nio.file.Paths;
+import java.util.Arrays;
+import java.util.Set;
+import java.util.TreeSet;
+import java.util.jar.JarFile;
+import java.util.jar.Manifest;
+import java.util.stream.Collectors;
+
+@Category({RestAPITest.class})
+public class GeodeDependencyJarIntegrationTest {
+
+ private static final String GEODE_HOME = System.getenv("GEODE_HOME");
+ private Set<String> expectedClasspathElements;
+
+ @Before
+ public void loadExpectedClassPath() throws IOException {
+ String dependencyClasspath =
+ TestUtil.getResourcePath(AssemblyContentsIntegrationTest.class,
+ "/dependency_classpath.txt");
+
+ expectedClasspathElements =
+ Files.lines(Paths.get(dependencyClasspath)).collect(Collectors.toSet());
+ }
+
+ @Test
+ public void verifyManifestClassPath() throws IOException {
+ Set<String> currentClasspathElements = getManifestClassPath();
+
+ Files.write(Paths.get("dependency_classpath.txt"), currentClasspathElements);
+
+ Set<String> newClasspathElements = new TreeSet<>(currentClasspathElements);
+ newClasspathElements.removeAll(expectedClasspathElements);
+ Set<String> missingClasspathElements = new TreeSet<>(expectedClasspathElements);
+ missingClasspathElements.removeAll(currentClasspathElements);
+
+ String message =
+ "The geode-dependency jar's manifest classpath has changed. Verify dependencies."
+ + "\nWhen fixed, copy geode-assembly/build/integrationTest/dependency_classpath.txt"
+ + "\nto src/integrationTest/resources/dependency_classpath.txt"
+ + "\nRemoved Elements\n--------------\n"
+ + String.join("\n", missingClasspathElements) + "\n\nAdded Elements\n--------------\n"
+ + String.join("\n", newClasspathElements) + "\n\n";
+
+ assertTrue(message, expectedClasspathElements.equals(currentClasspathElements));
+ }
+
+ /**
+ * Find all of the jars bundled with the project. Key is the name of the jar, value is the path.
+ */
+ private Set<String> getManifestClassPath() throws IOException {
+ File geodeHomeDirectory = new File(GEODE_HOME);
+
+ assertTrue(
+ "Please set the GEODE_HOME environment variable to the product installation directory.",
+ geodeHomeDirectory.isDirectory());
+
+ JarFile geodeDependencies =
+ new JarFile(new File(geodeHomeDirectory, "lib/geode-dependencies.jar"));
+
+ Manifest geodeDependenciesManifest = geodeDependencies.getManifest();
+
+ String classpath = geodeDependenciesManifest.getMainAttributes().getValue("Class-Path");
+
+ return Arrays.stream(classpath.split(" ")).collect(Collectors.toSet());
+ }
+}
diff --git a/geode-assembly/src/integrationTest/resources/dependency_classpath.txt b/geode-assembly/src/integrationTest/resources/dependency_classpath.txt
new file mode 100644
index 0000000..687e09e
--- /dev/null
+++ b/geode-assembly/src/integrationTest/resources/dependency_classpath.txt
@@ -0,0 +1,67 @@
+HikariCP-3.2.0.jar
+antlr-2.7.7.jar
+classgraph-4.0.6.jar
+commons-beanutils-1.9.3.jar
+commons-codec-1.10.jar
+commons-collections-3.2.2.jar
+commons-io-2.6.jar
+commons-lang-2.6.jar
+commons-logging-1.2.jar
+commons-validator-1.6.jar
+fastutil-8.2.1.jar
+geode-common-1.8.0-SNAPSHOT.jar
+geode-connectors-1.8.0-SNAPSHOT.jar
+geode-core-1.8.0-SNAPSHOT.jar
+geode-cq-1.8.0-SNAPSHOT.jar
+geode-json-1.8.0-SNAPSHOT.jar
+geode-lucene-1.8.0-SNAPSHOT.jar
+geode-old-client-support-1.8.0-SNAPSHOT.jar
+geode-protobuf-1.8.0-SNAPSHOT.jar
+geode-protobuf-messages-1.8.0-SNAPSHOT.jar
+geode-rebalancer-1.8.0-SNAPSHOT.jar
+geode-wan-1.8.0-SNAPSHOT.jar
+jackson-annotations-2.9.6.jar
+jackson-core-2.9.6.jar
+jackson-databind-2.9.6.jar
+jansi-1.17.1.jar
+javax.resource-api-1.7.jar
+javax.servlet-api-3.1.0.jar
+javax.transaction-api-1.2.jar
+jetty-http-9.4.8.v20171121.jar
+jetty-io-9.4.8.v20171121.jar
+jetty-security-9.4.8.v20171121.jar
+jetty-server-9.4.8.v20171121.jar
+jetty-servlet-9.4.8.v20171121.jar
+jetty-util-9.4.8.v20171121.jar
+jetty-webapp-9.4.8.v20171121.jar
+jetty-xml-9.4.8.v20171121.jar
+jgroups-3.6.14.Final.jar
+jline-2.12.jar
+jna-4.1.0.jar
+jopt-simple-5.0.4.jar
+log4j-api-2.11.0.jar
+log4j-core-2.11.0.jar
+log4j-jcl-2.11.0.jar
+log4j-jul-2.11.0.jar
+log4j-slf4j-impl-2.11.0.jar
+lucene-analyzers-common-6.6.2.jar
+lucene-analyzers-phonetic-6.6.2.jar
+lucene-core-6.6.2.jar
+lucene-queries-6.6.2.jar
+lucene-queryparser-6.6.2.jar
+netty-all-4.1.27.Final.jar
+protobuf-java-3.6.0.jar
+rmiio-2.1.2.jar
+shiro-cache-1.4.0.jar
+shiro-config-core-1.4.0.jar
+shiro-config-ogdl-1.4.0.jar
+shiro-core-1.4.0.jar
+shiro-crypto-cipher-1.4.0.jar
+shiro-crypto-core-1.4.0.jar
+shiro-crypto-hash-1.4.0.jar
+shiro-event-1.4.0.jar
+shiro-lang-1.4.0.jar
+slf4j-api-1.7.25.jar
+snappy-0.4.jar
+spring-core-4.3.18.RELEASE.jar
+spring-shell-1.2.0.RELEASE.jar