public class printlntest {
@Test
public void test() {
GroovyShell shell = new GroovyShell();
URL url = getClass().getClassLoader().getResource("println.groovy");
String file = url.getFile();
System.out.println("file: " + file);
try {
shell.evaluate(url.toURI());
} catch (Exception e) {
e.printStackTrace();
}
}
@Test
public void test2() {
GroovyShell shell = new GroovyShell();
URL url = getClass().getClassLoader().getResource("println2.groovy");
String file = url.getFile();
System.out.println("file: " + file);
try {
shell.evaluate(url.toURI());
} catch (Exception e) {
e.printStackTrace();
}
}
@Test
public void test3() {
ScriptEngineManager manager = new ScriptEngineManager();
ScriptEngine engine = manager.getEngineByName("groovy");
URL url = getClass().getClassLoader().getResource("println.groovy");
String file = url.getFile();
System.out.println("file: " + file);
Reader reader = null;
try {
reader = new InputStreamReader(url.openStream());
} catch (IOException e) {
e.printStackTrace();
}
try {
engine.eval(reader);
} catch (ScriptException e) {
e.printStackTrace();
}
}
@Test
public void test4() {
ScriptEngineManager manager = new ScriptEngineManager();
ScriptEngine engine = manager.getEngineByName("groovy");
URL url = getClass().getClassLoader().getResource("println2.groovy");
String file = url.getFile();
System.out.println("file: " + file);
Reader reader = null;
try {
reader = new InputStreamReader(url.openStream());
} catch (IOException e) {
e.printStackTrace();
}
try {
engine.eval(reader);
} catch (ScriptException e) {
e.printStackTrace();
}
}
@Test
public void test5() {
GroovyShell shell = new GroovyShell();
URL url = getClass().getClassLoader().getResource("fn.groovy");
String file = url.getFile();
System.out.println("file: " + file);
try {
Script script = shell.parse(url.toURI());
script.invokeMethod("debug", null);
} catch (Exception e) {
e.printStackTrace();
}
}
@Test
public void test6() {
GroovyShell shell = new GroovyShell();
URL url = getClass().getClassLoader().getResource("fn2.groovy");
String file = url.getFile();
System.out.println("file: " + file);
try {
Script script = shell.parse(url.toURI());
script.invokeMethod("debug", null);
} catch (Exception e) {
e.printStackTrace();
}
}
}
package com;
public class Greet {
public void println() {
System.out.println("greet!");
}
}
println.groovy
println('greet!');
println2.groovy
import com.Greet
Greet greet = new Greet();
greet.println();
fn.groovy
def debug() {
println('greet!');
}
fn2.groovy
import com.Greet
def debug() {
Greet greet = new Greet();
greet.println();
}
@Test
public void test() {
GroovyShell shell = new GroovyShell();
URL url = getClass().getClassLoader().getResource("println.groovy");
String file = url.getFile();
System.out.println("file: " + file);
try {
shell.evaluate(url.toURI());
} catch (Exception e) {
e.printStackTrace();
}
}
@Test
public void test2() {
GroovyShell shell = new GroovyShell();
URL url = getClass().getClassLoader().getResource("println2.groovy");
String file = url.getFile();
System.out.println("file: " + file);
try {
shell.evaluate(url.toURI());
} catch (Exception e) {
e.printStackTrace();
}
}
@Test
public void test3() {
ScriptEngineManager manager = new ScriptEngineManager();
ScriptEngine engine = manager.getEngineByName("groovy");
URL url = getClass().getClassLoader().getResource("println.groovy");
String file = url.getFile();
System.out.println("file: " + file);
Reader reader = null;
try {
reader = new InputStreamReader(url.openStream());
} catch (IOException e) {
e.printStackTrace();
}
try {
engine.eval(reader);
} catch (ScriptException e) {
e.printStackTrace();
}
}
@Test
public void test4() {
ScriptEngineManager manager = new ScriptEngineManager();
ScriptEngine engine = manager.getEngineByName("groovy");
URL url = getClass().getClassLoader().getResource("println2.groovy");
String file = url.getFile();
System.out.println("file: " + file);
Reader reader = null;
try {
reader = new InputStreamReader(url.openStream());
} catch (IOException e) {
e.printStackTrace();
}
try {
engine.eval(reader);
} catch (ScriptException e) {
e.printStackTrace();
}
}
@Test
public void test5() {
GroovyShell shell = new GroovyShell();
URL url = getClass().getClassLoader().getResource("fn.groovy");
String file = url.getFile();
System.out.println("file: " + file);
try {
Script script = shell.parse(url.toURI());
script.invokeMethod("debug", null);
} catch (Exception e) {
e.printStackTrace();
}
}
@Test
public void test6() {
GroovyShell shell = new GroovyShell();
URL url = getClass().getClassLoader().getResource("fn2.groovy");
String file = url.getFile();
System.out.println("file: " + file);
try {
Script script = shell.parse(url.toURI());
script.invokeMethod("debug", null);
} catch (Exception e) {
e.printStackTrace();
}
}
}
package com;
public class Greet {
public void println() {
System.out.println("greet!");
}
}
println.groovy
println('greet!');
println2.groovy
import com.Greet
Greet greet = new Greet();
greet.println();
fn.groovy
def debug() {
println('greet!');
}
fn2.groovy
import com.Greet
def debug() {
Greet greet = new Greet();
greet.println();
}