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 2019/12/16 13:46:48 UTC
[sling-whiteboard] branch master updated: Start of a Feature Reader
Service and test
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 2757d98 Start of a Feature Reader Service and test
2757d98 is described below
commit 2757d98f442e9d7d81effd77a705547f07eaf8c0
Author: David Bosschaert <da...@gmail.com>
AuthorDate: Mon Dec 16 13:46:21 2019 +0000
Start of a Feature Reader Service and test
---
.../main/java/org/osgi/feature/FeatureService.java | 27 ++++++++++++++
.../org/osgi/feature/impl/FeatureServiceImpl.java | 40 ++++++++++++++++++++
.../sling/feature/osgi/FeatureServiceImplTest.java | 43 ++++++++++++++++++++++
.../src/test/resources/features/test-feature.json | 28 ++++++++++++++
4 files changed, 138 insertions(+)
diff --git a/osgi-featuremodel/src/main/java/org/osgi/feature/FeatureService.java b/osgi-featuremodel/src/main/java/org/osgi/feature/FeatureService.java
new file mode 100644
index 0000000..2e6bacc
--- /dev/null
+++ b/osgi-featuremodel/src/main/java/org/osgi/feature/FeatureService.java
@@ -0,0 +1,27 @@
+/*
+ * 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.osgi.feature;
+
+import java.io.IOException;
+import java.io.Reader;
+import java.io.Writer;
+
+public interface FeatureService {
+ Feature readFeature(Reader jsonReader) throws IOException;
+
+ void writeFeature(Feature feature, Writer jsonWriter) throws IOException;
+}
diff --git a/osgi-featuremodel/src/main/java/org/osgi/feature/impl/FeatureServiceImpl.java b/osgi-featuremodel/src/main/java/org/osgi/feature/impl/FeatureServiceImpl.java
new file mode 100644
index 0000000..b28eff5
--- /dev/null
+++ b/osgi-featuremodel/src/main/java/org/osgi/feature/impl/FeatureServiceImpl.java
@@ -0,0 +1,40 @@
+/*
+ * 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.osgi.feature.impl;
+
+import org.osgi.feature.Feature;
+import org.osgi.feature.FeatureService;
+
+import java.io.IOException;
+import java.io.Reader;
+import java.io.Writer;
+
+public class FeatureServiceImpl implements FeatureService {
+
+ @Override
+ public Feature readFeature(Reader jsonReader) throws IOException {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public void writeFeature(Feature feature, Writer jsonWriter) throws IOException {
+ // TODO Auto-generated method stub
+
+ }
+
+}
diff --git a/osgi-featuremodel/src/test/java/org/apache/sling/feature/osgi/FeatureServiceImplTest.java b/osgi-featuremodel/src/test/java/org/apache/sling/feature/osgi/FeatureServiceImplTest.java
new file mode 100644
index 0000000..5dc228b
--- /dev/null
+++ b/osgi-featuremodel/src/test/java/org/apache/sling/feature/osgi/FeatureServiceImplTest.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.feature.osgi;
+
+import org.junit.Test;
+import org.osgi.feature.Feature;
+import org.osgi.feature.FeatureService;
+import org.osgi.feature.impl.FeatureServiceImpl;
+
+import java.io.IOException;
+import java.io.InputStreamReader;
+import java.io.Reader;
+import java.net.URL;
+
+import static org.junit.Assert.assertEquals;
+
+public class FeatureServiceImplTest {
+ @Test
+ public void testReadFeature() throws IOException {
+ FeatureService fs = new FeatureServiceImpl();
+
+ URL res = getClass().getResource("/features/test-feature.json");
+ try (Reader r = new InputStreamReader(res.openStream())) {
+ Feature f = fs.readFeature(r);
+
+ assertEquals("The feature description", f.getDescription());
+ }
+ }
+}
diff --git a/osgi-featuremodel/src/test/resources/features/test-feature.json b/osgi-featuremodel/src/test/resources/features/test-feature.json
new file mode 100644
index 0000000..378b3ca
--- /dev/null
+++ b/osgi-featuremodel/src/test/resources/features/test-feature.json
@@ -0,0 +1,28 @@
+{
+ "id" : "org.apache.sling:test-feature:1.1",
+ "description": "The feature description",
+
+ "bundles" :[
+ {
+ "id" : "org.osgi:osgi.promise:7.0.1",
+ "hash" : "4632463464363646436",
+ "start-order" : 1
+ },
+ {
+ "id" : "org.slf4j:slf4j-api:1.7.29"
+ },
+ {
+ "id" : "org.slf4j:slf4j-simple:1.7.29"
+ }
+ ],
+ "configurations" : {
+ "my.pid" : {
+ "foo" : 5,
+ "bar" : "test",
+ "number:Integer" : 7
+ },
+ "my.factory.pid~name" : {
+ "a.value" : "yeah"
+ }
+ }
+}
\ No newline at end of file