use of com.redhat.ceylon.tools.importjar.CeylonImportJarTool in project ceylon-compiler by ceylon.
the class ImportJarToolTests method testWithUnknownModule.
@Test
public void testWithUnknownModule() throws Exception {
FileUtil.delete(destFile("importtest"));
ToolModel<CeylonImportJarTool> model = pluginLoader.loadToolModel("import-jar");
Assert.assertNotNull(model);
try {
CeylonImportJarTool tool = pluginFactory.bindArguments(model, getMainTool(), options("--descriptor", "test/src/com/redhat/ceylon/tools/test/test-descriptor-unknown.properties", "importtest/1.0", "test/src/com/redhat/ceylon/tools/test/test.jar"));
tool.run();
Assert.fail();
} catch (ToolUsageError e) {
Assert.assertEquals("Problems were found, aborting.", e.getMessage());
}
}
use of com.redhat.ceylon.tools.importjar.CeylonImportJarTool in project ceylon-compiler by ceylon.
the class ImportJarToolTests method testModuleOnlyJar.
@Test
public void testModuleOnlyJar() {
ToolModel<CeylonImportJarTool> model = pluginLoader.loadToolModel("import-jar");
Assert.assertNotNull(model);
try {
CeylonImportJarTool tool = pluginFactory.bindArguments(model, getMainTool(), options("test", "my.jar"));
Assert.fail();
} catch (OptionArgumentException e) {
Assert.assertEquals("Invalid value 'test' given for argument 'module' to command 'import-jar'", e.getMessage());
}
}
use of com.redhat.ceylon.tools.importjar.CeylonImportJarTool in project ceylon-compiler by ceylon.
the class ImportJarToolTests method testWithMissingXmlDescriptor.
@Test
public void testWithMissingXmlDescriptor() throws Exception {
FileUtil.delete(destFile("importtest"));
ToolModel<CeylonImportJarTool> model = pluginLoader.loadToolModel("import-jar");
Assert.assertNotNull(model);
try {
CeylonImportJarTool tool = pluginFactory.bindArguments(model, getMainTool(), options("--descriptor", "test/src/com/redhat/ceylon/tools/test/test-nonexistent-descriptor.xml", "importtest/1.0", "test/src/com/redhat/ceylon/tools/test/test.jar"));
tool.run();
Assert.fail();
} catch (ImportJarException e) {
String xmlName = "test/src/com/redhat/ceylon/tools/test/test-nonexistent-descriptor.xml";
xmlName = xmlName.replace('/', File.separatorChar);
Assert.assertEquals("Descriptor file " + xmlName + " does not exist", e.getMessage());
}
}
use of com.redhat.ceylon.tools.importjar.CeylonImportJarTool in project ceylon-compiler by ceylon.
the class ImportJarToolTests method testWithPropertiesDescriptorCwd.
@Test
public void testWithPropertiesDescriptorCwd() throws Exception {
File destDir = destFile("importtest");
FileUtil.delete(destDir);
destDir.mkdirs();
FileUtil.copyAll(new File("test/src/com/redhat/ceylon/tools/test/test-descriptor.properties"), destDir);
FileUtil.copyAll(new File("test/src/com/redhat/ceylon/tools/test/test.jar"), destDir);
ToolModel<CeylonImportJarTool> model = pluginLoader.loadToolModel("import-jar");
Assert.assertNotNull(model);
CeylonImportJarTool tool = pluginFactory.bindArguments(model, getMainTool(), Arrays.asList("--cwd", destDir.getPath(), "--descriptor", "test-descriptor.properties", "importtest/1.0", "test.jar"));
tool.run();
File f1 = destFile("importtest/modules/importtest/1.0/importtest-1.0.jar");
File f2 = destFile("importtest/modules/importtest/1.0/importtest-1.0.jar.sha1");
File f3 = destFile("importtest/modules/importtest/1.0/module.properties");
Assert.assertTrue(f1.exists() && f2.exists());
Assert.assertTrue(f3.exists());
}
use of com.redhat.ceylon.tools.importjar.CeylonImportJarTool in project ceylon-compiler by ceylon.
the class ImportJarToolTests method testNonexistentJar.
@Test
public void testNonexistentJar() {
ToolModel<CeylonImportJarTool> model = pluginLoader.loadToolModel("import-jar");
Assert.assertNotNull(model);
try {
CeylonImportJarTool tool = pluginFactory.bindArguments(model, getMainTool(), options("test/1.0", "test/src/com/redhat/ceylon/tools/test/nonexistent.jar"));
Assert.fail();
} catch (ImportJarException e) {
String jarName = "test/src/com/redhat/ceylon/tools/test/nonexistent.jar";
jarName = jarName.replace('/', File.separatorChar);
Assert.assertEquals("Jar file " + jarName + " does not exist", e.getMessage());
}
}
Aggregations