refactor
This commit is contained in:
coderfengyun 2014-04-09 14:02:00 +08:00
parent 8b2b7c1c89
commit c588495dd9
5 changed files with 11 additions and 16 deletions

View File

@ -9,4 +9,7 @@ import java.lang.annotation.Target;
@Retention(RetentionPolicy.RUNTIME) @Retention(RetentionPolicy.RUNTIME)
public @interface Plugin { public @interface Plugin {
String value(); String value();
public static @interface Constructor {
}
} }

View File

@ -14,6 +14,9 @@ import org.bench4q.agent.utils.Type.SupportTypes;
@Plugin("Hbase") @Plugin("Hbase")
public class HBasePlugin { public class HBasePlugin {
public HBasePlugin() {
}
@Behavior("Send") @Behavior("Send")
public ElectReturn send( public ElectReturn send(
@Parameter(value = "beginTime", type = SupportTypes.Field) String beginTime, @Parameter(value = "beginTime", type = SupportTypes.Field) String beginTime,

View File

@ -32,6 +32,7 @@ import org.apache.commons.httpclient.methods.StringRequestEntity;
import org.bench4q.agent.plugin.Behavior; import org.bench4q.agent.plugin.Behavior;
import org.bench4q.agent.plugin.Parameter; import org.bench4q.agent.plugin.Parameter;
import org.bench4q.agent.plugin.Plugin; import org.bench4q.agent.plugin.Plugin;
import org.bench4q.agent.plugin.Plugin.Constructor;
import org.bench4q.agent.utils.ParameterParser; import org.bench4q.agent.utils.ParameterParser;
import org.bench4q.agent.utils.Type.SupportTypes; import org.bench4q.agent.utils.Type.SupportTypes;
import org.bench4q.agent.utils.types.Table; import org.bench4q.agent.utils.types.Table;
@ -48,6 +49,7 @@ public class HttpPlugin {
this.httpClient = httpClient; this.httpClient = httpClient;
} }
@Constructor
public HttpPlugin() { public HttpPlugin() {
this.setHttpClient(new HttpClient()); this.setHttpClient(new HttpClient());
} }
@ -58,18 +60,6 @@ public class HttpPlugin {
for (NameValuePair nv : nvPairs) { for (NameValuePair nv : nvPairs) {
method.addRequestHeader(nv.getName(), nv.getValue()); method.addRequestHeader(nv.getName(), nv.getValue());
} }
// // New add
// String cookieValue = "";
// for (Cookie cookie :
// this.getHttpClient().getState().getCookies()) {
// if (!cookieValue.isEmpty()) {
// cookieValue += ";";
// }
// cookieValue += cookie.getName() + "=" + cookie.getValue();
// }
// if (!cookieValue.isEmpty()) {
// method.addRequestHeader("Cookie", cookieValue);
// }
} }
} }

View File

@ -33,7 +33,7 @@ public class ScenarioContext {
private DataCollector dataStatistics; private DataCollector dataStatistics;
private ParameterizationManager parameterizationManager; private ParameterizationManager parameterizationManager;
private UUID getTestId() { public UUID getTestId() {
return testId; return testId;
} }

View File

@ -12,7 +12,7 @@ public class Table extends Type {
public static class Row { public static class Row {
private List<String> cells = new ArrayList<String>(); private List<String> cells = new ArrayList<String>();
private List<String> getCells() { public List<String> getCells() {
return cells; return cells;
} }
@ -69,12 +69,12 @@ public class Table extends Type {
public static Table buildTable(String value, public static Table buildTable(String value,
List<String> columnLablesInSequence) { List<String> columnLablesInSequence) {
Table result = new Table(); Table result = new Table();
result.setColumnLables(columnLablesInSequence);
List<List<String>> realContent = buildTableContent(value); List<List<String>> realContent = buildTableContent(value);
result.setRealContent(realContent); result.setRealContent(realContent);
for (List<String> tableRow : realContent) { for (List<String> tableRow : realContent) {
result.getRows().add(new Row(tableRow)); result.getRows().add(new Row(tableRow));
} }
result.setColumnLables(columnLablesInSequence);
return result; return result;
} }
@ -133,7 +133,6 @@ public class Table extends Type {
*/ */
private static void arrangeTableWithRowSeparatorTail(List<String> values) { private static void arrangeTableWithRowSeparatorTail(List<String> values) {
for (int i = 0; i < values.size(); i++) { for (int i = 0; i < values.size(); i++) {
String currentToken = values.get(i); String currentToken = values.get(i);
if (currentToken.equals(Table.ROW_SEPARATOR_TAIL) && i > 0) { if (currentToken.equals(Table.ROW_SEPARATOR_TAIL) && i > 0) {
values.set(i - 1, values.get(i - 1) + Table.ROW_SEPARATOR_TAIL); values.set(i - 1, values.get(i - 1) + Table.ROW_SEPARATOR_TAIL);