Skip to content

Commit 492ef98

Browse files
authored
Merge pull request #1038 from stbischof/ocx
osgi-test demos
2 parents 541a561 + 6fc9d92 commit 492ef98

File tree

51 files changed

+1421
-21
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

51 files changed

+1421
-21
lines changed

README.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,12 @@ This artifact provides support classes for OSGi testing with ConfigurationAdmin
3030

3131
This artifact provides a [JUnit 5](https://junit.org/junit5/) `TestExecutionListener` that logs test output via the OSGi Log Service.
3232

33+
## Examples
34+
35+
### [Maven Examples][9]
36+
37+
A set of example projects demonstrating how to set up OSGi testing with Maven, including a [comprehensive demo][10] showcasing all osgi-test features.
38+
3339
## Building
3440

3541
We use Maven to build and the repo includes `mvnw`.
@@ -79,4 +85,6 @@ This project uses the [Bnd Maven Plugins](https://github.com/bndtools/bnd) to bu
7985
[6]: org.osgi.test.junit5.cm/README.md
8086
[7]: org.osgi.test.assertj.log/README.md
8187
[8]: org.osgi.test.junit5.listeners.log.osgi/README.md
88+
[9]: examples/osgi-test-example-mvn
89+
[10]: examples/osgi-test-example-mvn/org.osgi.test.example.demo
8290

examples/osgi-test-example-mvn/org.osgi.test.example.api/.project renamed to examples/osgi-test-example-mvn/org.osgi.test.example.demo/.project

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<projectDescription>
3-
<name>org.osgi.test.example.api</name>
3+
<name>org.osgi.test.example.demo</name>
44
<comment></comment>
55
<projects>
66
</projects>
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
eclipse.preferences.version=1
2+
encoding//src/main/java=UTF-8
3+
encoding//src/main/resources=UTF-8
4+
encoding//src/test/java=UTF-8
5+
encoding//src/test/resources=UTF-8
6+
encoding/<project>=UTF-8
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
eclipse.preferences.version=1
2+
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8
3+
org.eclipse.jdt.core.compiler.compliance=1.8
4+
org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures=disabled
5+
org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning
6+
org.eclipse.jdt.core.compiler.problem.reportPreviewFeatures=ignore
7+
org.eclipse.jdt.core.compiler.release=enabled
8+
org.eclipse.jdt.core.compiler.source=1.8

examples/osgi-test-example-mvn/org.osgi.test.example.api/.settings/org.eclipse.m2e.core.prefs renamed to examples/osgi-test-example-mvn/org.osgi.test.example.demo/.settings/org.eclipse.m2e.core.prefs

File renamed without changes.
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
<!--
2+
Copyright (c) Contributors to the Eclipse Foundation
3+
4+
Licensed under the Apache License, Version 2.0 (the "License");
5+
you may not use this file except in compliance with the License.
6+
You may obtain a copy of the License at
7+
8+
http://www.apache.org/licenses/LICENSE-2.0
9+
10+
Unless required by applicable law or agreed to in writing, software
11+
distributed under the License is distributed on an "AS IS" BASIS,
12+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
See the License for the specific language governing permissions and
14+
limitations under the License.
15+
16+
SPDX-License-Identifier: Apache-2.0
17+
-->
18+
<configuration>
19+
<contextListener class="ch.qos.logback.classic.jul.LevelChangePropagator">
20+
<resetJUL>true</resetJUL>
21+
</contextListener>
22+
23+
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
24+
<encoder>
25+
<pattern>%-4relative [%.15thread] %-5level %logger{36}:%line - %msg%n</pattern>
26+
</encoder>
27+
</appender>
28+
29+
<logger name="org.osgi.test" level="DEBUG"/>
30+
31+
<root level="WARN">
32+
<appender-ref ref="STDOUT" />
33+
</root>
34+
</configuration>
Lines changed: 131 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,131 @@
1+
<project xmlns="http://maven.apache.org/POM/4.0.0"
2+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
3+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
4+
<modelVersion>4.0.0</modelVersion>
5+
<parent>
6+
<groupId>org.osgi.test.example</groupId>
7+
<artifactId>org.osgi.test.example.parent</artifactId>
8+
<version>${revision}</version>
9+
<relativePath>../pom.xml</relativePath>
10+
</parent>
11+
<artifactId>org.osgi.test.example.demo</artifactId>
12+
13+
<description>OSGi Testing Example - Demonstrates all Features</description>
14+
<name>${project.groupId}:${project.artifactId}</name>
15+
<url>https://www.osgi.org</url>
16+
17+
<dependencies>
18+
<dependency>
19+
<groupId>org.osgi</groupId>
20+
<artifactId>org.osgi.service.component.annotations</artifactId>
21+
</dependency>
22+
<dependency>
23+
<groupId>org.junit.jupiter</groupId>
24+
<artifactId>junit-jupiter</artifactId>
25+
<scope>test</scope>
26+
</dependency>
27+
<dependency>
28+
<groupId>org.assertj</groupId>
29+
<artifactId>assertj-core</artifactId>
30+
</dependency>
31+
<dependency>
32+
<groupId>org.mockito</groupId>
33+
<artifactId>mockito-core</artifactId>
34+
</dependency>
35+
<dependency>
36+
<groupId>org.osgi</groupId>
37+
<artifactId>osgi.core</artifactId>
38+
</dependency>
39+
<dependency>
40+
<groupId>org.osgi</groupId>
41+
<artifactId>org.osgi.service.cm</artifactId>
42+
<version>1.6.1</version>
43+
</dependency>
44+
<dependency>
45+
<groupId>org.osgi</groupId>
46+
<artifactId>org.osgi.namespace.service</artifactId>
47+
</dependency>
48+
<dependency>
49+
<groupId>org.osgi</groupId>
50+
<artifactId>org.osgi.test.common</artifactId>
51+
</dependency>
52+
<dependency>
53+
<groupId>org.osgi</groupId>
54+
<artifactId>org.osgi.test.junit5.cm</artifactId>
55+
</dependency>
56+
<dependency>
57+
<groupId>org.apache.felix</groupId>
58+
<artifactId>org.apache.felix.configadmin</artifactId>
59+
<version>1.9.26</version>
60+
</dependency>
61+
<dependency>
62+
<groupId>org.osgi</groupId>
63+
<artifactId>org.osgi.test.assertj.framework</artifactId>
64+
</dependency>
65+
<dependency>
66+
<groupId>org.osgi</groupId>
67+
<artifactId>org.osgi.test.junit5</artifactId>
68+
</dependency>
69+
</dependencies>
70+
<build>
71+
<plugins>
72+
<plugin>
73+
<groupId>org.apache.maven.plugins</groupId>
74+
<artifactId>maven-surefire-plugin</artifactId>
75+
<!-- We let bnd-testing-maven-plugin do all the testing -->
76+
<configuration>
77+
<skipTests>true</skipTests>
78+
</configuration>
79+
</plugin>
80+
<plugin>
81+
<groupId>biz.aQute.bnd</groupId>
82+
<artifactId>bnd-maven-plugin</artifactId>
83+
<executions>
84+
<execution>
85+
<!--
86+
https://github.com/bndtools/bnd/tree/master/maven-plugins/bnd-maven-plugin#test-jar-goal
87+
-->
88+
<id>test-jar</id>
89+
<goals>
90+
<goal>test-jar</goal>
91+
</goals>
92+
<configuration>
93+
<bnd><![CDATA[
94+
p = ${project.artifactId}
95+
Export-Package: ${p}.test.*;-split-package:=first
96+
97+
-make: (*).(jar); type=bnd; recipe="${.}/testbundles/$1.bnd"
98+
-includeresource:\
99+
embeddedTestBundles/tb1.jar=tb1.jar,\
100+
101+
-noextraheaders: true
102+
-noimportjava: true
103+
]]></bnd>
104+
<!-- prevents from include testbundles-->
105+
<includeClassesDir>false</includeClassesDir>
106+
<testCases>junit5</testCases>
107+
<!--
108+
https://github.com/bndtools/bnd/tree/master/maven-plugins/bnd-maven-plugin#aspects-common-to-both-test-goals
109+
-->
110+
<artifactFragment>true</artifactFragment>
111+
<!--
112+
If true, make the tests artifact a fragment using ${project.artifactId} as the
113+
Fragment-Host header and setting the
114+
Bundle-SymbolicName of the tests artifact to
115+
${project.artifactId}-tests. Defaults to false
116+
-->
117+
</configuration>
118+
</execution>
119+
</executions>
120+
</plugin>
121+
<plugin>
122+
<groupId>biz.aQute.bnd</groupId>
123+
<artifactId>bnd-resolver-maven-plugin</artifactId>
124+
</plugin>
125+
<plugin>
126+
<groupId>biz.aQute.bnd</groupId>
127+
<artifactId>bnd-testing-maven-plugin</artifactId>
128+
</plugin>
129+
</plugins>
130+
</build>
131+
</project>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
package org.osgi.test.example.demo.api;
2+
3+
public interface EchoService {
4+
5+
String echo(String text);
6+
}

examples/osgi-test-example-mvn/org.osgi.test.example.api/src/main/java/org/osgi/test/example/api/package-info.java renamed to examples/osgi-test-example-mvn/org.osgi.test.example.demo/src/main/java/org/osgi/test/example/demo/api/package-info.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,4 +17,4 @@
1717
*******************************************************************************/
1818
@org.osgi.annotation.versioning.Version("1.0.0")
1919
@org.osgi.annotation.bundle.Export
20-
package org.osgi.test.example.api;
20+
package org.osgi.test.example.demo.api;
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
package org.osgi.test.example.demo.complex;
2+
3+
import org.osgi.service.component.annotations.Component;
4+
import org.osgi.test.example.demo.api.EchoService;
5+
6+
@Component(property = "type=complex")
7+
public class ComplexEchoService implements EchoService {
8+
9+
@Override
10+
public String echo(String text) {
11+
return text +" "+ text;
12+
}
13+
14+
}

0 commit comments

Comments
 (0)