- Timestamp:
- 09/30/11 17:36:08 (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/EventBenchConsole/src/de/ugoe/cs/eventbench/web/data/WebRequest.java
r171 r225 9 9 * <p> 10 10 * Contains all information related to a web request, i.e., the path, the POST 11 * variables and the GET variables. 11 * variables and the GET variables. The generated replay are for the command 12 * line tool {@code curl}. The requests do not contain correct values for the 13 * POST and GET request. Instead, only the parameters that are part of the 14 * requests are added and the values of the parameters are 15 * DATA_$PARAMNAME$_DATA, where $PARAMNAME$ is the upper case string of the 16 * parameter name. This allows test data generators to insert concrete values, 17 * as EventBench does not include a test data generator for web software. 12 18 * </p> 13 19 * … … 47 53 /** 48 54 * <p> 55 * URL of the server. 56 * </p> 57 */ 58 String serverUrl; 59 60 /** 61 * <p> 49 62 * Constructor. Creates a new WebRequest. 50 63 * </p> … … 57 70 * GET variables of the request 58 71 */ 59 public WebRequest(String uri, List<String> postVars, List<String> getVars) { 72 public WebRequest(String url, String uri, List<String> postVars, 73 List<String> getVars) { 74 serverUrl = url; 60 75 targetUri = uri; 61 76 this.postVars = new ArrayList<String>(postVars); // defensive copy … … 70 85 @Override 71 86 public String getReplay() { 72 // TODO implement method 73 return null; 87 StringBuilder builder = new StringBuilder(); 88 builder.append("curl"); 89 if (!postVars.isEmpty()) { 90 boolean isFirstPost = true; 91 for (String postVar : postVars) { 92 if (isFirstPost) { 93 builder.append(" --data \""); 94 isFirstPost = false; 95 } else { 96 builder.append("&"); 97 } 98 builder.append(postVar + "=DATA_" + postVar.toUpperCase() 99 + "_DATA"); 100 } 101 builder.append("\""); 102 } 103 builder.append(" "); 104 if (serverUrl != null) { 105 builder.append(serverUrl); 106 } 107 builder.append(targetUri); 108 if (!getVars.isEmpty()) { 109 boolean isFirstGet = true; 110 for (String getVar : getVars) { 111 if (isFirstGet) { 112 builder.append("?"); 113 isFirstGet = false; 114 } else { 115 builder.append("&"); 116 } 117 builder.append(getVar + "=DATA_" + getVar.toUpperCase() 118 + "_DATA"); 119 } 120 } 121 return builder.toString(); 74 122 } 75 123 … … 81 129 @Override 82 130 public String getTarget() { 83 // TODO implement method 84 return null; 131 return targetUri; 85 132 } 86 133
Note: See TracChangeset
for help on using the changeset viewer.