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-whiteboard.git
The following commit(s) were added to refs/heads/master by this push:
new 845ea25 Capabilities module moved to
https://github.com/apache/sling-org-apache-sling-capabilities
845ea25 is described below
commit 845ea258ec3e0011218908c37e290076c3a7573c
Author: Bertrand Delacretaz <[email protected]>
AuthorDate: Thu Jun 21 14:34:09 2018 +0200
Capabilities module moved to
https://github.com/apache/sling-org-apache-sling-capabilities
---
capabilities/README.md | 48 --------
capabilities/pom.xml | 124 ---------------------
.../sling/capabilities/CapabilitiesSource.java | 43 -------
.../capabilities/internal/CapabilitiesServlet.java | 61 ----------
.../internal/JSONCapabilitiesWriter.java | 61 ----------
.../internal/CapabilitesServletTest.java | 78 -------------
.../internal/JSONCapabilitiesWriterTest.java | 76 -------------
.../sling/capabilities/internal/MockSource.java | 51 ---------
8 files changed, 542 deletions(-)
diff --git a/capabilities/README.md b/capabilities/README.md
deleted file mode 100644
index b84cb65..0000000
--- a/capabilities/README.md
+++ /dev/null
@@ -1,48 +0,0 @@
-Sling Capabilities Module
-=========================
-
-The servlet provided by this module allows for creating Capabilities HTTP
endpoints
-on a Sling instance: Resources that provide information on which services are
available,
-version levels etc.
-
-For now, a single type of endpoint is provided: all Resources which have the
-`sling/capabilities` resource type will return the same set of Capabilities,
generated
-by aggregating the output of all active `CapabilitiesSource` services.
-
-This can be easily expanded to multiple sets of Capabilities if needed later
on,
-by changing the code to use service properties to group or tag the
`CapabilitiesSource` services.
-
-The tests provide simple `CapabilitiesSource` examples, that API is as follows:
-
- @ProviderType
- public interface CapabilitiesSource {
-
- /** @return the namespace to use to group our capabilities.
- * That name must be unique in a given Sling instance.
- */
- String getNamespace();
-
- /** @return zero to N capabilities, each being represented by
- * a key/value pair.
- * @throws Exception if the capabilities could not be computed.
- */
- Map<String, Object> getCapabilities() throws Exception;
- }
-
-The `CapabilitiesServlet` produces output as in the example below, where two
-`CapabilitiesSource` services are available:
-
- $ curl -s -u admin:admin http://localhost:8080/tmp/cap.json | jq .
- {
- "org.apache.sling.capabilities": {
-
"org.apache.sling.capabilities.internal.OsgiFrameworkCapabilitiesSource": {
- "framework.bundle.symbolic.name": "org.apache.felix.framework",
- "framework.bundle.version": "5.6.10"
- },
- "org.apache.sling.capabilities.internal.JvmCapabilitiesSource": {
- "java.specification.version": "1.8",
- "java.vm.version": "25.171-b11",
- "java.vm.vendor": "Oracle Corporation"
- }
- }
- }
diff --git a/capabilities/pom.xml b/capabilities/pom.xml
deleted file mode 100644
index c566b9e..0000000
--- a/capabilities/pom.xml
+++ /dev/null
@@ -1,124 +0,0 @@
-<?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>30</version>
- <relativePath/>
- </parent>
- <modelVersion>4.0.0</modelVersion>
- <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>
- </properties>
- <build>
- <plugins>
- <plugin>
- <groupId>org.apache.felix</groupId>
- <artifactId>maven-scr-plugin</artifactId>
- </plugin>
- <plugin>
- <groupId>org.apache.felix</groupId>
- <artifactId>maven-bundle-plugin</artifactId>
- <extensions>true</extensions>
- <configuration>
- <instructions>
- <Embed-Dependency>
-
org.apache.felix.utils;inline=org/apache/felix/utils/json/JSONWriter.class
- </Embed-Dependency>
- </instructions>
- </configuration>
- </plugin>
- </plugins>
- </build>
- <dependencies>
- <dependency>
- <groupId>biz.aQute.bnd</groupId>
- <artifactId>biz.aQute.bndlib</artifactId>
- </dependency>
- <dependency>
- <groupId>org.apache.sling</groupId>
- <artifactId>org.apache.sling.api</artifactId>
- <version>2.16.4</version>
- <scope>provided</scope>
- </dependency>
- <dependency>
- <groupId>javax.servlet</groupId>
- <artifactId>javax.servlet-api</artifactId>
- <scope>provided</scope>
- </dependency>
- <dependency>
- <groupId>org.apache.felix</groupId>
- <artifactId>org.apache.felix.scr.annotations</artifactId>
- <scope>provided</scope>
- </dependency>
- <dependency>
- <groupId>org.apache.felix</groupId>
- <artifactId>org.apache.felix.utils</artifactId>
- <version>1.9.0</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>
- <dependency>
- <groupId>org.slf4j</groupId>
- <artifactId>slf4j-api</artifactId>
- <scope>provided</scope>
- </dependency>
- <!-- TESTING -->
- <dependency>
- <groupId>org.apache.sling</groupId>
- <artifactId>org.apache.sling.commons.johnzon</artifactId>
- <version>1.0.0</version>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.apache.sling</groupId>
- <artifactId>org.apache.sling.testing.osgi-mock</artifactId>
- <version>2.3.8</version>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.apache.sling</groupId>
- <artifactId>org.apache.sling.testing.sling-mock</artifactId>
- <version>2.2.18</version>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>junit</groupId>
- <artifactId>junit</artifactId>
- <scope>test</scope>
- </dependency>
- </dependencies>
-</project>
diff --git
a/capabilities/src/main/java/org/apache/sling/capabilities/CapabilitiesSource.java
b/capabilities/src/main/java/org/apache/sling/capabilities/CapabilitiesSource.java
deleted file mode 100644
index e6ec9d5..0000000
---
a/capabilities/src/main/java/org/apache/sling/capabilities/CapabilitiesSource.java
+++ /dev/null
@@ -1,43 +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.sling.capabilities;
-
-import java.util.Map;
-import org.osgi.annotation.versioning.ProviderType;
-
-/** A CapabilitiesSource provides capabilities, as a Map of key/value
- * pairs.
- * Various types of CapabilitiesSources are meant
- * to be implemented, using Health Checks, OSGi environment status
- * or any suitable input to find out which capabilities are present.
- */
-@ProviderType
-public interface CapabilitiesSource {
-
- /** @return the namespace to use to group our capabilities.
- * That name must be unique in a given Sling instance.
- */
- String getNamespace();
-
- /** @return zero to N capabilities, each being represented by
- * a key/value pair.
- * @throws Exception if the capabilities could not be computed.
- */
- Map<String, Object> getCapabilities() throws Exception;
-}
\ No newline at end of file
diff --git
a/capabilities/src/main/java/org/apache/sling/capabilities/internal/CapabilitiesServlet.java
b/capabilities/src/main/java/org/apache/sling/capabilities/internal/CapabilitiesServlet.java
deleted file mode 100644
index 35e2819..0000000
---
a/capabilities/src/main/java/org/apache/sling/capabilities/internal/CapabilitiesServlet.java
+++ /dev/null
@@ -1,61 +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.sling.capabilities.internal;
-
-import java.io.IOException;
-import java.util.List;
-import javax.servlet.Servlet;
-import javax.servlet.ServletException;
-import org.apache.sling.api.SlingHttpServletRequest;
-import org.apache.sling.api.SlingHttpServletResponse;
-import org.apache.sling.api.servlets.SlingSafeMethodsServlet;
-import org.apache.sling.capabilities.CapabilitiesSource;
-import org.osgi.service.component.annotations.Component;
-import org.osgi.service.component.annotations.Reference;
-import org.osgi.service.component.annotations.ReferenceCardinality;
-import org.osgi.service.component.annotations.ReferencePolicy;
-import org.osgi.service.component.annotations.ReferencePolicyOption;
-
-@Component(service = Servlet.class,
-property = {
- "sling.servlet.resourceTypes=sling/capabilities",
- "sling.servlet.methods=GET",
- "sling.servlet.selectors=capabilities",
- "sling.servlet.extensions=json"
-})
-
-public class CapabilitiesServlet extends SlingSafeMethodsServlet {
-
- @Reference(
- policy=ReferencePolicy.DYNAMIC,
- cardinality=ReferenceCardinality.AT_LEAST_ONE,
- policyOption=ReferencePolicyOption.GREEDY)
- volatile List<CapabilitiesSource> sources;
-
- CapabilitiesServlet() {
- }
-
- @Override
- protected void doGet(SlingHttpServletRequest request,
SlingHttpServletResponse response) throws ServletException, IOException {
- response.setContentType("application/json");
- response.setCharacterEncoding("UTF-8");
- new JSONCapabilitiesWriter().writeJson(response.getWriter(), sources);
- response.getWriter().flush();
- }
-}
\ No newline at end of file
diff --git
a/capabilities/src/main/java/org/apache/sling/capabilities/internal/JSONCapabilitiesWriter.java
b/capabilities/src/main/java/org/apache/sling/capabilities/internal/JSONCapabilitiesWriter.java
deleted file mode 100644
index 3552941..0000000
---
a/capabilities/src/main/java/org/apache/sling/capabilities/internal/JSONCapabilitiesWriter.java
+++ /dev/null
@@ -1,61 +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.sling.capabilities.internal;
-
-import java.io.IOException;
-import java.io.Writer;
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.Map;
-import org.apache.felix.utils.json.JSONWriter;
-import org.apache.sling.capabilities.CapabilitiesSource;
-
-/** Create the JSON output of our servlet */
-class JSONCapabilitiesWriter {
-
- static final String CAPS_KEY = "org.apache.sling.capabilities";
-
- /** Write JSON to the supplied Writer, using the supplied sources */
- void writeJson(Writer w, Collection<CapabilitiesSource> sources) throws
IOException {
- final JSONWriter jw = new JSONWriter(w);
- jw.object();
- jw.key(CAPS_KEY);
- jw.object();
-
- Map<String, Object> values = null;
- for(CapabilitiesSource s : sources) {
- try {
- values = s.getCapabilities();
- } catch(Exception e) {
- values = new HashMap<>();
- values.put("_EXCEPTION_", e.getClass().getName() + ":" +
e.getMessage());
- }
- jw.key(s.getNamespace());
- jw.object();
- for(Map.Entry<String, Object> e : values.entrySet()) {
- jw.key(e.getKey());
- jw.value(e.getValue());
- }
- jw.endObject();
- }
-
- jw.endObject();
- jw.endObject();
- }
-}
\ No newline at end of file
diff --git
a/capabilities/src/test/java/org/apache/sling/capabilities/internal/CapabilitesServletTest.java
b/capabilities/src/test/java/org/apache/sling/capabilities/internal/CapabilitesServletTest.java
deleted file mode 100644
index 80017e0..0000000
---
a/capabilities/src/test/java/org/apache/sling/capabilities/internal/CapabilitesServletTest.java
+++ /dev/null
@@ -1,78 +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.sling.capabilities.internal;
-
-import java.io.IOException;
-import java.io.StringReader;
-import javax.json.Json;
-import javax.json.JsonObject;
-import javax.json.JsonReader;
-import javax.servlet.ServletException;
-import org.apache.sling.api.resource.ResourceResolver;
-import org.apache.sling.api.servlets.SlingSafeMethodsServlet;
-import org.apache.sling.capabilities.CapabilitiesSource;
-import org.apache.sling.servlethelpers.MockSlingHttpServletRequest;
-import org.apache.sling.servlethelpers.MockSlingHttpServletResponse;
-import org.apache.sling.testing.mock.osgi.MockOsgi;
-import org.junit.Before;
-import org.junit.Rule;
-import org.junit.Test;
-import org.apache.sling.testing.mock.osgi.junit.OsgiContext;
-import org.apache.sling.testing.mock.sling.MockSling;
-import static org.junit.Assert.assertEquals;
-import org.osgi.framework.BundleContext;
-
-/** Test the JSONCapabilitiesWriter */
-public class CapabilitesServletTest {
-
- private SlingSafeMethodsServlet servlet;
-
- @Rule
- public final OsgiContext context = new OsgiContext();
-
- private BundleContext bundleContext;
-
- @Before
- public void setup() {
- servlet = new CapabilitiesServlet();
- bundleContext = MockOsgi.newBundleContext();
-
- bundleContext.registerService(CapabilitiesSource.class.getName(), new
MockSource("F", 2), null);
- bundleContext.registerService(CapabilitiesSource.class.getName(), new
MockSource("G", 43), null);
-
- MockOsgi.injectServices(servlet, bundleContext);
- }
-
- @Test
- public void testServlet() throws ServletException, IOException {
- final ResourceResolver resolver =
MockSling.newResourceResolver(bundleContext);
- MockSlingHttpServletRequest req = new
MockSlingHttpServletRequest(resolver);
- MockSlingHttpServletResponse resp = new MockSlingHttpServletResponse();
-
- servlet.service(req, resp);
-
- // Just verify that both sources are taken into account
- // the JSON format details are tested elsewhere
- final JsonReader r = Json.createReader(new
StringReader(resp.getOutputAsString()));
- final JsonObject rootJson = r.readObject();
- final JsonObject json =
rootJson.getJsonObject(JSONCapabilitiesWriter.CAPS_KEY);
- assertEquals("VALUE_1_F",
json.getJsonObject("F").getString("KEY_1_F"));
- assertEquals("VALUE_42_G",
json.getJsonObject("G").getString("KEY_42_G"));
- }
-}
\ No newline at end of file
diff --git
a/capabilities/src/test/java/org/apache/sling/capabilities/internal/JSONCapabilitiesWriterTest.java
b/capabilities/src/test/java/org/apache/sling/capabilities/internal/JSONCapabilitiesWriterTest.java
deleted file mode 100644
index dd7227a..0000000
---
a/capabilities/src/test/java/org/apache/sling/capabilities/internal/JSONCapabilitiesWriterTest.java
+++ /dev/null
@@ -1,76 +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.sling.capabilities.internal;
-
-import java.io.IOException;
-import java.io.StringReader;
-import java.io.StringWriter;
-import java.util.ArrayList;
-import java.util.List;
-import javax.json.Json;
-import javax.json.JsonObject;
-import javax.json.JsonReader;
-import org.apache.sling.capabilities.CapabilitiesSource;
-import static org.junit.Assert.assertEquals;
-import org.junit.Test;
-
-/** Test the JSONCapabilitiesWriter */
-public class JSONCapabilitiesWriterTest {
-
- @Test
- public void testWithTwoSources() throws IOException {
- final List<CapabilitiesSource> sources = new ArrayList<>();
- sources.add(new MockSource("A", 2));
- sources.add(new MockSource("B", 1));
-
- final StringWriter w = new StringWriter();
- new JSONCapabilitiesWriter().writeJson(w, sources);
-
- final JsonReader r = Json.createReader(new StringReader(w.toString()));
- final JsonObject rootJson = r.readObject();
- final JsonObject json =
rootJson.getJsonObject(JSONCapabilitiesWriter.CAPS_KEY);
- assertEquals("VALUE_0_A",
json.getJsonObject("A").getString("KEY_0_A"));
- assertEquals("VALUE_1_A",
json.getJsonObject("A").getString("KEY_1_A"));
- assertEquals("VALUE_0_B",
json.getJsonObject("B").getString("KEY_0_B"));
-
- assertEquals("Expecting 1 root key", 1, rootJson.keySet().size());
- assertEquals("Expecting 2 keys at A", 2,
json.getJsonObject("A").keySet().size());
- assertEquals("Expecting 1 key at B", 1,
json.getJsonObject("B").keySet().size());
- }
-
- @Test
- public void testWithException() throws IOException {
- final List<CapabilitiesSource> sources = new ArrayList<>();
- sources.add(new MockSource("A", 1));
- sources.add(new MockSource("EXCEPTION", 2));
- sources.add(new MockSource("B", 1));
-
- final StringWriter w = new StringWriter();
- new JSONCapabilitiesWriter().writeJson(w, sources);
-
- final JsonReader r = Json.createReader(new StringReader(w.toString()));
- final JsonObject rootJson = r.readObject();
- final JsonObject json =
rootJson.getJsonObject(JSONCapabilitiesWriter.CAPS_KEY);
- assertEquals("VALUE_0_A",
json.getJsonObject("A").getString("KEY_0_A"));
- assertEquals("java.lang.IllegalArgumentException:Simulating a
problem", json.getJsonObject("EXCEPTION").getString("_EXCEPTION_"));
- assertEquals("VALUE_0_B",
json.getJsonObject("B").getString("KEY_0_B"));
-
- assertEquals("Expecting 1 key at EXCEPTION", 1,
json.getJsonObject("EXCEPTION").keySet().size());
- }
-}
\ No newline at end of file
diff --git
a/capabilities/src/test/java/org/apache/sling/capabilities/internal/MockSource.java
b/capabilities/src/test/java/org/apache/sling/capabilities/internal/MockSource.java
deleted file mode 100644
index 50b8652..0000000
---
a/capabilities/src/test/java/org/apache/sling/capabilities/internal/MockSource.java
+++ /dev/null
@@ -1,51 +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.sling.capabilities.internal;
-
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.Map;
-import org.apache.sling.capabilities.CapabilitiesSource;
-
-class MockSource implements CapabilitiesSource {
-
- private final String namespace;
- private final Map<String, Object> props = new HashMap<>();
-
- MockSource(String namespace, int propsCount) {
- this.namespace = namespace;
- for (int i = 0; i < propsCount; i++) {
- props.put("KEY_" + i + "_" + namespace, "VALUE_" + i + "_" +
namespace);
- }
- }
-
- @Override
- public Map<String, Object> getCapabilities() throws Exception {
- if (namespace.contains("EXCEPTION")) {
- throw new IllegalArgumentException("Simulating a problem");
- }
- return Collections.unmodifiableMap(props);
- }
-
- @Override
- public String getNamespace() {
- return namespace;
- }
-
-}