diff --git a/classlib/src/main/java/org/teavm/classlib/java/lang/TClass.java b/classlib/src/main/java/org/teavm/classlib/java/lang/TClass.java index 8aa91e7e5..d5bf22ead 100644 --- a/classlib/src/main/java/org/teavm/classlib/java/lang/TClass.java +++ b/classlib/src/main/java/org/teavm/classlib/java/lang/TClass.java @@ -15,6 +15,7 @@ */ package org.teavm.classlib.java.lang; +import java.io.InputStream; import java.util.HashMap; import java.util.Map; @@ -266,4 +267,8 @@ public class TClass extends TObject implements TAnnotatedElement { annotationsByType.put((TClass) (Object) annot.annotationType(), annot); } } + + public InputStream getResourceAsStream(String name) { + throw new IllegalStateException("Cannot read resource " + name); + } } diff --git a/html4j/src/test/java/org/teavm/html4j/test/JavaScriptBodyTest.java b/html4j/src/test/java/org/teavm/html4j/test/JavaScriptBodyTest.java index 02ebb9e75..9c3f679f4 100644 --- a/html4j/src/test/java/org/teavm/html4j/test/JavaScriptBodyTest.java +++ b/html4j/src/test/java/org/teavm/html4j/test/JavaScriptBodyTest.java @@ -15,9 +15,14 @@ */ package org.teavm.html4j.test; +import java.io.BufferedReader; +import java.io.IOException; +import java.io.InputStream; +import java.io.InputStreamReader; import static org.junit.Assert.assertEquals; import java.util.Calendar; import net.java.html.js.JavaScriptBody; +import static org.junit.Assert.assertNotNull; import org.junit.Test; /** @@ -25,6 +30,16 @@ import org.junit.Test; * @author Alexey Andreev */ public class JavaScriptBodyTest { + @Test + public void readResource() throws IOException { + InputStream is = JavaScriptBodyTest.class.getResourceAsStream("jvm.txt"); + assertNotNull("Resource jvm.txt found", is); + try (BufferedReader r = new BufferedReader(new InputStreamReader(is))) { + String line = r.readLine(); + assertEquals("Line read", "TeaVM", line); + } + } + @Test public void javaScriptBodyHandled() { assertEquals(23, simpleNativeMethod()); diff --git a/html4j/src/test/resources/org/teavm/html4j/test/jvm.txt b/html4j/src/test/resources/org/teavm/html4j/test/jvm.txt new file mode 100644 index 000000000..6d8fe9182 --- /dev/null +++ b/html4j/src/test/resources/org/teavm/html4j/test/jvm.txt @@ -0,0 +1 @@ +TeaVM