Last active
August 29, 2015 14:16
-
-
Save bassosimone/b3e30821472e9307b38b to your computer and use it in GitHub Desktop.
Possible abstract API for running libight tests in Java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package io.github.libight.api; | |
class GenericTest { | |
public native GenericTest(Map<String, String> settings); | |
public native void begin(); | |
public native void end(); | |
public void on_test_done() { | |
/* TODO: override */ | |
} | |
public void on_report_sent() { | |
/* TODO: override */ | |
} | |
} | |
class LibIght { | |
public static native void break_loop(); | |
public static native void loop(); | |
}; | |
// FIXME: What is missing is a way to know the progress status | |
// Maybe we can add a callback called progress? | |
/// Usage: | |
import io.github.libight.api.GenericTest; | |
import io.github.libight.api.LibIght; | |
class Foo extends GenericTest { | |
GenericTest(Map<String, String> settings) { | |
super(settings); | |
} | |
public void on_test_done() { | |
end(); | |
} | |
public void on_report_sent() { | |
LibIght.break_loop(); | |
} | |
}; | |
Map<String, String> settings = new HashMap<>(); | |
settings.put("nameserver", "8.8.8.8"); | |
settings.put("input_filepath", "/foo/bar"); | |
settings.put("test_name", "ooni/dns_injection"); | |
Foo foo = Foo(settings); | |
foo.begin(); | |
LibIght.loop(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment