author | sundar |
Tue, 12 Mar 2013 18:12:42 +0530 | |
changeset 16522 | d643e3ee819c |
parent 16243 | f5fdf89e1583 |
permissions | -rw-r--r-- |
16243
f5fdf89e1583
8008305: ScriptEngine.eval should offer the ability to provide a codebase
sundar
parents:
diff
changeset
|
1 |
/** |
f5fdf89e1583
8008305: ScriptEngine.eval should offer the ability to provide a codebase
sundar
parents:
diff
changeset
|
2 |
* JDK-8008305: ScriptEngine.eval should offer the ability to provide a codebase |
f5fdf89e1583
8008305: ScriptEngine.eval should offer the ability to provide a codebase
sundar
parents:
diff
changeset
|
3 |
* |
f5fdf89e1583
8008305: ScriptEngine.eval should offer the ability to provide a codebase
sundar
parents:
diff
changeset
|
4 |
* @test |
f5fdf89e1583
8008305: ScriptEngine.eval should offer the ability to provide a codebase
sundar
parents:
diff
changeset
|
5 |
* @run |
f5fdf89e1583
8008305: ScriptEngine.eval should offer the ability to provide a codebase
sundar
parents:
diff
changeset
|
6 |
*/ |
f5fdf89e1583
8008305: ScriptEngine.eval should offer the ability to provide a codebase
sundar
parents:
diff
changeset
|
7 |
|
f5fdf89e1583
8008305: ScriptEngine.eval should offer the ability to provide a codebase
sundar
parents:
diff
changeset
|
8 |
var URLReader = Java.type("jdk.nashorn.api.scripting.URLReader"); |
f5fdf89e1583
8008305: ScriptEngine.eval should offer the ability to provide a codebase
sundar
parents:
diff
changeset
|
9 |
var URL = Java.type("java.net.URL"); |
f5fdf89e1583
8008305: ScriptEngine.eval should offer the ability to provide a codebase
sundar
parents:
diff
changeset
|
10 |
var File = Java.type("java.io.File"); |
f5fdf89e1583
8008305: ScriptEngine.eval should offer the ability to provide a codebase
sundar
parents:
diff
changeset
|
11 |
var JString = Java.type("java.lang.String"); |
16522 | 12 |
var SourceHelper = Java.type("jdk.nashorn.test.models.SourceHelper"); |
16243
f5fdf89e1583
8008305: ScriptEngine.eval should offer the ability to provide a codebase
sundar
parents:
diff
changeset
|
13 |
|
f5fdf89e1583
8008305: ScriptEngine.eval should offer the ability to provide a codebase
sundar
parents:
diff
changeset
|
14 |
var url = new File(__FILE__).toURI().toURL(); |
f5fdf89e1583
8008305: ScriptEngine.eval should offer the ability to provide a codebase
sundar
parents:
diff
changeset
|
15 |
var reader = new URLReader(url); |
f5fdf89e1583
8008305: ScriptEngine.eval should offer the ability to provide a codebase
sundar
parents:
diff
changeset
|
16 |
|
f5fdf89e1583
8008305: ScriptEngine.eval should offer the ability to provide a codebase
sundar
parents:
diff
changeset
|
17 |
// check URLReader.getURL() method |
f5fdf89e1583
8008305: ScriptEngine.eval should offer the ability to provide a codebase
sundar
parents:
diff
changeset
|
18 |
//Assert.assertEquals(url, reader.getURL()); |
f5fdf89e1583
8008305: ScriptEngine.eval should offer the ability to provide a codebase
sundar
parents:
diff
changeset
|
19 |
|
f5fdf89e1583
8008305: ScriptEngine.eval should offer the ability to provide a codebase
sundar
parents:
diff
changeset
|
20 |
// check URL read |
f5fdf89e1583
8008305: ScriptEngine.eval should offer the ability to provide a codebase
sundar
parents:
diff
changeset
|
21 |
// read URL content by directly reading from URL |
16522 | 22 |
var str = SourceHelper.readFully(url); |
16243
f5fdf89e1583
8008305: ScriptEngine.eval should offer the ability to provide a codebase
sundar
parents:
diff
changeset
|
23 |
// read URL content via URLReader |
16522 | 24 |
var content = new JString(SourceHelper.readFully(reader)); |
16243
f5fdf89e1583
8008305: ScriptEngine.eval should offer the ability to provide a codebase
sundar
parents:
diff
changeset
|
25 |
|
f5fdf89e1583
8008305: ScriptEngine.eval should offer the ability to provide a codebase
sundar
parents:
diff
changeset
|
26 |
// assert that the content is same |
f5fdf89e1583
8008305: ScriptEngine.eval should offer the ability to provide a codebase
sundar
parents:
diff
changeset
|
27 |
Assert.assertEquals(str, content); |