1 19 20 package com.sslexplorer.httpunit; 21 22 import java.util.Collection ; 23 import java.util.Collections ; 24 import java.util.HashMap ; 25 import java.util.HashSet ; 26 import java.util.Map ; 27 import java.util.Set ; 28 29 31 public final class HttpTestEntryStep { 32 static final String POST = "post"; 33 static final String GET = "get"; 34 35 private String name; 36 private boolean isPost; 37 private String url; 38 private int expectedCode = 200; 39 private String redirectUrl; 40 private final Map <String , String > parameters; 41 private final Set <String > errors; 42 private final Set <String > messages; 43 44 46 public HttpTestEntryStep() { 47 parameters = new HashMap <String , String >(); 48 messages = new HashSet <String >(); 49 errors = new HashSet <String >(); 50 } 51 52 55 String getName() { 56 return name; 57 } 58 59 62 public void setName(String name) { 63 this.name = name; 64 } 65 66 69 boolean isPost() { 70 return isPost; 71 } 72 73 76 public void setMethod(String method) { 77 isPost = method == null || method.equals(GET) ? false : true; 78 } 79 80 83 String getUrl() { 84 return url; 85 } 86 87 90 public void setUrl(String url) { 91 this.url = url; 92 } 93 94 97 int getExpectedCode() { 98 return expectedCode; 99 } 100 101 104 public void setExpectedCode(int expectedCode) { 105 this.expectedCode = expectedCode; 106 } 107 108 111 public String getRedirectUrl() { 112 return redirectUrl; 113 } 114 115 118 public void setRedirectUrl(String redirectUrl) { 119 this.redirectUrl = redirectUrl; 120 } 121 122 125 Map <String , String > getParameters() { 126 return Collections.unmodifiableMap(parameters); 127 } 128 129 132 public void addParameter(Parameter parameter) { 133 parameters.put(parameter.getKey(), parameter.getValue()); 134 } 135 138 Collection <String > getErrors() { 139 return Collections.unmodifiableSet(errors); 140 } 141 142 145 public void addError(Value message) { 146 String realMessage = message.getValue(); 147 if (realMessage != null) 148 errors.add(realMessage); 149 } 150 151 154 Collection <String > getMessages() { 155 return Collections.unmodifiableSet(messages); 156 } 157 158 161 public void addMessage(Value message) { 162 String realMessage = message.getValue(); 163 if (realMessage != null) 164 messages.add(realMessage); 165 } 166 167 @Override 168 public String toString() { 169 StringBuffer buffer = new StringBuffer (); 170 buffer.append("Name='").append(name).append("' "); 171 buffer.append("IsPort='").append(isPost).append("' "); 172 buffer.append("Url='").append(url).append("' "); 173 buffer.append("ExpectedCode='").append(expectedCode).append("' "); 174 buffer.append("RedirectUrl='").append(redirectUrl).append("' "); 175 buffer.append("Parameters='").append(parameters).append("' "); 176 buffer.append("Errors='").append(errors).append("' "); 177 buffer.append("Messages='").append(messages).append("'"); 178 return buffer.toString(); 179 } 180 181 183 public static final class Value { 184 185 private String value; 186 187 190 private String getValue() { 191 return value; 192 } 193 194 197 public void setValue(String value) { 198 this.value = value; 199 } 200 } 201 202 204 public static final class Parameter { 205 private String key; 206 private String value; 207 208 private String getKey() { 209 return key; 210 } 211 212 215 public void setKey(String key) { 216 this.key = key; 217 } 218 219 222 private String getValue() { 223 return value; 224 } 225 226 229 public void setValue(String value) { 230 this.value = value; 231 } 232 } 233 } | Popular Tags |