-
Notifications
You must be signed in to change notification settings - Fork 368
Expand file tree
/
Copy pathOSGiBundleTest.java
More file actions
70 lines (60 loc) · 2.41 KB
/
OSGiBundleTest.java
File metadata and controls
70 lines (60 loc) · 2.41 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
/*
* Copyright 2013-2025 chronicle.software; SPDX-License-Identifier: Apache-2.0
*/
package net.openhft.affinity.osgi;
import org.junit.Ignore;
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.osgi.framework.Bundle;
import org.osgi.framework.BundleContext;
import javax.inject.Inject;
import static org.junit.Assert.*;
import static org.ops4j.pax.exam.CoreOptions.*;
@Ignore("Pax Exam still relies on the JUnit 4 runner in this module; migrate once a JUnit 5 extension is available")
@RunWith(PaxExam.class)
public class OSGiBundleTest extends net.openhft.affinity.osgi.OSGiTestBase {
@Inject
private BundleContext context;
@Configuration
public Option[] config() {
return options(
systemProperty("org.osgi.framework.storage.clean").value("true"),
systemProperty("org.ops4j.pax.logging.DefaultServiceLog.level").value("WARN"),
mavenBundleAsInProject("org.slf4j", "slf4j-api"),
mavenBundleAsInProject("org.slf4j", "slf4j-simple").noStart(),
mavenBundleAsInProject("net.openhft", "affinity"),
workspaceBundle("affinity-test"),
junitBundles(),
systemPackage("sun.misc"),
systemPackage("sun.nio.ch"),
systemPackage("com.sun.jna"),
systemPackage("com.sun.jna.ptr"),
cleanCaches()
);
}
@Test
public void checkInject() {
assertNotNull(context);
}
@Test
public void checkBundleState() {
final Bundle bundle = findBundle(context, "net.openhft.affinity");
assertNotNull(bundle);
assertEquals(Bundle.ACTIVE, bundle.getState());
}
@Test
public void checkBundleExports() {
final Bundle bundle = findBundle(context, "net.openhft.affinity");
assertNotNull(bundle);
final String exports = bundle.getHeaders().get("Export-Package");
final String[] packages = exports.split(",");
assertTrue(packages.length >= 2);
assertTrue(packages[0].startsWith("net.openhft.affinity;")
|| packages[0].startsWith("net.openhft.affinity.impl;"));
assertTrue(packages[1].startsWith("net.openhft.affinity;")
|| packages[1].startsWith("net.openhft.affinity.impl;"));
}
}