add type info to Annotation @Parameter
add type info to Annotation @Parameter
This commit is contained in:
parent
bbeae6ffb6
commit
82be07d484
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,66 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
||||||
|
<runScenario>
|
||||||
|
<pages>
|
||||||
|
<page>
|
||||||
|
<batches>
|
||||||
|
<batch>
|
||||||
|
<behaviors>
|
||||||
|
<behaviorModel>
|
||||||
|
<id>0</id>
|
||||||
|
<name>Get</name>
|
||||||
|
<parameters>
|
||||||
|
<parameter>
|
||||||
|
<key>url</key>
|
||||||
|
<value>
|
||||||
|
http://www.baidu.com
|
||||||
|
</value>
|
||||||
|
</parameter>
|
||||||
|
<parameter>
|
||||||
|
<key>parameters</key>
|
||||||
|
<value></value>
|
||||||
|
</parameter>
|
||||||
|
</parameters>
|
||||||
|
<type>USERBEHAVIOR</type>
|
||||||
|
<use>http</use>
|
||||||
|
</behaviorModel>
|
||||||
|
</behaviors>
|
||||||
|
<childId>2</childId>
|
||||||
|
<id>0</id>
|
||||||
|
<parentId>-1</parentId>
|
||||||
|
</batch>
|
||||||
|
<batch>
|
||||||
|
<behaviors>
|
||||||
|
<behaviorModel>
|
||||||
|
<id>0</id>
|
||||||
|
<name>Sleep</name>
|
||||||
|
<parameters>
|
||||||
|
<parameter>
|
||||||
|
<key>time</key>
|
||||||
|
<value>230</value>
|
||||||
|
</parameter>
|
||||||
|
</parameters>
|
||||||
|
<type>TIMERBEHAVIOR</type>
|
||||||
|
<use>timer</use>
|
||||||
|
</behaviorModel>
|
||||||
|
</behaviors>
|
||||||
|
<childId>-1</childId>
|
||||||
|
<id>1</id>
|
||||||
|
<parentId>-1</parentId>
|
||||||
|
</batch>
|
||||||
|
</batches>
|
||||||
|
</page>
|
||||||
|
</pages>
|
||||||
|
<poolSize>0</poolSize>
|
||||||
|
<usePlugins>
|
||||||
|
<usePlugin>
|
||||||
|
<id>http</id>
|
||||||
|
<name>Http</name>
|
||||||
|
<parameters />
|
||||||
|
</usePlugin>
|
||||||
|
<usePlugin>
|
||||||
|
<id>timer</id>
|
||||||
|
<name>ConstantTimer</name>
|
||||||
|
<parameters />
|
||||||
|
</usePlugin>
|
||||||
|
</usePlugins>
|
||||||
|
</runScenario>
|
|
@ -5,8 +5,12 @@ import java.lang.annotation.Retention;
|
||||||
import java.lang.annotation.RetentionPolicy;
|
import java.lang.annotation.RetentionPolicy;
|
||||||
import java.lang.annotation.Target;
|
import java.lang.annotation.Target;
|
||||||
|
|
||||||
|
import org.bench4q.agent.scenario.util.Type.SupportTypes;
|
||||||
|
|
||||||
@Target(ElementType.PARAMETER)
|
@Target(ElementType.PARAMETER)
|
||||||
@Retention(RetentionPolicy.RUNTIME)
|
@Retention(RetentionPolicy.RUNTIME)
|
||||||
public @interface Parameter {
|
public @interface Parameter {
|
||||||
String value();
|
String value();
|
||||||
|
|
||||||
|
SupportTypes type();
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,6 +7,7 @@ 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.result.CommandLineReturn;
|
import org.bench4q.agent.plugin.result.CommandLineReturn;
|
||||||
|
import org.bench4q.agent.scenario.util.Type.SupportTypes;
|
||||||
|
|
||||||
@Plugin("CommandLine")
|
@Plugin("CommandLine")
|
||||||
public class CommandLinePlugin {
|
public class CommandLinePlugin {
|
||||||
|
@ -34,7 +35,8 @@ public class CommandLinePlugin {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Behavior("Command")
|
@Behavior("Command")
|
||||||
public CommandLineReturn command(@Parameter("command") String command) {
|
public CommandLineReturn command(
|
||||||
|
@Parameter(value = "command", type = SupportTypes.Field) String command) {
|
||||||
try {
|
try {
|
||||||
final Process process = Runtime.getRuntime().exec(command);
|
final Process process = Runtime.getRuntime().exec(command);
|
||||||
new Thread() {
|
new Thread() {
|
||||||
|
|
|
@ -5,6 +5,7 @@ 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.result.TimerReturn;
|
import org.bench4q.agent.plugin.result.TimerReturn;
|
||||||
|
import org.bench4q.agent.scenario.util.Type.SupportTypes;
|
||||||
|
|
||||||
@Plugin("ConstantTimer")
|
@Plugin("ConstantTimer")
|
||||||
public class ConstantTimerPlugin {
|
public class ConstantTimerPlugin {
|
||||||
|
@ -15,7 +16,8 @@ public class ConstantTimerPlugin {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Behavior("Sleep")
|
@Behavior("Sleep")
|
||||||
public TimerReturn sleep(@Parameter("time") int time) {
|
public TimerReturn sleep(
|
||||||
|
@Parameter(value = "time", type = SupportTypes.Field) int time) {
|
||||||
try {
|
try {
|
||||||
Thread.sleep(time);
|
Thread.sleep(time);
|
||||||
return new TimerReturn(true);
|
return new TimerReturn(true);
|
||||||
|
|
|
@ -4,6 +4,7 @@ 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.result.LogReturn;
|
import org.bench4q.agent.plugin.result.LogReturn;
|
||||||
|
import org.bench4q.agent.scenario.util.Type.SupportTypes;
|
||||||
|
|
||||||
@Plugin("Log")
|
@Plugin("Log")
|
||||||
public class LogPlugin {
|
public class LogPlugin {
|
||||||
|
@ -12,7 +13,8 @@ public class LogPlugin {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Behavior("Log")
|
@Behavior("Log")
|
||||||
public LogReturn log(@Parameter("message") String message) {
|
public LogReturn log(
|
||||||
|
@Parameter(value = "message", type = SupportTypes.Field) String message) {
|
||||||
System.out.println(message);
|
System.out.println(message);
|
||||||
return new LogReturn(true);
|
return new LogReturn(true);
|
||||||
}
|
}
|
||||||
|
|
|
@ -34,6 +34,7 @@ import org.bench4q.agent.plugin.Parameter;
|
||||||
import org.bench4q.agent.plugin.Plugin;
|
import org.bench4q.agent.plugin.Plugin;
|
||||||
import org.bench4q.agent.plugin.result.HttpReturn;
|
import org.bench4q.agent.plugin.result.HttpReturn;
|
||||||
import org.bench4q.agent.scenario.util.ParameterParser;
|
import org.bench4q.agent.scenario.util.ParameterParser;
|
||||||
|
import org.bench4q.agent.scenario.util.Type.SupportTypes;
|
||||||
import org.bench4q.agent.scenario.util.types.Table;
|
import org.bench4q.agent.scenario.util.types.Table;
|
||||||
|
|
||||||
@Plugin("Http")
|
@Plugin("Http")
|
||||||
|
@ -128,10 +129,11 @@ public class HttpPlugin {
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
@Behavior("Get")
|
@Behavior("Get")
|
||||||
public HttpReturn get(@Parameter("url") String url,
|
public HttpReturn get(
|
||||||
@Parameter("queryParams") String queryParams,
|
@Parameter(value = "url", type = SupportTypes.Field) String url,
|
||||||
@Parameter("headers") String headers,
|
@Parameter(value = "queryParams", type = SupportTypes.NField) String queryParams,
|
||||||
@Parameter("respVarsToSaveInSession") String respVarsToSaveInSession) {
|
@Parameter(value = "headers", type = SupportTypes.Table) String headers,
|
||||||
|
@Parameter(value = "respVarsToSaveInSession", type = SupportTypes.Table) String respVarsToSaveInSession) {
|
||||||
|
|
||||||
GetMethod method = new GetMethod(completeUri(url));
|
GetMethod method = new GetMethod(completeUri(url));
|
||||||
if (isValid(queryParams)) {
|
if (isValid(queryParams)) {
|
||||||
|
@ -252,12 +254,13 @@ public class HttpPlugin {
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
@Behavior("Post")
|
@Behavior("Post")
|
||||||
public HttpReturn post(@Parameter("url") String url,
|
public HttpReturn post(
|
||||||
@Parameter("queryParams") String queryParams,
|
@Parameter(value = "url", type = SupportTypes.Field) String url,
|
||||||
@Parameter("headers") String headers,
|
@Parameter(value = "queryParams", type = SupportTypes.NField) String queryParams,
|
||||||
@Parameter("bodyContent") String bodyContent,
|
@Parameter(value = "headers", type = SupportTypes.Table) String headers,
|
||||||
@Parameter("bodyparameters") String bodyParams,
|
@Parameter(value = "bodyContent", type = SupportTypes.Field) String bodyContent,
|
||||||
@Parameter("respVarsToSaveInSession") String respVarToSaveInSession) {
|
@Parameter(value = "bodyparameters", type = SupportTypes.NField) String bodyParams,
|
||||||
|
@Parameter(value = "respVarsToSaveInSession", type = SupportTypes.Table) String respVarToSaveInSession) {
|
||||||
PostMethod method = new PostMethod(completeUri(url));
|
PostMethod method = new PostMethod(completeUri(url));
|
||||||
setHeaders(method, headers);
|
setHeaders(method, headers);
|
||||||
if (isValid(queryParams)) {
|
if (isValid(queryParams)) {
|
||||||
|
@ -297,12 +300,13 @@ public class HttpPlugin {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Behavior("Put")
|
@Behavior("Put")
|
||||||
public HttpReturn put(@Parameter("url") String url,
|
public HttpReturn put(
|
||||||
@Parameter("queryParams") String queryParams,
|
@Parameter(value = "url", type = SupportTypes.Field) String url,
|
||||||
@Parameter("headers") String headers,
|
@Parameter(value = "queryParams", type = SupportTypes.NField) String queryParams,
|
||||||
@Parameter("bodyContent") String bodyContent,
|
@Parameter(value = "headers", type = SupportTypes.Table) String headers,
|
||||||
@Parameter("bodyparameters") String bodyParams,
|
@Parameter(value = "bodyContent", type = SupportTypes.Field) String bodyContent,
|
||||||
@Parameter("respVarsToSaveInSession") String respVarToSaveInSession) {
|
@Parameter(value = "bodyparameters", type = SupportTypes.NField) String bodyParams,
|
||||||
|
@Parameter(value = "respVarsToSaveInSession", type = SupportTypes.Table) String respVarToSaveInSession) {
|
||||||
PutMethod method = new PutMethod(completeUri(url));
|
PutMethod method = new PutMethod(completeUri(url));
|
||||||
setHeaders(method, headers);
|
setHeaders(method, headers);
|
||||||
if (isValid(queryParams)) {
|
if (isValid(queryParams)) {
|
||||||
|
@ -323,10 +327,11 @@ public class HttpPlugin {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Behavior("Delete")
|
@Behavior("Delete")
|
||||||
public HttpReturn delete(@Parameter("url") String url,
|
public HttpReturn delete(
|
||||||
@Parameter("queryParams") String queryParams,
|
@Parameter(value = "url", type = SupportTypes.Field) String url,
|
||||||
@Parameter("headers") String headers,
|
@Parameter(value = "queryParams", type = SupportTypes.NField) String queryParams,
|
||||||
@Parameter("respVarsToSaveInSession") String respVarToSaveInSession) {
|
@Parameter(value = "headers", type = SupportTypes.Table) String headers,
|
||||||
|
@Parameter(value = "respVarsToSaveInSession", type = SupportTypes.Table) String respVarToSaveInSession) {
|
||||||
DeleteMethod method = new DeleteMethod(completeUri(url));
|
DeleteMethod method = new DeleteMethod(completeUri(url));
|
||||||
setHeaders(method, headers);
|
setHeaders(method, headers);
|
||||||
if (isValid(queryParams)) {
|
if (isValid(queryParams)) {
|
||||||
|
|
|
@ -1,5 +1,8 @@
|
||||||
package org.bench4q.agent.scenario.util;
|
package org.bench4q.agent.scenario.util;
|
||||||
|
|
||||||
public class Type {
|
public class Type {
|
||||||
|
public static enum SupportTypes {
|
||||||
|
Field, NField, Table, Radio, CheckBox
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,5 @@
|
||||||
|
package org.bench4q.agent.scenario.util.types;
|
||||||
|
|
||||||
|
public class CheckBox {
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,5 @@
|
||||||
|
package org.bench4q.agent.scenario.util.types;
|
||||||
|
|
||||||
|
public class NField {
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,5 @@
|
||||||
|
package org.bench4q.agent.scenario.util.types;
|
||||||
|
|
||||||
|
public class Radio {
|
||||||
|
|
||||||
|
}
|
Loading…
Reference in New Issue