mirror of
https://github.com/servalproject/serval-dna.git
synced 2025-02-20 17:33:08 +00:00
Add another JNI command-line interface test
This commit is contained in:
parent
6c044d5e8d
commit
219e863999
38
java/org/servalproject/servald/ServalDTests.java
Normal file
38
java/org/servalproject/servald/ServalDTests.java
Normal file
@ -0,0 +1,38 @@
|
||||
package org.servalproject.servald;
|
||||
|
||||
import java.lang.reflect.*;
|
||||
import java.util.Arrays;
|
||||
import org.servalproject.servald.ServalD;
|
||||
import org.servalproject.servald.ServalDResult;
|
||||
|
||||
class ServalDTests
|
||||
{
|
||||
public static void main(String[] args)
|
||||
{
|
||||
try {
|
||||
Class cls = new Object() { }.getClass().getEnclosingClass();
|
||||
Method m = cls.getMethod(args[0], String[].class);
|
||||
m.invoke(null, (Object) Arrays.copyOfRange(args, 1, args.length));
|
||||
}
|
||||
catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
System.exit(1);
|
||||
}
|
||||
System.exit(0);
|
||||
}
|
||||
|
||||
public static void repeat(String[] args)
|
||||
{
|
||||
int repeat = Integer.decode(args[0]);
|
||||
ServalD sdi = new ServalD();
|
||||
for (int i = 0; i != repeat; ++i) {
|
||||
ServalDResult res = sdi.command(Arrays.copyOfRange(args, 1, args.length));
|
||||
System.out.print(res.status);
|
||||
for (String s: res.outv) {
|
||||
System.out.print(":");
|
||||
System.out.print(s);
|
||||
}
|
||||
System.out.println("");
|
||||
}
|
||||
}
|
||||
}
|
@ -36,6 +36,7 @@ compile_java_classes() {
|
||||
assert [ -r classes/org/servalproject/servald/ServalD.class ]
|
||||
assert [ -r classes/org/servalproject/servald/ServalDResult.class ]
|
||||
assert [ -r classes/org/servalproject/servald/ServalDReentranceError.class ]
|
||||
assert [ -r classes/org/servalproject/servald/ServalDTests.class ]
|
||||
}
|
||||
|
||||
# Make sure that the normal echo command-line works, without JNI.
|
||||
@ -61,5 +62,11 @@ test_Delim() {
|
||||
assertStdoutIs 'Hello,:::world!:::'
|
||||
}
|
||||
|
||||
runTests "$@"
|
||||
doc_Repeat="Serval JNI repeated calls in same process"
|
||||
test_Repeat() {
|
||||
executeOk java -classpath "$PWD/classes" org.servalproject.servald.ServalDTests repeat 50 echo 'Hello,' 'world!'
|
||||
assertStdoutLineCount '==' 50
|
||||
assertStdoutGrep --matches=50 '^0:Hello,:world!$'
|
||||
}
|
||||
|
||||
runTests "$@"
|
||||
|
Loading…
x
Reference in New Issue
Block a user