File tree Expand file tree Collapse file tree 5 files changed +47
-1
lines changed
src/test/java/io/opentelemetry/semconv Expand file tree Collapse file tree 5 files changed +47
-1
lines changed Original file line number Diff line number Diff line change @@ -9,4 +9,5 @@ import org.gradle.api.provider.Property
99
1010abstract class OtelJavaExtension {
1111 abstract val moduleName: Property <String >
12+ abstract val bundleName: Property <String >
1213}
Original file line number Diff line number Diff line change @@ -94,7 +94,11 @@ tasks {
9494 " Built-JDK" to System .getProperty(" java.version" ),
9595 " Implementation-Title" to project.base.archivesName,
9696 " Implementation-Version" to project.version,
97- " -exportcontents" to " ${otelJava.moduleName.get()} .*"
97+ // Add OSGi manifest headers with bnd
98+ " -exportcontents" to " ${otelJava.moduleName.get()} .*" ,
99+ " Bundle-Name" to otelJava.bundleName,
100+ " Bundle-SymbolicName" to " ${otelJava.moduleName.get()} .${project.base.archivesName.get()} " ,
101+ " Import-Package" to " io.opentelemetry.api.*;resolution:=optional" // FIXME: should not be optional, dependency should be provided
98102 )
99103 }
100104 }
Original file line number Diff line number Diff line change 1010 archivesName.set(" opentelemetry-semconv-incubating" )
1111}
1212otelJava.moduleName.set(" io.opentelemetry.semconv.incubating" )
13+ otelJava.bundleName.set(" OpenTelemetry - Semantic Conventions Incubating" )
1314
1415dependencies {
1516 api(project(" :semconv" ))
Original file line number Diff line number Diff line change @@ -12,9 +12,13 @@ base {
1212 archivesName.set(" opentelemetry-semconv" )
1313}
1414otelJava.moduleName.set(" io.opentelemetry.semconv" )
15+ otelJava.bundleName.set(" OpenTelemetry - Semantic Conventions" )
1516
1617dependencies {
1718 compileOnly(" io.opentelemetry:opentelemetry-api" )
1819
1920 testImplementation(" io.opentelemetry:opentelemetry-api" )
21+ // FIXME: dependency and version should not be managed here
22+ testImplementation(" org.apache.felix:org.apache.felix.framework:7.0.5" )
23+ testImplementation(" org.osgi:osgi.core:6.0.0" )
2024}
Original file line number Diff line number Diff line change 1+ package io .opentelemetry .semconv ;
2+
3+ import static org .junit .jupiter .api .Assertions .assertEquals ;
4+
5+ import java .io .File ;
6+ import java .util .HashMap ;
7+ import java .util .Map ;
8+ import org .apache .felix .framework .Felix ;
9+ import org .junit .jupiter .api .Test ;
10+ import org .osgi .framework .Bundle ;
11+ import org .osgi .framework .BundleContext ;
12+ import org .osgi .framework .BundleException ;
13+ import org .osgi .framework .Constants ;
14+ import org .osgi .framework .launch .Framework ;
15+
16+ class OSGiBundleTest {
17+ @ Test
18+ void bundleIsActive () throws BundleException {
19+ Map <String ,String > params = new HashMap <String , String >();
20+ // FIXME: do not use hardcoded build path
21+ params .put (Constants .FRAMEWORK_STORAGE , "build" );
22+
23+ Framework framework = new Felix (params );
24+ framework .init ();
25+ framework .start ();
26+
27+ BundleContext context = framework .getBundleContext ();
28+ // FIXME: do not use hardcoded bundle path
29+ File bundleFile = new File ("build/libs/opentelemetry-semconv-1.27.0-alpha-SNAPSHOT.jar" );
30+
31+ Bundle bundle = context .installBundle (bundleFile .toURI ().toString ());
32+ bundle .start ();
33+
34+ assertEquals (Bundle .ACTIVE , bundle .getState ());
35+ }
36+ }
You can’t perform that action at this time.
0 commit comments