Merge branch 'v1.1' of https://github.com/metersphere/server into v1.1
This commit is contained in:
commit
4eeede9322
|
@ -224,6 +224,12 @@
|
|||
<version>0.0.4</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>io.github.ningyu</groupId>
|
||||
<artifactId>jmeter-plugins-dubbo</artifactId>
|
||||
<version>2.7.7</version>
|
||||
</dependency>
|
||||
|
||||
<!-- LDAP Module -->
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
|
@ -358,6 +364,11 @@
|
|||
<name>fit2cloud</name>
|
||||
<url>https://maven.pkg.github.com/fit2cloud/quartz-spring-boot-starter</url>
|
||||
</repository>
|
||||
<repository>
|
||||
<id>github</id>
|
||||
<name>metersphere</name>
|
||||
<url>https://maven.pkg.github.com/metersphere/jmeter-plugins-for-apache-dubbo</url>
|
||||
</repository>
|
||||
</repositories>
|
||||
|
||||
|
||||
|
|
|
@ -1,92 +0,0 @@
|
|||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
* (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package io.metersphere.api.dubbo;
|
||||
|
||||
|
||||
import io.metersphere.api.dubbo.utils.JsonUtils;
|
||||
import io.metersphere.api.dubbo.utils.StringUtils;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
|
||||
/**
|
||||
* MethodArgument
|
||||
*/
|
||||
public class MethodArgument implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = -2567457932227227262L;
|
||||
private String paramType;
|
||||
private String paramValue;
|
||||
|
||||
public MethodArgument(String paramType, String paramValue) {
|
||||
setParamType(paramType);
|
||||
setParamValue(paramValue);
|
||||
}
|
||||
|
||||
public String getParamType() {
|
||||
return paramType;
|
||||
}
|
||||
|
||||
public void setParamType(String paramType) {
|
||||
this.paramType = (paramType == null ? null : StringUtils.trimAllWhitespace(paramType));
|
||||
}
|
||||
|
||||
public String getParamValue() {
|
||||
return paramValue;
|
||||
}
|
||||
|
||||
public void setParamValue(String paramValue) {
|
||||
this.paramValue = (paramValue == null ? null : StringUtils.trimWhitespace(paramValue));
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return JsonUtils.toJson(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
final int prime = 31;
|
||||
int result = 1;
|
||||
result = prime * result + ((paramType == null) ? 0 : paramType.hashCode());
|
||||
result = prime * result + ((paramValue == null) ? 0 : paramValue.hashCode());
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (this == obj)
|
||||
return true;
|
||||
if (obj == null)
|
||||
return false;
|
||||
if (getClass() != obj.getClass())
|
||||
return false;
|
||||
MethodArgument other = (MethodArgument) obj;
|
||||
if (paramType == null) {
|
||||
if (other.paramType != null)
|
||||
return false;
|
||||
} else if (!paramType.equals(other.paramType))
|
||||
return false;
|
||||
if (paramValue == null) {
|
||||
if (other.paramValue != null)
|
||||
return false;
|
||||
} else if (!paramValue.equals(other.paramValue))
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
|
@ -1,112 +0,0 @@
|
|||
package io.metersphere.api.dubbo;
|
||||
|
||||
import io.metersphere.api.dubbo.utils.Constants;
|
||||
import org.apache.dubbo.common.URL;
|
||||
import org.apache.dubbo.config.ApplicationConfig;
|
||||
import org.apache.dubbo.config.ReferenceConfig;
|
||||
import org.apache.dubbo.config.ReferenceConfigBase;
|
||||
import org.apache.dubbo.config.RegistryConfig;
|
||||
import org.apache.dubbo.config.utils.ReferenceConfigCache;
|
||||
import org.apache.dubbo.registry.RegistryService;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.concurrent.ConcurrentMap;
|
||||
|
||||
/**
|
||||
* ProviderService
|
||||
*/
|
||||
public class ProviderService implements Serializable {
|
||||
|
||||
private static final Logger log = LoggerFactory.getLogger(ProviderService.class);
|
||||
|
||||
private static final long serialVersionUID = -750353929981409079L;
|
||||
ConcurrentMap<String, Map<String, URL>> providerUrls = null;
|
||||
|
||||
private static ConcurrentMap<String, ProviderService> cache = new ConcurrentHashMap<>();
|
||||
|
||||
public static ProviderService get(String key) {
|
||||
ProviderService service = cache.get(key);
|
||||
if (service == null) {
|
||||
cache.putIfAbsent(key, new ProviderService());
|
||||
service = cache.get(key);
|
||||
}
|
||||
return service;
|
||||
}
|
||||
|
||||
public Map<String, URL> findByService(String serviceName) {
|
||||
return providerUrls == null ? null : providerUrls.get(serviceName);
|
||||
}
|
||||
|
||||
public List<String> getProviders(String protocol, String address, String group) throws RuntimeException {
|
||||
if (protocol.equals("zookeeper") || protocol.equals("nacos") || protocol.equals("redis")) {
|
||||
return executeRegistry(protocol, address, group);
|
||||
// } else if (protocol.equals("none")) {
|
||||
// return executeTelnet();
|
||||
} else {
|
||||
throw new RuntimeException("Registry Protocol please use zookeeper or nacos or redis!");
|
||||
}
|
||||
}
|
||||
|
||||
private List<String> executeTelnet() throws RuntimeException {
|
||||
throw new RuntimeException();
|
||||
}
|
||||
|
||||
private List<String> executeRegistry(String protocol, String address, String group) throws RuntimeException {
|
||||
ReferenceConfig reference = new ReferenceConfig();
|
||||
// set application
|
||||
reference.setApplication(new ApplicationConfig("DubboSample"));
|
||||
RegistryConfig registry = null;
|
||||
switch (protocol) {
|
||||
case Constants.REGISTRY_ZOOKEEPER:
|
||||
registry = new RegistryConfig();
|
||||
registry.setProtocol(Constants.REGISTRY_ZOOKEEPER);
|
||||
registry.setGroup(group);
|
||||
registry.setAddress(address);
|
||||
reference.setRegistry(registry);
|
||||
break;
|
||||
case Constants.REGISTRY_NACOS:
|
||||
registry = new RegistryConfig();
|
||||
registry.setProtocol(Constants.REGISTRY_NACOS);
|
||||
registry.setGroup(group);
|
||||
registry.setAddress(address);
|
||||
reference.setRegistry(registry);
|
||||
break;
|
||||
case Constants.REGISTRY_REDIS:
|
||||
registry = new RegistryConfig();
|
||||
registry.setProtocol(Constants.REGISTRY_REDIS);
|
||||
registry.setGroup(group);
|
||||
registry.setAddress(address);
|
||||
reference.setRegistry(registry);
|
||||
break;
|
||||
}
|
||||
reference.setInterface("org.apache.dubbo.registry.RegistryService");
|
||||
try {
|
||||
ReferenceConfigCache cache = ReferenceConfigCache.getCache(address + "_" + group, new ReferenceConfigCache.KeyGenerator() {
|
||||
|
||||
@Override
|
||||
public String generateKey(ReferenceConfigBase<?> referenceConfig) {
|
||||
return referenceConfig.toString();
|
||||
}
|
||||
});
|
||||
RegistryService registryService = (RegistryService) cache.get(reference);
|
||||
if (registryService == null) {
|
||||
throw new RuntimeException("Can't get the interface list, please check if the address is wrong!");
|
||||
}
|
||||
RegistryServerSync registryServerSync = RegistryServerSync.get(address + "_" + group);
|
||||
registryService.subscribe(RegistryServerSync.SUBSCRIBE, registryServerSync);
|
||||
List<String> ret = new ArrayList<String>();
|
||||
providerUrls = registryServerSync.getRegistryCache().get(com.alibaba.dubbo.common.Constants.PROVIDERS_CATEGORY);
|
||||
if (providerUrls != null) ret.addAll(providerUrls.keySet());
|
||||
return ret;
|
||||
} catch (Exception e) {
|
||||
log.error("get provider list is error!", e);
|
||||
throw new RuntimeException("Can't get the interface list, please check if the address is wrong!", e);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,171 +0,0 @@
|
|||
package io.metersphere.api.dubbo;
|
||||
|
||||
import io.metersphere.api.dubbo.utils.MD5Util;
|
||||
import org.apache.dubbo.common.URL;
|
||||
import org.apache.dubbo.common.constants.CommonConstants;
|
||||
import org.apache.dubbo.common.constants.RegistryConstants;
|
||||
import org.apache.dubbo.common.utils.NetUtils;
|
||||
import org.apache.dubbo.common.utils.StringUtils;
|
||||
import org.apache.dubbo.registry.Constants;
|
||||
import org.apache.dubbo.registry.NotifyListener;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.concurrent.ConcurrentMap;
|
||||
|
||||
/**
|
||||
* RegistryServerSync
|
||||
*/
|
||||
public class RegistryServerSync implements NotifyListener, Serializable {
|
||||
|
||||
private static final long serialVersionUID = -1744756264793278229L;
|
||||
private static ConcurrentMap<String, RegistryServerSync> cache = new ConcurrentHashMap<>();
|
||||
|
||||
public static RegistryServerSync get(String key) {
|
||||
RegistryServerSync sync = cache.get(key);
|
||||
if (sync == null) {
|
||||
cache.putIfAbsent(key, new RegistryServerSync());
|
||||
sync = cache.get(key);
|
||||
}
|
||||
return sync;
|
||||
}
|
||||
|
||||
public static final URL SUBSCRIBE = new URL(Constants.ADMIN_PROTOCOL, NetUtils.getLocalHost(), 0, "",
|
||||
CommonConstants.INTERFACE_KEY, CommonConstants.ANY_VALUE,
|
||||
CommonConstants.GROUP_KEY, CommonConstants.ANY_VALUE,
|
||||
CommonConstants.VERSION_KEY, CommonConstants.ANY_VALUE,
|
||||
CommonConstants.CLASSIFIER_KEY, CommonConstants.ANY_VALUE,
|
||||
RegistryConstants.CATEGORY_KEY, RegistryConstants.PROVIDERS_CATEGORY,
|
||||
// Constants.CATEGORY_KEY, Constants.PROVIDERS_CATEGORY + ","
|
||||
// + Constants.CONSUMERS_CATEGORY + ","
|
||||
// + Constants.ROUTERS_CATEGORY + ","
|
||||
// + Constants.CONFIGURATORS_CATEGORY,
|
||||
CommonConstants.ENABLED_KEY, CommonConstants.ANY_VALUE,
|
||||
CommonConstants.CHECK_KEY, String.valueOf(false));
|
||||
|
||||
// ConcurrentMap<category, ConcurrentMap<servicename, Map<MD5, URL>>>
|
||||
private final ConcurrentMap<String, ConcurrentMap<String, Map<String, URL>>>
|
||||
registryCache = new ConcurrentHashMap<>();
|
||||
/**
|
||||
* Make sure ID never changed when the same url notified many times
|
||||
*/
|
||||
private final ConcurrentHashMap<String, String> URL_IDS_MAPPER = new ConcurrentHashMap<>();
|
||||
|
||||
public RegistryServerSync() {
|
||||
}
|
||||
|
||||
public ConcurrentMap<String, ConcurrentMap<String, Map<String, URL>>> getRegistryCache() {
|
||||
return registryCache;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void notify(List<URL> urls) {
|
||||
if (urls == null || urls.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
// Map<category, Map<servicename, Map<Long, URL>>>
|
||||
final Map<String, Map<String, Map<String, URL>>> categories = new HashMap<>();
|
||||
String interfaceName = null;
|
||||
for (URL url : urls) {
|
||||
String category = url.getParameter(RegistryConstants.CATEGORY_KEY, RegistryConstants.PROVIDERS_CATEGORY);
|
||||
if (RegistryConstants.EMPTY_PROTOCOL.equalsIgnoreCase(url.getProtocol())) { // NOTE: group and version in empty protocol is *
|
||||
ConcurrentMap<String, Map<String, URL>> services = registryCache.get(category);
|
||||
if (services != null) {
|
||||
String group = url.getParameter(CommonConstants.GROUP_KEY);
|
||||
String version = url.getParameter(CommonConstants.VERSION_KEY);
|
||||
// NOTE: group and version in empty protocol is *
|
||||
if (!CommonConstants.ANY_VALUE.equals(group) && !CommonConstants.ANY_VALUE.equals(version)) {
|
||||
services.remove(url.getServiceKey());
|
||||
} else {
|
||||
for (Map.Entry<String, Map<String, URL>> serviceEntry : services.entrySet()) {
|
||||
String service = serviceEntry.getKey();
|
||||
if (this.getInterface(service).equals(url.getServiceInterface())
|
||||
&& (CommonConstants.ANY_VALUE.equals(group) || StringUtils.isEquals(group, this.getGroup(service)))
|
||||
&& (CommonConstants.ANY_VALUE.equals(version) || StringUtils.isEquals(version, this.getVersion(service)))) {
|
||||
services.remove(service);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (StringUtils.isEmpty(interfaceName)) {
|
||||
interfaceName = url.getServiceInterface();
|
||||
}
|
||||
Map<String, Map<String, URL>> services = categories.get(category);
|
||||
if (services == null) {
|
||||
services = new HashMap<>();
|
||||
categories.put(category, services);
|
||||
}
|
||||
String service = url.getServiceKey();
|
||||
Map<String, URL> ids = services.get(service);
|
||||
if (ids == null) {
|
||||
ids = new HashMap<>();
|
||||
services.put(service, ids);
|
||||
}
|
||||
|
||||
// Make sure we use the same ID for the same URL
|
||||
if (URL_IDS_MAPPER.containsKey(url.toFullString())) {
|
||||
ids.put(URL_IDS_MAPPER.get(url.toFullString()), url);
|
||||
} else {
|
||||
String md5 = MD5Util.MD5_16bit(url.toFullString());
|
||||
ids.put(md5, url);
|
||||
URL_IDS_MAPPER.putIfAbsent(url.toFullString(), md5);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (categories.size() == 0) {
|
||||
return;
|
||||
}
|
||||
for (Map.Entry<String, Map<String, Map<String, URL>>> categoryEntry : categories.entrySet()) {
|
||||
String category = categoryEntry.getKey();
|
||||
ConcurrentMap<String, Map<String, URL>> services = registryCache.get(category);
|
||||
if (services == null) {
|
||||
services = new ConcurrentHashMap<String, Map<String, URL>>();
|
||||
registryCache.put(category, services);
|
||||
} else {// Fix map can not be cleared when service is unregistered: when a unique “group/service:version” service is unregistered, but we still have the same services with different version or group, so empty protocols can not be invoked.
|
||||
Set<String> keys = new HashSet<String>(services.keySet());
|
||||
for (String key : keys) {
|
||||
if (this.getInterface(key).equals(interfaceName) && !categoryEntry.getValue().entrySet().contains(key)) {
|
||||
services.remove(key);
|
||||
}
|
||||
}
|
||||
}
|
||||
services.putAll(categoryEntry.getValue());
|
||||
}
|
||||
}
|
||||
|
||||
public String getInterface(String service) {
|
||||
if (service != null && service.length() > 0) {
|
||||
int i = service.indexOf('/');
|
||||
if (i >= 0) {
|
||||
service = service.substring(i + 1);
|
||||
}
|
||||
i = service.lastIndexOf(':');
|
||||
if (i >= 0) {
|
||||
service = service.substring(0, i);
|
||||
}
|
||||
}
|
||||
return service;
|
||||
}
|
||||
|
||||
public String getGroup(String service) {
|
||||
if (service != null && service.length() > 0) {
|
||||
int i = service.indexOf('/');
|
||||
if (i >= 0) {
|
||||
return service.substring(0, i);
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public String getVersion(String service) {
|
||||
if (service != null && service.length() > 0) {
|
||||
int i = service.lastIndexOf(':');
|
||||
if (i >= 0) {
|
||||
return service.substring(i + 1);
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
|
@ -1,614 +0,0 @@
|
|||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
* (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package io.metersphere.api.dubbo.utils;
|
||||
|
||||
import io.metersphere.api.dubbo.MethodArgument;
|
||||
import org.apache.jmeter.testelement.TestElement;
|
||||
import org.apache.jmeter.testelement.property.IntegerProperty;
|
||||
import org.apache.jmeter.testelement.property.StringProperty;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Constants
|
||||
*/
|
||||
public class Constants {
|
||||
|
||||
//Registry Protocol
|
||||
public static final String REGISTRY_NONE = "none";
|
||||
public static final String REGISTRY_ZOOKEEPER = "zookeeper";
|
||||
public static final String REGISTRY_NACOS = "nacos";
|
||||
public static final String APOLLO = "apollo";
|
||||
public static final String REGISTRY_MULTICAST = "multicast";
|
||||
public static final String REGISTRY_REDIS = "redis";
|
||||
public static final String REGISTRY_SIMPLE = "simple";
|
||||
|
||||
//RPC Protocol
|
||||
public static final String RPC_PROTOCOL_DUBBO = "dubbo";
|
||||
public static final String RPC_PROTOCOL_RMI = "rmi";
|
||||
public static final String RPC_PROTOCOL_HESSIAN = "hessian";
|
||||
public static final String RPC_PROTOCOL_HTTP = "http";
|
||||
public static final String RPC_PROTOCOL_WEBSERVICE = "webservice";
|
||||
public static final String RPC_PROTOCOL_THRIFT = "thrift";
|
||||
public static final String RPC_PROTOCOL_MEMCACHED = "memcached";
|
||||
public static final String RPC_PROTOCOL_REDIS = "redis";
|
||||
|
||||
public static final String ASYNC = "async";
|
||||
public static final String SYMBOL = "://";
|
||||
|
||||
public static final int INT_DEFAULT = 0;
|
||||
public static final double DOUBLE_DEFAULT = 0.0d;
|
||||
public static final boolean BOOLEAN_DEFAULT = false;
|
||||
public static final char CHAR_DEFAULT = '\u0000';
|
||||
public static final float FLOAT_DEFAULT = 0.0f;
|
||||
public static final byte BYTE_DEFAULT = 0;
|
||||
public static final long LONG_DEFAULT = 0l;
|
||||
public static final short SHORT_DEFAULT = 0;
|
||||
public static final int[] INT_ARRAY_DEFAULT = null;
|
||||
public static final double[] DOUBLE_ARRAY_DEFAULT = null;
|
||||
public static final boolean[] BOOLEAN_ARRAY_DEFAULT = null;
|
||||
public static final char[] CHAT_ARRAY_DEFAULT = null;
|
||||
public static final float[] FLOAT_ARRAY_DEFAULT = null;
|
||||
public static final byte[] BYTE_ARRAY_DEFAULT = null;
|
||||
public static final long[] LONG_ARRAY_DEFAULT = null;
|
||||
public static final short[] SHORT_ARRAY_DEFAULT = null;
|
||||
|
||||
public static final String FIELD_DUBBO_REGISTRY_PROTOCOL = "FIELD_DUBBO_REGISTRY_PROTOCOL";
|
||||
public static final String FIELD_DUBBO_REGISTRY_GROUP = "FIELD_DUBBO_REGISTRY_GROUP";
|
||||
public static final String FIELD_DUBBO_REGISTRY_USER_NAME = "FIELD_DUBBO_REGISTRY_USER_NAME";
|
||||
public static final String FIELD_DUBBO_REGISTRY_PASSWORD = "FIELD_DUBBO_REGISTRY_PASSWORD";
|
||||
public static final String FIELD_DUBBO_REGISTRY_TIMEOUT = "FIELD_DUBBO_REGISTRY_TIMEOUT";
|
||||
public static final String FIELD_DUBBO_CONFIG_CENTER_PROTOCOL = "FIELD_DUBBO_CONFIG_CENTER_PROTOCOL";
|
||||
public static final String FIELD_DUBBO_CONFIG_CENTER_GROUP = "FIELD_DUBBO_CONFIG_CENTER_GROUP";
|
||||
public static final String FIELD_DUBBO_CONFIG_CENTER_NAMESPACE = "FIELD_DUBBO_CONFIG_CENTER_NAMESPACE";
|
||||
public static final String FIELD_DUBBO_CONFIG_CENTER_USER_NAME = "FIELD_DUBBO_CONFIG_CENTER_USER_NAME";
|
||||
public static final String FIELD_DUBBO_CONFIG_CENTER_PASSWORD = "FIELD_DUBBO_CONFIG_CENTER_PASSWORD";
|
||||
public static final String FIELD_DUBBO_CONFIG_CENTER_TIMEOUT = "FIELD_DUBBO_CONFIG_CENTER_TIMEOUT";
|
||||
public static final String FIELD_DUBBO_CONFIG_CENTER_ADDRESS = "FIELD_DUBBO_CONFIG_CENTER_ADDRESS";
|
||||
public static final String FIELD_DUBBO_RPC_PROTOCOL = "FIELD_DUBBO_RPC_PROTOCOL";
|
||||
public static final String FIELD_DUBBO_ADDRESS = "FIELD_DUBBO_ADDRESS";
|
||||
public static final String FIELD_DUBBO_TIMEOUT = "FIELD_DUBBO_TIMEOUT";
|
||||
public static final String FIELD_DUBBO_VERSION = "FIELD_DUBBO_VERSION";
|
||||
public static final String FIELD_DUBBO_RETRIES = "FIELD_DUBBO_RETRIES";
|
||||
public static final String FIELD_DUBBO_CLUSTER = "FIELD_DUBBO_CLUSTER";
|
||||
public static final String FIELD_DUBBO_GROUP = "FIELD_DUBBO_GROUP";
|
||||
public static final String FIELD_DUBBO_CONNECTIONS = "FIELD_DUBBO_CONNECTIONS";
|
||||
public static final String FIELD_DUBBO_LOADBALANCE = "FIELD_DUBBO_LOADBALANCE";
|
||||
public static final String FIELD_DUBBO_ASYNC = "FIELD_DUBBO_ASYNC";
|
||||
public static final String FIELD_DUBBO_INTERFACE = "FIELD_DUBBO_INTERFACE";
|
||||
public static final String FIELD_DUBBO_METHOD = "FIELD_DUBBO_METHOD";
|
||||
public static final String FIELD_DUBBO_METHOD_ARGS = "FIELD_DUBBO_METHOD_ARGS";
|
||||
public static final String FIELD_DUBBO_METHOD_ARGS_SIZE = "FIELD_DUBBO_METHOD_ARGS_SIZE";
|
||||
public static final String FIELD_DUBBO_ATTACHMENT_ARGS = "FIELD_DUBBO_ATTACHMENT_ARGS";
|
||||
public static final String FIELD_DUBBO_ATTACHMENT_ARGS_SIZE = "FIELD_DUBBO_ATTACHMENT_ARGS_SIZE";
|
||||
public static final String DEFAULT_TIMEOUT = "1000";
|
||||
public static final String DEFAULT_VERSION = "1.0";
|
||||
public static final String DEFAULT_RETRIES = "0";
|
||||
public static final String DEFAULT_CLUSTER = "failfast";
|
||||
public static final String DEFAULT_CONNECTIONS = "100";
|
||||
|
||||
//冗余配置元件中的address、protocols、group,用于在sample gui获取配置元件中的默认值
|
||||
public static String DEFAULT_PANEL_ADDRESS = "";
|
||||
public static String DEFAULT_PANEL_PROTOCOLS = "";
|
||||
public static String DEFAULT_PANEL_GROUP = "";
|
||||
|
||||
public static final void redundancy(TestElement element) {
|
||||
DEFAULT_PANEL_ADDRESS = Constants.getAddress(element);
|
||||
DEFAULT_PANEL_PROTOCOLS = Constants.getRegistryProtocol(element);
|
||||
DEFAULT_PANEL_GROUP = Constants.getRegistryGroup(element);
|
||||
}
|
||||
|
||||
/**
|
||||
* get Registry Protocol
|
||||
*
|
||||
* @return the protocol
|
||||
*/
|
||||
public static final String getRegistryProtocol(TestElement element) {
|
||||
return element.getPropertyAsString(FIELD_DUBBO_REGISTRY_PROTOCOL);
|
||||
}
|
||||
|
||||
/**
|
||||
* set Registry Protocol
|
||||
*
|
||||
* @param registryProtocol the protocol to set
|
||||
*/
|
||||
public static final void setRegistryProtocol(String registryProtocol, TestElement element) {
|
||||
element.setProperty(new StringProperty(FIELD_DUBBO_REGISTRY_PROTOCOL, StringUtils.trimAllWhitespace(registryProtocol)));
|
||||
}
|
||||
|
||||
/**
|
||||
* get Registry Group
|
||||
*
|
||||
* @return the group
|
||||
*/
|
||||
public static final String getRegistryGroup(TestElement element) {
|
||||
return element.getPropertyAsString(FIELD_DUBBO_REGISTRY_GROUP);
|
||||
}
|
||||
|
||||
/**
|
||||
* set Registry Group
|
||||
*
|
||||
* @param registryGroup the group to set
|
||||
*/
|
||||
public static final void setRegistryGroup(String registryGroup, TestElement element) {
|
||||
element.setProperty(new StringProperty(FIELD_DUBBO_REGISTRY_GROUP, StringUtils.trimAllWhitespace(registryGroup)));
|
||||
}
|
||||
|
||||
/**
|
||||
* get Registry username
|
||||
*
|
||||
* @return the username
|
||||
*/
|
||||
public static final String getRegistryUserName(TestElement element) {
|
||||
return element.getPropertyAsString(FIELD_DUBBO_REGISTRY_USER_NAME);
|
||||
}
|
||||
|
||||
/**
|
||||
* set Registry username
|
||||
*
|
||||
* @param username the username to set
|
||||
*/
|
||||
public static final void setRegistryUserName(String username, TestElement element) {
|
||||
element.setProperty(new StringProperty(FIELD_DUBBO_REGISTRY_USER_NAME, StringUtils.trimAllWhitespace(username)));
|
||||
}
|
||||
|
||||
/**
|
||||
* get Registry password
|
||||
*
|
||||
* @return the password
|
||||
*/
|
||||
public static final String getRegistryPassword(TestElement element) {
|
||||
return element.getPropertyAsString(FIELD_DUBBO_REGISTRY_PASSWORD);
|
||||
}
|
||||
|
||||
/**
|
||||
* set Registry password
|
||||
*
|
||||
* @param password the password to set
|
||||
*/
|
||||
public static final void setRegistryPassword(String password, TestElement element) {
|
||||
element.setProperty(new StringProperty(FIELD_DUBBO_REGISTRY_PASSWORD, StringUtils.trimAllWhitespace(password)));
|
||||
}
|
||||
|
||||
/**
|
||||
* get Registry timeout
|
||||
*
|
||||
* @return the timeout
|
||||
*/
|
||||
public static final String getRegistryTimeout(TestElement element) {
|
||||
return element.getPropertyAsString(FIELD_DUBBO_REGISTRY_TIMEOUT);
|
||||
}
|
||||
|
||||
/**
|
||||
* set Registry timeout
|
||||
*
|
||||
* @param timeout the group to set
|
||||
*/
|
||||
public static final void setRegistryTimeout(String timeout, TestElement element) {
|
||||
element.setProperty(new StringProperty(FIELD_DUBBO_REGISTRY_TIMEOUT, StringUtils.trimAllWhitespace(timeout)));
|
||||
}
|
||||
|
||||
/**
|
||||
* get ConfigCenter protocol
|
||||
*
|
||||
* @return the protocol
|
||||
*/
|
||||
public static final String getConfigCenterProtocol(TestElement element) {
|
||||
return element.getPropertyAsString(FIELD_DUBBO_CONFIG_CENTER_PROTOCOL);
|
||||
}
|
||||
|
||||
/**
|
||||
* set ConfigCenter protocol
|
||||
*
|
||||
* @param protocol the protocol to set
|
||||
*/
|
||||
public static final void setConfigCenterProtocol(String protocol, TestElement element) {
|
||||
element.setProperty(new StringProperty(FIELD_DUBBO_CONFIG_CENTER_PROTOCOL, StringUtils.trimAllWhitespace(protocol)));
|
||||
}
|
||||
|
||||
/**
|
||||
* get ConfigCenter group
|
||||
*
|
||||
* @return the group
|
||||
*/
|
||||
public static final String getConfigCenterGroup(TestElement element) {
|
||||
return element.getPropertyAsString(FIELD_DUBBO_CONFIG_CENTER_GROUP);
|
||||
}
|
||||
|
||||
/**
|
||||
* set ConfigCenter group
|
||||
*
|
||||
* @param group the group to set
|
||||
*/
|
||||
public static final void setConfigCenterGroup(String group, TestElement element) {
|
||||
element.setProperty(new StringProperty(FIELD_DUBBO_CONFIG_CENTER_GROUP, StringUtils.trimAllWhitespace(group)));
|
||||
}
|
||||
|
||||
/**
|
||||
* get ConfigCenter namespace
|
||||
*
|
||||
* @return the namespace
|
||||
*/
|
||||
public static final String getConfigCenterNamespace(TestElement element) {
|
||||
return element.getPropertyAsString(FIELD_DUBBO_CONFIG_CENTER_NAMESPACE);
|
||||
}
|
||||
|
||||
/**
|
||||
* set ConfigCenter namespace
|
||||
*
|
||||
* @param namespace the namespace to set
|
||||
*/
|
||||
public static final void setConfigCenterNamespace(String namespace, TestElement element) {
|
||||
element.setProperty(new StringProperty(FIELD_DUBBO_CONFIG_CENTER_NAMESPACE, StringUtils.trimAllWhitespace(namespace)));
|
||||
}
|
||||
|
||||
/**
|
||||
* get ConfigCenter username
|
||||
*
|
||||
* @return the username
|
||||
*/
|
||||
public static final String getConfigCenterUserName(TestElement element) {
|
||||
return element.getPropertyAsString(FIELD_DUBBO_CONFIG_CENTER_USER_NAME);
|
||||
}
|
||||
|
||||
/**
|
||||
* set ConfigCenter username
|
||||
*
|
||||
* @param username the username to set
|
||||
*/
|
||||
public static final void setConfigCenterUserName(String username, TestElement element) {
|
||||
element.setProperty(new StringProperty(FIELD_DUBBO_CONFIG_CENTER_USER_NAME, StringUtils.trimAllWhitespace(username)));
|
||||
}
|
||||
|
||||
/**
|
||||
* get ConfigCenter password
|
||||
*
|
||||
* @return the password
|
||||
*/
|
||||
public static final String getConfigCenterPassword(TestElement element) {
|
||||
return element.getPropertyAsString(FIELD_DUBBO_CONFIG_CENTER_PASSWORD);
|
||||
}
|
||||
|
||||
/**
|
||||
* set ConfigCenter password
|
||||
*
|
||||
* @param password the password to set
|
||||
*/
|
||||
public static final void setConfigCenterPassword(String password, TestElement element) {
|
||||
element.setProperty(new StringProperty(FIELD_DUBBO_CONFIG_CENTER_PASSWORD, StringUtils.trimAllWhitespace(password)));
|
||||
}
|
||||
|
||||
/**
|
||||
* get ConfigCenter address
|
||||
*
|
||||
* @return the address
|
||||
*/
|
||||
public static final String getConfigCenterAddress(TestElement element) {
|
||||
return element.getPropertyAsString(FIELD_DUBBO_CONFIG_CENTER_ADDRESS);
|
||||
}
|
||||
|
||||
/**
|
||||
* set ConfigCenter namespace
|
||||
*
|
||||
* @param address the address to set
|
||||
*/
|
||||
public static final void setConfigCenterAddress(String address, TestElement element) {
|
||||
element.setProperty(new StringProperty(FIELD_DUBBO_CONFIG_CENTER_ADDRESS, StringUtils.trimAllWhitespace(address)));
|
||||
}
|
||||
|
||||
/**
|
||||
* get ConfigCenter timeout
|
||||
*
|
||||
* @return the timeout
|
||||
*/
|
||||
public static final String getConfigCenterTimeout(TestElement element) {
|
||||
return element.getPropertyAsString(FIELD_DUBBO_CONFIG_CENTER_TIMEOUT);
|
||||
}
|
||||
|
||||
/**
|
||||
* set ConfigCenter namespace
|
||||
*
|
||||
* @param timeout the timeout to set
|
||||
*/
|
||||
public static final void setConfigCenterTimeout(String timeout, TestElement element) {
|
||||
element.setProperty(new StringProperty(FIELD_DUBBO_CONFIG_CENTER_TIMEOUT, StringUtils.trimAllWhitespace(timeout)));
|
||||
}
|
||||
|
||||
/**
|
||||
* get RPC protocol
|
||||
*
|
||||
* @return the RPC protocol
|
||||
*/
|
||||
public static final String getRpcProtocol(TestElement element) {
|
||||
return element.getPropertyAsString(FIELD_DUBBO_RPC_PROTOCOL);
|
||||
}
|
||||
|
||||
/**
|
||||
* set RPC protocol
|
||||
*
|
||||
* @param rpcProtocol the protocol to set
|
||||
*/
|
||||
public static final void setRpcProtocol(String rpcProtocol, TestElement element) {
|
||||
element.setProperty(new StringProperty(FIELD_DUBBO_RPC_PROTOCOL, StringUtils.trimAllWhitespace(rpcProtocol)));
|
||||
}
|
||||
|
||||
/**
|
||||
* get address
|
||||
*
|
||||
* @return the address
|
||||
*/
|
||||
public static final String getAddress(TestElement element) {
|
||||
return element.getPropertyAsString(FIELD_DUBBO_ADDRESS);
|
||||
}
|
||||
|
||||
/**
|
||||
* set address
|
||||
*
|
||||
* @param address the address to set
|
||||
*/
|
||||
public static final void setAddress(String address, TestElement element) {
|
||||
element.setProperty(new StringProperty(FIELD_DUBBO_ADDRESS, StringUtils.trimAllWhitespace(address)));
|
||||
}
|
||||
|
||||
/**
|
||||
* get timeout
|
||||
*
|
||||
* @return the timeout
|
||||
*/
|
||||
public static final String getTimeout(TestElement element) {
|
||||
return element.getPropertyAsString(FIELD_DUBBO_TIMEOUT, DEFAULT_TIMEOUT);
|
||||
}
|
||||
|
||||
/**
|
||||
* set timeout
|
||||
*
|
||||
* @param timeout the timeout to set
|
||||
*/
|
||||
public static final void setTimeout(String timeout, TestElement element) {
|
||||
element.setProperty(new StringProperty(FIELD_DUBBO_TIMEOUT, StringUtils.trimAllWhitespace(timeout)));
|
||||
}
|
||||
|
||||
/**
|
||||
* get version
|
||||
*
|
||||
* @return the version
|
||||
*/
|
||||
public static final String getVersion(TestElement element) {
|
||||
return element.getPropertyAsString(FIELD_DUBBO_VERSION, DEFAULT_VERSION);
|
||||
}
|
||||
|
||||
/**
|
||||
* set version
|
||||
*
|
||||
* @param version the version to set
|
||||
*/
|
||||
public static final void setVersion(String version, TestElement element) {
|
||||
element.setProperty(new StringProperty(FIELD_DUBBO_VERSION, StringUtils.trimAllWhitespace(version)));
|
||||
}
|
||||
|
||||
/**
|
||||
* get retries
|
||||
*
|
||||
* @return the retries
|
||||
*/
|
||||
public static final String getRetries(TestElement element) {
|
||||
return element.getPropertyAsString(FIELD_DUBBO_RETRIES, DEFAULT_RETRIES);
|
||||
}
|
||||
|
||||
/**
|
||||
* set retries
|
||||
*
|
||||
* @param retries the retries to set
|
||||
*/
|
||||
public static final void setRetries(String retries, TestElement element) {
|
||||
element.setProperty(new StringProperty(FIELD_DUBBO_RETRIES, StringUtils.trimAllWhitespace(retries)));
|
||||
}
|
||||
|
||||
/**
|
||||
* get cluster
|
||||
*
|
||||
* @return the cluster
|
||||
*/
|
||||
public static final String getCluster(TestElement element) {
|
||||
return element.getPropertyAsString(FIELD_DUBBO_CLUSTER, DEFAULT_CLUSTER);
|
||||
}
|
||||
|
||||
/**
|
||||
* set cluster
|
||||
*
|
||||
* @param cluster the cluster to set
|
||||
*/
|
||||
public static final void setCluster(String cluster, TestElement element) {
|
||||
element.setProperty(new StringProperty(FIELD_DUBBO_CLUSTER, StringUtils.trimAllWhitespace(cluster)));
|
||||
}
|
||||
|
||||
/**
|
||||
* get group
|
||||
*
|
||||
* @return the group
|
||||
*/
|
||||
public static final String getGroup(TestElement element) {
|
||||
return element.getPropertyAsString(FIELD_DUBBO_GROUP, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* set group
|
||||
*
|
||||
* @param group the group to set
|
||||
*/
|
||||
public static final void setGroup(String group, TestElement element) {
|
||||
element.setProperty(new StringProperty(FIELD_DUBBO_GROUP, StringUtils.trimAllWhitespace(group)));
|
||||
}
|
||||
|
||||
/**
|
||||
* get connections
|
||||
*
|
||||
* @return the group
|
||||
*/
|
||||
public static final String getConnections(TestElement element) {
|
||||
return element.getPropertyAsString(FIELD_DUBBO_CONNECTIONS, DEFAULT_CONNECTIONS);
|
||||
}
|
||||
|
||||
/**
|
||||
* set connections
|
||||
*
|
||||
* @param connections the connections to set
|
||||
*/
|
||||
public static final void setConnections(String connections, TestElement element) {
|
||||
element.setProperty(new StringProperty(FIELD_DUBBO_CONNECTIONS, StringUtils.trimAllWhitespace(connections)));
|
||||
}
|
||||
|
||||
/**
|
||||
* get loadbalance
|
||||
*
|
||||
* @return the loadbalance
|
||||
*/
|
||||
public static final String getLoadbalance(TestElement element) {
|
||||
return element.getPropertyAsString(FIELD_DUBBO_LOADBALANCE);
|
||||
}
|
||||
|
||||
/**
|
||||
* set loadbalance
|
||||
*
|
||||
* @param loadbalance the loadbalance to set
|
||||
*/
|
||||
public static final void setLoadbalance(String loadbalance, TestElement element) {
|
||||
element.setProperty(new StringProperty(FIELD_DUBBO_LOADBALANCE, StringUtils.trimAllWhitespace(loadbalance)));
|
||||
}
|
||||
|
||||
/**
|
||||
* get async
|
||||
*
|
||||
* @return the async
|
||||
*/
|
||||
public static final String getAsync(TestElement element) {
|
||||
return element.getPropertyAsString(FIELD_DUBBO_ASYNC);
|
||||
}
|
||||
|
||||
/**
|
||||
* set async
|
||||
*
|
||||
* @param async the async to set
|
||||
*/
|
||||
public static final void setAsync(String async, TestElement element) {
|
||||
element.setProperty(new StringProperty(FIELD_DUBBO_ASYNC, StringUtils.trimAllWhitespace(async)));
|
||||
}
|
||||
|
||||
/**
|
||||
* get interfaceName
|
||||
*
|
||||
* @return the interfaceName
|
||||
*/
|
||||
public static final String getInterface(TestElement element) {
|
||||
return element.getPropertyAsString(FIELD_DUBBO_INTERFACE);
|
||||
}
|
||||
|
||||
/**
|
||||
* set interfaceName
|
||||
*
|
||||
* @param interfaceName the interfaceName to set
|
||||
*/
|
||||
public static final void setInterfaceName(String interfaceName, TestElement element) {
|
||||
element.setProperty(new StringProperty(FIELD_DUBBO_INTERFACE, StringUtils.trimAllWhitespace(interfaceName)));
|
||||
}
|
||||
|
||||
/**
|
||||
* get method
|
||||
*
|
||||
* @return the method
|
||||
*/
|
||||
public static final String getMethod(TestElement element) {
|
||||
return element.getPropertyAsString(FIELD_DUBBO_METHOD);
|
||||
}
|
||||
|
||||
/**
|
||||
* set method
|
||||
*
|
||||
* @param method the method to set
|
||||
*/
|
||||
public static final void setMethod(String method, TestElement element) {
|
||||
element.setProperty(new StringProperty(FIELD_DUBBO_METHOD, StringUtils.trimAllWhitespace(method)));
|
||||
}
|
||||
|
||||
/**
|
||||
* get methodArgs
|
||||
*
|
||||
* @return the methodArgs
|
||||
*/
|
||||
public static final List<MethodArgument> getMethodArgs(TestElement element) {
|
||||
int paramsSize = element.getPropertyAsInt(FIELD_DUBBO_METHOD_ARGS_SIZE, 0);
|
||||
List<MethodArgument> list = new ArrayList<MethodArgument>();
|
||||
for (int i = 1; i <= paramsSize; i++) {
|
||||
String paramType = element.getPropertyAsString(FIELD_DUBBO_METHOD_ARGS + "_PARAM_TYPE" + i);
|
||||
String paramValue = element.getPropertyAsString(FIELD_DUBBO_METHOD_ARGS + "_PARAM_VALUE" + i);
|
||||
MethodArgument args = new MethodArgument(paramType, paramValue);
|
||||
list.add(args);
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
/**
|
||||
* set methodArgs
|
||||
*
|
||||
* @param methodArgs the methodArgs to set
|
||||
*/
|
||||
public static final void setMethodArgs(List<MethodArgument> methodArgs, TestElement element) {
|
||||
int size = methodArgs == null ? 0 : methodArgs.size();
|
||||
element.setProperty(new IntegerProperty(FIELD_DUBBO_METHOD_ARGS_SIZE, size));
|
||||
if (size > 0) {
|
||||
for (int i = 1; i <= methodArgs.size(); i++) {
|
||||
element.setProperty(new StringProperty(FIELD_DUBBO_METHOD_ARGS + "_PARAM_TYPE" + i, methodArgs.get(i - 1).getParamType()));
|
||||
element.setProperty(new StringProperty(FIELD_DUBBO_METHOD_ARGS + "_PARAM_VALUE" + i, methodArgs.get(i - 1).getParamValue()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* get attachmentArgs
|
||||
*
|
||||
* @return the attachmentArgs
|
||||
*/
|
||||
public static final List<MethodArgument> getAttachmentArgs(TestElement element) {
|
||||
int paramsSize = element.getPropertyAsInt(FIELD_DUBBO_ATTACHMENT_ARGS_SIZE, 0);
|
||||
List<MethodArgument> list = new ArrayList<MethodArgument>();
|
||||
for (int i = 1; i <= paramsSize; i++) {
|
||||
String paramType = element.getPropertyAsString(FIELD_DUBBO_ATTACHMENT_ARGS + "_KEY" + i);
|
||||
String paramValue = element.getPropertyAsString(FIELD_DUBBO_ATTACHMENT_ARGS + "_VALUE" + i);
|
||||
MethodArgument args = new MethodArgument(paramType, paramValue);
|
||||
list.add(args);
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
/**
|
||||
* set attachmentArgs
|
||||
*
|
||||
* @param methodArgs the attachmentArgs to set
|
||||
*/
|
||||
public static final void setAttachmentArgs(List<MethodArgument> methodArgs, TestElement element) {
|
||||
int size = methodArgs == null ? 0 : methodArgs.size();
|
||||
element.setProperty(new IntegerProperty(FIELD_DUBBO_ATTACHMENT_ARGS_SIZE, size));
|
||||
if (size > 0) {
|
||||
for (int i = 1; i <= methodArgs.size(); i++) {
|
||||
element.setProperty(new StringProperty(FIELD_DUBBO_ATTACHMENT_ARGS + "_KEY" + i, methodArgs.get(i - 1).getParamType()));
|
||||
element.setProperty(new StringProperty(FIELD_DUBBO_ATTACHMENT_ARGS + "_VALUE" + i, methodArgs.get(i - 1).getParamValue()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -1,52 +0,0 @@
|
|||
package io.metersphere.api.dubbo.utils;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.GsonBuilder;
|
||||
import com.google.gson.JsonSyntaxException;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.lang.reflect.Type;
|
||||
|
||||
/**
|
||||
* JsonUtils
|
||||
*/
|
||||
public class JsonUtils {
|
||||
|
||||
private static final Logger logger = LoggerFactory.getLogger(JsonUtils.class);
|
||||
|
||||
private static final Gson gson = new GsonBuilder()
|
||||
.setDateFormat("yyyy-MM-dd HH:mm:ss")
|
||||
.setPrettyPrinting()
|
||||
.disableHtmlEscaping()
|
||||
.serializeNulls()
|
||||
.create();
|
||||
|
||||
public static String toJson(Object obj) {
|
||||
return gson.toJson(obj);
|
||||
}
|
||||
|
||||
public static String toJson(Object obj, Type type) {
|
||||
return gson.toJson(obj, type);
|
||||
}
|
||||
|
||||
public static <T> T formJson(String json, Class<T> classOfT) {
|
||||
try {
|
||||
return gson.fromJson(json, classOfT);
|
||||
} catch (JsonSyntaxException e) {
|
||||
logger.error("json to class[" + classOfT.getName() + "] is error!",
|
||||
e);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static <T> T formJson(String json, Type type) {
|
||||
try {
|
||||
return gson.fromJson(json, type);
|
||||
} catch (JsonSyntaxException e) {
|
||||
logger.error("json to class[" + type.getClass().getName()
|
||||
+ "] is error!", e);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
|
@ -1,65 +0,0 @@
|
|||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
* (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package io.metersphere.api.dubbo.utils;
|
||||
|
||||
import java.security.MessageDigest;
|
||||
import java.security.NoSuchAlgorithmException;
|
||||
|
||||
/**
|
||||
* MD5Util
|
||||
*/
|
||||
public class MD5Util {
|
||||
private static MessageDigest md;
|
||||
private static final char[] hexCode = "0123456789ABCDEF".toCharArray();
|
||||
|
||||
static {
|
||||
try {
|
||||
md = MessageDigest.getInstance("MD5");
|
||||
} catch (NoSuchAlgorithmException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public static String MD5_16bit(String input) {
|
||||
String hash = MD5_32bit(input);
|
||||
if (hash == null) {
|
||||
return null;
|
||||
}
|
||||
return hash.substring(8, 24);
|
||||
}
|
||||
|
||||
public static String MD5_32bit(String input) {
|
||||
if (input == null || input.length() == 0) {
|
||||
return null;
|
||||
}
|
||||
md.update(input.getBytes());
|
||||
byte[] digest = md.digest();
|
||||
String hash = convertToString(digest);
|
||||
return hash;
|
||||
}
|
||||
|
||||
private static String convertToString(byte[] data) {
|
||||
StringBuilder r = new StringBuilder(data.length * 2);
|
||||
for (byte b : data) {
|
||||
r.append(hexCode[(b >> 4) & 0xF]);
|
||||
r.append(hexCode[(b & 0xF)]);
|
||||
}
|
||||
return r.toString();
|
||||
}
|
||||
|
||||
}
|
|
@ -1,69 +0,0 @@
|
|||
package io.metersphere.api.dubbo.utils;
|
||||
|
||||
/**
|
||||
* StringUtils
|
||||
*/
|
||||
public class StringUtils {
|
||||
|
||||
public static boolean hasLength(String str) {
|
||||
return str != null && !str.isEmpty();
|
||||
}
|
||||
|
||||
public static String trimAllWhitespace(String str) {
|
||||
if (!hasLength(str)) {
|
||||
return str;
|
||||
} else {
|
||||
int len = str.length();
|
||||
StringBuilder sb = new StringBuilder(str.length());
|
||||
|
||||
for (int i = 0; i < len; ++i) {
|
||||
char c = str.charAt(i);
|
||||
if (!Character.isWhitespace(c)) {
|
||||
sb.append(c);
|
||||
}
|
||||
}
|
||||
|
||||
return sb.toString();
|
||||
}
|
||||
}
|
||||
|
||||
public static String trimWhitespace(String str) {
|
||||
if (!hasLength(str)) {
|
||||
return str;
|
||||
} else {
|
||||
StringBuilder sb = new StringBuilder(str);
|
||||
|
||||
while (sb.length() > 0 && Character.isWhitespace(sb.charAt(0))) {
|
||||
sb.deleteCharAt(0);
|
||||
}
|
||||
|
||||
while (sb.length() > 0 && Character.isWhitespace(sb.charAt(sb.length() - 1))) {
|
||||
sb.deleteCharAt(sb.length() - 1);
|
||||
}
|
||||
|
||||
return sb.toString();
|
||||
}
|
||||
}
|
||||
|
||||
public static boolean isBlank(CharSequence cs) {
|
||||
int strLen;
|
||||
if (cs != null && (strLen = cs.length()) != 0) {
|
||||
for (int i = 0; i < strLen; ++i) {
|
||||
if (!Character.isWhitespace(cs.charAt(i))) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
public static boolean isBlank1(String paramValue) {
|
||||
if (isBlank(paramValue) || "null".equals(paramValue.toLowerCase())) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
|
@ -142,9 +142,20 @@
|
|||
<select id="list" resultType="io.metersphere.track.dto.TestCaseDTO">
|
||||
select test_case.* from test_case
|
||||
<where>
|
||||
<if test="request.name != null">
|
||||
and test_case.name like CONCAT('%', #{request.name},'%')
|
||||
</if>
|
||||
<choose>
|
||||
<!--高级-->
|
||||
<when test="request.combine != null">
|
||||
<include refid="combine">
|
||||
<property name="condition" value="request.combine"/>
|
||||
</include>
|
||||
</when>
|
||||
<!--普通-->
|
||||
<otherwise>
|
||||
<if test="request.name != null">
|
||||
and test_case.name like CONCAT('%', #{request.name},'%')
|
||||
</if>
|
||||
</otherwise>
|
||||
</choose>
|
||||
<if test="request.nodeIds != null and request.nodeIds.size() > 0">
|
||||
and test_case.node_id in
|
||||
<foreach collection="request.nodeIds" item="nodeId" separator="," open="(" close=")">
|
||||
|
|
|
@ -6,15 +6,114 @@
|
|||
extends="io.metersphere.base.mapper.TestPlanMapper.BaseResultMap">
|
||||
<result column="project_name" property="projectName"/>
|
||||
</resultMap>
|
||||
<sql id="condition">
|
||||
<choose>
|
||||
<when test='${object}.operator == "like"'>
|
||||
like CONCAT('%', #{${object}.value},'%')
|
||||
</when>
|
||||
<when test='${object}.operator == "not like"'>
|
||||
not like CONCAT('%', #{${object}.value},'%')
|
||||
</when>
|
||||
<when test='${object}.operator == "in"'>
|
||||
in
|
||||
<foreach collection="${object}.value" item="v" separator="," open="(" close=")">
|
||||
#{v}
|
||||
</foreach>
|
||||
</when>
|
||||
<when test='${object}.operator == "not in"'>
|
||||
not in
|
||||
<foreach collection="${object}.value" item="v" separator="," open="(" close=")">
|
||||
#{v}
|
||||
</foreach>
|
||||
</when>
|
||||
<when test='${object}.operator == "between"'>
|
||||
between #{${object}.value[0]} and #{${object}.value[1]}
|
||||
</when>
|
||||
<when test='${object}.operator == "gt"'>
|
||||
> #{${object}.value}
|
||||
</when>
|
||||
<when test='${object}.operator == "lt"'>
|
||||
< #{${object}.value}
|
||||
</when>
|
||||
<when test='${object}.operator == "ge"'>
|
||||
>= #{${object}.value}
|
||||
</when>
|
||||
<when test='${object}.operator == "le"'>
|
||||
<= #{${object}.value}
|
||||
</when>
|
||||
<when test='${object}.operator == "current user"'>
|
||||
= '${@io.metersphere.commons.utils.SessionUtils@getUserId()}'
|
||||
</when>
|
||||
<otherwise>
|
||||
= #{${object}.value}
|
||||
</otherwise>
|
||||
</choose>
|
||||
</sql>
|
||||
|
||||
<sql id="combine">
|
||||
<if test="${condition}.name != null">
|
||||
and test_plan.name
|
||||
<include refid="condition">
|
||||
<property name="object" value="${condition}.name"/>
|
||||
</include>
|
||||
</if>
|
||||
<if test="${condition}.projectName != null">
|
||||
and project.name
|
||||
<include refid="condition">
|
||||
<property name="object" value="${condition}.projectName"/>
|
||||
</include>
|
||||
</if>
|
||||
<if test="${condition}.principal != null">
|
||||
and test_plan.principal
|
||||
<include refid="condition">
|
||||
<property name="object" value="${condition}.principal"/>
|
||||
</include>
|
||||
</if>
|
||||
<if test="${condition}.createTime != null">
|
||||
and test_plan.create_time
|
||||
<include refid="condition">
|
||||
<property name="object" value="${condition}.createTime"/>
|
||||
</include>
|
||||
</if>
|
||||
<if test="${condition}.status != null">
|
||||
and test_plan.status
|
||||
<include refid="condition">
|
||||
<property name="object" value="${condition}.status"/>
|
||||
</include>
|
||||
</if>
|
||||
<if test="${condition}.updateTime != null">
|
||||
and test_plan.update_time
|
||||
<include refid="condition">
|
||||
<property name="object" value="${condition}.updateTime"/>
|
||||
</include>
|
||||
</if>
|
||||
<if test="${condition}.stage != null">
|
||||
and test_plan.stage
|
||||
<include refid="condition">
|
||||
<property name="object" value="${condition}.stage"/>
|
||||
</include>
|
||||
</if>
|
||||
</sql>
|
||||
|
||||
<select id="list" resultMap="BaseResultMap" parameterType="io.metersphere.track.request.testcase.QueryTestPlanRequest">
|
||||
select test_plan.*, project.name as project_name
|
||||
from test_plan
|
||||
left join project on test_plan.project_id = project.id
|
||||
<where>
|
||||
<if test="request.name != null">
|
||||
and test_plan.name like CONCAT('%', #{request.name},'%')
|
||||
</if>
|
||||
<choose>
|
||||
<!--高级-->
|
||||
<when test="request.combine != null">
|
||||
<include refid="combine">
|
||||
<property name="condition" value="request.combine"/>
|
||||
</include>
|
||||
</when>
|
||||
<!--普通-->
|
||||
<otherwise>
|
||||
<if test="request.name != null">
|
||||
and test_plan.name like CONCAT('%', #{request.name},'%')
|
||||
</if>
|
||||
</otherwise>
|
||||
</choose>
|
||||
<if test="request.workspaceId != null">
|
||||
AND project.workspace_id = #{request.workspaceId}
|
||||
</if>
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
</resultMap>
|
||||
|
||||
<select id="getUserList" resultMap="BaseResultMap">
|
||||
select u.id, u.name, u.email, u.phone, u.language, u.status,
|
||||
select u.id, u.name, u.email, u.phone, u.language, u.status, u.source,
|
||||
u.last_organization_id, u.last_workspace_id, u.language, u.create_time, u.update_time
|
||||
from `user` u
|
||||
<where>
|
||||
|
|
|
@ -2,9 +2,13 @@ package io.metersphere.controller;
|
|||
|
||||
import io.metersphere.base.domain.SystemParameter;
|
||||
import io.metersphere.commons.constants.ParamConstants;
|
||||
import io.metersphere.commons.constants.RoleConstants;
|
||||
import io.metersphere.ldap.domain.LdapInfo;
|
||||
import io.metersphere.service.SystemParameterService;
|
||||
import org.apache.shiro.authz.annotation.Logical;
|
||||
import org.apache.shiro.authz.annotation.RequiresRoles;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
@ -16,11 +20,13 @@ public class SystemParameterController {
|
|||
private SystemParameterService SystemParameterService;
|
||||
|
||||
@PostMapping("/edit/email")
|
||||
@RequiresRoles(value = {RoleConstants.ADMIN})
|
||||
public void editMail(@RequestBody List<SystemParameter> systemParameter) {
|
||||
SystemParameterService.editMail(systemParameter);
|
||||
}
|
||||
|
||||
@PostMapping("/testConnection")
|
||||
@RequiresRoles(value = {RoleConstants.ADMIN})
|
||||
public void testConnection(@RequestBody HashMap<String, String> hashMap) {
|
||||
SystemParameterService.testConnection(hashMap);
|
||||
}
|
||||
|
@ -31,16 +37,19 @@ public class SystemParameterController {
|
|||
}
|
||||
|
||||
@GetMapping("/mail/info")
|
||||
@RequiresRoles(value = {RoleConstants.ADMIN})
|
||||
public Object mailInfo() {
|
||||
return SystemParameterService.mailInfo(ParamConstants.Classify.MAIL.getValue());
|
||||
}
|
||||
|
||||
@PostMapping("/save/ldap")
|
||||
@RequiresRoles(value = {RoleConstants.ADMIN})
|
||||
public void saveLdap(@RequestBody List<SystemParameter> systemParameter) {
|
||||
SystemParameterService.saveLdap(systemParameter);
|
||||
}
|
||||
|
||||
@GetMapping("/ldap/info")
|
||||
@RequiresRoles(value = {RoleConstants.ADMIN})
|
||||
public LdapInfo getLdapInfo() {
|
||||
return SystemParameterService.getLdapInfo(ParamConstants.Classify.LDAP.getValue());
|
||||
}
|
||||
|
|
|
@ -1,9 +1,12 @@
|
|||
package io.metersphere.controller;
|
||||
|
||||
import io.metersphere.base.domain.UserKey;
|
||||
import io.metersphere.commons.constants.RoleConstants;
|
||||
import io.metersphere.commons.utils.SessionUtils;
|
||||
import io.metersphere.security.ApiKeyHandler;
|
||||
import io.metersphere.service.UserKeyService;
|
||||
import org.apache.shiro.authz.annotation.Logical;
|
||||
import org.apache.shiro.authz.annotation.RequiresRoles;
|
||||
import org.apache.shiro.web.util.WebUtils;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
|
@ -16,6 +19,7 @@ import java.util.List;
|
|||
|
||||
@RestController
|
||||
@RequestMapping("user/key")
|
||||
@RequiresRoles(value = {RoleConstants.ADMIN, RoleConstants.TEST_MANAGER, RoleConstants.TEST_USER, RoleConstants.TEST_VIEWER, RoleConstants.ORG_ADMIN}, logical = Logical.OR)
|
||||
public class UserKeysController {
|
||||
|
||||
@Resource
|
||||
|
|
|
@ -109,7 +109,7 @@ public class DockerTestEngine extends AbstractEngine {
|
|||
restTemplateWithTimeOut.getForObject(uri, String.class);
|
||||
} catch (Exception e) {
|
||||
LogUtil.error("stop load test fail... " + testId, e);
|
||||
MSException.throwException(Translator.get("container_delete_fail") + ", Error: " + e.getMessage());
|
||||
MSException.throwException(Translator.get("container_delete_fail"));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
|
@ -25,6 +25,7 @@ import java.util.List;
|
|||
|
||||
@RequestMapping("/test/case")
|
||||
@RestController
|
||||
@RequiresRoles(value = {RoleConstants.ADMIN, RoleConstants.TEST_MANAGER, RoleConstants.TEST_USER, RoleConstants.TEST_VIEWER, RoleConstants.ORG_ADMIN}, logical = Logical.OR)
|
||||
public class TestCaseController {
|
||||
|
||||
@Resource
|
||||
|
|
|
@ -10,10 +10,11 @@ import org.apache.shiro.authz.annotation.RequiresRoles;
|
|||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.*;
|
||||
import java.util.List;
|
||||
|
||||
@RequestMapping("/case/node")
|
||||
@RestController
|
||||
@RequiresRoles(value = {RoleConstants.ADMIN, RoleConstants.TEST_MANAGER, RoleConstants.TEST_USER, RoleConstants.TEST_VIEWER, RoleConstants.ORG_ADMIN}, logical = Logical.OR)
|
||||
public class TestCaseNodeController {
|
||||
|
||||
@Resource
|
||||
|
|
|
@ -19,4 +19,6 @@ public class QueryTestPlanRequest extends TestPlan {
|
|||
private List<OrderRequest> orders;
|
||||
|
||||
private Map<String, List<String>> filters;
|
||||
|
||||
private Map<String, Object> combine;
|
||||
}
|
||||
|
|
|
@ -366,7 +366,7 @@ public class TestCaseService {
|
|||
data.setStepResult("");
|
||||
data.setRemark(t.getPerformName());
|
||||
}
|
||||
data.setMaintainer(user.getId());
|
||||
data.setMaintainer(t.getMaintainer());
|
||||
list.add(data);
|
||||
|
||||
});
|
||||
|
|
|
@ -1,33 +1,36 @@
|
|||
INSERT INTO user (id, name, email, password, status, create_time, update_time, language, last_workspace_id, last_organization_id, phone)
|
||||
VALUES ('admin', 'Administrator', 'admin@metersphere.io', md5('metersphere'), '1', 1582597567455, 1582597567455, null, '', null, null);
|
||||
VALUES ('admin', 'Administrator', 'admin@metersphere.io', md5('metersphere'), '1', unix_timestamp() * 1000, unix_timestamp() * 1000, NULL, '', NULL,
|
||||
NULL);
|
||||
|
||||
INSERT INTO user_role (id, user_id, role_id, source_id, create_time, update_time)
|
||||
VALUES (uuid(), 'admin', 'admin', '1', 1581576575948, 1581576575948);
|
||||
VALUES (uuid(), 'admin', 'admin', '1', unix_timestamp() * 1000, unix_timestamp() * 1000);
|
||||
|
||||
INSERT INTO role (id, name, description, type, create_time, update_time)
|
||||
VALUES ('admin', '系统管理员', NULL, NULL, 1581576575948, 1581576575948);
|
||||
VALUES ('admin', '系统管理员', NULL, NULL, unix_timestamp() * 1000, unix_timestamp() * 1000);
|
||||
INSERT INTO role (id, name, description, type, create_time, update_time)
|
||||
VALUES ('org_admin', '组织管理员', NULL, NULL, 1581576575948, 1581576575948);
|
||||
VALUES ('org_admin', '组织管理员', NULL, NULL, unix_timestamp() * 1000, unix_timestamp() * 1000);
|
||||
INSERT INTO role (id, name, description, type, create_time, update_time)
|
||||
VALUES ('test_manager', '测试经理', NULL, NULL, 1581576575948, 1581576575948);
|
||||
VALUES ('test_manager', '测试经理', NULL, NULL, unix_timestamp() * 1000, unix_timestamp() * 1000);
|
||||
INSERT INTO role (id, name, description, type, create_time, update_time)
|
||||
VALUES ('test_user', '测试人员', NULL, NULL, 1581576575948, 1581576575948);
|
||||
VALUES ('test_user', '测试人员', NULL, NULL, unix_timestamp() * 1000, unix_timestamp() * 1000);
|
||||
INSERT INTO role (id, name, description, type, create_time, update_time)
|
||||
VALUES ('test_viewer', 'Viewer', NULL, NULL, 1581576575948, 1581576575948);
|
||||
VALUES ('test_viewer', 'Viewer', NULL, NULL, unix_timestamp() * 1000, unix_timestamp() * 1000);
|
||||
|
||||
INSERT INTO organization (id, name, description, create_time, update_time)
|
||||
VALUES (uuid(), '默认组织', '系统默认创建的组织', 1581576575948, 1581576575948);
|
||||
VALUES (uuid(), '默认组织', '系统默认创建的组织', unix_timestamp() * 1000, unix_timestamp() * 1000);
|
||||
INSERT INTO workspace (id, organization_id, name, description, create_time, update_time)
|
||||
VALUES (uuid(), (select id from organization where name like '默认组织'), '默认工作空间', '系统默认创建的工作空间', 1581576575948, 1581576575948);
|
||||
VALUES (uuid(), (SELECT id FROM organization WHERE name LIKE '默认组织'), '默认工作空间', '系统默认创建的工作空间', unix_timestamp() * 1000, unix_timestamp() * 1000);
|
||||
INSERT INTO user_role (id, user_id, role_id, source_id, create_time, update_time)
|
||||
VALUES (uuid(), 'admin', 'org_admin', (select id from organization where name like '默认组织'), 1581576575948, 1581576575948);
|
||||
VALUES (uuid(), 'admin', 'org_admin', (SELECT id FROM organization WHERE name LIKE '默认组织'), unix_timestamp() * 1000, unix_timestamp() * 1000);
|
||||
INSERT INTO user_role (id, user_id, role_id, source_id, create_time, update_time)
|
||||
VALUES (uuid(), 'admin', 'test_manager', (select id from workspace where name like '默认工作空间'), 1581576575948, 1581576575948);
|
||||
VALUES (uuid(), 'admin', 'test_manager', (SELECT id FROM workspace WHERE name LIKE '默认工作空间'), unix_timestamp() * 1000, unix_timestamp() * 1000);
|
||||
|
||||
INSERT INTO test_resource_pool (id, name, type, description, status, create_time, update_time)
|
||||
VALUES (uuid(), 'LOCAL', 'NODE', '系统默认创建的本地资源池', 'VALID', 1581576575948, 1581576575948);
|
||||
VALUES (uuid(), 'LOCAL', 'NODE', '系统默认创建的本地资源池', 'VALID', unix_timestamp() * 1000, unix_timestamp() * 1000);
|
||||
INSERT INTO test_resource (id, test_resource_pool_id, configuration, status, create_time, update_time)
|
||||
VALUES (uuid(), (select id from test_resource_pool where name like 'LOCAL'), 'GgC8aAZVAsiNDdnvp4gobdv1iwAvloLCAaeqb7Ms1VaLzW+iXHsFhGg8ZaPEk53W6xA5A6g+UUUxbKvU2s7yZw==', 'VALID', 1581576575948, 1581576575948);
|
||||
VALUES (uuid(), (SELECT id FROM test_resource_pool WHERE name LIKE 'LOCAL'),
|
||||
'GgC8aAZVAsiNDdnvp4gobdv1iwAvloLCAaeqb7Ms1VaLzW+iXHsFhGg8ZaPEk53W6xA5A6g+UUUxbKvU2s7yZw==', 'VALID', unix_timestamp() * 1000,
|
||||
unix_timestamp() * 1000);
|
||||
|
||||
INSERT INTO test_case_report_template (id, name, content)
|
||||
VALUES (uuid(), 'default', '{\"components\": [1,2,3,4,5]}');
|
||||
|
|
|
@ -46,7 +46,7 @@ max_thread_insufficient=并发用户数超额
|
|||
related_case_del_fail_prefix=已关联到
|
||||
related_case_del_fail_suffix=测试用例,请先解除关联
|
||||
jmx_content_valid=JMX 内容无效,请检查
|
||||
container_delete_fail=容器停止失败,请重试
|
||||
container_delete_fail=容器由于网络原因停止失败,请重试
|
||||
#workspace
|
||||
workspace_name_is_null=工作空间名不能为空
|
||||
workspace_name_already_exists=工作空间名已存在
|
||||
|
|
|
@ -46,7 +46,7 @@ max_thread_insufficient=並發用戶數超額
|
|||
related_case_del_fail_prefix=已關聯到
|
||||
related_case_del_fail_suffix=測試用例,請先解除關聯
|
||||
jmx_content_valid=JMX 內容無效,請檢查
|
||||
container_delete_fail=容器停止失敗,請重試
|
||||
container_delete_fail=容器由於網絡原因停止失敗,請重試
|
||||
#workspace
|
||||
workspace_name_is_null=工作空間名不能為空
|
||||
workspace_name_already_exists=工作空間名已存在
|
||||
|
|
|
@ -220,8 +220,72 @@ export const MODULE = {
|
|||
},
|
||||
}
|
||||
|
||||
export const PRINCIPAL = {
|
||||
key: "principal",
|
||||
name: 'MsTableSearchSelect',
|
||||
label: 'test_track.plan.plan_principal',
|
||||
operator: {
|
||||
options: [OPERATORS.IN, OPERATORS.NOT_IN, OPERATORS.CURRENT_USER],
|
||||
change: function (component, value) { // 运算符change事件
|
||||
if (value === OPERATORS.CURRENT_USER.value) {
|
||||
component.value = value;
|
||||
}
|
||||
}
|
||||
},
|
||||
options: { // 异步获取候选项
|
||||
url: "/user/list",
|
||||
labelKey: "name",
|
||||
valueKey: "id",
|
||||
showLabel: option => {
|
||||
return option.label + "(" + option.value + ")";
|
||||
}
|
||||
},
|
||||
props: {
|
||||
multiple: true
|
||||
},
|
||||
isShow: operator => {
|
||||
return operator !== OPERATORS.CURRENT_USER.value;
|
||||
}
|
||||
};
|
||||
|
||||
export const STAGE = {
|
||||
key: "stage",
|
||||
name: 'MsTableSearchSelect',
|
||||
label: "test_track.plan.plan_stage",
|
||||
operator: {
|
||||
options: [OPERATORS.IN, OPERATORS.NOT_IN]
|
||||
},
|
||||
options: [
|
||||
{label: 'test_track.plan.smoke_test', value: 'smoke'},
|
||||
{label: 'test_track.plan.regression_test', value: 'regression'},
|
||||
{label: 'test_track.plan.system_test', value: 'system'}
|
||||
],
|
||||
props: {
|
||||
multiple: true
|
||||
}
|
||||
};
|
||||
|
||||
export const TEST_PLAN_STATUS = {
|
||||
key: "status",
|
||||
name: 'MsTableSearchSelect',
|
||||
label: "test_track.plan.plan_status",
|
||||
operator: {
|
||||
options: [OPERATORS.IN, OPERATORS.NOT_IN]
|
||||
},
|
||||
options: [
|
||||
{label: 'test_track.plan.plan_status_prepare', value: 'Prepare'},
|
||||
{label: 'test_track.plan.plan_status_running', value: 'Underway'},
|
||||
{label: 'test_track.plan.plan_status_completed', value: 'Completed'}
|
||||
],
|
||||
props: {
|
||||
multiple: true
|
||||
}
|
||||
};
|
||||
|
||||
export const TEST_CONFIGS = [NAME, UPDATE_TIME, PROJECT_NAME, CREATE_TIME, STATUS, CREATOR];
|
||||
|
||||
export const REPORT_CONFIGS = [NAME, TEST_NAME, PROJECT_NAME, CREATE_TIME, STATUS, CREATOR, TRIGGER_MODE];
|
||||
|
||||
export const TEST_CASE_CONFIGS = [NAME, MODULE, PRIORITY, CREATE_TIME, TYPE, UPDATE_TIME, METHOD, CREATOR];
|
||||
|
||||
export const TEST_PLAN_CONFIGS = [NAME, UPDATE_TIME, PROJECT_NAME, CREATE_TIME, PRINCIPAL, TEST_PLAN_STATUS, STAGE];
|
||||
|
|
|
@ -101,7 +101,7 @@
|
|||
rule: {
|
||||
name: [
|
||||
{required: true, message: this.$t('member.input_name'), trigger: 'blur'},
|
||||
{min: 2, max: 10, message: this.$t('commons.input_limit', [2, 10]), trigger: 'blur'},
|
||||
{min: 2, max: 20, message: this.$t('commons.input_limit', [2, 20]), trigger: 'blur'},
|
||||
{
|
||||
required: true,
|
||||
pattern: /^[\u4e00-\u9fa5_a-zA-Z0-9.·-]+$/,
|
||||
|
|
|
@ -72,12 +72,7 @@
|
|||
data() {
|
||||
return {
|
||||
formInline: {
|
||||
/*host: 'smtp.163.com',
|
||||
port: '465',
|
||||
account: 'xjj0608@163.com',
|
||||
password: '2345678',*/
|
||||
},
|
||||
|
||||
input: '',
|
||||
visible: true,
|
||||
result: {},
|
||||
|
@ -113,7 +108,7 @@
|
|||
}
|
||||
},
|
||||
|
||||
activated() {
|
||||
created() {
|
||||
this.query()
|
||||
},
|
||||
methods: {
|
||||
|
@ -129,6 +124,9 @@
|
|||
this.$set(this.formInline, "SSL", JSON.parse(response.data[4].paramValue));
|
||||
this.$set(this.formInline, "TLS", JSON.parse(response.data[5].paramValue));
|
||||
this.$set(this.formInline, "SMTP", JSON.parse(response.data[6].paramValue));
|
||||
this.$nextTick(() => {
|
||||
this.$refs.formInline.clearValidate();
|
||||
})
|
||||
})
|
||||
},
|
||||
change() {
|
||||
|
|
|
@ -37,7 +37,7 @@
|
|||
<ms-table-operator @editClick="edit(scope.row)" @deleteClick="del(scope.row)">
|
||||
<template v-slot:behind>
|
||||
<ms-table-operator-button :tip="$t('member.edit_password')" icon="el-icon-s-tools"
|
||||
type="success" @exec="editPassword(scope.row)"/>
|
||||
type="success" @exec="editPassword(scope.row)" v-if="!scope.row.isLdapUser"/>
|
||||
</template>
|
||||
</ms-table-operator>
|
||||
</template>
|
||||
|
@ -163,7 +163,7 @@
|
|||
|
||||
<!--Modify user information in system settings-->
|
||||
<el-dialog :title="$t('user.modify')" :visible.sync="updateVisible" width="35%" :destroy-on-close="true"
|
||||
@close="handleClose">
|
||||
@close="handleClose" v-loading="result.loading">
|
||||
<el-form :model="form" label-position="right" label-width="120px" size="small" :rules="rule" ref="updateUserForm">
|
||||
<el-form-item label="ID" prop="id">
|
||||
<el-input v-model="form.id" autocomplete="off" :disabled="true"/>
|
||||
|
@ -172,7 +172,7 @@
|
|||
<el-input v-model="form.name" autocomplete="off"/>
|
||||
</el-form-item>
|
||||
<el-form-item :label="$t('commons.email')" prop="email">
|
||||
<el-input v-model="form.email" autocomplete="off"/>
|
||||
<el-input v-model="form.email" autocomplete="off" :disabled="form.source === 'LDAP' ? true : false"/>
|
||||
</el-form-item>
|
||||
<el-form-item :label="$t('commons.phone')" prop="phone">
|
||||
<el-input v-model="form.phone" autocomplete="off"/>
|
||||
|
@ -488,6 +488,7 @@
|
|||
let roles = data.roles;
|
||||
// let userRoles = result.userRoles;
|
||||
this.$set(this.tableData[i], "roles", roles);
|
||||
this.$set(this.tableData[i], "isLdapUser", this.tableData[i].source === 'LDAP' ? true : false);
|
||||
});
|
||||
}
|
||||
})
|
||||
|
|
|
@ -130,7 +130,8 @@
|
|||
import MsTableOperator from "../../../common/components/MsTableOperator";
|
||||
import MsTableOperatorButton from "../../../common/components/MsTableOperatorButton";
|
||||
import MsTableButton from "../../../common/components/MsTableButton";
|
||||
import {_filter, _sort, downloadFile, humpToLine} from "../../../../../common/js/utils";
|
||||
import {_filter, _sort} from "../../../../../common/js/utils";
|
||||
import {TEST_CASE_CONFIGS} from "../../../common/components/search/search-components";
|
||||
|
||||
export default {
|
||||
name: "TestCaseList",
|
||||
|
@ -147,7 +148,9 @@
|
|||
return {
|
||||
result: {},
|
||||
deletePath: "/test/case/delete",
|
||||
condition: {},
|
||||
condition: {
|
||||
components: TEST_CASE_CONFIGS
|
||||
},
|
||||
tableData: [],
|
||||
currentPage: 1,
|
||||
pageSize: 10,
|
||||
|
@ -193,11 +196,20 @@
|
|||
}
|
||||
},
|
||||
methods: {
|
||||
initTableData() {
|
||||
this.condition.nodeIds = this.selectNodeIds;
|
||||
initTableData(combine) {
|
||||
// 只有在点击高级搜索的查询按钮时combine才有值
|
||||
let condition = combine ? {combine: combine} : this.condition;
|
||||
if (this.planId) {
|
||||
// param.planId = this.planId;
|
||||
condition.planId = this.planId;
|
||||
}
|
||||
if (this.selectNodeIds && this.selectNodeIds.length > 0) {
|
||||
// param.nodeIds = this.selectNodeIds;
|
||||
condition.nodeIds = this.selectNodeIds;
|
||||
}
|
||||
if (this.currentProject) {
|
||||
this.condition.projectId = this.currentProject.id;
|
||||
this.result = this.$post(this.buildPagePath('/test/case/list'), this.condition, response => {
|
||||
condition.projectId = this.currentProject.id;
|
||||
this.result = this.$post(this.buildPagePath('/test/case/list'), condition, response => {
|
||||
let data = response.data;
|
||||
this.total = data.itemCount;
|
||||
this.tableData = data.listObject;
|
||||
|
@ -252,7 +264,7 @@
|
|||
});
|
||||
},
|
||||
refresh() {
|
||||
this.condition = {};
|
||||
this.condition = {components: TEST_CASE_CONFIGS};
|
||||
this.selectIds.clear();
|
||||
this.$emit('refresh');
|
||||
},
|
||||
|
|
|
@ -118,6 +118,7 @@
|
|||
import TestReportTemplateList from "../view/comonents/TestReportTemplateList";
|
||||
import TestCaseReportView from "../view/comonents/report/TestCaseReportView";
|
||||
import MsDeleteConfirm from "../../../common/components/MsDeleteConfirm";
|
||||
import {TEST_PLAN_CONFIGS} from "../../../common/components/search/search-components";
|
||||
|
||||
export default {
|
||||
name: "TestPlanList",
|
||||
|
@ -133,7 +134,9 @@
|
|||
result: {},
|
||||
queryPath: "/test/plan/list",
|
||||
deletePath: "/test/plan/delete",
|
||||
condition: {},
|
||||
condition: {
|
||||
components: TEST_PLAN_CONFIGS
|
||||
},
|
||||
currentPage: 1,
|
||||
pageSize: 10,
|
||||
isTestManagerOrTestUser: false,
|
||||
|
@ -164,8 +167,18 @@
|
|||
this.initTableData();
|
||||
},
|
||||
methods: {
|
||||
initTableData() {
|
||||
this.result = this.$post(this.buildPagePath(this.queryPath), this.condition, response => {
|
||||
initTableData(combine) {
|
||||
// 只有在点击高级搜索的查询按钮时combine才有值
|
||||
let condition = combine ? {combine: combine} : this.condition;
|
||||
if (this.planId) {
|
||||
// param.planId = this.planId;
|
||||
condition.planId = this.planId;
|
||||
}
|
||||
if (this.selectNodeIds && this.selectNodeIds.length > 0) {
|
||||
// param.nodeIds = this.selectNodeIds;
|
||||
condition.nodeIds = this.selectNodeIds;
|
||||
}
|
||||
this.result = this.$post(this.buildPagePath(this.queryPath), condition, response => {
|
||||
let data = response.data;
|
||||
this.total = data.itemCount;
|
||||
this.tableData = data.listObject;
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
<el-dialog :title="$t('test_track.plan_view.relevance_test_case')"
|
||||
:visible.sync="dialogFormVisible"
|
||||
@close="close"
|
||||
width="60%"
|
||||
width="60%" v-loading="result.loading"
|
||||
top="50px">
|
||||
|
||||
<el-container class="main-content">
|
||||
|
@ -18,7 +18,7 @@
|
|||
</el-aside>
|
||||
|
||||
<el-container>
|
||||
<el-main class="case-content" v-loading="result.loading">
|
||||
<el-main class="case-content">
|
||||
<ms-table-header :condition.sync="condition" @search="getCaseNames" title="" :show-create="false"/>
|
||||
<el-table
|
||||
:data="testCases"
|
||||
|
@ -26,7 +26,7 @@
|
|||
row-key="id"
|
||||
@select-all="handleSelectAll"
|
||||
@select="handleSelectionChange"
|
||||
height="70vh"
|
||||
height="50vh"
|
||||
ref="table">
|
||||
|
||||
<el-table-column
|
||||
|
@ -145,7 +145,7 @@
|
|||
let param = {};
|
||||
param.planId = this.planId;
|
||||
param.testCaseIds = [...this.selectIds];
|
||||
this.$post('/test/plan/relevance', param, () => {
|
||||
this.result = this.$post('/test/plan/relevance', param, () => {
|
||||
this.selectIds.clear();
|
||||
this.$success(this.$t('commons.save_success'));
|
||||
this.dialogFormVisible = false;
|
||||
|
|
|
@ -88,6 +88,10 @@
|
|||
<span class="cast_label">{{$t('test_track.case.module')}}:</span>
|
||||
<span class="cast_item">{{testCase.nodePath}}</span>
|
||||
</el-col>
|
||||
<el-col :span="4" :offset="1">
|
||||
<span class="cast_label">{{$t('test_track.case.prerequisite')}}:</span>
|
||||
<span class="cast_item">{{testCase.prerequisite}}</span>
|
||||
</el-col>
|
||||
</el-row>
|
||||
|
||||
<el-row v-if="testCase.method == 'auto' && testCase.testId">
|
||||
|
@ -121,17 +125,18 @@
|
|||
:default-sort="{prop: 'num', order: 'ascending'}"
|
||||
highlight-current-row>
|
||||
<el-table-column :label="$t('test_track.case.number')" prop="num" min-width="5%"></el-table-column>
|
||||
<el-table-column :label="$t('test_track.case.step_desc')" prop="desc" min-width="29%">
|
||||
|
||||
<el-table-column :label="$t('test_track.case.step_desc')" prop="desc" min-width="21%">
|
||||
<template v-slot:default="scope">
|
||||
<span>{{scope.row.desc}}</span>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column :label="$t('test_track.case.expected_results')" prop="result" min-width="28%">
|
||||
<el-table-column :label="$t('test_track.case.expected_results')" prop="result" min-width="21%">
|
||||
<template v-slot:default="scope">
|
||||
<span>{{scope.row.result}}</span>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column :label="$t('test_track.plan_view.actual_result')" min-width="29%">
|
||||
<el-table-column :label="$t('test_track.plan_view.actual_result')" min-width="21%">
|
||||
<template v-slot:default="scope">
|
||||
<el-input
|
||||
size="mini"
|
||||
|
@ -145,7 +150,7 @@
|
|||
<span>{{scope.row.actualResult}}</span>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column :label="$t('test_track.plan_view.step_result')" min-width="9%">
|
||||
<el-table-column :label="$t('test_track.plan_view.step_result')" min-width="12%">
|
||||
<template v-slot:default="scope">
|
||||
<el-select
|
||||
:disabled="isReadOnly"
|
||||
|
@ -297,15 +302,6 @@
|
|||
+ this.$t('test_track.length_less_than') + '300');
|
||||
return;
|
||||
}
|
||||
if (this.testCase.method != 'auto') {
|
||||
if (!result.executeResult) {
|
||||
this.$warning(this.testCase.steptResults[i].desc + this.$t('test_track.execution_result')
|
||||
);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
param.results.push(result);
|
||||
}
|
||||
|
||||
|
|
|
@ -206,7 +206,8 @@
|
|||
priorityFilters: [
|
||||
{text: 'P0', value: 'P0'},
|
||||
{text: 'P1', value: 'P1'},
|
||||
{text: 'P2', value: 'P2'}
|
||||
{text: 'P2', value: 'P2'},
|
||||
{text: 'P3', value: 'P3'}
|
||||
],
|
||||
methodFilters: [
|
||||
{text: this.$t('test_track.case.manual'), value: 'manual'},
|
||||
|
|
|
@ -418,9 +418,9 @@ export default {
|
|||
tip: "说明",
|
||||
export_tip: "导出方法",
|
||||
ms_tip: "支持 Metersphere json 格式",
|
||||
ms_export_tip: "通过 Metersphere Api 测试页面或者浏览器插件导出 json 格式文件",
|
||||
ms_export_tip: "通过 Metersphere 接口测试页面或者浏览器插件导出 json 格式文件",
|
||||
postman_tip: "只支持 Postman Collection v2.1 格式的 json 文件",
|
||||
swagger_tip: "只支持 Swagger2.x 版本的 json 文件",
|
||||
swagger_tip: "只支持 Swagger 2.x 版本的 json 文件",
|
||||
post_export_tip: "通过 Postman 导出测试集合",
|
||||
swagger_export_tip: "通过 Swagger 页面导出",
|
||||
suffixFormatErr: "文件格式不符合要求",
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
<meta charset="utf-8">
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
||||
<meta name="viewport" content="width=device-width,initial-scale=1.0">
|
||||
<link rel="icon" href="<%= BASE_URL %>favicon.png">
|
||||
<link rel="icon" href="<%= BASE_URL %>favicon.ico">
|
||||
<title>MeterSphere</title>
|
||||
</head>
|
||||
<body>
|
||||
|
|
Loading…
Reference in New Issue