Skip to content

Commit 1f435b7

Browse files
committed
Support tester.customservice property.
Signed-off-by: Eleanor Joslin <ejj@corefiling.com>
1 parent 851b4f6 commit 1f435b7

File tree

2 files changed

+16
-2
lines changed

2 files changed

+16
-2
lines changed

biz.aQute.tester.junit-platform/src/aQute/tester/junit/platform/Activator.java

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
import static aQute.junit.constants.TesterConstants.TESTER_CONTINUOUS;
44
import static aQute.junit.constants.TesterConstants.TESTER_CONTROLPORT;
5+
import static aQute.junit.constants.TesterConstants.TESTER_CUSTOMSERVICE;
56
import static aQute.junit.constants.TesterConstants.TESTER_DIR;
67
import static aQute.junit.constants.TesterConstants.TESTER_NAMES;
78
import static aQute.junit.constants.TesterConstants.TESTER_PORT;
@@ -88,11 +89,17 @@ public void start(BundleContext context) throws Exception {
8889
this.context = context;
8990
active = true;
9091

92+
boolean isCustomService = Boolean.valueOf(context.getProperty(TESTER_CUSTOMSERVICE));
9193
if (!Boolean.valueOf(context.getProperty(TESTER_SEPARATETHREAD))
92-
&& Boolean.valueOf(context.getProperty("launch.services"))) {
94+
&& (isCustomService || Boolean.valueOf(context.getProperty("launch.services")))) {
9395
// can't register services on mini framework
9496
Hashtable<String, String> ht = new Hashtable<>();
95-
ht.put("main.thread", "true");
97+
if (isCustomService) {
98+
ht.put("junit.tester", "true");
99+
}
100+
else {
101+
ht.put("main.thread", "true");
102+
}
96103
ht.put(Constants.SERVICE_DESCRIPTION, "JUnit tester");
97104
context.registerService(Runnable.class.getName(), this, ht);
98105
} else {

biz.aQute.tester/src/aQute/junit/constants/TesterConstants.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,4 +66,11 @@ public interface TesterConstants {
6666
* well to use this special thread to run all tests on.
6767
*/
6868
String TESTER_SEPARATETHREAD = "tester.separatethread";
69+
70+
/**
71+
* Register the tester {@link java.lang.Runnable} as a service with the
72+
* attribute {@code junit.tester=true}. User code may then obtain the
73+
* service and run then tests when convenient.
74+
*/
75+
String TESTER_CUSTOMSERVICE = "tester.customservice";
6976
}

0 commit comments

Comments
 (0)