Created
January 16, 2012 19:09
-
-
Save kvalle/1622421 to your computer and use it in GitHub Desktop.
Mininimal example of setup for writing Grinder test scripts 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
java_test_runner = my.java.package.MyTestRunner | |
grinder.script = grinder.py | |
grinder.runs = 10 | |
grinder.threads = 2 | |
# etc |
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
from net.grinder.plugin.http import HTTPRequest | |
from net.grinder.script.Grinder import grinder | |
def load_class(class_name): | |
m = __import__(class_name) | |
for comp in class_name.split('.')[1:]: | |
m = getattr(m, comp) | |
return m | |
test_runner = load_class(grinder.getProperties().getProperty('java_test_runner')) | |
class TestRunner: | |
def __init__(self): | |
self.runner = test_runner(HTTPRequest()) | |
def __call__(self): | |
self.runner.call() |
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 my.java.package; | |
import net.grinder.plugin.http.HTTPRequest; | |
import net.grinder.script.NotWrappableTypeException; | |
import net.grinder.script.Test; | |
public class MyTestRunner { | |
private HTTPRequest test; | |
public JavaTestRunner(HTTPRequest req) throws NotWrappableTypeException { | |
this.test = (HTTPRequest) new Test(100, "http test").wrap(req); | |
} | |
public void call() throws Exception { | |
this.test.GET("http://google.com"); | |
this.test.GET("http://nytimes.com"); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment