diff options
author | Olivier Thomann | 2006-12-13 02:38:28 +0000 |
---|---|---|
committer | Olivier Thomann | 2006-12-13 02:38:28 +0000 |
commit | 07f026e6ad41bdbf0421f23e277d69b140cb4de0 (patch) | |
tree | 4c61cc05a55863059b3b2fc2940d622f497ad9a8 /org.eclipse.jdt.compiler.tool.tests | |
parent | b8315251ffb02e48cefcddb514a7641a6c9516c4 (diff) | |
download | eclipse.jdt.core-07f026e6ad41bdbf0421f23e277d69b140cb4de0.tar.gz eclipse.jdt.core-07f026e6ad41bdbf0421f23e277d69b140cb4de0.tar.xz eclipse.jdt.core-07f026e6ad41bdbf0421f23e277d69b140cb4de0.zip |
*** empty log message ***
Diffstat (limited to 'org.eclipse.jdt.compiler.tool.tests')
-rw-r--r-- | org.eclipse.jdt.compiler.tool.tests/src/org/eclipse/jdt/compiler/tool/tests/CompilerToolTests.java | 50 |
1 files changed, 49 insertions, 1 deletions
diff --git a/org.eclipse.jdt.compiler.tool.tests/src/org/eclipse/jdt/compiler/tool/tests/CompilerToolTests.java b/org.eclipse.jdt.compiler.tool.tests/src/org/eclipse/jdt/compiler/tool/tests/CompilerToolTests.java index 9f5ddb53bb..0c9929ff2d 100644 --- a/org.eclipse.jdt.compiler.tool.tests/src/org/eclipse/jdt/compiler/tool/tests/CompilerToolTests.java +++ b/org.eclipse.jdt.compiler.tool.tests/src/org/eclipse/jdt/compiler/tool/tests/CompilerToolTests.java @@ -36,7 +36,7 @@ import javax.tools.JavaFileObject.Kind; import junit.framework.TestCase; import junit.framework.TestSuite; -import org.eclipse.jdt.compiler.tool.EclipseCompiler; +import org.eclipse.jdt.internal.compiler.tool.EclipseCompiler; public class CompilerToolTests extends TestCase { public CompilerToolTests(String name) { @@ -51,6 +51,7 @@ public class CompilerToolTests extends TestCase { suite.addTest(new CompilerToolTests("testCompilerOneClassWithEclipseCompiler")); suite.addTest(new CompilerToolTests("testCompilerOneClassWithEclipseCompiler2")); suite.addTest(new CompilerToolTests("testCompilerOneClassWithEclipseCompiler3")); + suite.addTest(new CompilerToolTests("testCompilerOneClassWithEclipseCompiler4")); suite.addTest(new CompilerToolTests("testCleanUp")); return suite; } @@ -506,6 +507,53 @@ public class CompilerToolTests extends TestCase { assertTrue("delete failed", inputFile.delete()); } + public void testCompilerOneClassWithEclipseCompiler4() { + String tmpFolder = System.getProperty("java.io.tmpdir"); + File inputFile = new File(tmpFolder, "X.java"); + BufferedWriter writer = null; + try { + writer = new BufferedWriter(new FileWriter(inputFile)); + writer.write( + "package p;\n" + + "public class X {}"); + writer.flush(); + writer.close(); + } catch (IOException e) { + // ignore + } finally { + if (writer != null) { + try { + writer.close(); + } catch (IOException e) { + // ignore + } + } + } + // create new list containing inputfile + List<File> files = new ArrayList<File>(); + files.add(inputFile); + JavaCompiler systemCompiler = ToolProvider.getSystemJavaCompiler(); + StandardJavaFileManager manager = systemCompiler.getStandardFileManager(null, Locale.getDefault(), Charset.defaultCharset()); + Iterable<? extends JavaFileObject> units = manager.getJavaFileObjectsFromFiles(files); + StringWriter stringWriter = new StringWriter(); + PrintWriter printWriter = new PrintWriter(stringWriter); + + List<String> options = new ArrayList<String>(); + options.add("-d"); + options.add(tmpFolder); + CompilationTask task = Compiler.getTask(null, null, null, options, null, units); + // check the classpath location + Boolean result = task.call(); + printWriter.flush(); + printWriter.close(); + if (!result.booleanValue()) { + System.err.println("Compilation failed: " + stringWriter.getBuffer().toString()); + assertTrue("Compilation failed ", false); + } + // check that the .class file exist for X + assertTrue("delete failed", inputFile.delete()); + } + /* * Clean up the compiler */ |