You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sling.apache.org by bd...@apache.org on 2018/10/11 14:37:51 UTC

[sling-org-apache-sling-capabilities] branch master updated (276f885 -> 799c1ac)

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

bdelacretaz pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-capabilities.git.


    from 276f885  Test the SlingServletsSource
     new 229fd4c  Remove stray printout
     new 799c1ac  CapabilitiesBundleIT added + bnd / Maven plugin fixes

The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 bnd.bnd                                            | 12 +--
 pom.xml                                            | 97 ++++++++++++++++++++--
 .../apache/sling/capabilities/package-info.java    | 22 +++++
 .../defaultsources/SlingServletsSourceTest.java    |  1 -
 .../capabilities/it/CapabilitiesBundleIT.java      | 76 +++++++++++++++++
 .../capabilities/it/CapabilitiesTestSupport.java   | 53 ++++++++++++
 src/test/resources/exam.properties                 | 19 +++++
 src/test/resources/logback.xml                     | 30 +++++++
 8 files changed, 291 insertions(+), 19 deletions(-)
 create mode 100644 src/main/java/org/apache/sling/capabilities/package-info.java
 create mode 100644 src/test/java/org/apache/sling/capabilities/it/CapabilitiesBundleIT.java
 create mode 100644 src/test/java/org/apache/sling/capabilities/it/CapabilitiesTestSupport.java
 create mode 100644 src/test/resources/exam.properties
 create mode 100644 src/test/resources/logback.xml


[sling-org-apache-sling-capabilities] 02/02: CapabilitiesBundleIT added + bnd / Maven plugin fixes

Posted by bd...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

bdelacretaz pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-capabilities.git

commit 799c1ac215fc28bd6e8f2bfd9df4f30a4a9bc56f
Author: Bertrand Delacretaz <bd...@apache.org>
AuthorDate: Thu Oct 11 16:37:40 2018 +0200

    CapabilitiesBundleIT added + bnd / Maven plugin fixes
---
 bnd.bnd                                            | 12 +--
 pom.xml                                            | 97 ++++++++++++++++++++--
 .../apache/sling/capabilities/package-info.java    | 22 +++++
 .../capabilities/it/CapabilitiesBundleIT.java      | 76 +++++++++++++++++
 .../capabilities/it/CapabilitiesTestSupport.java   | 53 ++++++++++++
 src/test/resources/exam.properties                 | 19 +++++
 src/test/resources/logback.xml                     | 30 +++++++
 7 files changed, 291 insertions(+), 18 deletions(-)

diff --git a/bnd.bnd b/bnd.bnd
index f5933e9..27f9589 100644
--- a/bnd.bnd
+++ b/bnd.bnd
@@ -1,12 +1,6 @@
-Bundle-Category: sling
-
-Bundle-Description: ${project.description}
-
-Bundle-DocURL: https://sling.apache.org
-
-Bundle-License: Apache License, Version 2.0
-
-Bundle-Vendor: The Apache Software Foundation
+Import-Package:\
+  org.apache.felix.utils.json;resolution:=optional,\
+  *
 
 -removeheaders:\
   Include-Resource,\
diff --git a/pom.xml b/pom.xml
index 84d3d72..a64ddcf 100644
--- a/pom.xml
+++ b/pom.xml
@@ -28,11 +28,11 @@
   <name>Apache Sling Capabilities</name>
   <artifactId>org.apache.sling.capabilities</artifactId>
   <version>0.0.1-SNAPSHOT</version>
-  <packaging>bundle</packaging>
   <properties>
     <!-- This module can work with older versions of Sling
          as well, so be conservative here -->
     <sling.java.version>7</sling.java.version>
+    <org.ops4j.pax.exam.version>4.12.0</org.ops4j.pax.exam.version>
   </properties>
   <build>
     <plugins>
@@ -41,15 +41,52 @@
         <artifactId>bnd-maven-plugin</artifactId>
       </plugin>
       <plugin>
-        <groupId>org.apache.felix</groupId>
-        <artifactId>maven-bundle-plugin</artifactId>
-        <extensions>true</extensions>
+        <groupId>org.apache.servicemix.tooling</groupId>
+        <artifactId>depends-maven-plugin</artifactId>
+      </plugin>
+      <plugin>
+        <groupId>org.apache.maven.plugins</groupId>
+        <artifactId>maven-dependency-plugin</artifactId>
+        <executions>
+          <execution>
+            <id>unpack-dependencies</id>
+            <phase>prepare-package</phase>
+            <goals>
+              <goal>unpack-dependencies</goal>
+            </goals>
+            <configuration>
+              <!-- embed a single class from felix.utils, this was previously done
+                   using Embed-Dependency with maven-bundle-plugin, maybe there's 
+                   a better way?
+              -->
+              <includeArtifactIds>org.apache.felix.utils</includeArtifactIds>
+              <includes>**/JSONWriter.class</includes>
+              <outputDirectory>${project.build.directory}/classes</outputDirectory>
+              <overWriteReleases>false</overWriteReleases>
+              <overWriteSnapshots>true</overWriteSnapshots>
+            </configuration>
+          </execution>
+        </executions>
+      </plugin>
+      <plugin>
+        <groupId>org.apache.maven.plugins</groupId>
+        <artifactId>maven-failsafe-plugin</artifactId>
+        <executions>
+          <execution>
+            <goals>
+              <goal>integration-test</goal>
+              <goal>verify</goal>
+            </goals>
+          </execution>
+        </executions>
         <configuration>
-          <instructions>
-            <Embed-Dependency>
-              org.apache.felix.utils;inline=org/apache/felix/utils/json/JSONWriter.class
-            </Embed-Dependency>
-          </instructions>
+          <redirectTestOutputToFile>true</redirectTestOutputToFile>
+          <systemProperties>
+            <property>
+              <name>bundle.filename</name>
+              <value>${basedir}/target/${project.build.finalName}.jar</value>
+            </property>
+          </systemProperties>
         </configuration>
       </plugin>
     </plugins>
@@ -117,5 +154,47 @@
       <artifactId>junit</artifactId>
       <scope>test</scope>
     </dependency>
+    <dependency>
+      <groupId>org.apache.felix</groupId>
+      <artifactId>org.apache.felix.framework</artifactId>
+      <version>5.6.10</version>
+      <scope>test</scope>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.sling</groupId>
+      <artifactId>org.apache.sling.testing.paxexam</artifactId>
+      <version>2.0.0</version>
+      <scope>test</scope>
+    </dependency>
+    <dependency>
+      <groupId>org.ops4j.pax.exam</groupId>
+      <artifactId>pax-exam</artifactId>
+      <version>${org.ops4j.pax.exam.version}</version>
+      <scope>test</scope>
+    </dependency>
+    <dependency>
+      <groupId>org.ops4j.pax.exam</groupId>
+      <artifactId>pax-exam-cm</artifactId>
+      <version>${org.ops4j.pax.exam.version}</version>
+      <scope>test</scope>
+    </dependency>
+    <dependency>
+      <groupId>org.ops4j.pax.exam</groupId>
+      <artifactId>pax-exam-container-forked</artifactId>
+      <version>${org.ops4j.pax.exam.version}</version>
+      <scope>test</scope>
+    </dependency>
+    <dependency>
+      <groupId>org.ops4j.pax.exam</groupId>
+      <artifactId>pax-exam-junit4</artifactId>
+      <version>${org.ops4j.pax.exam.version}</version>
+      <scope>test</scope>
+    </dependency>
+    <dependency>
+      <groupId>org.ops4j.pax.exam</groupId>
+      <artifactId>pax-exam-link-mvn</artifactId>
+      <version>${org.ops4j.pax.exam.version}</version>
+      <scope>test</scope>
+    </dependency>
   </dependencies>
 </project>
diff --git a/src/main/java/org/apache/sling/capabilities/package-info.java b/src/main/java/org/apache/sling/capabilities/package-info.java
new file mode 100644
index 0000000..f616f4b
--- /dev/null
+++ b/src/main/java/org/apache/sling/capabilities/package-info.java
@@ -0,0 +1,22 @@
+/*
+ * 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.
+ */
+@Version("1.0.0")
+package org.apache.sling.capabilities;
+
+import org.osgi.annotation.versioning.Version;
diff --git a/src/test/java/org/apache/sling/capabilities/it/CapabilitiesBundleIT.java b/src/test/java/org/apache/sling/capabilities/it/CapabilitiesBundleIT.java
new file mode 100644
index 0000000..00dc3dc
--- /dev/null
+++ b/src/test/java/org/apache/sling/capabilities/it/CapabilitiesBundleIT.java
@@ -0,0 +1,76 @@
+/*
+ * 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.sling.capabilities.it;
+
+import java.util.Map;
+import javax.inject.Inject;
+import org.apache.sling.capabilities.CapabilitiesSource;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.ops4j.pax.exam.junit.PaxExam;
+import org.ops4j.pax.exam.spi.reactors.ExamReactorStrategy;
+import org.ops4j.pax.exam.spi.reactors.PerClass;
+import org.osgi.framework.Bundle;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.ServiceRegistration;
+
+@RunWith(PaxExam.class)
+@ExamReactorStrategy(PerClass.class)
+public class CapabilitiesBundleIT extends CapabilitiesTestSupport {
+    
+    @Inject
+    private BundleContext bundleContext;
+    
+    private Bundle testBundle;
+
+    @Before
+    public void setup() {
+        final String symbolicName = "org.apache.sling.capabilities";
+        testBundle = null;
+        for(Bundle b : bundleContext.getBundles()) {
+            if(symbolicName.equals(b.getSymbolicName())) {
+                testBundle = b;
+                break;
+            }
+        }
+        assertNotNull("Expecting test bundle to be found:" + symbolicName, testBundle);
+    }
+    
+    @Test
+    public void testBundleActive() {
+        assertEquals("Expecting bundle to be active", Bundle.ACTIVE, testBundle.getState());
+    }
+    
+    @Test
+    public void testRegisterSource() {
+        // Verify that the bundle setup (exported packages) allows us to 
+        // register a source from the outside
+        final CapabilitiesSource src = new CapabilitiesSource() {
+            public String getNamespace() { return null; }
+            public Map<String, Object> getCapabilities() { return null; }
+        };
+        
+        final ServiceRegistration reg = bundleContext.registerService(CapabilitiesSource.class.getName(), src, null);
+        assertNotNull("Expecting ServiceRegistration", reg);
+        reg.unregister();
+    }
+}
diff --git a/src/test/java/org/apache/sling/capabilities/it/CapabilitiesTestSupport.java b/src/test/java/org/apache/sling/capabilities/it/CapabilitiesTestSupport.java
new file mode 100644
index 0000000..ad97852
--- /dev/null
+++ b/src/test/java/org/apache/sling/capabilities/it/CapabilitiesTestSupport.java
@@ -0,0 +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.sling.capabilities.it;
+
+import org.apache.sling.testing.paxexam.SlingOptions;
+import org.apache.sling.testing.paxexam.TestSupport;
+import org.ops4j.pax.exam.Configuration;
+import org.ops4j.pax.exam.Option;
+
+import static org.apache.sling.testing.paxexam.SlingOptions.logback;
+import static org.ops4j.pax.exam.CoreOptions.junitBundles;
+import static org.ops4j.pax.exam.CoreOptions.mavenBundle;
+
+public abstract class CapabilitiesTestSupport extends TestSupport {
+
+    @Configuration
+    public Option[] configuration() {
+        // Keep versions low for our dependencies, to make sure this bundle stays
+        // compatible with older Sling versions.
+        SlingOptions.versionResolver.setVersion("slf4j", "slf4j-api", "1.7.6");
+                
+        return new Option[]{
+            baseConfiguration(),
+            
+            mavenBundle().groupId("org.apache.felix").artifactId("org.apache.felix.http.servlet-api").version("1.1.2"),
+            mavenBundle().groupId("org.apache.felix").artifactId("org.apache.felix.scr").version("2.0.2"),
+            mavenBundle().groupId("org.apache.sling").artifactId("org.apache.sling.api").version("2.11.0"),
+                
+            // This bundle
+            testBundle("bundle.filename"),
+            
+            // Test stuff
+            junitBundles(),
+            logback()
+        };
+    }
+}
diff --git a/src/test/resources/exam.properties b/src/test/resources/exam.properties
new file mode 100644
index 0000000..c98a668
--- /dev/null
+++ b/src/test/resources/exam.properties
@@ -0,0 +1,19 @@
+#
+#  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.
+#
+pax.exam.logging=none
diff --git a/src/test/resources/logback.xml b/src/test/resources/logback.xml
new file mode 100644
index 0000000..d46a4ae
--- /dev/null
+++ b/src/test/resources/logback.xml
@@ -0,0 +1,30 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+    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.
+-->
+<configuration>
+  <appender name="file" class="ch.qos.logback.core.FileAppender">
+    <file>target/testing.log</file>
+    <encoder>
+      <pattern>%date %level [%thread] %logger{10} [%file : %line] %msg%n</pattern>
+    </encoder>
+  </appender>
+  <root level="debug">
+    <appender-ref ref="file"/>
+  </root>
+</configuration>


[sling-org-apache-sling-capabilities] 01/02: Remove stray printout

Posted by bd...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

bdelacretaz pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-capabilities.git

commit 229fd4c294c9dee5a5154e75f8408824bda4a6ed
Author: Bertrand Delacretaz <bd...@apache.org>
AuthorDate: Thu Oct 11 15:32:33 2018 +0200

    Remove stray printout
---
 .../sling/capabilities/defaultsources/SlingServletsSourceTest.java       | 1 -
 1 file changed, 1 deletion(-)

diff --git a/src/test/java/org/apache/sling/capabilities/defaultsources/SlingServletsSourceTest.java b/src/test/java/org/apache/sling/capabilities/defaultsources/SlingServletsSourceTest.java
index 390e1d4..884d54a 100644
--- a/src/test/java/org/apache/sling/capabilities/defaultsources/SlingServletsSourceTest.java
+++ b/src/test/java/org/apache/sling/capabilities/defaultsources/SlingServletsSourceTest.java
@@ -86,7 +86,6 @@ public class SlingServletsSourceTest {
 
         final Map<String, Object> caps = src.getCapabilities();
         assertNotNull("Expecting to get Capabilities", caps);
-        System.err.println(caps);
 
         assertEquals("Expecting capabilities for 2 json servlets", 2, caps.size());