diff --git a/api-test/backend/src/main/java/io/metersphere/api/dto/definition/request/assertions/document/Document.java b/api-test/backend/src/main/java/io/metersphere/api/dto/definition/request/assertions/document/Document.java index 22e90edac8..a821267d54 100644 --- a/api-test/backend/src/main/java/io/metersphere/api/dto/definition/request/assertions/document/Document.java +++ b/api-test/backend/src/main/java/io/metersphere/api/dto/definition/request/assertions/document/Document.java @@ -176,7 +176,7 @@ public class Document { assertion.setExpectNull(false); assertion.setInvert(false); - assertion.setName((StringUtils.isNotEmpty(assertionName) ? assertionName : "DocumentAssertion") + (delimiter + item.getJsonPath() + " " + getConditionStr(item, elementCondition))); + assertion.setName((StringUtils.isNotEmpty(assertionName) ? assertionName : "DocumentAssertion") + (delimiter + item.getJsonPath() + StringUtils.SPACE + getConditionStr(item, elementCondition))); assertion.setProperty(TestElement.TEST_CLASS, JSONPathAssertion.class.getName()); assertion.setProperty(TestElement.GUI_CLASS, SaveService.aliasToClass("JSONPathAssertionGui")); assertion.setJsonPath(item.getJsonPath()); @@ -195,7 +195,7 @@ public class Document { private XMLAssertion newXMLAssertion(DocumentElement item, ElementCondition elementCondition) { XMLAssertion assertion = new XMLAssertion(); assertion.setEnabled(true); - assertion.setName((StringUtils.isNotEmpty(assertionName) ? assertionName : "XMLAssertion") + delimiter + (item.getJsonPath() + " " + getConditionStr(item, elementCondition))); + assertion.setName((StringUtils.isNotEmpty(assertionName) ? assertionName : "XMLAssertion") + delimiter + (item.getJsonPath() + StringUtils.SPACE + getConditionStr(item, elementCondition))); assertion.setProperty(TestElement.TEST_CLASS, XMLAssertion.class.getName()); assertion.setProperty(TestElement.GUI_CLASS, SaveService.aliasToClass("XMLAssertionGui")); assertion.setProperty(PropertyConstant.XML_PATH, item.getJsonPath()); diff --git a/api-test/backend/src/main/java/io/metersphere/api/dto/definition/request/controller/MsIfController.java b/api-test/backend/src/main/java/io/metersphere/api/dto/definition/request/controller/MsIfController.java index 4aa25977fd..0dd4e8d65a 100644 --- a/api-test/backend/src/main/java/io/metersphere/api/dto/definition/request/controller/MsIfController.java +++ b/api-test/backend/src/main/java/io/metersphere/api/dto/definition/request/controller/MsIfController.java @@ -70,9 +70,9 @@ public class MsIfController extends MsTestElement { public String getLabelName() { if (isValid()) { - String label = "条件控制器:" + variable + " " + operator; + String label = "条件控制器:" + variable + StringUtils.SPACE + operator; if (StringUtils.isNotBlank(value)) { - label += " " + this.value; + label += StringUtils.SPACE + this.value; } return label; } diff --git a/api-test/backend/src/main/java/io/metersphere/api/dto/definition/request/controller/MsTransactionController.java b/api-test/backend/src/main/java/io/metersphere/api/dto/definition/request/controller/MsTransactionController.java index de117cc487..a46fd72e2f 100644 --- a/api-test/backend/src/main/java/io/metersphere/api/dto/definition/request/controller/MsTransactionController.java +++ b/api-test/backend/src/main/java/io/metersphere/api/dto/definition/request/controller/MsTransactionController.java @@ -66,7 +66,7 @@ public class MsTransactionController extends MsTestElement { public String getLabelName() { if (isValid()) { - return NAME_CN + " " + this.name; + return NAME_CN + StringUtils.SPACE + this.name; } return NAME_CN; } diff --git a/api-test/backend/src/main/java/io/metersphere/api/dto/definition/request/sampler/MsTCPSampler.java b/api-test/backend/src/main/java/io/metersphere/api/dto/definition/request/sampler/MsTCPSampler.java index b205ddeb58..c9c555173e 100644 --- a/api-test/backend/src/main/java/io/metersphere/api/dto/definition/request/sampler/MsTCPSampler.java +++ b/api-test/backend/src/main/java/io/metersphere/api/dto/definition/request/sampler/MsTCPSampler.java @@ -225,8 +225,8 @@ public class MsTCPSampler extends MsTestElement { if (!isCustomizeReq() && config != null && config.getTcpConfig() != null) { if (!isCustomizeReq() && config != null) { this.server = config.getTcpConfig().getServer(); - this.port = config.getTcpConfig().getPort() + ""; - if (StringUtils.equals(this.eolByte, " ")) { + this.port = config.getTcpConfig().getPort() + StringUtils.EMPTY; + if (StringUtils.equals(this.eolByte, StringUtils.SPACE)) { this.eolByte = ""; } else { if (StringUtils.isEmpty(this.eolByte)) { diff --git a/api-test/backend/src/main/java/io/metersphere/api/exec/engine/KubernetesTestEngine.java b/api-test/backend/src/main/java/io/metersphere/api/exec/engine/KubernetesTestEngine.java index 450a4e492d..84c753d963 100644 --- a/api-test/backend/src/main/java/io/metersphere/api/exec/engine/KubernetesTestEngine.java +++ b/api-test/backend/src/main/java/io/metersphere/api/exec/engine/KubernetesTestEngine.java @@ -12,6 +12,7 @@ import io.metersphere.xpack.resourcepool.engine.provider.ClientCredential; import io.metersphere.xpack.resourcepool.engine.provider.KubernetesProvider; import org.apache.commons.beanutils.ConstructorUtils; import org.apache.commons.collections4.CollectionUtils; +import org.apache.commons.lang3.StringUtils; import org.reflections.Reflections; import java.util.Set; @@ -55,12 +56,12 @@ public class KubernetesTestEngine extends AbstractEngine { .append(JSON.toJSONString(pod.getMetadata())).append(" 】"); LoggerUtil.info(logMsg); // 拼接CURL执行命令 - StringBuffer command = new StringBuffer("curl -H \"Accept: application/json\" -H \"Content-type: application/json\" -X POST -d").append(" "); + StringBuffer command = new StringBuffer("curl -H \"Accept: application/json\" -H \"Content-type: application/json\" -X POST -d").append(StringUtils.SPACE); command.append("'").append(JSON.toJSONString(runRequest)).append("'"); // 请求参数 - command.append(" ").append("--connect-timeout 30"); // 设置连接超时时间为30S - command.append(" ").append("--max-time 120"); // 设置请求超时时间为120S - command.append(" ").append("--retry 3"); // 设置重试次数3次 - command.append(" ").append("http://127.0.0.1:8082/jmeter/api/start"); + command.append(StringUtils.SPACE).append("--connect-timeout 30"); // 设置连接超时时间为30S + command.append(StringUtils.SPACE).append("--max-time 120"); // 设置请求超时时间为120S + command.append(StringUtils.SPACE).append("--retry 3"); // 设置重试次数3次 + command.append(StringUtils.SPACE).append("http://127.0.0.1:8082/jmeter/api/start"); KubernetesApiExec.newExecWatch(client, clientCredential.getNamespace(), pod.getMetadata().getName(), command.toString()); } catch (Exception e) { LoggerUtil.error("当前报告:【" + runRequest.getReportId() + "】资源:【" + runRequest.getTestId() + "】CURL失败:", e); diff --git a/api-test/backend/src/main/java/io/metersphere/api/jmeter/JMeterLoggerAppender.java b/api-test/backend/src/main/java/io/metersphere/api/jmeter/JMeterLoggerAppender.java index 63c8d45340..1e1ae6d012 100644 --- a/api-test/backend/src/main/java/io/metersphere/api/jmeter/JMeterLoggerAppender.java +++ b/api-test/backend/src/main/java/io/metersphere/api/jmeter/JMeterLoggerAppender.java @@ -6,6 +6,7 @@ import ch.qos.logback.core.UnsynchronizedAppenderBase; import io.metersphere.commons.utils.DateUtils; import io.metersphere.commons.utils.LogUtil; import io.metersphere.commons.utils.FixedCapacityUtil; +import org.apache.commons.lang3.StringUtils; public class JMeterLoggerAppender extends UnsynchronizedAppenderBase { @Override @@ -13,9 +14,9 @@ public class JMeterLoggerAppender extends UnsynchronizedAppenderBase 1) { nameListStr = nameListStr.substring(0, nameListStr.length() - 1) + "]"; } - String msg = deleteCaseName + " " + Translator.get("delete_check_reference_by") + ": " + nameListStr + " "; + String msg = deleteCaseName + StringUtils.SPACE + Translator.get("delete_check_reference_by") + ": " + nameListStr + StringUtils.SPACE; checkMsgList.add(msg); } } diff --git a/api-test/backend/src/main/java/io/metersphere/service/scenario/ApiScenarioService.java b/api-test/backend/src/main/java/io/metersphere/service/scenario/ApiScenarioService.java index 2b43cd3cc5..3113eb55b7 100644 --- a/api-test/backend/src/main/java/io/metersphere/service/scenario/ApiScenarioService.java +++ b/api-test/backend/src/main/java/io/metersphere/service/scenario/ApiScenarioService.java @@ -568,7 +568,7 @@ public class ApiScenarioService { } List apiScenarioWithBLOBs = extApiScenarioMapper.listWithRefIds(ids); List scenarioIds = apiScenarioWithBLOBs.stream().map(ApiScenarioWithBLOBs::getId).collect(Collectors.toList()); - Map scenarioIdDefinitionMap = apiScenarioWithBLOBs.stream().collect(Collectors.toMap(ApiScenarioWithBLOBs::getId, scenario -> scenario.getScenarioDefinition() == null ? " " : scenario.getScenarioDefinition())); + Map scenarioIdDefinitionMap = apiScenarioWithBLOBs.stream().collect(Collectors.toMap(ApiScenarioWithBLOBs::getId, scenario -> scenario.getScenarioDefinition() == null ? StringUtils.SPACE : scenario.getScenarioDefinition())); preDelAndResource(scenarioIdDefinitionMap); TestPlanApiScenarioExample example = new TestPlanApiScenarioExample(); @@ -1941,14 +1941,14 @@ public class ApiScenarioService { List scenarioNames = extApiScenarioMapper.selectNameByIdIn(scenarioIdList); if (StringUtils.isNotEmpty(deleteScenarioName) && CollectionUtils.isNotEmpty(scenarioNames)) { - String nameListStr = " "; + String nameListStr = StringUtils.SPACE; for (String name : scenarioNames) { nameListStr += name + ","; } if (nameListStr.length() > 1) { - nameListStr = nameListStr.substring(0, nameListStr.length() - 1) + " "; + nameListStr = nameListStr.substring(0, nameListStr.length() - 1) + StringUtils.SPACE; } - String msg = deleteScenarioName + " " + Translator.get("delete_check_reference_by") + ": " + nameListStr + " "; + String msg = deleteScenarioName + StringUtils.SPACE + Translator.get("delete_check_reference_by") + ": " + nameListStr + StringUtils.SPACE; checkMsgList.add(msg); } } diff --git a/framework/gateway/src/main/java/io/metersphere/gateway/service/LdapService.java b/framework/gateway/src/main/java/io/metersphere/gateway/service/LdapService.java index 7b7465334a..9efa7393ac 100644 --- a/framework/gateway/src/main/java/io/metersphere/gateway/service/LdapService.java +++ b/framework/gateway/src/main/java/io/metersphere/gateway/service/LdapService.java @@ -269,12 +269,12 @@ public class LdapService { String mapAttr = (String) jsonObject.get(attr); if (StringUtils.isBlank(mapAttr)) { - MSException.throwException(Translator.get("check_ldap_mapping") + " " + attr); + MSException.throwException(Translator.get("check_ldap_mapping") + StringUtils.SPACE + attr); } String result = dirContext.getStringAttribute(mapAttr); if (StringUtils.isBlank(result)) { - MSException.throwException(Translator.get("ldap_mapping_value_null") + " " + mapAttr); + MSException.throwException(Translator.get("ldap_mapping_value_null") + StringUtils.SPACE + mapAttr); } return result; diff --git a/framework/sdk-parent/sdk/src/main/java/io/metersphere/controller/handler/WebLogAspect.java b/framework/sdk-parent/sdk/src/main/java/io/metersphere/controller/handler/WebLogAspect.java index 14b1d5e579..d32a86dc95 100644 --- a/framework/sdk-parent/sdk/src/main/java/io/metersphere/controller/handler/WebLogAspect.java +++ b/framework/sdk-parent/sdk/src/main/java/io/metersphere/controller/handler/WebLogAspect.java @@ -4,6 +4,7 @@ package io.metersphere.controller.handler; import io.metersphere.commons.utils.LogUtil; import lombok.Builder; import lombok.Data; +import org.apache.commons.lang3.StringUtils; import org.aspectj.lang.JoinPoint; import org.aspectj.lang.annotation.AfterReturning; import org.aspectj.lang.annotation.Aspect; @@ -49,13 +50,13 @@ public class WebLogAspect { StringBuilder sb = new StringBuilder() .append(h.getMethod()).append(": ") - .append(h.getUrl()).append(" ") + .append(h.getUrl()).append(StringUtils.SPACE) .append("TIME: ") .append((System.currentTimeMillis() - h.getStartTime())).append("ms "); if (LogUtil.getLogger().isDebugEnabled()) { sb.append("ARGS: ") - .append(Arrays.toString(h.getArgs())).append(" ") + .append(Arrays.toString(h.getArgs())).append(StringUtils.SPACE) .append("RETURN: ") .append(ret); LogUtil.debug(sb.toString()); diff --git a/framework/sdk-parent/sdk/src/main/java/io/metersphere/environment/service/BaseEnvironmentService.java b/framework/sdk-parent/sdk/src/main/java/io/metersphere/environment/service/BaseEnvironmentService.java index cb38178487..714b89628e 100644 --- a/framework/sdk-parent/sdk/src/main/java/io/metersphere/environment/service/BaseEnvironmentService.java +++ b/framework/sdk-parent/sdk/src/main/java/io/metersphere/environment/service/BaseEnvironmentService.java @@ -398,7 +398,7 @@ public class BaseEnvironmentService extends NodeTreeService { criteria.andIdNotEqualTo(request.getId()); } if (apiTestEnvironmentMapper.selectByExample(example).size() > 0) { - existNames.append(" ").append(request.getName()); + existNames.append(StringUtils.SPACE).append(request.getName()); continue; } } diff --git a/framework/sdk-parent/sdk/src/main/java/io/metersphere/environment/service/CommandService.java b/framework/sdk-parent/sdk/src/main/java/io/metersphere/environment/service/CommandService.java index 78497b895f..ae7f03c6d7 100644 --- a/framework/sdk-parent/sdk/src/main/java/io/metersphere/environment/service/CommandService.java +++ b/framework/sdk-parent/sdk/src/main/java/io/metersphere/environment/service/CommandService.java @@ -142,7 +142,7 @@ public class CommandService { arguments.add("-destkeypass"); arguments.add("ms123..."); - LoggerUtil.info("证书合并命令:", String.join(" ", arguments)); + LoggerUtil.info("证书合并命令:", String.join(StringUtils.SPACE, arguments)); SystemCommand nativeCommand = new SystemCommand(destFile.getParentFile(), (Map) null); int exitVal = nativeCommand.run(arguments); if (exitVal > 0) { diff --git a/framework/sdk-parent/sdk/src/main/java/io/metersphere/environment/utils/XMLUtils.java b/framework/sdk-parent/sdk/src/main/java/io/metersphere/environment/utils/XMLUtils.java index 7da65f73f5..53661bdac1 100644 --- a/framework/sdk-parent/sdk/src/main/java/io/metersphere/environment/utils/XMLUtils.java +++ b/framework/sdk-parent/sdk/src/main/java/io/metersphere/environment/utils/XMLUtils.java @@ -109,7 +109,7 @@ public class XMLUtils { pattern = Pattern.compile(rgex); m = pattern.matcher(xml); xml = m.replaceAll(" extends AnalysisEventListener { if (!StringUtils.isEmpty(errMsg)) { ExcelErrData excelErrData = new ExcelErrData(t, rowIndex, - Translator.get("number") + " " + rowIndex + " " + Translator.get("row") + Translator.get("error") + Translator.get("number") + org.apache.commons.lang3.StringUtils.SPACE + rowIndex + org.apache.commons.lang3.StringUtils.SPACE + Translator.get("row") + Translator.get("error") + ":" + errMsg); errList.add(excelErrData); } else { diff --git a/framework/sdk-parent/sdk/src/main/java/io/metersphere/ldap/service/LdapService.java b/framework/sdk-parent/sdk/src/main/java/io/metersphere/ldap/service/LdapService.java index 196fee276f..98351b3d6e 100644 --- a/framework/sdk-parent/sdk/src/main/java/io/metersphere/ldap/service/LdapService.java +++ b/framework/sdk-parent/sdk/src/main/java/io/metersphere/ldap/service/LdapService.java @@ -217,12 +217,12 @@ public class LdapService { String mapAttr = (String) jsonObject.get(attr); if (StringUtils.isBlank(mapAttr)) { - MSException.throwException(Translator.get("check_ldap_mapping") + " " + attr); + MSException.throwException(Translator.get("check_ldap_mapping") + StringUtils.SPACE + attr); } String result = dirContext.getStringAttribute(mapAttr); if (StringUtils.isBlank(result)) { - MSException.throwException(Translator.get("ldap_mapping_value_null") + " " + mapAttr); + MSException.throwException(Translator.get("ldap_mapping_value_null") + StringUtils.SPACE + mapAttr); } return result; diff --git a/framework/sdk-parent/sdk/src/main/java/io/metersphere/log/utils/ReflexObjectUtil.java b/framework/sdk-parent/sdk/src/main/java/io/metersphere/log/utils/ReflexObjectUtil.java index b85eed4ba6..26849bd9af 100644 --- a/framework/sdk-parent/sdk/src/main/java/io/metersphere/log/utils/ReflexObjectUtil.java +++ b/framework/sdk-parent/sdk/src/main/java/io/metersphere/log/utils/ReflexObjectUtil.java @@ -212,11 +212,11 @@ public class ReflexObjectUtil { } else { String newValue = Objects.toString(column.getNewValue().toString(), ""); if (StringUtils.isNotEmpty(newValue)) { - column.setNewValue(newValue.replaceAll("\\n", " ")); + column.setNewValue(newValue.replaceAll("\\n", StringUtils.SPACE)); } - String oldValue = Objects.toString(column.getOriginalValue(), ""); + String oldValue = Objects.toString(column.getOriginalValue(), StringUtils.EMPTY); if (StringUtils.isNotEmpty(oldValue)) { - column.setOriginalValue(oldValue.replaceAll("\\n", " ")); + column.setOriginalValue(oldValue.replaceAll("\\n", StringUtils.SPACE)); } } comparedColumns.add(column); diff --git a/framework/sdk-parent/sdk/src/main/java/io/metersphere/log/utils/diff/json/IncavaEntry.java b/framework/sdk-parent/sdk/src/main/java/io/metersphere/log/utils/diff/json/IncavaEntry.java index 7c51a2de50..ff7b6aff85 100644 --- a/framework/sdk-parent/sdk/src/main/java/io/metersphere/log/utils/diff/json/IncavaEntry.java +++ b/framework/sdk-parent/sdk/src/main/java/io/metersphere/log/utils/diff/json/IncavaEntry.java @@ -30,6 +30,8 @@ package io.metersphere.log.utils.diff.json; SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ +import org.apache.commons.lang3.StringUtils; + /** * Represents a difference, as used in Diff. A difference consists of two pairs of starting and ending * points, each pair representing either the "from" or the "to" collection passed to Diff. If an ending @@ -148,7 +150,7 @@ public class IncavaEntry { public String toString() { StringBuffer buf = new StringBuffer(); buf.append("del: [" + delStart + ", " + delEnd + "]"); - buf.append(" "); + buf.append(StringUtils.SPACE); buf.append("add: [" + addStart + ", " + addEnd + "]"); return buf.toString(); } diff --git a/framework/sdk-parent/sdk/src/main/java/io/metersphere/notice/sender/impl/LarkNoticeSender.java b/framework/sdk-parent/sdk/src/main/java/io/metersphere/notice/sender/impl/LarkNoticeSender.java index 747a5abdcf..8aa5846637 100644 --- a/framework/sdk-parent/sdk/src/main/java/io/metersphere/notice/sender/impl/LarkNoticeSender.java +++ b/framework/sdk-parent/sdk/src/main/java/io/metersphere/notice/sender/impl/LarkNoticeSender.java @@ -28,7 +28,7 @@ public class LarkNoticeSender extends AbstractNoticeSender { .collect(Collectors.toList()); LogUtil.info("飞书收件人: {}", userIds); - context += StringUtils.join(collect, " "); + context += StringUtils.join(collect, StringUtils.SPACE); LarkClient.send(messageDetail.getWebhook(), "消息通知: \n" + context); } diff --git a/performance-test/backend/src/main/java/io/metersphere/engine/EngineFactory.java b/performance-test/backend/src/main/java/io/metersphere/engine/EngineFactory.java index fbcabb32a9..a84fcab0a4 100644 --- a/performance-test/backend/src/main/java/io/metersphere/engine/EngineFactory.java +++ b/performance-test/backend/src/main/java/io/metersphere/engine/EngineFactory.java @@ -221,7 +221,7 @@ public class EngineFactory { if (!(Boolean) prop.get("enable")) { continue; } - dns.append(prop.get("ip")).append(" ").append(prop.get("domain")).append("\n"); + dns.append(prop.get("ip")).append(StringUtils.SPACE).append(prop.get("domain")).append("\n"); } } } diff --git a/project-management/backend/src/main/java/io/metersphere/code/snippet/JMeterLoggerAppender.java b/project-management/backend/src/main/java/io/metersphere/code/snippet/JMeterLoggerAppender.java index bbce0d4e49..0327f0b435 100644 --- a/project-management/backend/src/main/java/io/metersphere/code/snippet/JMeterLoggerAppender.java +++ b/project-management/backend/src/main/java/io/metersphere/code/snippet/JMeterLoggerAppender.java @@ -6,6 +6,7 @@ import ch.qos.logback.core.UnsynchronizedAppenderBase; import io.metersphere.commons.utils.DateUtils; import io.metersphere.commons.utils.LogUtil; import io.metersphere.code.snippet.util.FixedCapacityUtils; +import org.apache.commons.lang3.StringUtils; public class JMeterLoggerAppender extends UnsynchronizedAppenderBase { @@ -14,9 +15,9 @@ public class JMeterLoggerAppender extends UnsynchronizedAppenderBase 1) { for (int i = 1; i < previewContentArr.length; i++) { String itemStr = previewContentArr[i]; diff --git a/system-setting/backend/src/main/java/io/metersphere/excel/listener/EasyExcelListener.java b/system-setting/backend/src/main/java/io/metersphere/excel/listener/EasyExcelListener.java index 877d73cad6..d49b2b4fff 100644 --- a/system-setting/backend/src/main/java/io/metersphere/excel/listener/EasyExcelListener.java +++ b/system-setting/backend/src/main/java/io/metersphere/excel/listener/EasyExcelListener.java @@ -50,7 +50,7 @@ public abstract class EasyExcelListener extends AnalysisEventListener { if (!StringUtils.isEmpty(errMsg)) { ExcelErrData excelErrData = new ExcelErrData(t, rowIndex, - Translator.get("number") + " " + rowIndex + " " + Translator.get("row") + Translator.get("error") + Translator.get("number") + org.apache.commons.lang3.StringUtils.SPACE + rowIndex + org.apache.commons.lang3.StringUtils.SPACE + Translator.get("row") + Translator.get("error") + ":" + errMsg); errList.add(excelErrData); } else { diff --git a/test-track/backend/src/main/java/io/metersphere/excel/listener/TestCaseNoModelDataListener.java b/test-track/backend/src/main/java/io/metersphere/excel/listener/TestCaseNoModelDataListener.java index 1182607b22..9bec9f6c0c 100644 --- a/test-track/backend/src/main/java/io/metersphere/excel/listener/TestCaseNoModelDataListener.java +++ b/test-track/backend/src/main/java/io/metersphere/excel/listener/TestCaseNoModelDataListener.java @@ -202,8 +202,8 @@ public class TestCaseNoModelDataListener extends AnalysisEventListener