forked from micw/php-java-bridge
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSimpleCompileable.java
More file actions
31 lines (25 loc) · 804 Bytes
/
Copy pathSimpleCompileable.java
File metadata and controls
31 lines (25 loc) · 804 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
package php.java.test;
import javax.script.Compilable;
import javax.script.CompiledScript;
import javax.script.ScriptEngineManager;
import junit.framework.TestCase;
public class SimpleCompileable extends TestCase {
private CompiledScript script;
public SimpleCompileable(String name) {
super(name);
}
protected void setUp() throws Exception {
super.setUp();
script =((Compilable)(new ScriptEngineManager().getEngineByName("php"))).compile(
"<?php echo 'Hello '.java_context()->get('hello').'!'; ?>");
}
protected void tearDown() throws Exception {
super.tearDown();
}
public void test() throws Exception {
script.getEngine().put("hello", "world!");
script.eval();
script.getEngine().put("hello", String.valueOf(this));
script.eval();
}
}