@Test
public void testValidatingJavaOptions() throws Exception {
ToolModel<CeylonCompileTool> model = pluginLoader.loadToolModel("compile");
Assert.assertNotNull(model);
try{
CeylonCompileTool tool = pluginFactory.bindArguments(model,
options("--javac=-target=foo", "com.example"));
Assert.fail("Tool should have thrown an exception");
}catch(OptionArgumentException x){
Assert.assertEquals("Invalid --javac option: -target: invalid target release: foo", x.getMessage());
}
try{
CeylonCompileTool tool = pluginFactory.bindArguments(model,
options("--javac=-source=foo", "com.example"));
Assert.fail("Tool should have thrown an exception");
}catch(OptionArgumentException x){
Assert.assertEquals("Invalid --javac option: -source: invalid source release: foo", x.getMessage());
}
try{
CeylonCompileTool tool = pluginFactory.bindArguments(model,
options("--javac=-monkey", "com.example"));
Assert.fail("Tool should have thrown an exception");
}catch(OptionArgumentException x){
Assert.assertEquals("Unknown --javac option: -monkey", x.getMessage());
}
{
CeylonCompileTool tool = pluginFactory.bindArguments(model,
options("--javac=-Xlint:cast",
"--src=test/src", "com.redhat.ceylon.tools.test.ceylon"));
}
try{
CeylonCompileTool tool = pluginFactory.bindArguments(model,
options("--javac=-Xlint:monkey",
"--src=test/src", "com.redhat.ceylon.tools.test.ceylon"));
Assert.fail("Tool should have thrown an exception");
}catch(OptionArgumentException x){
Assert.assertEquals("Unknown --javac option: -Xlint:monkey", x.getMessage());