01: package org.jzonic.webtester.commands;
02:
03: import org.jzonic.webtester.WebTestContext;
04:
05: /**
06: * This command will get the content from a HTML page.
07: * The url can contain properties
08: * <br/>
09: * parameter: the url
10: * <br/>
11: * examples:
12: * <br/>
13: * get_html | http://localhost:8080/myapp/welcome.page
14: * <br/>
15: * get_html | ${base_url}/myapp/welcome.page
16: *
17: * @author Mecky
18: */
19: public class GetHtmlCommand implements WebTestNode {
20:
21: public static final String COMMAND_NAME = "get_html";
22: private String url;
23:
24: public void setParameter(String value) {
25: url = value;
26: }
27:
28: public WebTestNodeResult execute(WebTestContext context) {
29: WebTestNodeResult result = new WebTestNodeResult(COMMAND_NAME,
30: url);
31: try {
32: context.getContent(context.replaceVar(context
33: .getUrlPrefix()
34: + url));
35: result.setSuccess(true);
36: } catch (Exception e) {
37: result.setSuccess(false);
38: result.setException(e);
39: }
40: return result;
41: }
42:
43: public String getName() {
44: return COMMAND_NAME;
45: }
46:
47: }
|