forked from micw/php-java-bridge
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTestDiscovery.java
More file actions
42 lines (36 loc) · 1.03 KB
/
Copy pathTestDiscovery.java
File metadata and controls
42 lines (36 loc) · 1.03 KB
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
32
33
34
35
36
37
38
39
40
41
42
package php.java.test;
import javax.script.ScriptEngine;
import javax.script.ScriptEngineManager;
import junit.framework.TestCase;
public class TestDiscovery extends TestCase {
public TestDiscovery(String name) {
super(name);
}
protected void setUp() throws Exception {
super.setUp();
}
protected void tearDown() throws Exception {
super.tearDown();
}
public void testDiscovery() {
try {
StringBuffer s = new StringBuffer();
ScriptEngineManager manager = new ScriptEngineManager();
ScriptEngine e = manager.getEngineByName("php");
e.put("hello", new StringBuffer("hello world"));
e.put("s", s);
e.eval("<?php " +
"$s = java_context()->getAttribute('s');" +
"$s->append(java_values(java_context()->getAttribute('hello')));" +
"/*echo java_values($s);*/" +
"java_context()->setAttribute('hello', '!', 100);" +
"?>");
s.append(e.get("hello"));
if(!(s.toString().equals("hello world!"))) {
fail("ERROR");
}
} catch (Exception e) {
fail (String.valueOf(e));
}
}
}