1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package net.grinderscript.dotnet.scriptengine;
18
19 import grinderscript.net.core.IGrinderTest;
20 import net.grinder.script.Grinder.ScriptContext;
21 import net.grinder.script.InvalidContextException;
22
23 import org.slf4j.Logger;
24 import org.slf4j.LoggerFactory;
25
26 public class DotNetTestBridge implements IGrinderTest {
27
28 private final Logger logger = LoggerFactory
29 .getLogger(DotNetTestBridge.class);
30
31 private final IGrinderTest testAction;
32 private final ScriptContext scriptContext;
33
34 public DotNetTestBridge(ScriptContext scriptContext, IGrinderTest testAction) {
35 logger.trace("ctor: Enter, scriptContext = {}, testAction = {}", scriptContext, testAction);
36 this.scriptContext = scriptContext;
37 this.testAction = testAction;
38 logger.trace("ctor: Exit");
39 }
40
41 @Override
42 public void Run() {
43 logger.trace("run: Enter");
44 try {
45 testAction.Run();
46 } catch (system.Exception clrEx) {
47 try {
48 scriptContext.getStatistics().getForCurrentTest()
49 .setSuccess(false);
50 } catch (InvalidContextException e) {
51 throw new DotNetCheckedExceptionMarshall(e);
52 }
53 }
54 logger.trace("run: Exit");
55 }
56
57 IGrinderTest getTestAction() {
58 return testAction;
59 }
60
61 ScriptContext getScriptContext() {
62 return scriptContext;
63 }
64 }