use of org.eclipse.ceylon.compiler.java.test.CompilerError in project ceylon by eclipse.
the class CMRTests method testMdlAetherMissingDependencies.
@Test
public void testMdlAetherMissingDependencies() throws IOException {
CompilerError[] expectedErrors = new CompilerError[] { new CompilerError(6, "Error while loading the org.apache.camel:camel-jetty/2.9.4 module:\n" + " Declaration 'org.apache.camel.component.http.HttpComponent' could not be found in module 'org.apache.camel:camel-jetty' or its imported modules"), new CompilerError(10, "argument must be assignable to parameter 'arg1' of 'addComponent' in 'DefaultCamelContext': 'JettyHttpComponent' is not assignable to 'Component?': Error while loading the org.apache.camel:camel-jetty/2.9.4 module:\n" + " Declaration 'org.apache.camel.component.http.HttpComponent' could not be found in module 'org.apache.camel:camel-jetty' or its imported modules") };
ErrorCollector collector = new ErrorCollector();
// Try to compile the ceylon module
CeyloncTaskImpl ceylonTask = getCompilerTask(Arrays.asList("-out", destDir, "-rep", "aether"), collector, "modules/bug1100/module.ceylon", "modules/bug1100/test.ceylon");
assertEquals("Compilation failed", Boolean.FALSE, ceylonTask.call());
TreeSet<CompilerError> actualErrors = collector.get(Diagnostic.Kind.ERROR);
compareErrors(actualErrors, expectedErrors);
}
use of org.eclipse.ceylon.compiler.java.test.CompilerError in project ceylon by eclipse.
the class CMRTests method testOverridesCeylonModuleInSourceImport.
@Test
public void testOverridesCeylonModuleInSourceImport() {
setupBinaryModulesForOverridesCeylonModuleTests();
ErrorCollector collector = new ErrorCollector();
CeyloncTaskImpl compilerTask = getCompilerTask(Arrays.asList("-continue", "-src", getPackagePath() + "/modules", "-overrides", getPackagePath() + "modules/overridesCeylonModule/overrides-a-version.xml"), collector, "modules/overridesCeylonModule/module.ceylon");
ModulesRetriever modulesRetriever = new ModulesRetriever(compilerTask.getContext());
compilerTask.setTaskListener(modulesRetriever);
Boolean result = compilerTask.call();
Assert.assertEquals(Boolean.TRUE, result);
compareErrors(collector.get(Diagnostic.Kind.WARNING), new CompilerError(Kind.WARNING, null, 1, "all-lowercase ASCII module names are recommended"), new CompilerError(Kind.WARNING, null, 2, "project source module import is overridden in module overrides file: 'a/2' overrides 'a/1'"));
assert (modulesRetriever.modules != null);
Module a = modulesRetriever.modules.get("a");
Module b = modulesRetriever.modules.get("b");
Module c = modulesRetriever.modules.get("c");
assert (a != null);
assert (b != null);
assert (c != null);
assertEquals("The version override should not be applied to modules imported in source code", "2", a.getVersion());
assertEquals("The version override should not be applied to modules imported in source code", "2", b.getVersion());
assertEquals("The version override should not be applied to modules imported in source code", "2", c.getVersion());
}
use of org.eclipse.ceylon.compiler.java.test.CompilerError in project ceylon by eclipse.
the class CMRTests method testMdlBug1062IncompatibleNonSharedImport.
@Test
public void testMdlBug1062IncompatibleNonSharedImport() throws IOException {
// compile our java class
File classesOutputFolder = new File(destDir + "-jar-classes");
cleanCars(classesOutputFolder.getPath());
classesOutputFolder.mkdirs();
File jarOutputFolder = new File(destDir + "-jar");
cleanCars(jarOutputFolder.getPath());
jarOutputFolder.mkdirs();
compileJavaModule(jarOutputFolder, classesOutputFolder, "bug1062.javaA", "1", new File(getPackagePath() + "/modules/bug1062/javaA1-src"), new File[0], "bug1062/javaA/JavaA.java");
compileJavaModule(jarOutputFolder, classesOutputFolder, "bug1062.javaA", "2", new File(getPackagePath() + "/modules/bug1062/javaA2-src"), new File[0], "bug1062/javaA/JavaA.java");
compileJavaModule(jarOutputFolder, classesOutputFolder, "bug1062.javaB", "1", new File(getPackagePath() + "/modules/bug1062/javaB-module-src"), new File[] { new File(jarOutputFolder, "bug1062/javaA/1/bug1062.javaA-1.jar") }, "bug1062/javaB/JavaB.java");
// ceylon module imports JavaA/2 and JavaB/1
// JavaB/1 imports JavaA/1
assertErrors("modules/bug1062/ceylon/test", Arrays.asList("-rep", jarOutputFolder.getPath(), "-cp", getClassPathAsPath()), null, new CompilerError(5, "could not determine type of method or attribute reference: 'method' of 'JavaB' is ambiguous - Error while loading the bug1062.javaB/1 module:\n" + " Declaration 'bug1062.javaA.JavaA' could not be found in module 'bug1062.javaB' or its imported modules but was found in the non-imported module 'bug1062.javaA'"), new CompilerError(5, "parameter type could not be determined: 'arg0' of 'method' in 'JavaB' - Error while loading the bug1062.javaB/1 module:\n" + " Declaration 'bug1062.javaA.JavaA' could not be found in module 'bug1062.javaB' or its imported modules but was found in the non-imported module 'bug1062.javaA'"));
}
use of org.eclipse.ceylon.compiler.java.test.CompilerError in project ceylon by eclipse.
the class CMRTests method testMdlMultipleVersionsDuringImport.
@Test
public void testMdlMultipleVersionsDuringImport() {
// Compile module A/1
Boolean result = getCompilerTask(Arrays.asList("-src", getPackagePath() + "/modules/multiversion/a1"), "modules/multiversion/a1/a/module.ceylon", "modules/multiversion/a1/a/package.ceylon", "modules/multiversion/a1/a/A.ceylon").call();
Assert.assertEquals(Boolean.TRUE, result);
// Compile module A/2
result = getCompilerTask(Arrays.asList("-src", getPackagePath() + "/modules/multiversion/a2"), "modules/multiversion/a2/a/module.ceylon", "modules/multiversion/a2/a/package.ceylon", "modules/multiversion/a2/a/A.ceylon").call();
Assert.assertEquals(Boolean.TRUE, result);
ErrorCollector collector = new ErrorCollector();
// Compile module cImportsATwice which imports both A/1 and A/2
result = getCompilerTask(Arrays.asList("-src", getPackagePath() + "/modules/multiversion/c"), collector, "modules/multiversion/c/cImportsATwice/module.ceylon", "modules/multiversion/c/cImportsATwice/C.ceylon").call();
Assert.assertEquals(Boolean.FALSE, result);
compareErrors(collector.get(Diagnostic.Kind.ERROR), new CompilerError(20, "source code imports two different versions of module 'a': version '1' and version '2'"), new CompilerError(22, "duplicate module import: 'a'"));
}
use of org.eclipse.ceylon.compiler.java.test.CompilerError in project ceylon by eclipse.
the class BcTests method testBinaryVersionIncompatibleModule2.
// tests after we renamed module_.class to $module_.class
@Test
public void testBinaryVersionIncompatibleModule2() throws IOException {
CompilationTask compiler = compileJava("binaryVersionOld2/$module_.java");
Assert.assertTrue(compiler.call());
// so now make a jar containing the java module
File jarFolder = new File(destDir, "org/eclipse/ceylon/compiler/java/test/bc/binaryVersionOld2/1/");
jarFolder.mkdirs();
File jarFile = new File(jarFolder, "org.eclipse.ceylon.compiler.java.test.bc.binaryVersionOld2-1.jar");
// now jar it up
JarOutputStream outputStream = new JarOutputStream(new FileOutputStream(jarFile));
ZipEntry entry = new ZipEntry("org/eclipse/ceylon/compiler/java/test/bc/binaryVersionOld2/$module_.class");
outputStream.putNextEntry(entry);
File javaClass = new File(destDir, "org/eclipse/ceylon/compiler/java/test/bc/binaryVersionOld2/$module_.class");
FileInputStream inputStream = new FileInputStream(javaClass);
Util.copy(inputStream, outputStream);
inputStream.close();
outputStream.close();
assertErrors("binaryVersion2/module", new CompilerError(21, "version '1' of module 'org.eclipse.ceylon.compiler.java.test.bc.binaryVersionOld2' was compiled by" + " an incompatible version of the compiler" + " (binary version 0.0 of module is not compatible with binary version " + Versions.JVM_BINARY_MAJOR_VERSION + "." + Versions.JVM_BINARY_MINOR_VERSION + " of this compiler)"));
}
Aggregations