Revision 44389 trunk/org.gvsig.desktop/org.gvsig.desktop.library/org.gvsig.expressionevaluator/org.gvsig.expressionevaluator.lib/org.gvsig.expressionevaluator.lib.impl/src/test/java/org/gvsig/expresionevaluator/impl/TestScript1.java
TestScript1.java | ||
---|---|---|
7 | 7 |
import org.gvsig.expressionevaluator.Expression; |
8 | 8 |
import org.gvsig.expressionevaluator.ExpressionEvaluatorLocator; |
9 | 9 |
import org.gvsig.expressionevaluator.ExpressionEvaluatorManager; |
10 |
import org.gvsig.expressionevaluator.impl.javascripting.CosaScriptEngineFactory; |
|
10 | 11 |
import org.gvsig.tools.library.impl.DefaultLibrariesInitializer; |
11 | 12 |
import org.gvsig.tools.script.Script; |
12 | 13 |
|
... | ... | |
37 | 38 |
Object r; |
38 | 39 |
Script sc; |
39 | 40 |
try { |
40 |
sc = manager.createScript("test1", source, "COSA");
|
|
41 |
} catch(Exception ex) { |
|
41 |
sc = manager.createScript("test1", source, CosaScriptEngineFactory.LANGUAGE_NAME);
|
|
42 |
} catch (Exception ex) {
|
|
42 | 43 |
System.err.println(ex.getMessage()); |
43 | 44 |
throw ex; |
44 | 45 |
} |
... | ... | |
57 | 58 |
Object r; |
58 | 59 |
Script sc; |
59 | 60 |
try { |
60 |
sc = manager.createScript("test2", source, "COSA");
|
|
61 |
} catch(Exception ex) { |
|
61 |
sc = manager.createScript("test2", source, CosaScriptEngineFactory.LANGUAGE_NAME);
|
|
62 |
} catch (Exception ex) {
|
|
62 | 63 |
System.err.println(ex.getMessage()); |
63 | 64 |
throw ex; |
64 | 65 |
} |
... | ... | |
67 | 68 |
|
68 | 69 |
r = sc.invokeFunction("test2", null); |
69 | 70 |
assertEquals(" hola adios fin", r); |
70 |
|
|
71 |
|
|
72 |
} |
|
73 |
|
|
74 |
public void testScript3() throws Exception { |
|
75 |
InputStream is = this.getClass().getResource("/org/gvsig/expressionevaluator/impl/TestScript1_2.txt").openStream(); |
|
76 |
String source = StringUtils.join(IOUtils.readLines(is), "\n"); |
|
77 |
ExpressionEvaluatorManager manager = ExpressionEvaluatorLocator.getManager(); |
|
78 |
|
|
79 |
Object r; |
|
80 |
Script sc; |
|
81 |
try { |
|
82 |
sc = manager.createScript("test3", source, CosaScriptEngineFactory.LANGUAGE_NAME); |
|
83 |
} catch (Exception ex) { |
|
84 |
System.err.println(ex.getMessage()); |
|
85 |
throw ex; |
|
71 | 86 |
} |
87 |
r = sc.invokeFunction("test3", null); |
|
88 |
assertEquals("Hola amigos", r); |
|
89 |
|
|
90 |
r = sc.invokeFunction("saluda", new Object[] { "pato" }); |
|
91 |
assertEquals("Hola pato", r); |
|
92 |
|
|
93 |
} |
|
94 |
|
|
72 | 95 |
} |
Also available in: Unified diff