01: package org.jzonic.webtester.commands;
02:
03: import org.jzonic.webtester.WebTestContext;
04:
05: /**
06: * This command will save the proxy settings and everytime get_html
07: * is called the connection will use the proxy server. If the parameter
08: * does not contain the : the system will use port 80 as default
09: * <br/>
10: * parameter: proxyHost:proxyPort
11: * <br/>
12: * examples:
13: * <br/>
14: * set_proxy | 10.100.12.14:8080
15: * <br/>
16: * set_proxy | 10.100.12.14
17: *
18: * @author Mecky
19: */
20: public class SetProxyCommand implements WebTestNode {
21:
22: public static final String COMMAND_NAME = "set_proxy";
23: private String proxyString;
24:
25: public void setParameter(String value) {
26: proxyString = value;
27: }
28:
29: public WebTestNodeResult execute(WebTestContext context) {
30: WebTestNodeResult result = new WebTestNodeResult(COMMAND_NAME,
31: proxyString);
32: if (proxyString.indexOf(":") != -1) {
33: String host = proxyString.substring(0, proxyString
34: .indexOf(":"));
35: String pport = proxyString.substring(proxyString
36: .indexOf(":") + 1);
37: int port = Integer.parseInt(pport);
38: context.setProxyHost(host);
39: context.setProxyPort(port);
40: } else {
41: context.setProxyHost(proxyString);
42: context.setProxyPort(80);
43: }
44: result.setSuccess(true);
45: return result;
46: }
47:
48: public String getName() {
49: return COMMAND_NAME;
50: }
51:
52: }
|