summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'tests/org.eclipse.jet.tests/src/org/eclipse/jet/tests/compiler/TestJET2Parser.java')
-rw-r--r--tests/org.eclipse.jet.tests/src/org/eclipse/jet/tests/compiler/TestJET2Parser.java25
1 files changed, 4 insertions, 21 deletions
diff --git a/tests/org.eclipse.jet.tests/src/org/eclipse/jet/tests/compiler/TestJET2Parser.java b/tests/org.eclipse.jet.tests/src/org/eclipse/jet/tests/compiler/TestJET2Parser.java
index 200bfde..a18ced4 100644
--- a/tests/org.eclipse.jet.tests/src/org/eclipse/jet/tests/compiler/TestJET2Parser.java
+++ b/tests/org.eclipse.jet.tests/src/org/eclipse/jet/tests/compiler/TestJET2Parser.java
@@ -6,17 +6,11 @@ import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import java.net.MalformedURLException;
-import java.net.URL;
-import java.nio.CharBuffer;
-import java.nio.MappedByteBuffer;
-import java.nio.channels.FileChannel;
-import java.nio.charset.Charset;
import java.util.Iterator;
import java.util.Map;
import junit.framework.TestCase;
-import org.eclipse.core.runtime.Platform;
import org.eclipse.jet.compiler.Comment;
import org.eclipse.jet.compiler.JET2ASTVisitor;
import org.eclipse.jet.compiler.JET2CompilationUnit;
@@ -29,6 +23,7 @@ import org.eclipse.jet.compiler.TextElement;
import org.eclipse.jet.compiler.XMLBodyElement;
import org.eclipse.jet.compiler.XMLEmptyElement;
import org.eclipse.jet.internal.compiler.templates.JET2JavaGenerator;
+import org.eclipse.jet.tests.FileUtils;
public class TestJET2Parser extends TestCase {
@@ -188,20 +183,8 @@ public class TestJET2Parser extends TestCase {
}
- private String getFileContents(String urlString) throws Exception {
- FileInputStream inputStream = getFileContentsAsStream(urlString);
- FileChannel channel = inputStream.getChannel();
- MappedByteBuffer mapBuffer = channel.map(FileChannel.MapMode.READ_ONLY, 0, channel.size());
- Charset utf8Decoder = Charset.forName("UTF-8");
- CharBuffer charBuffer = utf8Decoder.decode(mapBuffer);
- String contents = charBuffer.toString();
- channel.close();
- inputStream.close();
- return contents;
- }
-
private FileInputStream getFileContentsAsStream(String urlString) throws IOException, MalformedURLException, FileNotFoundException {
- String fileName = Platform.resolve(new URL(urlString)).getFile();
+ String fileName = FileUtils.resolveURLToLocationString(urlString);
FileInputStream inputStream = new FileInputStream(new File(fileName));
return inputStream;
}
@@ -220,7 +203,7 @@ public class TestJET2Parser extends TestCase {
DumpAST astDumper = new DumpAST();
cu.accept(astDumper);
- assertEquals(getFileContents(urlString + ".astdump.expected"), astDumper.getLog());
+ assertEquals(FileUtils.getFileContents(urlString + ".astdump.expected", true), astDumper.getLog());
}
@@ -238,7 +221,7 @@ public class TestJET2Parser extends TestCase {
cu.setOutputJavaClassName("X");
String result = writer.generate(cu);
- assertEquals(getFileContents(urlString + ".expected.java"), result);
+ assertEquals(FileUtils.getFileContents(urlString + ".expected.java", true), result);
}