You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sling.apache.org by kw...@apache.org on 2020/06/14 17:49:29 UTC

[sling-slingfeature-maven-plugin] 01/02: SING-9518 add failing IT

This is an automated email from the ASF dual-hosted git repository.

kwin pushed a commit to branch bugfix/SLING-9518-failing-it
in repository https://gitbox.apache.org/repos/asf/sling-slingfeature-maven-plugin.git

commit 89fc66c350f6fce42805cbd7c663580b3ca15c45
Author: Konrad Windszus <kw...@apache.org>
AuthorDate: Sun Jun 14 19:48:40 2020 +0200

    SING-9518 add failing IT
---
 src/it/apis-jar-cnd/invoker.properties          | 17 +++++++
 src/it/apis-jar-cnd/pom.xml                     | 52 +++++++++++++++++++++
 src/it/apis-jar-cnd/src/main/features/main.json |  8 ++++
 src/it/apis-jar-cnd/verify.bsh                  | 60 +++++++++++++++++++++++++
 4 files changed, 137 insertions(+)

diff --git a/src/it/apis-jar-cnd/invoker.properties b/src/it/apis-jar-cnd/invoker.properties
new file mode 100644
index 0000000..4a5809a
--- /dev/null
+++ b/src/it/apis-jar-cnd/invoker.properties
@@ -0,0 +1,17 @@
+# 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.
+
+invoker.goals = clean package
+invoker.debug = true
diff --git a/src/it/apis-jar-cnd/pom.xml b/src/it/apis-jar-cnd/pom.xml
new file mode 100644
index 0000000..e3f4705
--- /dev/null
+++ b/src/it/apis-jar-cnd/pom.xml
@@ -0,0 +1,52 @@
+<?xml version="1.0" encoding="ISO-8859-1"?>
+<!--
+    Licensed to the Apache Software Foundation (ASF) under one or more contributor license
+    agreements. See the NOTICE file distributed with this work for additional information
+    regarding copyright ownership. The ASF licenses this file to you under the Apache License,
+    Version 2.0 (the "License"); you may not use this file except in compliance with the
+    License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
+
+    Unless required by applicable law or agreed to in writing, software distributed under the
+    License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
+    either express or implied. See the License for the specific language governing permissions
+    and limitations under the License.
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+
+  <modelVersion>4.0.0</modelVersion>
+  <groupId>org.apache.sling</groupId>
+  <artifactId>slingfeature-maven-plugin-test</artifactId>
+  <packaging>jar</packaging>
+  <version>1.0.0-SNAPSHOT</version>
+
+  <name>Apache Sling Features Maven plugin test</name>
+
+  <build>
+    <plugins>
+      <plugin>
+        <groupId>@project.groupId@</groupId>
+        <artifactId>@project.artifactId@</artifactId>
+        <version>@project.version@</version>
+        <extensions>true</extensions>
+        <executions>
+          <execution>
+            <id>analyze</id>
+            <phase>package</phase>
+            <goals>
+              <goal>apis-jar</goal>
+            </goals>
+          </execution>
+        </executions>
+        <configuration>
+          <selection>
+            <filesInclude>**/*.json</filesInclude>
+          </selection>
+          <includeResources>
+            <includeResource>**/*.cnd</includeResource>
+          </includeResources>
+        </configuration>
+      </plugin>
+    </plugins>
+  </build>
+
+</project>
diff --git a/src/it/apis-jar-cnd/src/main/features/main.json b/src/it/apis-jar-cnd/src/main/features/main.json
new file mode 100644
index 0000000..a91c5ea
--- /dev/null
+++ b/src/it/apis-jar-cnd/src/main/features/main.json
@@ -0,0 +1,8 @@
+{
+  "id":"org.apache.sling:slingfeature-maven-plugin-test:1.0.0-SNAPSHOT",
+  "bundles":[
+    {
+      "id":"org.apache.sling:org.apache.sling.i18n:2.5.14"
+    }
+  ]
+}
diff --git a/src/it/apis-jar-cnd/verify.bsh b/src/it/apis-jar-cnd/verify.bsh
new file mode 100644
index 0000000..0ffd982
--- /dev/null
+++ b/src/it/apis-jar-cnd/verify.bsh
@@ -0,0 +1,60 @@
+/*
+ * 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.
+ */
+
+import java.io.*;
+import java.util.*;
+import java.util.jar.*;
+
+import org.codehaus.plexus.util.*;
+
+    boolean check() throws Exception {
+        File apisJarDir = new File(basedir, "target/apis-jars");
+
+        // base
+
+        File baseApiJar = new File(apisJarDir, "slingfeature-maven-plugin-test-1.0.0-SNAPSHOT-global-apis.jar");
+        if (!baseApiJar.exists()) {
+            System.out.println("FAILED!");
+            System.out.println("File '" + baseApiJar + "' not found");
+            return false;
+        }
+
+        JarFile jarFile = null;
+        // cannot use try..finally due to https://github.com/beanshell/beanshell/issues/367
+        jarFile = new JarFile(baseApiJar);
+        Manifest manifest= jarFile.getManifest();
+        String nodeTypes = manifest.getMainAttributes().getValue("Sling-Nodetypes");
+
+        for (String expectedEntry : nodeTypes.split(",")) {
+            if (jarFile.getJarEntry(expectedEntry) == null) {
+                System.out.println("FAILED!");
+                System.out.println("Entry '" + expectedEntry + "' does not exist in bundle '" + baseApiJar + "' but it is referenced from Sling-Nodetypes");
+                jarFile.close();
+                return false;
+            }
+        }
+        jarFile.close();
+        return true;
+    }
+
+    try {
+        return check();
+    } catch(Throwable t) {
+        t.printStackTrace();
+        return false;
+    }
+