use of org.scijava.plugin.PluginIndex in project imagej-omero by imagej.
the class ScriptGeneratorTest method testGenerateAll.
@Test
public void testGenerateAll() throws IOException {
// create a context with a minimal command set
final PluginIndex pluginIndex = new PluginIndex() {
@Override
public void discover() {
super.discover();
removeAll(getPlugins(Command.class));
add(pluginInfo(FileNew.class));
add(pluginInfo(FileOpen.class));
add(pluginInfo(FileSave.class));
add(pluginInfo(FileExit.class));
add(pluginInfo(Lion.class));
add(pluginInfo(Tiger.class));
add(pluginInfo(Bear.class));
}
};
final ArrayList<Class<? extends Service>> classes = new ArrayList<Class<? extends Service>>();
classes.add(AppService.class);
classes.add(CommandService.class);
classes.add(MenuService.class);
final Context context = new Context(classes, pluginIndex);
final ScriptGenerator scriptGen = new ScriptGenerator(context);
final File tempDir = TestUtils.createTemporaryDirectory("script-generator-");
final File libDir = new File(tempDir, "lib");
final File scriptsDir = new File(libDir, "scripts");
assertTrue(scriptsDir.mkdirs());
final int returnCode = scriptGen.generateAll(tempDir);
context.dispose();
assertEquals(0, returnCode);
final File imagejDir = new File(scriptsDir, "imagej");
assertTrue(imagejDir.isDirectory());
final File fileDir = new File(imagejDir, "File");
assertTrue(fileDir.isDirectory());
final File animalsDir = new File(imagejDir, "\ufeffAnimals");
assertTrue(animalsDir.isDirectory());
assertTrue(new File(fileDir, "New.py").exists());
assertTrue(new File(fileDir, "\ufeffOpen.py").exists());
assertTrue(new File(fileDir, "\ufeff\ufeffSave.py").exists());
assertTrue(new File(fileDir, "\ufeff\ufeff\ufeffExit.py").exists());
assertTrue(new File(animalsDir, "Lion.py").exists());
assertTrue(new File(animalsDir, "\ufeffTiger.py").exists());
assertTrue(new File(animalsDir, "\ufeff\ufeffBear.py").exists());
FileUtils.deleteRecursively(tempDir);
}
Aggregations