Skip to content

Commit e73ce62

Browse files
committed
Ensure all core services are SciJavaServices
This will prevent issues like b811a4d49683e8e5b0e344d7451365ed26fc447f from going uncaught in the future.
1 parent 0c26083 commit e73ce62

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

src/test/java/org/scijava/ContextCreationTest.java

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@
4747
import org.scijava.plugin.PluginInfo;
4848
import org.scijava.plugin.SciJavaPlugin;
4949
import org.scijava.service.AbstractService;
50+
import org.scijava.service.SciJavaService;
5051
import org.scijava.service.Service;
5152
import org.scijava.thread.ThreadService;
5253

@@ -107,6 +108,26 @@ public void testFull() {
107108
verifyServiceOrder(expected, context);
108109
}
109110

111+
/**
112+
* Tests that a new fully populated {@link Context} has exactly the same
113+
* {@link Service}s available as one created with only {@link SciJavaService}
114+
* implementations.
115+
* <p>
116+
* In other words: tests that all {@link Service}s implemented in SciJava
117+
* Common are tagged with the {@link SciJavaService} interface.
118+
* </p>
119+
*/
120+
@Test
121+
public void testSciJavaServices() {
122+
final Context full = new Context();
123+
final Context sciJava = new Context(SciJavaService.class);
124+
for (final Service s : full.getServiceIndex()) {
125+
final Class<? extends Service> c = s.getClass();
126+
final Service sjs = sciJava.getService(c);
127+
if (sjs == null) fail("Not a SciJavaService? " + s.getClass().getName());
128+
}
129+
}
130+
110131
/**
111132
* Tests that dependent {@link Service}s are automatically created and
112133
* populated in downstream {@link Service} classes.

0 commit comments

Comments
 (0)