You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@felix.apache.org by du...@apache.org on 2018/05/09 11:53:12 UTC
svn commit: r1831246 [2/2] - in /felix/trunk/systemready: ./ docs/ src/
src/main/ src/main/java/ src/main/java/org/ src/main/java/org/apache/
src/main/java/org/apache/felix/ src/main/java/org/apache/felix/systemready/
src/main/java/org/apache/felix/sys...
Added: felix/trunk/systemready/src/main/java/org/apache/felix/systemready/rootcause/RootCausePrinter.java
URL: http://svn.apache.org/viewvc/felix/trunk/systemready/src/main/java/org/apache/felix/systemready/rootcause/RootCausePrinter.java?rev=1831246&view=auto
==============================================================================
--- felix/trunk/systemready/src/main/java/org/apache/felix/systemready/rootcause/RootCausePrinter.java (added)
+++ felix/trunk/systemready/src/main/java/org/apache/felix/systemready/rootcause/RootCausePrinter.java Wed May 9 11:53:11 2018
@@ -0,0 +1,74 @@
+/*
+ * 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.felix.systemready.rootcause;
+
+import java.util.Arrays;
+import java.util.function.Consumer;
+
+import org.osgi.service.component.runtime.dto.ComponentConfigurationDTO;
+
+public class RootCausePrinter {
+ private Consumer<String> printCallback;
+
+ public RootCausePrinter() {
+ this(System.out::println);
+ }
+
+ public RootCausePrinter(Consumer<String> printCallback) {
+ this.printCallback = printCallback;
+ }
+
+ public void print(DSComp desc) {
+ print(desc, 0);
+ }
+
+ public void print(DSComp comp, int level) {
+ if (comp.config == null && "require".equals(comp.desc.configurationPolicy)) {
+ println(level, "Component %s missing config on pid %s", comp.desc.name, Arrays.asList(comp.desc.configurationPid));
+ } else if (comp.config != null && comp.config.state == ComponentConfigurationDTO.UNSATISFIED_CONFIGURATION){
+ println(level, "Component %s unsatisifed configuration on pid %s", comp.desc.name, Arrays.asList(comp.desc.configurationPid));
+ } else if (!comp.unsatisfied.isEmpty()) {
+ println(level, "Component %s unsatisfied references", comp.desc.name);
+ } else {
+ println(level, "Component %s satisfied", comp.desc.name);
+ }
+ int l2 = level + 2;
+ int l3 = l2 + 2;
+ for (DSRef ref : comp.unsatisfied) {
+ println(l2, "unsatisfied ref %s interface %s %s", ref.name, ref.iface, getFilterSt(ref.filter));
+ for (DSComp cand : ref.candidates) {
+ print(cand, l3);
+ }
+ }
+ }
+
+ private Object getFilterSt(String filter) {
+ return filter == null ? "" : ", filter " + filter;
+ }
+
+ private void println(int level, String format, Object... args) {
+ printCallback.accept(spaces(level) + String.format(format, args));
+ }
+
+ private String spaces(int length) {
+ char[] bytes = new char[length];
+ Arrays.fill(bytes, ' ');
+ return new String(bytes);
+ }
+}
Added: felix/trunk/systemready/src/test/java/org/apache/felix/systemready/StateTest.java
URL: http://svn.apache.org/viewvc/felix/trunk/systemready/src/test/java/org/apache/felix/systemready/StateTest.java?rev=1831246&view=auto
==============================================================================
--- felix/trunk/systemready/src/test/java/org/apache/felix/systemready/StateTest.java (added)
+++ felix/trunk/systemready/src/test/java/org/apache/felix/systemready/StateTest.java Wed May 9 11:53:11 2018
@@ -0,0 +1,39 @@
+/*
+ * 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.felix.systemready;
+
+import static org.hamcrest.Matchers.equalTo;
+import static org.junit.Assert.assertThat;
+
+import java.util.Arrays;
+
+import org.junit.Test;
+
+public class StateTest {
+
+ @Test
+ public void testCompare() {
+ assertThat(worstOf(Status.State.GREEN, Status.State.YELLOW), equalTo(Status.State.YELLOW));
+ assertThat(worstOf(Status.State.GREEN, Status.State.YELLOW, Status.State.RED), equalTo(Status.State.RED));
+ }
+
+ private Status.State worstOf(Status.State...states) {
+ return Status.State.worstOf(Arrays.asList(states).stream());
+ }
+}
Added: felix/trunk/systemready/src/test/java/org/apache/felix/systemready/osgi/ComponentsCheckTest.java
URL: http://svn.apache.org/viewvc/felix/trunk/systemready/src/test/java/org/apache/felix/systemready/osgi/ComponentsCheckTest.java?rev=1831246&view=auto
==============================================================================
--- felix/trunk/systemready/src/test/java/org/apache/felix/systemready/osgi/ComponentsCheckTest.java (added)
+++ felix/trunk/systemready/src/test/java/org/apache/felix/systemready/osgi/ComponentsCheckTest.java Wed May 9 11:53:11 2018
@@ -0,0 +1,79 @@
+/*
+ * 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.felix.systemready.osgi;
+
+import static org.hamcrest.Matchers.containsString;
+import static org.hamcrest.Matchers.is;
+import static org.junit.Assert.assertThat;
+import static org.ops4j.pax.tinybundles.core.TinyBundles.bundle;
+
+import java.io.IOException;
+
+import javax.inject.Inject;
+
+import org.apache.felix.systemready.Status;
+import org.apache.felix.systemready.SystemReadyCheck;
+import org.apache.felix.systemready.osgi.examples.CompWithoutService2;
+import org.apache.felix.systemready.osgi.util.BaseTest;
+import org.apache.felix.systemready.osgi.examples.CompWithoutService;
+import org.apache.felix.systemready.osgi.util.BndDSOptions;
+import org.hamcrest.Matchers;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.ops4j.pax.exam.Configuration;
+import org.ops4j.pax.exam.Option;
+import org.ops4j.pax.exam.junit.PaxExam;
+import org.ops4j.pax.exam.util.Filter;
+import org.osgi.service.cm.ConfigurationAdmin;
+
+@RunWith(PaxExam.class)
+public class ComponentsCheckTest extends BaseTest {
+
+ @Inject
+ @Filter("(component.name=ComponentsCheck)")
+ SystemReadyCheck check;
+
+ @Inject
+ ConfigurationAdmin configAdmin;
+
+ @Configuration
+ public Option[] configuration() {
+ return new Option[] {
+ baseConfiguration(),
+ componentsCheckConfig("CompWithoutService", "CompWithoutService2"),
+ BndDSOptions.dsBundle("test", bundle()
+ .add(CompWithoutService.class)
+ .add(CompWithoutService2.class)
+ )
+ };
+ }
+
+ @Test
+ public void test() throws IOException {
+ Status status = check.getStatus();
+ assertThat(status.getState(), Matchers.is(Status.State.YELLOW));
+ assertThat(status.getDetails(), containsString("unsatisfied references"));
+ //configAdmin.getConfiguration("CompWithoutService").update();
+ context.registerService(Runnable.class, () -> {}, null);
+ Status status2 = check.getStatus();
+ System.out.println(status2);
+ assertThat(status2.getState(), Matchers.is(Status.State.GREEN));
+ assertThat(status2.getDetails(), containsString(" satisfied"));
+ }
+}
Added: felix/trunk/systemready/src/test/java/org/apache/felix/systemready/osgi/DSRootCauseTest.java
URL: http://svn.apache.org/viewvc/felix/trunk/systemready/src/test/java/org/apache/felix/systemready/osgi/DSRootCauseTest.java?rev=1831246&view=auto
==============================================================================
--- felix/trunk/systemready/src/test/java/org/apache/felix/systemready/osgi/DSRootCauseTest.java (added)
+++ felix/trunk/systemready/src/test/java/org/apache/felix/systemready/osgi/DSRootCauseTest.java Wed May 9 11:53:11 2018
@@ -0,0 +1,129 @@
+/*
+ * 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.felix.systemready.osgi;
+
+import static org.hamcrest.Matchers.equalTo;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertThat;
+import static org.ops4j.pax.tinybundles.core.TinyBundles.bundle;
+
+import javax.inject.Inject;
+
+import org.apache.felix.systemready.osgi.examples.CompWithCyclicRef;
+import org.apache.felix.systemready.osgi.examples.CompWithMissingConfig;
+import org.apache.felix.systemready.osgi.util.BaseTest;
+import org.apache.felix.systemready.osgi.examples.CompWithMissingRef;
+import org.apache.felix.systemready.osgi.examples.CompWithMissingRef2;
+import org.apache.felix.systemready.osgi.examples.CompWithoutService;
+import org.apache.felix.systemready.osgi.util.BndDSOptions;
+import org.apache.felix.systemready.rootcause.DSComp;
+import org.apache.felix.systemready.rootcause.DSRef;
+import org.apache.felix.systemready.rootcause.DSRootCause;
+import org.apache.felix.systemready.rootcause.RootCausePrinter;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.ops4j.pax.exam.Configuration;
+import org.ops4j.pax.exam.Option;
+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.service.component.runtime.ServiceComponentRuntime;
+import org.osgi.service.component.runtime.dto.ComponentDescriptionDTO;
+
+@RunWith(PaxExam.class)
+@ExamReactorStrategy(PerClass.class)
+public class DSRootCauseTest extends BaseTest {
+
+ @Inject
+ ServiceComponentRuntime scr;
+
+ DSRootCause dsRootCause;
+
+ @Configuration
+ public Option[] configuration() {
+ return new Option[] {
+ baseConfiguration(),
+ BndDSOptions.dsBundle("test", bundle()
+ .add(CompWithMissingConfig.class)
+ .add(CompWithMissingRef.class)
+ .add(CompWithCyclicRef.class)
+ .add(CompWithMissingRef2.class)
+ .add(CompWithoutService.class)
+ )
+ };
+ }
+
+ @Before
+ public void before() {
+ dsRootCause = new DSRootCause(scr);
+ }
+
+
+ @Test
+ public void testMissingConfig() throws InterruptedException {
+ ComponentDescriptionDTO desc = getComponentDesc(CompWithMissingConfig.class);
+ DSComp rootCause = dsRootCause.getRootCause(desc);
+ new RootCausePrinter().print(rootCause);
+ assertEquals("CompWithMissingConfig", rootCause.desc.name);
+ assertNull(rootCause.config);
+ }
+
+ @Test
+ public void testMissingRef() throws InterruptedException {
+ ComponentDescriptionDTO desc = getComponentDesc(CompWithMissingRef.class);
+ DSComp rootCause = dsRootCause.getRootCause(desc);
+ new RootCausePrinter().print(rootCause);
+ assertEquals(1, rootCause.unsatisfied.size());
+ DSRef unsatisfied = rootCause.unsatisfied.iterator().next();
+ assertEquals(1, rootCause.unsatisfied.size());
+ DSComp candidate = unsatisfied.candidates.iterator().next();
+ assertEquals("CompWithMissingConfig", candidate.desc.name);
+ assertNull(candidate.config);
+ }
+
+ @Test
+ public void testMissingRef2() throws InterruptedException {
+ ComponentDescriptionDTO desc = getComponentDesc(CompWithMissingRef2.class);
+ DSComp rootCause = dsRootCause.getRootCause(desc);
+ new RootCausePrinter().print(rootCause);
+ assertEquals(1, rootCause.unsatisfied.size());
+ DSRef unsatisfied = rootCause.unsatisfied.iterator().next();
+ assertEquals(1, rootCause.unsatisfied.size());
+ DSComp candidate = unsatisfied.candidates.iterator().next();
+ assertEquals("CompWithMissingRef", candidate.desc.name);
+ assertNull(candidate.config);
+ }
+
+ @Test
+ public void testNoService() throws InterruptedException {
+ ComponentDescriptionDTO desc = getComponentDesc(CompWithoutService.class);
+ DSComp rootCause = dsRootCause.getRootCause(desc);
+ assertThat(rootCause.desc.serviceInterfaces.length, equalTo(0));
+ new RootCausePrinter().print(rootCause);
+ }
+
+ @Test(expected = IllegalStateException.class)
+ public void testCyclic() throws InterruptedException {
+ ComponentDescriptionDTO desc = getComponentDesc(CompWithCyclicRef.class);
+ dsRootCause.getRootCause(desc);
+ }
+
+}
Added: felix/trunk/systemready/src/test/java/org/apache/felix/systemready/osgi/FrameworkStartTest.java
URL: http://svn.apache.org/viewvc/felix/trunk/systemready/src/test/java/org/apache/felix/systemready/osgi/FrameworkStartTest.java?rev=1831246&view=auto
==============================================================================
--- felix/trunk/systemready/src/test/java/org/apache/felix/systemready/osgi/FrameworkStartTest.java (added)
+++ felix/trunk/systemready/src/test/java/org/apache/felix/systemready/osgi/FrameworkStartTest.java Wed May 9 11:53:11 2018
@@ -0,0 +1,58 @@
+/*
+ * 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.felix.systemready.osgi;
+
+import static org.junit.Assert.assertEquals;
+import static org.ops4j.pax.exam.cm.ConfigurationAdminOptions.newConfiguration;
+
+import javax.inject.Inject;
+
+import org.apache.felix.systemready.Status;
+import org.apache.felix.systemready.SystemReadyCheck;
+import org.apache.felix.systemready.osgi.util.BaseTest;
+import org.junit.Assert;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.ops4j.pax.exam.Configuration;
+import org.ops4j.pax.exam.Option;
+import org.ops4j.pax.exam.junit.PaxExam;
+import org.ops4j.pax.exam.util.Filter;
+
+@RunWith(PaxExam.class)
+public class FrameworkStartTest extends BaseTest {
+
+ @Inject
+ @Filter("(component.name=FrameworkStartCheck)")
+ SystemReadyCheck check;
+
+ @Configuration
+ public Option[] configuration() {
+ return new Option[] {
+ baseConfiguration(),
+ newConfiguration("FrameworkStartCheck")
+ .asOption()
+ };
+ }
+
+ @Test
+ public void test() {
+ Status status = check.getStatus();
+ Assert.assertEquals(Status.State.GREEN, status.getState());
+ }
+}
Added: felix/trunk/systemready/src/test/java/org/apache/felix/systemready/osgi/ServicesCheckTest.java
URL: http://svn.apache.org/viewvc/felix/trunk/systemready/src/test/java/org/apache/felix/systemready/osgi/ServicesCheckTest.java?rev=1831246&view=auto
==============================================================================
--- felix/trunk/systemready/src/test/java/org/apache/felix/systemready/osgi/ServicesCheckTest.java (added)
+++ felix/trunk/systemready/src/test/java/org/apache/felix/systemready/osgi/ServicesCheckTest.java Wed May 9 11:53:11 2018
@@ -0,0 +1,66 @@
+/*
+ * 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.felix.systemready.osgi;
+
+import static org.hamcrest.Matchers.containsString;
+import static org.hamcrest.Matchers.equalTo;
+import static org.hamcrest.Matchers.is;
+import static org.junit.Assert.assertThat;
+
+import javax.inject.Inject;
+
+import org.apache.felix.systemready.SystemReadyCheck;
+import org.apache.felix.systemready.Status;
+import org.apache.felix.systemready.Status.State;
+import org.apache.felix.systemready.osgi.util.BaseTest;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.ops4j.pax.exam.Configuration;
+import org.ops4j.pax.exam.Option;
+import org.ops4j.pax.exam.junit.PaxExam;
+import org.ops4j.pax.exam.util.Filter;
+import org.osgi.service.component.runtime.ServiceComponentRuntime;
+
+@RunWith(PaxExam.class)
+public class ServicesCheckTest extends BaseTest {
+
+ @Inject
+ @Filter("(component.name=ServicesCheck)")
+ SystemReadyCheck check;
+
+ @Configuration
+ public Option[] configuration() {
+ return new Option[] {
+ baseConfiguration(),
+ servicesCheckConfig(Runnable.class.getName(), ServiceComponentRuntime.class.getName()),
+ };
+ }
+
+ @Test
+ public void test() {
+ Status status = check.getStatus();
+ assertThat(status.getState(), is(State.YELLOW));
+ assertThat(status.getDetails(), containsString("Missing service without matching DS component: java.lang.Runnable"));
+ context.registerService(Runnable.class, () -> {}, null);
+ Status status2 = check.getStatus();
+ System.out.println(status2);
+ assertThat(status2.getState(), is(State.GREEN));
+ assertThat(status2.getDetails(), equalTo(""));
+ }
+}
Added: felix/trunk/systemready/src/test/java/org/apache/felix/systemready/osgi/ServletTest.java
URL: http://svn.apache.org/viewvc/felix/trunk/systemready/src/test/java/org/apache/felix/systemready/osgi/ServletTest.java?rev=1831246&view=auto
==============================================================================
--- felix/trunk/systemready/src/test/java/org/apache/felix/systemready/osgi/ServletTest.java (added)
+++ felix/trunk/systemready/src/test/java/org/apache/felix/systemready/osgi/ServletTest.java Wed May 9 11:53:11 2018
@@ -0,0 +1,98 @@
+/*
+ * 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.felix.systemready.osgi;
+
+import static org.hamcrest.CoreMatchers.is;
+import static org.hamcrest.Matchers.equalTo;
+import static org.hamcrest.Matchers.notNullValue;
+import static org.hamcrest.core.StringContains.containsString;
+import static org.junit.Assert.assertThat;
+
+import java.io.BufferedReader;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.net.HttpURLConnection;
+import java.net.MalformedURLException;
+import java.net.URI;
+import java.net.URL;
+import java.util.stream.Collectors;
+
+import javax.inject.Inject;
+
+import org.apache.felix.systemready.SystemReadyMonitor;
+import org.apache.felix.systemready.osgi.util.BaseTest;
+import org.awaitility.Awaitility;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.ops4j.pax.exam.Configuration;
+import org.ops4j.pax.exam.Option;
+import org.ops4j.pax.exam.junit.PaxExam;
+
+@RunWith(PaxExam.class)
+public class ServletTest extends BaseTest {
+ public static final String SERVLET_PATH = "/servlet/path";
+ @Inject
+ SystemReadyMonitor monitor;
+
+ @Configuration
+ public Option[] configuration() {
+ return new Option[] {
+ baseConfiguration(),
+ servletConfig(SERVLET_PATH),
+ httpService(),
+ monitorConfig(),
+ servicesCheckConfig(Runnable.class.getName())
+ };
+ }
+
+ @Test
+ public void test() throws IOException, InterruptedException {
+ disableFrameworkStartCheck();
+
+ Awaitility.pollInSameThread();
+ Awaitility.await().until(monitor::isReady, is(false));
+ String content = Awaitility.await().until(() -> readFromUrl(getUrl(SERVLET_PATH), 503), notNullValue());
+ System.out.println(content);
+ assertThat(content, containsString("\"systemStatus\": \"YELLOW\""));
+ context.registerService(Runnable.class, () -> {}, null);
+ System.out.println(content);
+ Awaitility.await().until(monitor::isReady, is(true));
+ String content2 = Awaitility.await().until(() -> readFromUrl(getUrl(SERVLET_PATH), 200), notNullValue());
+ assertThat(content2, containsString("\"systemStatus\": \"GREEN\""));
+ }
+
+ private String getUrl(String path) {
+ return URI.create("http://localhost:8080").resolve(path).toString();
+ }
+
+ private String readFromUrl(String address, int expectedCode) throws MalformedURLException, IOException {
+ URL url = new URL(address);
+ HttpURLConnection urlConnection = (HttpURLConnection) url.openConnection();
+ int code = urlConnection.getResponseCode();
+ assertThat(code, equalTo(expectedCode));
+ InputStream in = code == 200 ? urlConnection.getInputStream(): urlConnection.getErrorStream();
+ InputStreamReader reader = new InputStreamReader(in);
+ BufferedReader buffered = new BufferedReader(reader);
+ String content = buffered.lines().collect(Collectors.joining("\n"));
+ buffered.close();
+ return content;
+ }
+
+}
Added: felix/trunk/systemready/src/test/java/org/apache/felix/systemready/osgi/SystemReadyMonitorTest.java
URL: http://svn.apache.org/viewvc/felix/trunk/systemready/src/test/java/org/apache/felix/systemready/osgi/SystemReadyMonitorTest.java?rev=1831246&view=auto
==============================================================================
--- felix/trunk/systemready/src/test/java/org/apache/felix/systemready/osgi/SystemReadyMonitorTest.java (added)
+++ felix/trunk/systemready/src/test/java/org/apache/felix/systemready/osgi/SystemReadyMonitorTest.java Wed May 9 11:53:11 2018
@@ -0,0 +1,111 @@
+/*
+ * 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.felix.systemready.osgi;
+
+import static org.awaitility.Awaitility.await;
+import static org.hamcrest.CoreMatchers.containsString;
+import static org.hamcrest.Matchers.is;
+import static org.junit.Assert.assertThat;
+
+import java.net.MalformedURLException;
+import java.util.concurrent.TimeUnit;
+
+import javax.inject.Inject;
+
+import org.apache.felix.systemready.CheckStatus;
+import org.apache.felix.systemready.Status;
+import org.apache.felix.systemready.SystemReadyCheck;
+import org.apache.felix.systemready.SystemReadyMonitor;
+import org.apache.felix.systemready.osgi.examples.TestSystemReadyCheck;
+import org.apache.felix.systemready.osgi.util.BaseTest;
+import org.awaitility.Awaitility;
+import org.awaitility.core.ConditionFactory;
+import org.hamcrest.Matchers;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.ops4j.pax.exam.Configuration;
+import org.ops4j.pax.exam.Option;
+import org.ops4j.pax.exam.junit.PaxExam;
+
+@RunWith(PaxExam.class)
+public class SystemReadyMonitorTest extends BaseTest {
+
+ @Inject
+ SystemReadyMonitor monitor;
+
+ private final ConditionFactory wait = await().atMost(1000, TimeUnit.MILLISECONDS);
+
+ @Configuration
+ public Option[] configuration() throws MalformedURLException {
+ return new Option[] {
+ baseConfiguration(),
+ monitorConfig()
+ };
+ }
+
+ @Test
+ public void test() throws InterruptedException {
+ disableFrameworkStartCheck();
+
+ Awaitility.setDefaultPollDelay(0, TimeUnit.MILLISECONDS);
+ assertNumChecks(0);
+ wait.until(monitor::isReady, is(true));
+
+ TestSystemReadyCheck check = new TestSystemReadyCheck();
+ context.registerService(SystemReadyCheck.class, check, null);
+ assertNumChecks(1);
+ wait.until(monitor::isReady, is(false));
+
+ // make the status green
+ check.setInternalState(Status.State.GREEN);
+ wait.until(monitor::isReady, is(true));
+
+ // make the status fail and check that the monitor handles that
+ check.exception();
+ wait.until(monitor::isReady, is(false));
+ assertNumChecks(1);
+
+ CheckStatus status = monitor.getStatus().getCheckStates().iterator().next();
+ assertThat(status.getCheckName(), is(check.getClass().getName()));
+ assertThat(status.getStatus().getState(), Matchers.is(Status.State.RED));
+ assertThat(status.getStatus().getDetails(), containsString("Failure"));
+
+ check.setInternalState(Status.State.RED);
+ assertNumChecks(1);
+ wait.until(monitor::isReady, is(false));
+
+
+ // register a second check
+ TestSystemReadyCheck check2 = new TestSystemReadyCheck();
+ context.registerService(SystemReadyCheck.class, check2, null);
+ assertNumChecks(2);
+ wait.until(monitor::isReady, is(false));
+
+ check2.setInternalState(Status.State.GREEN);
+ wait.until(monitor::isReady, is(false));
+
+ check.setInternalState(Status.State.GREEN);
+ wait.until(monitor::isReady, is(true));
+
+ }
+
+ private void assertNumChecks(int expectedNum) {
+ wait.until(() -> monitor.getStatus().getCheckStates().size(), is(expectedNum));
+ }
+}
Added: felix/trunk/systemready/src/test/java/org/apache/felix/systemready/osgi/examples/CompWithCyclicRef.java
URL: http://svn.apache.org/viewvc/felix/trunk/systemready/src/test/java/org/apache/felix/systemready/osgi/examples/CompWithCyclicRef.java?rev=1831246&view=auto
==============================================================================
--- felix/trunk/systemready/src/test/java/org/apache/felix/systemready/osgi/examples/CompWithCyclicRef.java (added)
+++ felix/trunk/systemready/src/test/java/org/apache/felix/systemready/osgi/examples/CompWithCyclicRef.java Wed May 9 11:53:11 2018
@@ -0,0 +1,28 @@
+/*
+ * 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.felix.systemready.osgi.examples;
+
+import org.osgi.service.component.annotations.Component;
+import org.osgi.service.component.annotations.Reference;
+
+@Component(service=CompWithCyclicRef.class)
+public class CompWithCyclicRef {
+ @Reference
+ CompWithCyclicRef ref;
+}
Added: felix/trunk/systemready/src/test/java/org/apache/felix/systemready/osgi/examples/CompWithMissingConfig.java
URL: http://svn.apache.org/viewvc/felix/trunk/systemready/src/test/java/org/apache/felix/systemready/osgi/examples/CompWithMissingConfig.java?rev=1831246&view=auto
==============================================================================
--- felix/trunk/systemready/src/test/java/org/apache/felix/systemready/osgi/examples/CompWithMissingConfig.java (added)
+++ felix/trunk/systemready/src/test/java/org/apache/felix/systemready/osgi/examples/CompWithMissingConfig.java Wed May 9 11:53:11 2018
@@ -0,0 +1,31 @@
+/*
+ * 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.felix.systemready.osgi.examples;
+
+import org.osgi.service.component.annotations.Component;
+import org.osgi.service.component.annotations.ConfigurationPolicy;
+
+@Component(
+ service = CompWithMissingConfig.class,
+ name="CompWithMissingConfig",
+ configurationPolicy=ConfigurationPolicy.REQUIRE
+ )
+public class CompWithMissingConfig {
+
+}
Added: felix/trunk/systemready/src/test/java/org/apache/felix/systemready/osgi/examples/CompWithMissingRef.java
URL: http://svn.apache.org/viewvc/felix/trunk/systemready/src/test/java/org/apache/felix/systemready/osgi/examples/CompWithMissingRef.java?rev=1831246&view=auto
==============================================================================
--- felix/trunk/systemready/src/test/java/org/apache/felix/systemready/osgi/examples/CompWithMissingRef.java (added)
+++ felix/trunk/systemready/src/test/java/org/apache/felix/systemready/osgi/examples/CompWithMissingRef.java Wed May 9 11:53:11 2018
@@ -0,0 +1,32 @@
+/*
+ * 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.felix.systemready.osgi.examples;
+
+import org.osgi.service.component.annotations.Component;
+import org.osgi.service.component.annotations.Reference;
+
+@Component(
+ name = "CompWithMissingRef",
+ service = CompWithMissingRef.class
+ )
+public class CompWithMissingRef {
+ @Reference
+ CompWithMissingConfig other;
+
+}
Added: felix/trunk/systemready/src/test/java/org/apache/felix/systemready/osgi/examples/CompWithMissingRef2.java
URL: http://svn.apache.org/viewvc/felix/trunk/systemready/src/test/java/org/apache/felix/systemready/osgi/examples/CompWithMissingRef2.java?rev=1831246&view=auto
==============================================================================
--- felix/trunk/systemready/src/test/java/org/apache/felix/systemready/osgi/examples/CompWithMissingRef2.java (added)
+++ felix/trunk/systemready/src/test/java/org/apache/felix/systemready/osgi/examples/CompWithMissingRef2.java Wed May 9 11:53:11 2018
@@ -0,0 +1,31 @@
+/*
+ * 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.felix.systemready.osgi.examples;
+
+import org.osgi.service.component.annotations.Component;
+import org.osgi.service.component.annotations.Reference;
+
+@Component(
+ name = "CompWithMissingRef2",
+ service = CompWithMissingRef2.class
+ )
+public class CompWithMissingRef2 {
+ @Reference
+ CompWithMissingRef other;
+}
Added: felix/trunk/systemready/src/test/java/org/apache/felix/systemready/osgi/examples/CompWithoutService.java
URL: http://svn.apache.org/viewvc/felix/trunk/systemready/src/test/java/org/apache/felix/systemready/osgi/examples/CompWithoutService.java?rev=1831246&view=auto
==============================================================================
--- felix/trunk/systemready/src/test/java/org/apache/felix/systemready/osgi/examples/CompWithoutService.java (added)
+++ felix/trunk/systemready/src/test/java/org/apache/felix/systemready/osgi/examples/CompWithoutService.java Wed May 9 11:53:11 2018
@@ -0,0 +1,31 @@
+/*
+ * 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.felix.systemready.osgi.examples;
+
+import org.osgi.service.component.annotations.Component;
+import org.osgi.service.component.annotations.Reference;
+
+@Component(
+ name = "CompWithoutService"
+ )
+public class CompWithoutService {
+
+ @Reference
+ Runnable dummy;
+}
Added: felix/trunk/systemready/src/test/java/org/apache/felix/systemready/osgi/examples/CompWithoutService2.java
URL: http://svn.apache.org/viewvc/felix/trunk/systemready/src/test/java/org/apache/felix/systemready/osgi/examples/CompWithoutService2.java?rev=1831246&view=auto
==============================================================================
--- felix/trunk/systemready/src/test/java/org/apache/felix/systemready/osgi/examples/CompWithoutService2.java (added)
+++ felix/trunk/systemready/src/test/java/org/apache/felix/systemready/osgi/examples/CompWithoutService2.java Wed May 9 11:53:11 2018
@@ -0,0 +1,31 @@
+/*
+ * 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.felix.systemready.osgi.examples;
+
+import org.osgi.service.component.annotations.Component;
+import org.osgi.service.component.annotations.Reference;
+
+@Component(
+ name = "CompWithoutService2"
+ )
+public class CompWithoutService2 {
+
+ @Reference
+ Runnable dummy;
+}
Added: felix/trunk/systemready/src/test/java/org/apache/felix/systemready/osgi/examples/TestSystemReadyCheck.java
URL: http://svn.apache.org/viewvc/felix/trunk/systemready/src/test/java/org/apache/felix/systemready/osgi/examples/TestSystemReadyCheck.java?rev=1831246&view=auto
==============================================================================
--- felix/trunk/systemready/src/test/java/org/apache/felix/systemready/osgi/examples/TestSystemReadyCheck.java (added)
+++ felix/trunk/systemready/src/test/java/org/apache/felix/systemready/osgi/examples/TestSystemReadyCheck.java Wed May 9 11:53:11 2018
@@ -0,0 +1,60 @@
+/*
+ * 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.felix.systemready.osgi.examples;
+
+import java.util.concurrent.atomic.AtomicReference;
+
+import org.apache.felix.systemready.Status;
+import org.apache.felix.systemready.Status.State;
+import org.apache.felix.systemready.SystemReadyCheck;
+
+public class TestSystemReadyCheck implements SystemReadyCheck {
+
+ private State state;
+ private AtomicReference<RuntimeException> ex = new AtomicReference<>(null);
+
+ public TestSystemReadyCheck() {
+ this.state = State.YELLOW;
+ }
+
+ @Override
+ public String getName() {
+ return "Test Check";
+ }
+
+ @Override
+ public Status getStatus() {
+ if (null == ex.get()) {
+ return new Status(state, state.name());
+ } else {
+ throw ex.get();
+ }
+ }
+
+ public void setInternalState(State state) {
+ this.ex.set(null);
+ this.state = state;
+ }
+
+ public void exception() {
+ this.ex.set(new RuntimeException("Failure"));
+ this.state = State.RED;
+ }
+
+}
Added: felix/trunk/systemready/src/test/java/org/apache/felix/systemready/osgi/util/BaseTest.java
URL: http://svn.apache.org/viewvc/felix/trunk/systemready/src/test/java/org/apache/felix/systemready/osgi/util/BaseTest.java?rev=1831246&view=auto
==============================================================================
--- felix/trunk/systemready/src/test/java/org/apache/felix/systemready/osgi/util/BaseTest.java (added)
+++ felix/trunk/systemready/src/test/java/org/apache/felix/systemready/osgi/util/BaseTest.java Wed May 9 11:53:11 2018
@@ -0,0 +1,127 @@
+/*
+ * 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.felix.systemready.osgi.util;
+
+import static org.ops4j.pax.exam.CoreOptions.bundle;
+import static org.ops4j.pax.exam.CoreOptions.mavenBundle;
+import static org.ops4j.pax.exam.CoreOptions.systemProperty;
+import static org.ops4j.pax.exam.cm.ConfigurationAdminOptions.newConfiguration;
+
+import javax.inject.Inject;
+
+import org.ops4j.pax.exam.CoreOptions;
+import org.ops4j.pax.exam.Option;
+import org.osgi.framework.BundleContext;
+import org.osgi.service.component.runtime.ServiceComponentRuntime;
+import org.osgi.service.component.runtime.dto.ComponentDescriptionDTO;
+
+import java.util.Optional;
+import java.util.function.Predicate;
+
+
+public class BaseTest {
+ @Inject
+ public BundleContext context;
+
+ @Inject
+ public ServiceComponentRuntime scr;
+
+
+ public Option baseConfiguration() {
+ return CoreOptions.composite(
+ systemProperty("pax.exam.invoker").value("junit"),
+ systemProperty("pax.exam.osgi.unresolved.fail").value("true"),
+ systemProperty("logback.configurationFile")
+ .value("src/test/resources/logback.xml"),
+ mavenBundle().groupId("org.slf4j").artifactId("slf4j-api").version("1.7.6"),
+ mavenBundle().groupId("ch.qos.logback").artifactId("logback-core").version("1.0.13"),
+ mavenBundle().groupId("ch.qos.logback").artifactId("logback-classic").version("1.0.13"),
+
+ bundle("link:classpath:META-INF/links/org.ops4j.pax.tipi.junit.link"),
+ bundle("link:classpath:META-INF/links/org.ops4j.pax.exam.invoker.junit.link"),
+ mavenBundle().groupId("org.apache.servicemix.bundles").artifactId("org.apache.servicemix.bundles.hamcrest").version("1.3_1"),
+ mavenBundle().groupId("org.awaitility").artifactId("awaitility").version("3.1.0"),
+
+ mavenBundle().groupId("org.apache.felix").artifactId("org.apache.felix.scr").version("2.0.14"),
+ mavenBundle().groupId("org.apache.felix").artifactId("org.apache.felix.configadmin").version("1.8.16"),
+ bundle("reference:file:target/classes/")
+
+ );
+ }
+
+ public Option servicesCheckConfig(String... services) {
+ return newConfiguration("ServicesCheck")
+ .put("services.list", services)
+ .asOption();
+ }
+
+ public Option componentsCheckConfig(String... components) {
+ return newConfiguration("ComponentsCheck")
+ .put("components.list", components)
+ .asOption();
+ }
+
+ public Option monitorConfig() {
+ return newConfiguration("SystemReadyMonitor")
+ .put("poll.interval", 50)
+ .asOption();
+ }
+
+ public Option httpService() {
+ return CoreOptions.composite(
+ mavenBundle("org.apache.felix", "org.apache.felix.http.servlet-api", "1.1.2"),
+ mavenBundle("org.apache.felix", "org.apache.felix.http.jetty", "3.4.8")
+ );
+ }
+
+ public Option servletConfig(String path) {
+ return newConfiguration("SystemReadyServlet")
+ .put("osgi.http.whiteboard.servlet.pattern", path)
+ .asOption();
+ }
+
+ public ComponentDescriptionDTO getComponentDesc(String compName) {
+ return getComponentDesc(desc -> desc.name.equals(compName), compName);
+ }
+
+ public ComponentDescriptionDTO getComponentDesc(Class<?> compClass) {
+ return getComponentDesc(desc -> desc.implementationClass.equals(compClass.getName()), compClass.getName());
+ }
+
+ public ComponentDescriptionDTO getComponentDesc(Predicate<ComponentDescriptionDTO> predicate, String label) {
+ Optional<ComponentDescriptionDTO> result = scr.getComponentDescriptionDTOs().stream()
+ .filter(predicate)
+ .findFirst();
+ if (result.isPresent()) {
+ return result.get();
+ } else {
+ throw new RuntimeException("Component " + label + " not found");
+ }
+ }
+
+ public void disableComponent(String name) {
+ ComponentDescriptionDTO desc = getComponentDesc(name);
+ scr.disableComponent(desc);
+ }
+
+ public void disableFrameworkStartCheck() {
+ disableComponent("FrameworkStartCheck");
+ }
+
+}
Added: felix/trunk/systemready/src/test/java/org/apache/felix/systemready/osgi/util/BndDSOptions.java
URL: http://svn.apache.org/viewvc/felix/trunk/systemready/src/test/java/org/apache/felix/systemready/osgi/util/BndDSOptions.java?rev=1831246&view=auto
==============================================================================
--- felix/trunk/systemready/src/test/java/org/apache/felix/systemready/osgi/util/BndDSOptions.java (added)
+++ felix/trunk/systemready/src/test/java/org/apache/felix/systemready/osgi/util/BndDSOptions.java Wed May 9 11:53:11 2018
@@ -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.felix.systemready.osgi.util;
+
+import static org.ops4j.pax.exam.CoreOptions.streamBundle;
+import static org.ops4j.pax.tinybundles.core.TinyBundles.withBnd;
+
+import org.ops4j.pax.exam.Option;
+import org.ops4j.pax.tinybundles.core.TinyBundle;
+
+/**
+ * This must be in its own bundle and static to avoid that TinyBundles has to be deployed in OSGi
+ */
+public class BndDSOptions {
+
+ private BndDSOptions() {
+ }
+
+ /**
+ * Create a bundle with DS support and automatically generated exports and imports
+ */
+ public static Option dsBundle(String symbolicName, TinyBundle bundleDef) {
+ return streamBundle(bundleDef
+ .symbolicName(symbolicName)
+ .build(withBnd()));
+ }
+}
Added: felix/trunk/systemready/src/test/resources/exam.properties
URL: http://svn.apache.org/viewvc/felix/trunk/systemready/src/test/resources/exam.properties?rev=1831246&view=auto
==============================================================================
--- felix/trunk/systemready/src/test/resources/exam.properties (added)
+++ felix/trunk/systemready/src/test/resources/exam.properties Wed May 9 11:53:11 2018
@@ -0,0 +1 @@
+pax.exam.logging = none
Added: felix/trunk/systemready/src/test/resources/logback.xml
URL: http://svn.apache.org/viewvc/felix/trunk/systemready/src/test/resources/logback.xml?rev=1831246&view=auto
==============================================================================
--- felix/trunk/systemready/src/test/resources/logback.xml (added)
+++ felix/trunk/systemready/src/test/resources/logback.xml Wed May 9 11:53:11 2018
@@ -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="console" class="ch.qos.logback.core.ConsoleAppender">
+ <encoder>
+ <pattern>%date %level [%thread] %logger{20} [%file : %line] %msg - %mdc %n</pattern>
+ </encoder>
+ </appender>
+
+ <root level="info">
+ <appender-ref ref="console"/>
+ </root>
+</configuration>