Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

请教如果传参是ENUM类型如何处理 #34

Closed
ribrib1234 opened this issue Nov 15, 2018 · 10 comments
Closed

请教如果传参是ENUM类型如何处理 #34

ribrib1234 opened this issue Nov 15, 2018 · 10 comments
Labels
type/bug Something isn't working

Comments

@ribrib1234
Copy link

测试过程中使用到的枚举类代码如下:
public enum SubscribeChannelType {

WE_CHAT(2), MOBILE_APP(5);

private int code;

SubscribeChannelType(int code) {
	this.code = code;
}

public int getCode() {
	return code;
}

public void setValue(int code) {
	this.code = code;
}

public static SubscribeChannelType convert(int value) {
	SubscribeChannelType result = null;
	for (SubscribeChannelType item : SubscribeChannelType.values()) {
		if (item.getCode() == value) {
			result = item;
			break;
		}
	}
	return result;
}

}

@zhuofengxichen
Copy link

你这边能用起来吗

@ribrib1234
Copy link
Author

我这边枚举类型用不起来,正常的简单类型、复杂类型可以

@ningyu1
Copy link
Collaborator

ningyu1 commented Nov 16, 2018

感谢你们的提问,我会针对枚举类型看一下的,我会把处理结果发出来

@ribrib1234
Copy link
Author

好的,谢谢处理

@ningyu1
Copy link
Collaborator

ningyu1 commented Nov 19, 2018

@ribrib1234 @zhuofengxichen
目前测试下来有两种方式可以解决:

  1. 不升级插件版本的情况下,将接口的api jar包加入jmeter classpath下可以正常的使用枚举参数
    ps. 枚举参数的传递方式例如:paramType:com.xxx.SubscribeChannelType,paramValue:WE_CHAT
    ps. api jar包加入jmeter classpath下有两种方式,第一种将jar包放入JMETER_HOME/ext/lib目录下,第二种在jmeter ui上添加入下图所示
    image

  2. 新版本的插件推崇的就是不使用api jar的方式即可调用接口,想要不使用api jar包来支持自定义枚举参数的需要等待下一个版本的插件升级,后面我会升级一个小版本[bugfix]来特殊处理一下枚举参数

@ningyu1 ningyu1 added the type/bug Something isn't working label Nov 21, 2018
@ribrib1234
Copy link
Author

引入JAR的方式可以解决目前的需求,期待下次的版本更新

@ningyu1
Copy link
Collaborator

ningyu1 commented Nov 22, 2018

@ribrib1234 就这几天刚好和其他几个问题一起修改后发布

@ningyu1
Copy link
Collaborator

ningyu1 commented Dec 18, 2018

V1.3.8

@ningyu1 ningyu1 closed this as completed Dec 18, 2018
@mawenlong3
Copy link

引入JAR的方式可以解决目前的需求,期待下次的版本更新

请问一下 这个问题怎么解决的,我也同样引入了jar包,但是枚举类型的数据在json里面怎么写都不能用

@ningyu1
Copy link
Collaborator

ningyu1 commented Mar 5, 2020

@mawenlong3 枚举就当做字符串传递就可以了

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type/bug Something isn't working
Projects
None yet
Development

No branches or pull requests

4 participants