Simple test to show expected behavior of resources

This commit is contained in:
Jaroslav Tulach 2015-12-24 06:46:37 +01:00
parent 1889560c78
commit 4aec89967b
3 changed files with 21 additions and 0 deletions

View File

@ -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<T> extends TObject implements TAnnotatedElement {
annotationsByType.put((TClass<?>) (Object) annot.annotationType(), annot);
}
}
public InputStream getResourceAsStream(String name) {
throw new IllegalStateException("Cannot read resource " + name);
}
}

View File

@ -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());

View File

@ -0,0 +1 @@
TeaVM