Search in sources :

Example 6 with CompilerError

use of com.redhat.ceylon.compiler.java.test.CompilerError in project ceylon-compiler by ceylon.

the class InteropTests method testIopCallsDefaultAccessClassInAnotherPkgWithOverloading.

@Test
public void testIopCallsDefaultAccessClassInAnotherPkgWithOverloading() {
    compile("access/JavaDefaultAccessClass4.java");
    assertErrors("CallsDefaultAccessClassInAnotherPkgWithOverloading", new CompilerError(26, "ambiguous invocation of overloaded method or class: there must be exactly one overloaded declaration of 'JavaDefaultAccessClass4' that accepts the given argument types ''"), new CompilerError(26, "class cannot be instantiated: 'JavaDefaultAccessClass4' does not have a default constructor"), new CompilerError(27, "type constructor is not visible: 'JavaDefaultAccessClass4'"), new CompilerError(28, "protected constructor is not visible: 'JavaDefaultAccessClass4'"));
}
Also used : CompilerError(com.redhat.ceylon.compiler.java.test.CompilerError) Test(org.junit.Test)

Example 7 with CompilerError

use of com.redhat.ceylon.compiler.java.test.CompilerError in project ceylon-compiler by ceylon.

the class InteropTests method testIopRefinesDefaultAccessMethodWithShared.

@Test
public void testIopRefinesDefaultAccessMethodWithShared() {
    compile("access/JavaAccessModifiers.java");
    assertErrors("access/RefinesDefaultAccessMethodWithShared", new CompilerError(22, "non-actual member collides with an inherited member: 'defaultAccessMethod' in 'RefinesDefaultAccessMethodWithShared' refines 'defaultAccessMethod' in 'JavaAccessModifiers'"));
}
Also used : CompilerError(com.redhat.ceylon.compiler.java.test.CompilerError) Test(org.junit.Test)

Example 8 with CompilerError

use of com.redhat.ceylon.compiler.java.test.CompilerError in project ceylon-compiler by ceylon.

the class InteropTests method testIopAmbiguousOverloading.

@Test
public void testIopAmbiguousOverloading() {
    compile("TypesJava.java", "JavaWithOverloadedMembers.java");
    assertErrors("AmbiguousOverloading", new CompilerError(25, "ambiguous invocation of overloaded method or class: there must be exactly one overloaded declaration of 'ambiguousOverload' that accepts the given argument types 'String, String'"), new CompilerError(26, "ambiguous invocation of overloaded method or class: there must be exactly one overloaded declaration of 'ambiguousOverload2' that accepts the given argument types 'Integer, Integer'"));
}
Also used : CompilerError(com.redhat.ceylon.compiler.java.test.CompilerError) Test(org.junit.Test)

Example 9 with CompilerError

use of com.redhat.ceylon.compiler.java.test.CompilerError in project ceylon-compiler by ceylon.

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);
    }
}
Also used : HttpServer(com.sun.net.httpserver.HttpServer) CompilerError(com.redhat.ceylon.compiler.java.test.CompilerError) JarFile(java.util.jar.JarFile) File(java.io.File) Test(org.junit.Test)

Example 10 with CompilerError

use of com.redhat.ceylon.compiler.java.test.CompilerError in project ceylon-compiler by ceylon.

the class CMRHTTPTests method testMdlHTTPTimeout.

@Test
public void testMdlHTTPTimeout() throws IOException {
    String moduleA = "com.redhat.ceylon.compiler.java.test.cmr.modules.depend.a";
    // Clean up any cached version
    File carFileInCache = getModuleArchive(moduleA, "6.6.6", cacheDir);
    if (carFileInCache.exists())
        carFileInCache.delete();
    // Compile the first module in its own repo
    File repo = makeRepo();
    Boolean result = getCompilerTask(Arrays.asList("-out", repo.getPath()), "modules/depend/a/module.ceylon", "modules/depend/a/package.ceylon", "modules/depend/a/A.ceylon").call();
    Assert.assertEquals(Boolean.TRUE, result);
    File carFile = getModuleArchive(moduleA, "6.6.6", repo.getPath());
    assertTrue(carFile.exists());
    final int port = allocPortForTest();
    final String repoAURL = getRepoUrl(port);
    String[] files = new String[] { "modules/depend/b/module.ceylon", "modules/depend/b/package.ceylon", "modules/depend/b/a.ceylon", "modules/depend/b/B.ceylon" };
    List<String> options = Arrays.asList("-out", destDir, "-rep", repoAURL, "-verbose:cmr", "-cp", getClassPathAsPath(), "-timeout", "1");
    // now serve the first repo over HTTP
    HttpServer server = startServer(port, repo, false, null, TimeoutIn.GetMiddle);
    try {
        // then try to compile only one module (the other being loaded from its car)
        assertErrors(files, options, null, new CompilerError(24, "cannot find module artifact com.redhat.ceylon.compiler.java.test.cmr.modules.depend.a-6.6.6.car\n" + "  due to connection error: java.net.SocketTimeoutException: Timed out reading com.redhat.ceylon.compiler.java.test.cmr.modules.depend.a-6.6.6.car from " + repoAURL + "\n" + "  \t- dependency tree: com.redhat.ceylon.compiler.java.test.cmr.modules.depend.b/6.6.6 -> com.redhat.ceylon.compiler.java.test.cmr.modules.depend.a/6.6.6"));
    } finally {
        server.stop(1);
    }
    if (carFileInCache.exists())
        carFileInCache.delete();
    server = startServer(port, repo, false, null, TimeoutIn.GetInitial);
    try {
        // then try to compile only one module (the other being loaded from its car)
        assertErrors(files, options, null, new CompilerError(24, "cannot find module artifact com.redhat.ceylon.compiler.java.test.cmr.modules.depend.a-6.6.6.car\n" + "  due to connection error: java.net.SocketTimeoutException: Timed out during connection to " + repoAURL + "/com/redhat/ceylon/compiler/java/test/cmr/modules/depend/a/6.6.6/com.redhat.ceylon.compiler.java.test.cmr.modules.depend.a-6.6.6.car\n" + "  \t- dependency tree: com.redhat.ceylon.compiler.java.test.cmr.modules.depend.b/6.6.6 -> com.redhat.ceylon.compiler.java.test.cmr.modules.depend.a/6.6.6"));
    } finally {
        server.stop(1);
    }
    if (carFileInCache.exists())
        carFileInCache.delete();
    server = startServer(port, repo, false, null, TimeoutIn.Head);
    try {
        // then try to compile only one module (the other being loaded from its car)
        assertErrors(files, options, null, new CompilerError(24, "cannot find module artifact com.redhat.ceylon.compiler.java.test.cmr.modules.depend.a-6.6.6(.car|.jar)\n" + "  \t- dependency tree: com.redhat.ceylon.compiler.java.test.cmr.modules.depend.b/6.6.6 -> com.redhat.ceylon.compiler.java.test.cmr.modules.depend.a/6.6.6"));
    } finally {
        server.stop(1);
    }
    // now with put
    server = startServer(port, repo, true, null, TimeoutIn.PutInitial);
    try {
        // then try to compile our module by outputting to HTTP
        assertErrors("modules/single/module", Arrays.asList("-out", repoAURL, "-verbose:cmr", "-timeout", "1"), null, new CompilerError(-1, "Failed to write module to repository: java.net.SocketTimeoutException: Timed out writing to " + repoAURL + "/com/redhat/ceylon/compiler/java/test/cmr/modules/single/6.6.6/com.redhat.ceylon.compiler.java.test.cmr.modules.single-6.6.6.src"));
    } finally {
        server.stop(1);
    }
    // now with put
    server = startServer(port, repo, true, null, TimeoutIn.PutMiddle);
    try {
        // then try to compile our module by outputting to HTTP
        assertErrors("modules/single/module", Arrays.asList("-out", repoAURL, "-verbose:cmr", "-timeout", "1"), null, new CompilerError(-1, "Failed to write module to repository: java.net.SocketTimeoutException: Timed out writing to " + repoAURL + "/com/redhat/ceylon/compiler/java/test/cmr/modules/single/6.6.6/com.redhat.ceylon.compiler.java.test.cmr.modules.single-6.6.6.src"));
    } finally {
        server.stop(1);
    }
}
Also used : HttpServer(com.sun.net.httpserver.HttpServer) CompilerError(com.redhat.ceylon.compiler.java.test.CompilerError) JarFile(java.util.jar.JarFile) File(java.io.File) Test(org.junit.Test)

Aggregations

CompilerError (com.redhat.ceylon.compiler.java.test.CompilerError)47 Test (org.junit.Test)47 ErrorCollector (com.redhat.ceylon.compiler.java.test.ErrorCollector)15 File (java.io.File)13 CeyloncTaskImpl (com.redhat.ceylon.compiler.java.tools.CeyloncTaskImpl)11 JarFile (java.util.jar.JarFile)11 ZipEntry (java.util.zip.ZipEntry)7 LinkedList (java.util.LinkedList)6 ZipFile (java.util.zip.ZipFile)4 HttpServer (com.sun.net.httpserver.HttpServer)2 FileInputStream (java.io.FileInputStream)2 FileOutputStream (java.io.FileOutputStream)2 JarOutputStream (java.util.jar.JarOutputStream)2 CompilationTask (javax.tools.JavaCompiler.CompilationTask)2 ExitState (com.redhat.ceylon.compiler.java.launcher.Main.ExitState)1 Module (com.redhat.ceylon.model.typechecker.model.Module)1 FileWriter (java.io.FileWriter)1 Writer (java.io.Writer)1 Ignore (org.junit.Ignore)1