Search in sources :

Example 1 with CeylonImportJarTool

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());
    }
}
Also used : CeylonImportJarTool(com.redhat.ceylon.tools.importjar.CeylonImportJarTool) ToolUsageError(com.redhat.ceylon.common.tool.ToolUsageError) Test(org.junit.Test)

Example 2 with CeylonImportJarTool

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());
    }
}
Also used : OptionArgumentException(com.redhat.ceylon.common.tool.OptionArgumentException) CeylonImportJarTool(com.redhat.ceylon.tools.importjar.CeylonImportJarTool) Test(org.junit.Test)

Example 3 with CeylonImportJarTool

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());
    }
}
Also used : ImportJarException(com.redhat.ceylon.tools.importjar.ImportJarException) CeylonImportJarTool(com.redhat.ceylon.tools.importjar.CeylonImportJarTool) Test(org.junit.Test)

Example 4 with CeylonImportJarTool

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());
}
Also used : CeylonImportJarTool(com.redhat.ceylon.tools.importjar.CeylonImportJarTool) File(java.io.File) Test(org.junit.Test)

Example 5 with CeylonImportJarTool

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());
    }
}
Also used : ImportJarException(com.redhat.ceylon.tools.importjar.ImportJarException) CeylonImportJarTool(com.redhat.ceylon.tools.importjar.CeylonImportJarTool) Test(org.junit.Test)

Aggregations

CeylonImportJarTool (com.redhat.ceylon.tools.importjar.CeylonImportJarTool)16 Test (org.junit.Test)16 File (java.io.File)6 ImportJarException (com.redhat.ceylon.tools.importjar.ImportJarException)5 OptionArgumentException (com.redhat.ceylon.common.tool.OptionArgumentException)3 ToolUsageError (com.redhat.ceylon.common.tool.ToolUsageError)2