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/18 15:12:34 UTC
[sling-org-apache-sling-capabilities-jcr] 01/01: Initial commit -
module skeleton
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-jcr.git
commit 278baad68249f7b0f924aec81a4112572ae835fc
Author: Bertrand Delacretaz <bd...@apache.org>
AuthorDate: Thu Oct 18 17:09:33 2018 +0200
Initial commit - module skeleton
---
.gitignore | 8 +
README.md | 10 ++
bnd.bnd | 7 +
pom.xml | 170 +++++++++++++++++++++
.../sling/capabilities/jcr/SearchSource.java | 43 ++++++
.../capabilities/it/JcrCapabilitiesBundleIT.java | 59 +++++++
.../it/JcrCapabilitiesTestSupport.java | 56 +++++++
7 files changed, 353 insertions(+)
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..b018844
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,8 @@
+.project
+.classpath
+.settings
+target
+bin
+*.iml
+.idea
+.DS_Store
diff --git a/README.md b/README.md
new file mode 100644
index 0000000..504b812
--- /dev/null
+++ b/README.md
@@ -0,0 +1,10 @@
+Sling Capabilities - JCR sources
+=======================================
+
+This modules provides information about the JCR repository to the Sling Capabilities module.
+
+It is implemented separately to avoid making the core module dependent on JCR APIs.
+
+TODO: complete this.
+
+TODO: add a link to these modules to the sling website bundles page.
\ No newline at end of file
diff --git a/bnd.bnd b/bnd.bnd
new file mode 100644
index 0000000..27f9589
--- /dev/null
+++ b/bnd.bnd
@@ -0,0 +1,7 @@
+Import-Package:\
+ org.apache.felix.utils.json;resolution:=optional,\
+ *
+
+-removeheaders:\
+ Include-Resource,\
+ Private-Package
diff --git a/pom.xml b/pom.xml
new file mode 100644
index 0000000..fd83750
--- /dev/null
+++ b/pom.xml
@@ -0,0 +1,170 @@
+<?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.
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~-->
+<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/xsd/maven-4.0.0.xsd">
+ <parent>
+ <artifactId>sling</artifactId>
+ <groupId>org.apache.sling</groupId>
+ <version>34</version>
+ <relativePath/>
+ </parent>
+ <modelVersion>4.0.0</modelVersion>
+ <name>Apache Sling Capabilities - JCR source</name>
+ <artifactId>org.apache.sling.capabilities.jcr</artifactId>
+ <version>0.0.1-SNAPSHOT</version>
+ <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>
+ <plugin>
+ <groupId>biz.aQute.bnd</groupId>
+ <artifactId>bnd-maven-plugin</artifactId>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.servicemix.tooling</groupId>
+ <artifactId>depends-maven-plugin</artifactId>
+ </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>
+ <redirectTestOutputToFile>true</redirectTestOutputToFile>
+ <systemProperties>
+ <property>
+ <name>bundle.filename</name>
+ <value>${basedir}/target/${project.build.finalName}.jar</value>
+ </property>
+ </systemProperties>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+ <dependencies>
+ <dependency>
+ <groupId>org.osgi</groupId>
+ <artifactId>org.osgi.service.metatype.annotations</artifactId>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.osgi</groupId>
+ <artifactId>org.osgi.service.component.annotations</artifactId>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.osgi</groupId>
+ <artifactId>org.osgi.annotation.versioning</artifactId>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.sling</groupId>
+ <artifactId>org.apache.sling.api</artifactId>
+ <version>2.11.0</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.sling</groupId>
+ <artifactId>org.apache.sling.jcr.api</artifactId>
+ <version>2.0.6</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.sling</groupId>
+ <artifactId>org.apache.sling.capabilities</artifactId>
+ <version>0.0.1-SNAPSHOT</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.osgi</groupId>
+ <artifactId>osgi.core</artifactId>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.osgi</groupId>
+ <artifactId>osgi.cmpn</artifactId>
+ <scope>provided</scope>
+ </dependency>
+
+ <!-- TESTING -->
+ <dependency>
+ <groupId>org.apache.geronimo.specs</groupId>
+ <artifactId>geronimo-atinject_1.0_spec</artifactId>
+ <version>1.0</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>junit</groupId>
+ <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/jcr/SearchSource.java b/src/main/java/org/apache/sling/capabilities/jcr/SearchSource.java
new file mode 100644
index 0000000..1deec51
--- /dev/null
+++ b/src/main/java/org/apache/sling/capabilities/jcr/SearchSource.java
@@ -0,0 +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.sling.capabilities.jcr;
+
+import java.util.HashMap;
+import java.util.Map;
+import org.apache.sling.capabilities.CapabilitiesSource;
+import org.osgi.service.component.annotations.Component;
+
+/** CapabilitiesSource that provides information on the JCR Repository's search features */
+@Component(service = CapabilitiesSource.class)
+public class SearchSource implements CapabilitiesSource {
+
+ public static final String NAMESPACE = "org.apache.sling.jcr.search";
+
+ @Override
+ public Map<String, Object> getCapabilities() throws Exception {
+ final Map<String, Object> result = new HashMap<>();
+ return result;
+ }
+
+ @Override
+ public String getNamespace() {
+ return NAMESPACE;
+ }
+
+}
\ No newline at end of file
diff --git a/src/test/java/org/apache/sling/capabilities/it/JcrCapabilitiesBundleIT.java b/src/test/java/org/apache/sling/capabilities/it/JcrCapabilitiesBundleIT.java
new file mode 100644
index 0000000..ac22b5a
--- /dev/null
+++ b/src/test/java/org/apache/sling/capabilities/it/JcrCapabilitiesBundleIT.java
@@ -0,0 +1,59 @@
+/*
+ * 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 javax.inject.Inject;
+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;
+
+@RunWith(PaxExam.class)
+@ExamReactorStrategy(PerClass.class)
+public class JcrCapabilitiesBundleIT extends JcrCapabilitiesTestSupport {
+
+ @Inject
+ private BundleContext bundleContext;
+
+ private Bundle testBundle;
+
+ @Before
+ public void setup() {
+ final String symbolicName = "org.apache.sling.capabilities.jcr";
+ 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());
+ }
+}
diff --git a/src/test/java/org/apache/sling/capabilities/it/JcrCapabilitiesTestSupport.java b/src/test/java/org/apache/sling/capabilities/it/JcrCapabilitiesTestSupport.java
new file mode 100644
index 0000000..56f47c1
--- /dev/null
+++ b/src/test/java/org/apache/sling/capabilities/it/JcrCapabilitiesTestSupport.java
@@ -0,0 +1,56 @@
+/*
+ * 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 JcrCapabilitiesTestSupport 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"),
+
+ // TODO update version once we have a release
+ mavenBundle().groupId("org.apache.sling").artifactId("org.apache.sling.capabilities").version("0.0.1-SNAPSHOT"),
+
+ // This bundle
+ testBundle("bundle.filename"),
+
+ // Test stuff
+ junitBundles(),
+ logback()
+ };
+ }
+}