Search in sources :

Example 6 with CeylonImportJarTool

use of org.eclipse.ceylon.tools.importjar.CeylonImportJarTool in project ceylon by eclipse.

the class ImportJarToolTests method testNonexistentSourceJar.

@Test
public void testNonexistentSourceJar() {
    ToolModel<CeylonImportJarTool> model = pluginLoader.loadToolModel("import-jar");
    Assert.assertNotNull(model);
    try {
        CeylonImportJarTool tool = pluginFactory.bindArguments(model, getMainTool(), toolOptions("test/1.0", "test/src/org/eclipse/ceylon/tools/test/test.jar", "test/src/org/eclipse/ceylon/tools/test/nonexistent-sources.jar"));
        Assert.fail();
    } catch (ImportJarException e) {
        String srcJarName = "test/src/org/eclipse/ceylon/tools/test/nonexistent-sources.jar";
        srcJarName = srcJarName.replace('/', File.separatorChar);
        Assert.assertEquals("Source jar file " + srcJarName + " does not exist", e.getMessage());
    }
}
Also used : ImportJarException(org.eclipse.ceylon.tools.importjar.ImportJarException) CeylonImportJarTool(org.eclipse.ceylon.tools.importjar.CeylonImportJarTool) Test(org.junit.Test)

Example 7 with CeylonImportJarTool

use of org.eclipse.ceylon.tools.importjar.CeylonImportJarTool in project ceylon by eclipse.

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(), toolOptions("--descriptor", "test/src/org/eclipse/ceylon/tools/test/test-descriptor-broken.properties", "importtest/1.0", "test/src/org/eclipse/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(org.eclipse.ceylon.tools.importjar.ImportJarException) CeylonImportJarTool(org.eclipse.ceylon.tools.importjar.CeylonImportJarTool) Test(org.junit.Test)

Example 8 with CeylonImportJarTool

use of org.eclipse.ceylon.tools.importjar.CeylonImportJarTool in project ceylon by eclipse.

the class ImportJarToolTests method testJarAndSourceJarNoDescriptorVerbose.

@Test
public void testJarAndSourceJarNoDescriptorVerbose() throws Exception {
    ToolModel<CeylonImportJarTool> model = pluginLoader.loadToolModel("import-jar");
    Assert.assertNotNull(model);
    CeylonImportJarTool tool = pluginFactory.bindArguments(model, getMainTool(), toolOptions("--force", "--verbose", "source.import.test/1.0", "test/src/org/eclipse/ceylon/tools/test/test.jar", "test/src/org/eclipse/ceylon/tools/test/test-source.jar"));
    tool.run();
    File jarFile = destFile("source/import/test/1.0/source.import.test-1.0.jar");
    File sha1JarFile = destFile("source/import/test/1.0/source.import.test-1.0.jar.sha1");
    File sourceJarFile = destFile("source/import/test/1.0/source.import.test-1.0-sources.jar");
    File sha1SourceJarFile = destFile("source/import/test/1.0/source.import.test-1.0-sources.jar.sha1");
    Assert.assertTrue(jarFile.exists() && sha1JarFile.exists() && sourceJarFile.exists() && sha1SourceJarFile.exists());
}
Also used : CeylonImportJarTool(org.eclipse.ceylon.tools.importjar.CeylonImportJarTool) File(java.io.File) Test(org.junit.Test)

Example 9 with CeylonImportJarTool

use of org.eclipse.ceylon.tools.importjar.CeylonImportJarTool in project ceylon by eclipse.

the class ImportJarToolTests method testJarAndSourceJarNoDescriptor.

@Test
public void testJarAndSourceJarNoDescriptor() throws Exception {
    ToolModel<CeylonImportJarTool> model = pluginLoader.loadToolModel("import-jar");
    Assert.assertNotNull(model);
    CeylonImportJarTool tool = pluginFactory.bindArguments(model, getMainTool(), toolOptions("--force", "source.import.test/1.0", "test/src/org/eclipse/ceylon/tools/test/test.jar", "test/src/org/eclipse/ceylon/tools/test/test-source.jar"));
    tool.run();
    File jarFile = destFile("source/import/test/1.0/source.import.test-1.0.jar");
    File sha1JarFile = destFile("source/import/test/1.0/source.import.test-1.0.jar.sha1");
    File sourceJarFile = destFile("source/import/test/1.0/source.import.test-1.0-sources.jar");
    File sha1SourceJarFile = destFile("source/import/test/1.0/source.import.test-1.0-sources.jar.sha1");
    Assert.assertTrue(jarFile.exists() && sha1JarFile.exists() && sourceJarFile.exists() && sha1SourceJarFile.exists());
}
Also used : CeylonImportJarTool(org.eclipse.ceylon.tools.importjar.CeylonImportJarTool) File(java.io.File) Test(org.junit.Test)

Example 10 with CeylonImportJarTool

use of org.eclipse.ceylon.tools.importjar.CeylonImportJarTool in project ceylon by eclipse.

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(), toolOptions("--descriptor", "test/src/org/eclipse/ceylon/tools/test/test-nonexistent-descriptor.xml", "importtest/1.0", "test/src/org/eclipse/ceylon/tools/test/test.jar"));
        tool.run();
        Assert.fail();
    } catch (ImportJarException e) {
        String xmlName = "test/src/org/eclipse/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(org.eclipse.ceylon.tools.importjar.ImportJarException) CeylonImportJarTool(org.eclipse.ceylon.tools.importjar.CeylonImportJarTool) Test(org.junit.Test)

Aggregations

CeylonImportJarTool (org.eclipse.ceylon.tools.importjar.CeylonImportJarTool)23 Test (org.junit.Test)22 File (java.io.File)12 ImportJarException (org.eclipse.ceylon.tools.importjar.ImportJarException)6 OptionArgumentException (org.eclipse.ceylon.common.tool.OptionArgumentException)3 ToolUsageError (org.eclipse.ceylon.common.tool.ToolUsageError)3 ArtifactContext (org.eclipse.ceylon.cmr.api.ArtifactContext)1 MavenArtifactContext (org.eclipse.ceylon.cmr.api.MavenArtifactContext)1 RepositoryManager (org.eclipse.ceylon.cmr.api.RepositoryManager)1 CeylonRepoManagerBuilder (org.eclipse.ceylon.cmr.ceylon.CeylonUtils.CeylonRepoManagerBuilder)1 ToolError (org.eclipse.ceylon.common.tool.ToolError)1