Search in sources :

Example 6 with CeylonImportJarTool

use of com.redhat.ceylon.tools.importjar.CeylonImportJarTool in project ceylon-compiler by ceylon.

the class ImportJarToolTests method testDescriptorSuffix.

@Test
public void testDescriptorSuffix() {
    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/ImportJarToolTests.java", "test/1.0", "test/src/com/redhat/ceylon/tools/test/test.jar"));
        Assert.fail();
    } catch (ImportJarException e) {
        Assert.assertEquals("Descriptor file test/src/com/redhat/ceylon/tools/test/ImportJarToolTests.java does not end with '.xml' or '.properties' extension", e.getMessage().replace('\\', '/'));
    }
}
Also used : ImportJarException(com.redhat.ceylon.tools.importjar.ImportJarException) CeylonImportJarTool(com.redhat.ceylon.tools.importjar.CeylonImportJarTool) Test(org.junit.Test)

Example 7 with CeylonImportJarTool

use of com.redhat.ceylon.tools.importjar.CeylonImportJarTool in project ceylon-compiler by ceylon.

the class ImportJarToolTests method testWithPropertiesDescriptor.

@Test
public void testWithPropertiesDescriptor() throws Exception {
    FileUtil.delete(destFile("importtest"));
    ToolModel<CeylonImportJarTool> model = pluginLoader.loadToolModel("import-jar");
    Assert.assertNotNull(model);
    CeylonImportJarTool tool = pluginFactory.bindArguments(model, getMainTool(), options("--descriptor", "test/src/com/redhat/ceylon/tools/test/test-descriptor.properties", "importtest/1.0", "test/src/com/redhat/ceylon/tools/test/test.jar"));
    tool.run();
    File f1 = destFile("importtest/1.0/importtest-1.0.jar");
    File f2 = destFile("importtest/1.0/importtest-1.0.jar.sha1");
    File f3 = destFile("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 8 with CeylonImportJarTool

use of com.redhat.ceylon.tools.importjar.CeylonImportJarTool in project ceylon-compiler by ceylon.

the class ImportJarToolTests method testWithInvalidXmlDescriptor.

@Test
public void testWithInvalidXmlDescriptor() 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-broken.xml", "importtest/1.0", "test/src/com/redhat/ceylon/tools/test/test.jar"));
        tool.run();
        Assert.fail();
    } catch (ImportJarException e) {
        Assert.assertEquals("Descriptor file test/src/com/redhat/ceylon/tools/test/test-descriptor-broken.xml is not a valid module.xml file: org.xml.sax.SAXParseException; lineNumber: 1; columnNumber: 1; Content is not allowed in prolog.", e.getMessage().replace('\\', '/'));
    }
}
Also used : ImportJarException(com.redhat.ceylon.tools.importjar.ImportJarException) CeylonImportJarTool(com.redhat.ceylon.tools.importjar.CeylonImportJarTool) Test(org.junit.Test)

Example 9 with CeylonImportJarTool

use of com.redhat.ceylon.tools.importjar.CeylonImportJarTool in project ceylon-compiler by ceylon.

the class ImportJarToolTests method testNoArgs.

@Test
public void testNoArgs() {
    ToolModel<CeylonImportJarTool> model = pluginLoader.loadToolModel("import-jar");
    Assert.assertNotNull(model);
    try {
        CeylonImportJarTool tool = pluginFactory.bindArguments(model, getMainTool(), options());
        Assert.fail();
    } catch (OptionArgumentException e) {
        Assert.assertEquals("Argument 'module' to command 'import-jar' should appear at least 1 time(s)", e.getMessage());
    }
}
Also used : OptionArgumentException(com.redhat.ceylon.common.tool.OptionArgumentException) CeylonImportJarTool(com.redhat.ceylon.tools.importjar.CeylonImportJarTool) Test(org.junit.Test)

Example 10 with CeylonImportJarTool

use of com.redhat.ceylon.tools.importjar.CeylonImportJarTool in project ceylon-compiler by ceylon.

the class ImportJarToolTests method testWithInvalidPropertiesDescriptor.

@Test
public void testWithInvalidPropertiesDescriptor() 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-broken.properties", "importtest/1.0", "test/src/com/redhat/ceylon/tools/test/test.jar"));
        tool.run();
        Assert.fail();
    } catch (ImportJarException e) {
        Assert.assertEquals("Invalid module version '' in module descriptor dependency list", 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