1 18 19 package org.apache.jmeter.protocol.http.util.accesslog; 20 21 import java.io.File ; 22 import java.io.FileWriter ; 23 import java.io.FileOutputStream ; 24 import java.io.IOException ; 25 import java.io.OutputStream ; 26 import java.io.Serializable ; 27 import org.apache.jmeter.protocol.http.sampler.HTTPSampler; 28 29 56 57 public class StandardGenerator implements Generator, Serializable { 58 59 protected HTTPSampler SAMPLE = null; 60 transient protected FileWriter WRITER = null; 61 transient protected OutputStream OUTPUT = null; 62 protected String FILENAME = null; 63 protected File FILE = null; 64 67 71 public StandardGenerator() { 72 super(); 73 init(); 74 } 75 76 80 public StandardGenerator(String file){ 81 FILENAME = file; 82 init(); 83 } 84 85 95 protected void init(){ 96 generateRequest(); 97 } 98 99 102 protected void initStream(){ 103 try { 104 this.OUTPUT = new FileOutputStream (FILE); 105 } catch (IOException exception){ 106 } 108 } 109 110 113 public void close() { 114 try { 115 if (OUTPUT != null){ 116 OUTPUT.close(); 117 } 118 if (WRITER != null){ 119 WRITER.close(); 120 } 121 } catch (IOException exception){ 122 } 123 } 124 125 128 public void setHost(String host) { 129 SAMPLE.setDomain(host); 130 } 131 132 135 public void setLabel(String label) { 136 137 } 138 139 142 public void setMethod(String post_get) { 143 SAMPLE.setMethod(post_get); 144 } 145 146 149 public void setParams(NVPair[] params) { 150 for (int idx=0; idx < params.length; idx++){ 151 SAMPLE.addArgument(params[idx].getName(),params[idx].getValue()); 152 } 153 } 154 155 158 public void setPath(String path) { 159 SAMPLE.setPath(path); 160 } 161 162 165 public void setPort(int port) { 166 SAMPLE.setPort(port); 167 } 168 169 172 public void setQueryString(String querystring) { 173 SAMPLE.parseArguments(querystring); 174 } 175 176 179 public void setSourceLogs(String sourcefile) { 180 } 181 182 185 public void setTarget(Object target) { 186 } 187 188 191 public Object generateRequest() { 192 try { 193 SAMPLE = new HTTPSampler(); 194 } catch (NullPointerException e){ 195 e.printStackTrace(); 196 } 197 return SAMPLE; 198 } 199 200 204 public void save(){ 205 try { 206 } catch (Exception exception){ 212 } 213 } 214 215 218 public void reset(){ 219 SAMPLE = null; 220 generateRequest(); 221 } 222 223 } 225 | Popular Tags |