You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sling.apache.org by da...@apache.org on 2018/04/25 10:05:29 UTC
[sling-whiteboard] branch master updated: Remove
CapabilityMatcherTest as that functionality is now in Felix Utils
This is an automated email from the ASF dual-hosted git repository.
davidb 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 42c7024 Remove CapabilityMatcherTest as that functionality is now in Felix Utils
42c7024 is described below
commit 42c70240ebca24404a3757c145af585178b58ac9
Author: David Bosschaert <da...@gmail.com>
AuthorDate: Wed Apr 25 11:04:52 2018 +0100
Remove CapabilityMatcherTest as that functionality is now in Felix Utils
---
.../support/util/CapabilityMatcherTest.java | 32 --------
.../org/apache/sling/feature/support/util/U.java | 89 ---------------------
.../src/test/resources/features/test.json | 92 ----------------------
3 files changed, 213 deletions(-)
diff --git a/featuremodel/feature-support/src/test/java/org/apache/sling/feature/support/util/CapabilityMatcherTest.java b/featuremodel/feature-support/src/test/java/org/apache/sling/feature/support/util/CapabilityMatcherTest.java
deleted file mode 100644
index af69b4a..0000000
--- a/featuremodel/feature-support/src/test/java/org/apache/sling/feature/support/util/CapabilityMatcherTest.java
+++ /dev/null
@@ -1,32 +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.feature.support.util;
-
-import org.apache.sling.feature.Feature;
-import org.junit.Test;
-import org.osgi.resource.Requirement;
-
-import static junit.framework.TestCase.assertTrue;
-
-public class CapabilityMatcherTest {
- @Test public void testCapabilityMatching() throws Exception {
- Feature feature = U.readFeature("test");
- Requirement requirement = U.findRequirement(feature.getRequirements(), "osgi.contract");
- assertTrue(CapabilityMatcher.matches(U.findCapability(feature.getCapabilities(), "osgi.contract"),
- SimpleFilter.parse(requirement.getDirectives().get("filter"))));
- }
-}
diff --git a/featuremodel/feature-support/src/test/java/org/apache/sling/feature/support/util/U.java b/featuremodel/feature-support/src/test/java/org/apache/sling/feature/support/util/U.java
deleted file mode 100644
index aff22c8..0000000
--- a/featuremodel/feature-support/src/test/java/org/apache/sling/feature/support/util/U.java
+++ /dev/null
@@ -1,89 +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.feature.support.util;
-
-import org.apache.sling.feature.Configuration;
-import org.apache.sling.feature.Feature;
-import org.apache.sling.feature.io.json.FeatureJSONReader;
-import org.apache.sling.feature.io.json.FeatureJSONReader.SubstituteVariables;
-import org.osgi.resource.Capability;
-import org.osgi.resource.Requirement;
-
-import java.io.InputStreamReader;
-import java.io.Reader;
-import java.util.List;
-
-import static org.junit.Assert.fail;
-
-/** Test utilities */
-public class U {
-
- /** Read the feature from the provided resource
- */
- public static Feature readFeature(final String name) throws Exception {
- return readFeature(name, SubstituteVariables.RESOLVE);
- }
-
- public static Feature readFeature(final String name, final SubstituteVariables phase) throws Exception {
- try ( final Reader reader = new InputStreamReader(U.class.getResourceAsStream("/features/" + name + ".json"),
- "UTF-8") ) {
- return FeatureJSONReader.read(reader, name, phase);
- }
- }
-
- public static Configuration findConfiguration(final List<Configuration> cfgs, final String pid) {
- for(final Configuration c : cfgs) {
- if ( !c.isFactoryConfiguration() && pid.equals(c.getPid()) ) {
- return c;
- }
- }
- fail("Configuration not found " + pid);
- return null;
- }
-
- public static Configuration findFactoryConfiguration(final List<Configuration> cfgs, final String factoryid, final String name) {
- for(final Configuration c : cfgs) {
- if ( c.isFactoryConfiguration() && factoryid.equals(c.getFactoryPid()) && name.equals(c.getName())) {
- return c;
- }
- }
- fail("Factory Configuration not found " + factoryid + "~" + name);
- return null;
- }
-
- public static Capability findCapability(List<Capability> capabilities, final String namespace) {
- for (Capability capability : capabilities) {
- if (capability.getNamespace().equals(namespace)) {
- return capability;
- }
- }
-
- fail(String.format("No Capability with namespace '%s' found", namespace));
- return null;
- }
-
- public static Requirement findRequirement(List<Requirement> requirements, final String namespace) {
- for (Requirement requirement : requirements) {
- if (requirement.getNamespace().equals(namespace)) {
- return requirement;
- }
- }
-
- fail(String.format("No Requirement with namespace '%s' found", namespace));
- return null;
- }
-}
diff --git a/featuremodel/feature-support/src/test/resources/features/test.json b/featuremodel/feature-support/src/test/resources/features/test.json
deleted file mode 100644
index 8ae346c..0000000
--- a/featuremodel/feature-support/src/test/resources/features/test.json
+++ /dev/null
@@ -1,92 +0,0 @@
-{
- "id" : "org.apache.sling/test-feature/1.1",
- "description": "The feature description",
-
- "includes" : [
- {
- "id" : "org.apache.sling/sling/9",
- "removals" : {
- "configurations" : [
- ],
- "bundles" : [
- ],
- "framework-properties" : [
- ]
- }
- }
- ],
- "requirements" : [
- {
- "namespace" : "osgi.contract",
- "directives" : {
- "filter" : "(&(osgi.contract=JavaServlet)(&(version>=3.0)(!(version>=4.0))))"
- }
- }
- ],
- "capabilities" : [
- {
- "namespace" : "osgi.implementation",
- "attributes" : {
- "osgi.implementation" : "osgi.http",
- "version:Version" : "1.1"
- },
- "directives" : {
- "uses" : "javax.servlet,javax.servlet.http,org.osgi.service.http.context,org.osgi.service.http.whiteboard"
- }
- },
- {
- "namespace" : "osgi.service",
- "attributes" : {
- "objectClass:List<String>" : "org.osgi.service.http.runtime.HttpServiceRuntime"
- },
- "directives" : {
- "uses" : "org.osgi.service.http.runtime,org.osgi.service.http.runtime.dto"
- }
- },
- {
- "namespace" : "osgi.contract",
- "attributes" : {
- "osgi.contract" : "JavaServlet",
- "osgi.implementation" : "osgi.http",
- "version:Version" : "3.1"
- },
- "directives" : {
- "uses" : "org.osgi.service.http.runtime,org.osgi.service.http.runtime.dto"
- }
- }
- ],
- "framework-properties" : {
- "foo" : 1,
- "brave" : "something",
- "org.apache.felix.scr.directory" : "launchpad/scr"
- },
- "bundles" :[
- {
- "id" : "org.apache.sling/oak-server/1.0.0",
- "hash" : "4632463464363646436",
- "start-order" : 1
- },
- {
- "id" : "org.apache.sling/application-bundle/2.0.0",
- "start-order" : 1
- },
- {
- "id" : "org.apache.sling/another-bundle/2.1.0",
- "start-order" : 1
- },
- {
- "id" : "org.apache.sling/foo-xyz/1.2.3",
- "start-order" : 2
- }
- ],
- "configurations" : {
- "my.pid" : {
- "foo" : 5,
- "bar" : "test",
- "number:Integer" : 7
- },
- "my.factory.pid~name" : {
- "a.value" : "yeah"
- }
- }
-}
\ No newline at end of file
--
To stop receiving notification emails like this one, please contact
davidb@apache.org.