use of org.eclipse.ceylon.compiler.java.test.CompilerError in project ceylon by eclipse.
the class BcTests method testBinaryVersionIncompatibleModule1.
// tests before we renamed module_.class to $module_.class
@Test
public void testBinaryVersionIncompatibleModule1() throws IOException {
CompilationTask compiler = compileJava("binaryVersionOld/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/binaryVersionOld/1/");
jarFolder.mkdirs();
File jarFile = new File(jarFolder, "org.eclipse.ceylon.compiler.java.test.bc.binaryVersionOld-1.jar");
// now jar it up
JarOutputStream outputStream = new JarOutputStream(new FileOutputStream(jarFile));
ZipEntry entry = new ZipEntry("org/eclipse/ceylon/compiler/java/test/bc/binaryVersionOld/module_.class");
outputStream.putNextEntry(entry);
File javaClass = new File(destDir, "org/eclipse/ceylon/compiler/java/test/bc/binaryVersionOld/module_.class");
FileInputStream inputStream = new FileInputStream(javaClass);
Util.copy(inputStream, outputStream);
inputStream.close();
outputStream.close();
assertErrors("binaryVersion/module", new CompilerError(21, "version '1' of module 'org.eclipse.ceylon.compiler.java.test.bc.binaryVersionOld' 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)"));
}
use of org.eclipse.ceylon.compiler.java.test.CompilerError in project ceylon by eclipse.
the class BcTests method testBinaryVersionIncompatible.
@Test
public void testBinaryVersionIncompatible() {
compile("JavaOldVersion.java");
assertErrors("CeylonNewVersion", new CompilerError(-1, "Ceylon class org.eclipse.ceylon.compiler.java.test.bc.JavaOldVersion was compiled by an incompatible version of the Ceylon compiler\n The class was compiled using 0.0.\n This compiler supports " + Versions.JVM_BINARY_MAJOR_VERSION + "." + Versions.JVM_BINARY_MINOR_VERSION + ".\n Please try to recompile your module using a compatible compiler.\n Binary compatibility will only be supported after Ceylon 1.2."));
}
use of org.eclipse.ceylon.compiler.java.test.CompilerError in project ceylon by eclipse.
the class CarGenerationTests method testCarMergedManifestComesFirst.
/*
* Although not in the JAR specification, there are tools and APIs
* which rely on the MANIFEST.MF being the first file entry in a Jar file.
*
* Test for the case of an existing MANIFEST.MF in resources
*/
@Test
public void testCarMergedManifestComesFirst() throws IOException {
ErrorCollector ec = new ErrorCollector();
List<String> options = new LinkedList<String>();
options.add("-src");
options.add(getPackagePath() + "meta/mergedmanifest/source");
options.add("-res");
options.add(getPackagePath() + "meta/mergedmanifest/resource");
options.addAll(defaultOptions);
CeyloncTaskImpl task = getCompilerTask(options, ec, Arrays.asList("test.mergedmanifest"));
assertTrue(task.call());
File carFile = getModuleArchive("test.mergedmanifest", "1.0");
assertTrue(carFile.exists());
assertTrue(ec.get(Diagnostic.Kind.ERROR).isEmpty());
// When the compiler value overrides a user value, we expect a warning
assertTrue(ec.get(Diagnostic.Kind.WARNING).size() == 1);
assertTrue(ec.get(Diagnostic.Kind.WARNING).iterator().next().equals(new CompilerError(Diagnostic.Kind.WARNING, null, -1, "manifest attribute provided by compiler: ignoring value from 'Bundle-ActivationPolicy' for module 'test.mergedmanifest'")));
try (JarFile car = new JarFile(carFile)) {
Manifest manifest = car.getManifest();
manifest.write(System.err);
assertTrue(manifest != null);
assertEquals("test.mergedmanifest", manifest.getMainAttributes().getValue("Bundle-SymbolicName"));
assertEquals("Baz", manifest.getMainAttributes().getValue("Foo-Bar"));
assertEquals("whatever", manifest.getMainAttributes().getValue("LastLineWithoutNewline"));
Enumeration<JarEntry> entries = car.entries();
assertTrue(entries.hasMoreElements());
JarEntry entry = entries.nextElement();
assertEquals("META-INF/", entry.getName());
assertTrue(entry.isDirectory());
entry = entries.nextElement();
assertEquals("META-INF/MANIFEST.MF", entry.getName());
assertTrue(!entry.isDirectory());
}
}
use of org.eclipse.ceylon.compiler.java.test.CompilerError in project ceylon by eclipse.
the class CMRHTTPTests method testMdlHTTPForbidden.
@Test
public void testMdlHTTPForbidden() throws IOException {
File repo = makeRepo();
final int port = allocPortForTest();
final String repoAURL = getRepoUrl(port);
HttpServer server = startServer(port, repo, true, null, HttpError.FORBIDDEN);
try {
// then try to compile our module by outputting to HTTP
assertErrors("modules/single/module", Arrays.asList("-out", repoAURL), null, new CompilerError(-1, "Failed to write module to repository: authentication failed on repository " + repoAURL));
} finally {
server.stop(1);
}
}
use of org.eclipse.ceylon.compiler.java.test.CompilerError in project ceylon by eclipse.
the class CMRTests method testMdlMultipleVersionsOnSameCompilation.
@Test
public void testMdlMultipleVersionsOnSameCompilation() {
// 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);
ErrorCollector collector = new ErrorCollector();
// Compile module A/2 with B importing A/1
result = getCompilerTask(Arrays.asList("-src", getPackagePath() + "/modules/multiversion/a2" + File.pathSeparator + getPackagePath() + "/modules/multiversion/b"), collector, "modules/multiversion/a2/a/module.ceylon", "modules/multiversion/a2/a/package.ceylon", "modules/multiversion/a2/a/A.ceylon", "modules/multiversion/b/b/module.ceylon", "modules/multiversion/b/b/B.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'"));
}
Aggregations