use of org.eclipse.ceylon.common.tool.example.TestSubtoolTool in project ceylon by eclipse.
the class ToolFactoryTest method testSubtool.
@Test
public void testSubtool() {
ToolModel<TestSubtoolTool> model = pluginLoader.loadToolModel("subtool");
TestSubtoolTool ex = pluginFactory.bindArguments(model, getMainTool(), Arrays.asList("subtool1"));
Assert.assertEquals(TestSubtoolTool.Subtool1.class, ex.getAction().getClass());
ex = pluginFactory.bindArguments(model, getMainTool(), Arrays.asList("subtool1", "--foo"));
Assert.assertEquals(TestSubtoolTool.Subtool1.class, ex.getAction().getClass());
try {
ex = pluginFactory.bindArguments(model, getMainTool(), Arrays.asList("subtool1", "--bar"));
Assert.fail();
} catch (OptionArgumentException e) {
Assert.assertEquals("Unrecognised long option '--bar' to command 'subtool1'", e.getMessage());
}
ex = pluginFactory.bindArguments(model, getMainTool(), Arrays.asList("subtool2"));
Assert.assertEquals(TestSubtoolTool.Subtool2.class, ex.getAction().getClass());
ex = pluginFactory.bindArguments(model, getMainTool(), Arrays.asList("subtool2", "--bar"));
Assert.assertEquals(TestSubtoolTool.Subtool2.class, ex.getAction().getClass());
try {
ex = pluginFactory.bindArguments(model, getMainTool(), Arrays.asList("subtool2", "--foo"));
Assert.fail();
} catch (OptionArgumentException e) {
Assert.assertEquals("Unrecognised long option '--foo' to command 'subtool2'", e.getMessage());
}
try {
ex = pluginFactory.bindArguments(model, getMainTool(), Arrays.asList("subtool3"));
Assert.fail();
} catch (OptionArgumentException e) {
String message = e.getMessage();
Assert.assertTrue(message, message.startsWith("Invalid value 'subtool3' given for argument 'action'"));
// Assert.assertTrue(message, message.contains("subtool1"));
// Assert.assertTrue(message, message.contains("subtool2"));
}
}
Aggregations