equal
deleted
inserted
replaced
|
1 /** |
|
2 * JDK-8008305: ScriptEngine.eval should offer the ability to provide a codebase |
|
3 * |
|
4 * @test |
|
5 * @run |
|
6 */ |
|
7 |
|
8 var URLReader = Java.type("jdk.nashorn.api.scripting.URLReader"); |
|
9 var URL = Java.type("java.net.URL"); |
|
10 var File = Java.type("java.io.File"); |
|
11 var JString = Java.type("java.lang.String"); |
|
12 var Source = Java.type("jdk.nashorn.internal.runtime.Source"); |
|
13 |
|
14 var url = new File(__FILE__).toURI().toURL(); |
|
15 var reader = new URLReader(url); |
|
16 |
|
17 // check URLReader.getURL() method |
|
18 //Assert.assertEquals(url, reader.getURL()); |
|
19 |
|
20 // check URL read |
|
21 // read URL content by directly reading from URL |
|
22 var str = new Source(url.toString(), url).getString(); |
|
23 // read URL content via URLReader |
|
24 var content = new JString(Source.readFully(reader)); |
|
25 |
|
26 // assert that the content is same |
|
27 Assert.assertEquals(str, content); |