This commit is contained in:
chenjianxing 2020-05-21 14:42:34 +08:00
commit 18b4250dbf
7 changed files with 40 additions and 43 deletions

View File

@ -85,6 +85,7 @@ public interface ParamConstants {
this.value = value; this.value = value;
} }
} }
public static enum MAIL { public static enum MAIL {
HOST("meter.host", 1), HOST("meter.host", 1),
PORT("meter.port", 2), PORT("meter.port", 2),

View File

@ -16,10 +16,12 @@ import java.util.List;
public class SystemParameterController { public class SystemParameterController {
@Resource @Resource
private SystemParameterService SystemParameterService; private SystemParameterService SystemParameterService;
@PostMapping("/edit/email") @PostMapping("/edit/email")
public void editMail(@RequestBody List<SystemParameter> SystemParameter){ public void editMail(@RequestBody List<SystemParameter> systemParameter) {
SystemParameterService.editMail(SystemParameter); SystemParameterService.editMail(systemParameter);
} }
@PostMapping("/testConnection") @PostMapping("/testConnection")
public void testConnection(@RequestBody HashMap<String, String> hashMap) { public void testConnection(@RequestBody HashMap<String, String> hashMap) {
SystemParameterService.testConnection(hashMap); SystemParameterService.testConnection(hashMap);

View File

@ -9,6 +9,7 @@ import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang3.BooleanUtils; import org.apache.commons.lang3.BooleanUtils;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Properties; import java.util.Properties;
@ -16,7 +17,6 @@ import java.util.Properties;
import org.springframework.mail.javamail.JavaMailSenderImpl; import org.springframework.mail.javamail.JavaMailSenderImpl;
import javax.annotation.Resource; import javax.annotation.Resource;
@ -39,6 +39,7 @@ public class SystemParameterService {
} }
return result; return result;
} }
public void editMail(List<SystemParameter> parameters) { public void editMail(List<SystemParameter> parameters) {
List<SystemParameter> paramList = this.getParamList(ParamConstants.Classify.MAIL.getValue()); List<SystemParameter> paramList = this.getParamList(ParamConstants.Classify.MAIL.getValue());
boolean empty = paramList.size() < 2; boolean empty = paramList.size() < 2;
@ -54,6 +55,7 @@ public class SystemParameterService {
} }
}); });
} }
public List<SystemParameter> getParamList(String type) { public List<SystemParameter> getParamList(String type) {
SystemParameterExample example = new SystemParameterExample(); SystemParameterExample example = new SystemParameterExample();
example.createCriteria().andParamKeyLike(type + "%"); example.createCriteria().andParamKeyLike(type + "%");

View File

@ -75,9 +75,9 @@
let parameters = []; let parameters = [];
let url = new URL(this.addProtocol(this.request.url)); let url = new URL(this.addProtocol(this.request.url));
url.searchParams.forEach(function (key, value) { url.searchParams.forEach((value, key) => {
if (key && value) { if (key && value) {
parameters.push(new KeyValue({name: key, value: value})); parameters.push(new KeyValue(key, value));
} }
}); });
// //

View File

@ -279,7 +279,7 @@ export class HTTPSamplerArguments extends Element {
let collectionProp = this.collectionProp('Arguments.arguments'); let collectionProp = this.collectionProp('Arguments.arguments');
this.args.forEach(arg => { this.args.forEach(arg => {
let elementProp = collectionProp.elementProp(arg.name, 'HTTPArgument'); let elementProp = collectionProp.elementProp(arg.name, 'HTTPArgument');
elementProp.boolProp('HTTPArgument.always_encode', arg.encode || false); elementProp.boolProp('HTTPArgument.always_encode', arg.encode || true);
elementProp.boolProp('HTTPArgument.use_equals', arg.equals || true); elementProp.boolProp('HTTPArgument.use_equals', arg.equals || true);
if (arg.name) { if (arg.name) {
elementProp.stringProp('Argument.name', arg.name); elementProp.stringProp('Argument.name', arg.name);

View File

@ -456,7 +456,7 @@ class JMXGenerator {
} }
addScenarioVariables(threadGroup, scenario) { addScenarioVariables(threadGroup, scenario) {
let args = scenario.variables.filter(this.filter) let args = this.replaceKV(scenario.variables);
if (args.length > 0) { if (args.length > 0) {
let name = scenario.name + " Variables" let name = scenario.name + " Variables"
threadGroup.put(new Arguments(name, args)); threadGroup.put(new Arguments(name, args));
@ -464,7 +464,7 @@ class JMXGenerator {
} }
addScenarioHeaders(threadGroup, scenario) { addScenarioHeaders(threadGroup, scenario) {
let headers = scenario.headers.filter(this.filter) let headers = this.replaceKV(scenario.headers);
if (headers.length > 0) { if (headers.length > 0) {
let name = scenario.name + " Headers" let name = scenario.name + " Headers"
threadGroup.put(new HeaderManager(name, headers)); threadGroup.put(new HeaderManager(name, headers));
@ -473,14 +473,14 @@ class JMXGenerator {
addRequestHeader(httpSamplerProxy, request) { addRequestHeader(httpSamplerProxy, request) {
let name = request.name + " Headers"; let name = request.name + " Headers";
let headers = request.headers.filter(this.filter); let headers = this.replaceKV(request.headers);
if (headers.length > 0) { if (headers.length > 0) {
httpSamplerProxy.put(new HeaderManager(name, headers)); httpSamplerProxy.put(new HeaderManager(name, headers));
} }
} }
addRequestArguments(httpSamplerProxy, request) { addRequestArguments(httpSamplerProxy, request) {
let args = request.parameters.filter(this.filter) let args = this.replaceKV(request.parameters);
if (args.length > 0) { if (args.length > 0) {
httpSamplerProxy.add(new HTTPSamplerArguments(args)); httpSamplerProxy.add(new HTTPSamplerArguments(args));
} }
@ -514,7 +514,7 @@ class JMXGenerator {
getAssertion(regex) { getAssertion(regex) {
let name = regex.description; let name = regex.description;
let type = JMX_ASSERTION_CONDITION.CONTAINS; // 固定用Match自己写正则 let type = JMX_ASSERTION_CONDITION.CONTAINS; // 固定用Match自己写正则
let value = regex.expression; let value = this.replace(regex.expression);
switch (regex.subject) { switch (regex.subject) {
case ASSERTION_REGEX_SUBJECT.RESPONSE_CODE: case ASSERTION_REGEX_SUBJECT.RESPONSE_CODE:
return new ResponseCodeAssertion(name, type, value); return new ResponseCodeAssertion(name, type, value);
@ -577,6 +577,20 @@ class JMXGenerator {
return config.isValid(); return config.isValid();
} }
replace(str) {
return str.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/'/g, "&apos;").replace(/"/g, "&quot;");
}
replaceKV(kvs) {
let results = [];
kvs.filter(this.filter).forEach(kv => {
let name = this.replace(kv.name);
let value = this.replace(kv.value);
results.push(new KeyValue(name, value));
});
return results;
}
toXML() { toXML() {
let xml = '<?xml version="1.0" encoding="UTF-8"?>\n'; let xml = '<?xml version="1.0" encoding="UTF-8"?>\n';
xml += this.jmeterTestPlan.toXML(); xml += this.jmeterTestPlan.toXML();

View File

@ -12,7 +12,7 @@
<el-form-item :label="$t('system_parameter_setting.SMTP_host')" prop="host"> <el-form-item :label="$t('system_parameter_setting.SMTP_host')" prop="host">
</el-form-item> </el-form-item>
<el-input v-model="formInline.host" :placeholder="$t('system_parameter_setting.SMTP_host')" <el-input v-model="formInline.host" :placeholder="$t('system_parameter_setting.SMTP_host')"
v-on:input="host('host')"></el-input> v-on:input="change()"></el-input>
</el-col> </el-col>
</el-row> </el-row>
<el-row> <el-row>
@ -20,7 +20,7 @@
<el-form-item :label="$t('system_parameter_setting.SMTP_port')" prop="port"> <el-form-item :label="$t('system_parameter_setting.SMTP_port')" prop="port">
</el-form-item> </el-form-item>
<el-input v-model="formInline.port" :placeholder="$t('system_parameter_setting.SMTP_port')" <el-input v-model="formInline.port" :placeholder="$t('system_parameter_setting.SMTP_port')"
v-on:input="port('port')"></el-input> v-on:input="change()"></el-input>
</el-col> </el-col>
</el-row> </el-row>
<el-row> <el-row>
@ -28,7 +28,7 @@
<el-form-item :label="$t('system_parameter_setting.SMTP_account')" prop="account"> <el-form-item :label="$t('system_parameter_setting.SMTP_account')" prop="account">
</el-form-item> </el-form-item>
<el-input v-model="formInline.account" :placeholder="$t('system_parameter_setting.SMTP_account')" <el-input v-model="formInline.account" :placeholder="$t('system_parameter_setting.SMTP_account')"
v-on:input="account('account')"></el-input> v-on:input="change()"></el-input>
</el-col> </el-col>
</el-row> </el-row>
<el-row> <el-row>
@ -94,7 +94,7 @@
host: [ host: [
{ {
required: true, required: true,
message: this.$t('commons.host_cannot_be_empty') message: ''
}, },
], ],
port: [ port: [
@ -114,30 +114,8 @@
methods: { methods: {
host() { change() {
let host = this.formInline.host; if (!this.formInline.host || !this.formInline.port || !this.formInline.account) {
if (!host) {
this.disabledConnection = true;
this.disabledSave = true;
} else {
this.disabledConnection = false;
this.disabledSave = false;
}
},
port() {
let port = this.formInline.port;
if (!port) {
this.disabledConnection = true;
this.disabledSave = true;
} else {
this.disabledConnection = false;
this.disabledSave = false;
}
},
account() {
let account = this.formInline.account;
if (!account) {
this.disabledConnection = true; this.disabledConnection = true;
this.disabledSave = true; this.disabledSave = true;
} else { } else {