Skip to content

Commit c9807b9

Browse files
bjhargravejoel-costigliola
authored andcommitted
Add OSGi integration testing to build (#1888)
We define a simple test class to verify basic operations. Fixes #1888 Signed-off-by: BJ Hargrave <[email protected]>
1 parent 7dec889 commit c9807b9

File tree

3 files changed

+188
-7
lines changed

3 files changed

+188
-7
lines changed

pom.xml

Lines changed: 113 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,37 @@
9696
<artifactId>junit-jupiter</artifactId>
9797
<scope>test</scope>
9898
</dependency>
99+
<!-- required to resolve
100+
These dependencies are required to workaround a bad
101+
interaction using includeDependencyManagement=true for
102+
the Bnd resolver and testing plugins and the enforcer
103+
plugin which causes a false positive from the enforcer
104+
plugin. The Bnd 5.2.0 resolver and testing plugins
105+
don't have this problem, so these dependencies
106+
can be removed when updating bnd.version to 5.2.0 and
107+
configuring the Bnd resolver and testing plugins to use
108+
includeDependencyManagement=true.
109+
-->
110+
<dependency>
111+
<groupId>org.junit.jupiter</groupId>
112+
<artifactId>junit-jupiter-engine</artifactId>
113+
<scope>test</scope>
114+
</dependency>
115+
<dependency>
116+
<groupId>org.junit.platform</groupId>
117+
<artifactId>junit-platform-launcher</artifactId>
118+
<scope>test</scope>
119+
</dependency>
120+
<dependency>
121+
<groupId>org.junit.platform</groupId>
122+
<artifactId>junit-platform-engine</artifactId>
123+
<scope>test</scope>
124+
</dependency>
125+
<dependency>
126+
<groupId>org.junit.platform</groupId>
127+
<artifactId>junit-platform-commons</artifactId>
128+
<scope>provided</scope>
129+
</dependency>
99130
<!-- required to run JUnit4 tests in eclipse without to explicitly select JUnit 4 runner ... -->
100131
<dependency>
101132
<groupId>org.junit.vintage</groupId>
@@ -173,6 +204,12 @@
173204
<version>3.4.2</version>
174205
<scope>test</scope>
175206
</dependency>
207+
<dependency>
208+
<groupId>org.eclipse.platform</groupId>
209+
<artifactId>org.eclipse.osgi</artifactId>
210+
<version>3.15.300</version>
211+
<scope>test</scope>
212+
</dependency>
176213
</dependencies>
177214
<build>
178215
<plugins>
@@ -218,6 +255,9 @@
218255
<configuration>
219256
<argLine>${argLine}</argLine>
220257
<trimStackTrace>false</trimStackTrace>
258+
<excludes>
259+
<exclude>org/assertj/core/osgi/**</exclude>
260+
</excludes>
221261
</configuration>
222262
</plugin>
223263
<plugin>
@@ -304,6 +344,21 @@
304344
]]></bnd>
305345
</configuration>
306346
</execution>
347+
<!-- Integration Test Configuration -->
348+
<execution>
349+
<id>bnd-process-tests</id>
350+
<phase>process-test-classes</phase>
351+
<goals>
352+
<goal>bnd-process-tests</goal>
353+
</goals>
354+
<configuration>
355+
<includeClassesDir>false</includeClassesDir>
356+
<bnd><![CDATA[
357+
-includepackage: org.assertj.core.osgi.*
358+
-removeheaders: Bnd-LastModified,Private-Package
359+
]]></bnd>
360+
</configuration>
361+
</execution>
307362
</executions>
308363
</plugin>
309364
<plugin>
@@ -367,6 +422,21 @@
367422
</archive>
368423
</configuration>
369424
</execution>
425+
<execution>
426+
<id>test-jar</id>
427+
<phase>package</phase>
428+
<goals>
429+
<goal>test-jar</goal>
430+
</goals>
431+
<configuration>
432+
<archive>
433+
<manifestFile>${project.build.testOutputDirectory}/META-INF/MANIFEST.MF</manifestFile>
434+
</archive>
435+
<includes>
436+
<include>org/assertj/core/osgi/**</include>
437+
</includes>
438+
</configuration>
439+
</execution>
370440
</executions>
371441
</plugin>
372442
<!-- generate jacoco report -->
@@ -450,14 +520,14 @@
450520
]]></footer>
451521
</configuration>
452522
</plugin>
523+
<!-- Resolve bundles for OSGi integration tests -->
453524
<plugin>
454-
<!-- Verify that additional OSGi package imports didn't sneak in. -->
455525
<groupId>biz.aQute.bnd</groupId>
456526
<artifactId>bnd-resolver-maven-plugin</artifactId>
457527
<version>${bnd.version}</version>
458528
<executions>
459529
<execution>
460-
<id>verify-osgi-metadata</id>
530+
<id>osgi-integration-resolving</id>
461531
<phase>pre-integration-test</phase>
462532
<goals>
463533
<goal>resolve</goal>
@@ -466,8 +536,49 @@
466536
<bndruns>
467537
<bndrun>verify.bndrun</bndrun>
468538
</bndruns>
539+
<bundles>
540+
<bundle>target/${project.build.finalName}-tests.jar</bundle>
541+
</bundles>
469542
<failOnChanges>false</failOnChanges>
470543
<reportOptional>false</reportOptional>
544+
<includeDependencyManagement>false</includeDependencyManagement>
545+
<scopes>
546+
<scope>provided</scope>
547+
<scope>compile</scope>
548+
<scope>runtime</scope>
549+
<scope>test</scope>
550+
</scopes>
551+
</configuration>
552+
</execution>
553+
</executions>
554+
</plugin>
555+
<!-- Run OSGi integration tests -->
556+
<plugin>
557+
<groupId>biz.aQute.bnd</groupId>
558+
<artifactId>bnd-testing-maven-plugin</artifactId>
559+
<version>${bnd.version}</version>
560+
<executions>
561+
<execution>
562+
<id>osgi-integration-testing</id>
563+
<goals>
564+
<goal>testing</goal>
565+
</goals>
566+
<configuration>
567+
<bndruns>
568+
<bndrun>verify.bndrun</bndrun>
569+
</bndruns>
570+
<bundles>
571+
<bundle>target/${project.build.finalName}-tests.jar</bundle>
572+
</bundles>
573+
<failOnChanges>false</failOnChanges>
574+
<includeDependencyManagement>false</includeDependencyManagement>
575+
<resolve>false</resolve>
576+
<scopes>
577+
<scope>provided</scope>
578+
<scope>compile</scope>
579+
<scope>runtime</scope>
580+
<scope>test</scope>
581+
</scopes>
471582
</configuration>
472583
</execution>
473584
</executions>
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
/*
2+
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
3+
* the License. You may obtain a copy of the License at
4+
*
5+
* http://www.apache.org/licenses/LICENSE-2.0
6+
*
7+
* Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
8+
* an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
9+
* specific language governing permissions and limitations under the License.
10+
*
11+
* Copyright 2012-2020 the original author or authors.
12+
*/
13+
package org.assertj.core.osgi;
14+
15+
import static org.assertj.core.api.Assertions.assertThat;
16+
import static org.assertj.core.api.Assertions.assertThatCode;
17+
18+
import org.junit.jupiter.api.Test;
19+
20+
class SimpleTest {
21+
22+
@Test
23+
void simple_success() {
24+
assertThat("A String").isNotNull()
25+
.isNotEmpty()
26+
.contains("A", "String")
27+
.isEqualTo("A String");
28+
}
29+
30+
@Test
31+
void simple_failure() {
32+
assertThatCode(() -> assertThat("A String").isNull()).isInstanceOf(AssertionError.class);
33+
}
34+
35+
}

verify.bndrun

Lines changed: 40 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,40 @@
1-
# It's ok if this version range changes. It's probably
2-
# because assertj just changed it's version. A future
3-
# version of bnd will solve this by not writing back
4-
# -runbundles when being used for verification.
5-
-runbundles: assertj-core;version='[3.17.1,3.17.2)'
1+
# Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
2+
# the License. You may obtain a copy of the License at
3+
#
4+
# http://www.apache.org/licenses/LICENSE-2.0
5+
#
6+
# Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
7+
# an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
8+
# specific language governing permissions and limitations under the License.
9+
#
10+
# Copyright 2020 the original author or authors.
11+
12+
-tester: biz.aQute.tester.junit-platform
13+
14+
-runfw: org.eclipse.osgi
15+
-resolve.effective: active
16+
-runproperties: \
17+
org.osgi.framework.bootdelegation=sun.reflect,\
18+
osgi.console=
19+
20+
-runrequires: \
21+
bnd.identity;id='${project.artifactId}-tests',\
22+
bnd.identity;id='junit-jupiter-engine',\
23+
bnd.identity;id='junit-platform-launcher'
24+
25+
# This will help us keep -runbundles sorted
26+
-runstartlevel: \
27+
order=sortbynameversion,\
28+
begin=-1
29+
30+
# The version ranges will change as the version of
31+
# AssertJ and/or its dependencies change.
32+
-runbundles: \
33+
assertj-core;version='[3.17.2,3.17.3)',\
34+
assertj-core-tests;version='[3.17.2,3.17.3)',\
35+
junit-jupiter-api;version='[5.6.2,5.6.3)',\
36+
junit-jupiter-engine;version='[5.6.2,5.6.3)',\
37+
junit-platform-commons;version='[1.6.2,1.6.3)',\
38+
junit-platform-engine;version='[1.6.2,1.6.3)',\
39+
junit-platform-launcher;version='[1.6.2,1.6.3)',\
40+
org.opentest4j;version='[1.2.0,1.2.1)'

0 commit comments

Comments
 (0)