feat(接口测试): 上传jar包

This commit is contained in:
chenjianxing 2020-10-20 12:54:09 +08:00
parent 9a009dbf28
commit bd43116ff4
23 changed files with 2036 additions and 290 deletions

View File

@ -150,6 +150,10 @@
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-slf4j-impl</artifactId>
</exclusion>
<exclusion>
<groupId>org.apache-extras.beanshell</groupId>
<artifactId>bsh</artifactId>
</exclusion>
</exclusions>
</dependency>
@ -506,6 +510,15 @@
<outputDirectory>src/main/resources/jmeter/lib/ext</outputDirectory>
<destFileName>jython-standalone.jar</destFileName>
</artifactItem>
<artifactItem>
<groupId>org.apache-extras.beanshell</groupId>
<artifactId>bsh</artifactId>
<version>2.0b6</version>
<type>jar</type>
<overWrite>true</overWrite>
<outputDirectory>src/main/resources/jmeter/lib/ext</outputDirectory>
<destFileName>bsh-2.0b6.jar</destFileName>
</artifactItem>
</artifactItems>
<outputDirectory>${project.build.directory}/wars</outputDirectory>
<overWriteReleases>false</overWriteReleases>
@ -584,4 +597,4 @@
</plugins>
</build>
</project>
</project>

View File

@ -6,6 +6,7 @@ import io.metersphere.commons.utils.LogUtil;
import io.metersphere.config.JmeterProperties;
import io.metersphere.i18n.Translator;
import org.apache.commons.lang3.StringUtils;
import org.apache.jmeter.NewDriver;
import org.apache.jmeter.config.Arguments;
import org.apache.jmeter.save.SaveService;
import org.apache.jmeter.util.JMeterUtils;
@ -29,6 +30,8 @@ public class JMeterService {
public void run(String testId, String debugReportId, InputStream is) {
String JMETER_HOME = getJmeterHome();
NewDriver.setContextClassLoader();
String JMETER_PROPERTIES = JMETER_HOME + "/bin/jmeter.properties";
JMeterUtils.loadJMeterProperties(JMETER_PROPERTIES);
JMeterUtils.setJMeterHome(JMETER_HOME);

View File

@ -1,4 +1,31 @@
package io.metersphere.api.jmeter;
import io.metersphere.commons.exception.MSException;
import io.metersphere.commons.utils.LogUtil;
import org.apache.jmeter.NewDriver;
import java.io.File;
import java.net.MalformedURLException;
public class NewDriverManager {
public static void loadJar(File file) {
if (file != null) {
try {
NewDriver.addURL(file.toURI().toURL());
} catch (Exception e) {
LogUtil.error(e.getMessage(), e);
MSException.throwException(e.getMessage());
}
}
}
public static void loadJar(String path) {
try {
NewDriver.addPath(path);
} catch (MalformedURLException e) {
LogUtil.error(e.getMessage(), e);
MSException.throwException(e.getMessage());
}
}
}

View File

@ -0,0 +1,29 @@
package io.metersphere.base.domain;
import java.io.Serializable;
import lombok.Data;
@Data
public class JarConfig implements Serializable {
private String id;
private String name;
private String fileName;
private String creator;
private String modifier;
private String path;
private Boolean enable;
private String description;
private Long createTime;
private Long updateTime;
private static final long serialVersionUID = 1L;
}

View File

@ -0,0 +1,870 @@
package io.metersphere.base.domain;
import java.util.ArrayList;
import java.util.List;
public class JarConfigExample {
protected String orderByClause;
protected boolean distinct;
protected List<Criteria> oredCriteria;
public JarConfigExample() {
oredCriteria = new ArrayList<Criteria>();
}
public void setOrderByClause(String orderByClause) {
this.orderByClause = orderByClause;
}
public String getOrderByClause() {
return orderByClause;
}
public void setDistinct(boolean distinct) {
this.distinct = distinct;
}
public boolean isDistinct() {
return distinct;
}
public List<Criteria> getOredCriteria() {
return oredCriteria;
}
public void or(Criteria criteria) {
oredCriteria.add(criteria);
}
public Criteria or() {
Criteria criteria = createCriteriaInternal();
oredCriteria.add(criteria);
return criteria;
}
public Criteria createCriteria() {
Criteria criteria = createCriteriaInternal();
if (oredCriteria.size() == 0) {
oredCriteria.add(criteria);
}
return criteria;
}
protected Criteria createCriteriaInternal() {
Criteria criteria = new Criteria();
return criteria;
}
public void clear() {
oredCriteria.clear();
orderByClause = null;
distinct = false;
}
protected abstract static class GeneratedCriteria {
protected List<Criterion> criteria;
protected GeneratedCriteria() {
super();
criteria = new ArrayList<Criterion>();
}
public boolean isValid() {
return criteria.size() > 0;
}
public List<Criterion> getAllCriteria() {
return criteria;
}
public List<Criterion> getCriteria() {
return criteria;
}
protected void addCriterion(String condition) {
if (condition == null) {
throw new RuntimeException("Value for condition cannot be null");
}
criteria.add(new Criterion(condition));
}
protected void addCriterion(String condition, Object value, String property) {
if (value == null) {
throw new RuntimeException("Value for " + property + " cannot be null");
}
criteria.add(new Criterion(condition, value));
}
protected void addCriterion(String condition, Object value1, Object value2, String property) {
if (value1 == null || value2 == null) {
throw new RuntimeException("Between values for " + property + " cannot be null");
}
criteria.add(new Criterion(condition, value1, value2));
}
public Criteria andIdIsNull() {
addCriterion("id is null");
return (Criteria) this;
}
public Criteria andIdIsNotNull() {
addCriterion("id is not null");
return (Criteria) this;
}
public Criteria andIdEqualTo(String value) {
addCriterion("id =", value, "id");
return (Criteria) this;
}
public Criteria andIdNotEqualTo(String value) {
addCriterion("id <>", value, "id");
return (Criteria) this;
}
public Criteria andIdGreaterThan(String value) {
addCriterion("id >", value, "id");
return (Criteria) this;
}
public Criteria andIdGreaterThanOrEqualTo(String value) {
addCriterion("id >=", value, "id");
return (Criteria) this;
}
public Criteria andIdLessThan(String value) {
addCriterion("id <", value, "id");
return (Criteria) this;
}
public Criteria andIdLessThanOrEqualTo(String value) {
addCriterion("id <=", value, "id");
return (Criteria) this;
}
public Criteria andIdLike(String value) {
addCriterion("id like", value, "id");
return (Criteria) this;
}
public Criteria andIdNotLike(String value) {
addCriterion("id not like", value, "id");
return (Criteria) this;
}
public Criteria andIdIn(List<String> values) {
addCriterion("id in", values, "id");
return (Criteria) this;
}
public Criteria andIdNotIn(List<String> values) {
addCriterion("id not in", values, "id");
return (Criteria) this;
}
public Criteria andIdBetween(String value1, String value2) {
addCriterion("id between", value1, value2, "id");
return (Criteria) this;
}
public Criteria andIdNotBetween(String value1, String value2) {
addCriterion("id not between", value1, value2, "id");
return (Criteria) this;
}
public Criteria andNameIsNull() {
addCriterion("`name` is null");
return (Criteria) this;
}
public Criteria andNameIsNotNull() {
addCriterion("`name` is not null");
return (Criteria) this;
}
public Criteria andNameEqualTo(String value) {
addCriterion("`name` =", value, "name");
return (Criteria) this;
}
public Criteria andNameNotEqualTo(String value) {
addCriterion("`name` <>", value, "name");
return (Criteria) this;
}
public Criteria andNameGreaterThan(String value) {
addCriterion("`name` >", value, "name");
return (Criteria) this;
}
public Criteria andNameGreaterThanOrEqualTo(String value) {
addCriterion("`name` >=", value, "name");
return (Criteria) this;
}
public Criteria andNameLessThan(String value) {
addCriterion("`name` <", value, "name");
return (Criteria) this;
}
public Criteria andNameLessThanOrEqualTo(String value) {
addCriterion("`name` <=", value, "name");
return (Criteria) this;
}
public Criteria andNameLike(String value) {
addCriterion("`name` like", value, "name");
return (Criteria) this;
}
public Criteria andNameNotLike(String value) {
addCriterion("`name` not like", value, "name");
return (Criteria) this;
}
public Criteria andNameIn(List<String> values) {
addCriterion("`name` in", values, "name");
return (Criteria) this;
}
public Criteria andNameNotIn(List<String> values) {
addCriterion("`name` not in", values, "name");
return (Criteria) this;
}
public Criteria andNameBetween(String value1, String value2) {
addCriterion("`name` between", value1, value2, "name");
return (Criteria) this;
}
public Criteria andNameNotBetween(String value1, String value2) {
addCriterion("`name` not between", value1, value2, "name");
return (Criteria) this;
}
public Criteria andFileNameIsNull() {
addCriterion("file_name is null");
return (Criteria) this;
}
public Criteria andFileNameIsNotNull() {
addCriterion("file_name is not null");
return (Criteria) this;
}
public Criteria andFileNameEqualTo(String value) {
addCriterion("file_name =", value, "fileName");
return (Criteria) this;
}
public Criteria andFileNameNotEqualTo(String value) {
addCriterion("file_name <>", value, "fileName");
return (Criteria) this;
}
public Criteria andFileNameGreaterThan(String value) {
addCriterion("file_name >", value, "fileName");
return (Criteria) this;
}
public Criteria andFileNameGreaterThanOrEqualTo(String value) {
addCriterion("file_name >=", value, "fileName");
return (Criteria) this;
}
public Criteria andFileNameLessThan(String value) {
addCriterion("file_name <", value, "fileName");
return (Criteria) this;
}
public Criteria andFileNameLessThanOrEqualTo(String value) {
addCriterion("file_name <=", value, "fileName");
return (Criteria) this;
}
public Criteria andFileNameLike(String value) {
addCriterion("file_name like", value, "fileName");
return (Criteria) this;
}
public Criteria andFileNameNotLike(String value) {
addCriterion("file_name not like", value, "fileName");
return (Criteria) this;
}
public Criteria andFileNameIn(List<String> values) {
addCriterion("file_name in", values, "fileName");
return (Criteria) this;
}
public Criteria andFileNameNotIn(List<String> values) {
addCriterion("file_name not in", values, "fileName");
return (Criteria) this;
}
public Criteria andFileNameBetween(String value1, String value2) {
addCriterion("file_name between", value1, value2, "fileName");
return (Criteria) this;
}
public Criteria andFileNameNotBetween(String value1, String value2) {
addCriterion("file_name not between", value1, value2, "fileName");
return (Criteria) this;
}
public Criteria andCreatorIsNull() {
addCriterion("creator is null");
return (Criteria) this;
}
public Criteria andCreatorIsNotNull() {
addCriterion("creator is not null");
return (Criteria) this;
}
public Criteria andCreatorEqualTo(String value) {
addCriterion("creator =", value, "creator");
return (Criteria) this;
}
public Criteria andCreatorNotEqualTo(String value) {
addCriterion("creator <>", value, "creator");
return (Criteria) this;
}
public Criteria andCreatorGreaterThan(String value) {
addCriterion("creator >", value, "creator");
return (Criteria) this;
}
public Criteria andCreatorGreaterThanOrEqualTo(String value) {
addCriterion("creator >=", value, "creator");
return (Criteria) this;
}
public Criteria andCreatorLessThan(String value) {
addCriterion("creator <", value, "creator");
return (Criteria) this;
}
public Criteria andCreatorLessThanOrEqualTo(String value) {
addCriterion("creator <=", value, "creator");
return (Criteria) this;
}
public Criteria andCreatorLike(String value) {
addCriterion("creator like", value, "creator");
return (Criteria) this;
}
public Criteria andCreatorNotLike(String value) {
addCriterion("creator not like", value, "creator");
return (Criteria) this;
}
public Criteria andCreatorIn(List<String> values) {
addCriterion("creator in", values, "creator");
return (Criteria) this;
}
public Criteria andCreatorNotIn(List<String> values) {
addCriterion("creator not in", values, "creator");
return (Criteria) this;
}
public Criteria andCreatorBetween(String value1, String value2) {
addCriterion("creator between", value1, value2, "creator");
return (Criteria) this;
}
public Criteria andCreatorNotBetween(String value1, String value2) {
addCriterion("creator not between", value1, value2, "creator");
return (Criteria) this;
}
public Criteria andModifierIsNull() {
addCriterion("modifier is null");
return (Criteria) this;
}
public Criteria andModifierIsNotNull() {
addCriterion("modifier is not null");
return (Criteria) this;
}
public Criteria andModifierEqualTo(String value) {
addCriterion("modifier =", value, "modifier");
return (Criteria) this;
}
public Criteria andModifierNotEqualTo(String value) {
addCriterion("modifier <>", value, "modifier");
return (Criteria) this;
}
public Criteria andModifierGreaterThan(String value) {
addCriterion("modifier >", value, "modifier");
return (Criteria) this;
}
public Criteria andModifierGreaterThanOrEqualTo(String value) {
addCriterion("modifier >=", value, "modifier");
return (Criteria) this;
}
public Criteria andModifierLessThan(String value) {
addCriterion("modifier <", value, "modifier");
return (Criteria) this;
}
public Criteria andModifierLessThanOrEqualTo(String value) {
addCriterion("modifier <=", value, "modifier");
return (Criteria) this;
}
public Criteria andModifierLike(String value) {
addCriterion("modifier like", value, "modifier");
return (Criteria) this;
}
public Criteria andModifierNotLike(String value) {
addCriterion("modifier not like", value, "modifier");
return (Criteria) this;
}
public Criteria andModifierIn(List<String> values) {
addCriterion("modifier in", values, "modifier");
return (Criteria) this;
}
public Criteria andModifierNotIn(List<String> values) {
addCriterion("modifier not in", values, "modifier");
return (Criteria) this;
}
public Criteria andModifierBetween(String value1, String value2) {
addCriterion("modifier between", value1, value2, "modifier");
return (Criteria) this;
}
public Criteria andModifierNotBetween(String value1, String value2) {
addCriterion("modifier not between", value1, value2, "modifier");
return (Criteria) this;
}
public Criteria andPathIsNull() {
addCriterion("`path` is null");
return (Criteria) this;
}
public Criteria andPathIsNotNull() {
addCriterion("`path` is not null");
return (Criteria) this;
}
public Criteria andPathEqualTo(String value) {
addCriterion("`path` =", value, "path");
return (Criteria) this;
}
public Criteria andPathNotEqualTo(String value) {
addCriterion("`path` <>", value, "path");
return (Criteria) this;
}
public Criteria andPathGreaterThan(String value) {
addCriterion("`path` >", value, "path");
return (Criteria) this;
}
public Criteria andPathGreaterThanOrEqualTo(String value) {
addCriterion("`path` >=", value, "path");
return (Criteria) this;
}
public Criteria andPathLessThan(String value) {
addCriterion("`path` <", value, "path");
return (Criteria) this;
}
public Criteria andPathLessThanOrEqualTo(String value) {
addCriterion("`path` <=", value, "path");
return (Criteria) this;
}
public Criteria andPathLike(String value) {
addCriterion("`path` like", value, "path");
return (Criteria) this;
}
public Criteria andPathNotLike(String value) {
addCriterion("`path` not like", value, "path");
return (Criteria) this;
}
public Criteria andPathIn(List<String> values) {
addCriterion("`path` in", values, "path");
return (Criteria) this;
}
public Criteria andPathNotIn(List<String> values) {
addCriterion("`path` not in", values, "path");
return (Criteria) this;
}
public Criteria andPathBetween(String value1, String value2) {
addCriterion("`path` between", value1, value2, "path");
return (Criteria) this;
}
public Criteria andPathNotBetween(String value1, String value2) {
addCriterion("`path` not between", value1, value2, "path");
return (Criteria) this;
}
public Criteria andEnableIsNull() {
addCriterion("`enable` is null");
return (Criteria) this;
}
public Criteria andEnableIsNotNull() {
addCriterion("`enable` is not null");
return (Criteria) this;
}
public Criteria andEnableEqualTo(Boolean value) {
addCriterion("`enable` =", value, "enable");
return (Criteria) this;
}
public Criteria andEnableNotEqualTo(Boolean value) {
addCriterion("`enable` <>", value, "enable");
return (Criteria) this;
}
public Criteria andEnableGreaterThan(Boolean value) {
addCriterion("`enable` >", value, "enable");
return (Criteria) this;
}
public Criteria andEnableGreaterThanOrEqualTo(Boolean value) {
addCriterion("`enable` >=", value, "enable");
return (Criteria) this;
}
public Criteria andEnableLessThan(Boolean value) {
addCriterion("`enable` <", value, "enable");
return (Criteria) this;
}
public Criteria andEnableLessThanOrEqualTo(Boolean value) {
addCriterion("`enable` <=", value, "enable");
return (Criteria) this;
}
public Criteria andEnableIn(List<Boolean> values) {
addCriterion("`enable` in", values, "enable");
return (Criteria) this;
}
public Criteria andEnableNotIn(List<Boolean> values) {
addCriterion("`enable` not in", values, "enable");
return (Criteria) this;
}
public Criteria andEnableBetween(Boolean value1, Boolean value2) {
addCriterion("`enable` between", value1, value2, "enable");
return (Criteria) this;
}
public Criteria andEnableNotBetween(Boolean value1, Boolean value2) {
addCriterion("`enable` not between", value1, value2, "enable");
return (Criteria) this;
}
public Criteria andDescriptionIsNull() {
addCriterion("description is null");
return (Criteria) this;
}
public Criteria andDescriptionIsNotNull() {
addCriterion("description is not null");
return (Criteria) this;
}
public Criteria andDescriptionEqualTo(String value) {
addCriterion("description =", value, "description");
return (Criteria) this;
}
public Criteria andDescriptionNotEqualTo(String value) {
addCriterion("description <>", value, "description");
return (Criteria) this;
}
public Criteria andDescriptionGreaterThan(String value) {
addCriterion("description >", value, "description");
return (Criteria) this;
}
public Criteria andDescriptionGreaterThanOrEqualTo(String value) {
addCriterion("description >=", value, "description");
return (Criteria) this;
}
public Criteria andDescriptionLessThan(String value) {
addCriterion("description <", value, "description");
return (Criteria) this;
}
public Criteria andDescriptionLessThanOrEqualTo(String value) {
addCriterion("description <=", value, "description");
return (Criteria) this;
}
public Criteria andDescriptionLike(String value) {
addCriterion("description like", value, "description");
return (Criteria) this;
}
public Criteria andDescriptionNotLike(String value) {
addCriterion("description not like", value, "description");
return (Criteria) this;
}
public Criteria andDescriptionIn(List<String> values) {
addCriterion("description in", values, "description");
return (Criteria) this;
}
public Criteria andDescriptionNotIn(List<String> values) {
addCriterion("description not in", values, "description");
return (Criteria) this;
}
public Criteria andDescriptionBetween(String value1, String value2) {
addCriterion("description between", value1, value2, "description");
return (Criteria) this;
}
public Criteria andDescriptionNotBetween(String value1, String value2) {
addCriterion("description not between", value1, value2, "description");
return (Criteria) this;
}
public Criteria andCreateTimeIsNull() {
addCriterion("create_time is null");
return (Criteria) this;
}
public Criteria andCreateTimeIsNotNull() {
addCriterion("create_time is not null");
return (Criteria) this;
}
public Criteria andCreateTimeEqualTo(Long value) {
addCriterion("create_time =", value, "createTime");
return (Criteria) this;
}
public Criteria andCreateTimeNotEqualTo(Long value) {
addCriterion("create_time <>", value, "createTime");
return (Criteria) this;
}
public Criteria andCreateTimeGreaterThan(Long value) {
addCriterion("create_time >", value, "createTime");
return (Criteria) this;
}
public Criteria andCreateTimeGreaterThanOrEqualTo(Long value) {
addCriterion("create_time >=", value, "createTime");
return (Criteria) this;
}
public Criteria andCreateTimeLessThan(Long value) {
addCriterion("create_time <", value, "createTime");
return (Criteria) this;
}
public Criteria andCreateTimeLessThanOrEqualTo(Long value) {
addCriterion("create_time <=", value, "createTime");
return (Criteria) this;
}
public Criteria andCreateTimeIn(List<Long> values) {
addCriterion("create_time in", values, "createTime");
return (Criteria) this;
}
public Criteria andCreateTimeNotIn(List<Long> values) {
addCriterion("create_time not in", values, "createTime");
return (Criteria) this;
}
public Criteria andCreateTimeBetween(Long value1, Long value2) {
addCriterion("create_time between", value1, value2, "createTime");
return (Criteria) this;
}
public Criteria andCreateTimeNotBetween(Long value1, Long value2) {
addCriterion("create_time not between", value1, value2, "createTime");
return (Criteria) this;
}
public Criteria andUpdateTimeIsNull() {
addCriterion("update_time is null");
return (Criteria) this;
}
public Criteria andUpdateTimeIsNotNull() {
addCriterion("update_time is not null");
return (Criteria) this;
}
public Criteria andUpdateTimeEqualTo(Long value) {
addCriterion("update_time =", value, "updateTime");
return (Criteria) this;
}
public Criteria andUpdateTimeNotEqualTo(Long value) {
addCriterion("update_time <>", value, "updateTime");
return (Criteria) this;
}
public Criteria andUpdateTimeGreaterThan(Long value) {
addCriterion("update_time >", value, "updateTime");
return (Criteria) this;
}
public Criteria andUpdateTimeGreaterThanOrEqualTo(Long value) {
addCriterion("update_time >=", value, "updateTime");
return (Criteria) this;
}
public Criteria andUpdateTimeLessThan(Long value) {
addCriterion("update_time <", value, "updateTime");
return (Criteria) this;
}
public Criteria andUpdateTimeLessThanOrEqualTo(Long value) {
addCriterion("update_time <=", value, "updateTime");
return (Criteria) this;
}
public Criteria andUpdateTimeIn(List<Long> values) {
addCriterion("update_time in", values, "updateTime");
return (Criteria) this;
}
public Criteria andUpdateTimeNotIn(List<Long> values) {
addCriterion("update_time not in", values, "updateTime");
return (Criteria) this;
}
public Criteria andUpdateTimeBetween(Long value1, Long value2) {
addCriterion("update_time between", value1, value2, "updateTime");
return (Criteria) this;
}
public Criteria andUpdateTimeNotBetween(Long value1, Long value2) {
addCriterion("update_time not between", value1, value2, "updateTime");
return (Criteria) this;
}
}
public static class Criteria extends GeneratedCriteria {
protected Criteria() {
super();
}
}
public static class Criterion {
private String condition;
private Object value;
private Object secondValue;
private boolean noValue;
private boolean singleValue;
private boolean betweenValue;
private boolean listValue;
private String typeHandler;
public String getCondition() {
return condition;
}
public Object getValue() {
return value;
}
public Object getSecondValue() {
return secondValue;
}
public boolean isNoValue() {
return noValue;
}
public boolean isSingleValue() {
return singleValue;
}
public boolean isBetweenValue() {
return betweenValue;
}
public boolean isListValue() {
return listValue;
}
public String getTypeHandler() {
return typeHandler;
}
protected Criterion(String condition) {
super();
this.condition = condition;
this.typeHandler = null;
this.noValue = true;
}
protected Criterion(String condition, Object value, String typeHandler) {
super();
this.condition = condition;
this.value = value;
this.typeHandler = typeHandler;
if (value instanceof List<?>) {
this.listValue = true;
} else {
this.singleValue = true;
}
}
protected Criterion(String condition, Object value) {
this(condition, value, null);
}
protected Criterion(String condition, Object value, Object secondValue, String typeHandler) {
super();
this.condition = condition;
this.value = value;
this.secondValue = secondValue;
this.typeHandler = typeHandler;
this.betweenValue = true;
}
protected Criterion(String condition, Object value, Object secondValue) {
this(condition, value, secondValue, null);
}
}
}

View File

@ -0,0 +1,30 @@
package io.metersphere.base.mapper;
import io.metersphere.base.domain.JarConfig;
import io.metersphere.base.domain.JarConfigExample;
import java.util.List;
import org.apache.ibatis.annotations.Param;
public interface JarConfigMapper {
long countByExample(JarConfigExample example);
int deleteByExample(JarConfigExample example);
int deleteByPrimaryKey(String id);
int insert(JarConfig record);
int insertSelective(JarConfig record);
List<JarConfig> selectByExample(JarConfigExample example);
JarConfig selectByPrimaryKey(String id);
int updateByExampleSelective(@Param("record") JarConfig record, @Param("example") JarConfigExample example);
int updateByExample(@Param("record") JarConfig record, @Param("example") JarConfigExample example);
int updateByPrimaryKeySelective(JarConfig record);
int updateByPrimaryKey(JarConfig record);
}

View File

@ -0,0 +1,291 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="io.metersphere.base.mapper.JarConfigMapper">
<resultMap id="BaseResultMap" type="io.metersphere.base.domain.JarConfig">
<id column="id" jdbcType="VARCHAR" property="id" />
<result column="name" jdbcType="VARCHAR" property="name" />
<result column="file_name" jdbcType="VARCHAR" property="fileName" />
<result column="creator" jdbcType="VARCHAR" property="creator" />
<result column="modifier" jdbcType="VARCHAR" property="modifier" />
<result column="path" jdbcType="VARCHAR" property="path" />
<result column="enable" jdbcType="BIT" property="enable" />
<result column="description" jdbcType="VARCHAR" property="description" />
<result column="create_time" jdbcType="BIGINT" property="createTime" />
<result column="update_time" jdbcType="BIGINT" property="updateTime" />
</resultMap>
<sql id="Example_Where_Clause">
<where>
<foreach collection="oredCriteria" item="criteria" separator="or">
<if test="criteria.valid">
<trim prefix="(" prefixOverrides="and" suffix=")">
<foreach collection="criteria.criteria" item="criterion">
<choose>
<when test="criterion.noValue">
and ${criterion.condition}
</when>
<when test="criterion.singleValue">
and ${criterion.condition} #{criterion.value}
</when>
<when test="criterion.betweenValue">
and ${criterion.condition} #{criterion.value} and #{criterion.secondValue}
</when>
<when test="criterion.listValue">
and ${criterion.condition}
<foreach close=")" collection="criterion.value" item="listItem" open="(" separator=",">
#{listItem}
</foreach>
</when>
</choose>
</foreach>
</trim>
</if>
</foreach>
</where>
</sql>
<sql id="Update_By_Example_Where_Clause">
<where>
<foreach collection="example.oredCriteria" item="criteria" separator="or">
<if test="criteria.valid">
<trim prefix="(" prefixOverrides="and" suffix=")">
<foreach collection="criteria.criteria" item="criterion">
<choose>
<when test="criterion.noValue">
and ${criterion.condition}
</when>
<when test="criterion.singleValue">
and ${criterion.condition} #{criterion.value}
</when>
<when test="criterion.betweenValue">
and ${criterion.condition} #{criterion.value} and #{criterion.secondValue}
</when>
<when test="criterion.listValue">
and ${criterion.condition}
<foreach close=")" collection="criterion.value" item="listItem" open="(" separator=",">
#{listItem}
</foreach>
</when>
</choose>
</foreach>
</trim>
</if>
</foreach>
</where>
</sql>
<sql id="Base_Column_List">
id, `name`, file_name, creator, modifier, `path`, `enable`, description, create_time,
update_time
</sql>
<select id="selectByExample" parameterType="io.metersphere.base.domain.JarConfigExample" resultMap="BaseResultMap">
select
<if test="distinct">
distinct
</if>
<include refid="Base_Column_List" />
from jar_config
<if test="_parameter != null">
<include refid="Example_Where_Clause" />
</if>
<if test="orderByClause != null">
order by ${orderByClause}
</if>
</select>
<select id="selectByPrimaryKey" parameterType="java.lang.String" resultMap="BaseResultMap">
select
<include refid="Base_Column_List" />
from jar_config
where id = #{id,jdbcType=VARCHAR}
</select>
<delete id="deleteByPrimaryKey" parameterType="java.lang.String">
delete from jar_config
where id = #{id,jdbcType=VARCHAR}
</delete>
<delete id="deleteByExample" parameterType="io.metersphere.base.domain.JarConfigExample">
delete from jar_config
<if test="_parameter != null">
<include refid="Example_Where_Clause" />
</if>
</delete>
<insert id="insert" parameterType="io.metersphere.base.domain.JarConfig">
insert into jar_config (id, `name`, file_name,
creator, modifier, `path`,
`enable`, description, create_time,
update_time)
values (#{id,jdbcType=VARCHAR}, #{name,jdbcType=VARCHAR}, #{fileName,jdbcType=VARCHAR},
#{creator,jdbcType=VARCHAR}, #{modifier,jdbcType=VARCHAR}, #{path,jdbcType=VARCHAR},
#{enable,jdbcType=BIT}, #{description,jdbcType=VARCHAR}, #{createTime,jdbcType=BIGINT},
#{updateTime,jdbcType=BIGINT})
</insert>
<insert id="insertSelective" parameterType="io.metersphere.base.domain.JarConfig">
insert into jar_config
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="id != null">
id,
</if>
<if test="name != null">
`name`,
</if>
<if test="fileName != null">
file_name,
</if>
<if test="creator != null">
creator,
</if>
<if test="modifier != null">
modifier,
</if>
<if test="path != null">
`path`,
</if>
<if test="enable != null">
`enable`,
</if>
<if test="description != null">
description,
</if>
<if test="createTime != null">
create_time,
</if>
<if test="updateTime != null">
update_time,
</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="id != null">
#{id,jdbcType=VARCHAR},
</if>
<if test="name != null">
#{name,jdbcType=VARCHAR},
</if>
<if test="fileName != null">
#{fileName,jdbcType=VARCHAR},
</if>
<if test="creator != null">
#{creator,jdbcType=VARCHAR},
</if>
<if test="modifier != null">
#{modifier,jdbcType=VARCHAR},
</if>
<if test="path != null">
#{path,jdbcType=VARCHAR},
</if>
<if test="enable != null">
#{enable,jdbcType=BIT},
</if>
<if test="description != null">
#{description,jdbcType=VARCHAR},
</if>
<if test="createTime != null">
#{createTime,jdbcType=BIGINT},
</if>
<if test="updateTime != null">
#{updateTime,jdbcType=BIGINT},
</if>
</trim>
</insert>
<select id="countByExample" parameterType="io.metersphere.base.domain.JarConfigExample" resultType="java.lang.Long">
select count(*) from jar_config
<if test="_parameter != null">
<include refid="Example_Where_Clause" />
</if>
</select>
<update id="updateByExampleSelective" parameterType="map">
update jar_config
<set>
<if test="record.id != null">
id = #{record.id,jdbcType=VARCHAR},
</if>
<if test="record.name != null">
`name` = #{record.name,jdbcType=VARCHAR},
</if>
<if test="record.fileName != null">
file_name = #{record.fileName,jdbcType=VARCHAR},
</if>
<if test="record.creator != null">
creator = #{record.creator,jdbcType=VARCHAR},
</if>
<if test="record.modifier != null">
modifier = #{record.modifier,jdbcType=VARCHAR},
</if>
<if test="record.path != null">
`path` = #{record.path,jdbcType=VARCHAR},
</if>
<if test="record.enable != null">
`enable` = #{record.enable,jdbcType=BIT},
</if>
<if test="record.description != null">
description = #{record.description,jdbcType=VARCHAR},
</if>
<if test="record.createTime != null">
create_time = #{record.createTime,jdbcType=BIGINT},
</if>
<if test="record.updateTime != null">
update_time = #{record.updateTime,jdbcType=BIGINT},
</if>
</set>
<if test="_parameter != null">
<include refid="Update_By_Example_Where_Clause" />
</if>
</update>
<update id="updateByExample" parameterType="map">
update jar_config
set id = #{record.id,jdbcType=VARCHAR},
`name` = #{record.name,jdbcType=VARCHAR},
file_name = #{record.fileName,jdbcType=VARCHAR},
creator = #{record.creator,jdbcType=VARCHAR},
modifier = #{record.modifier,jdbcType=VARCHAR},
`path` = #{record.path,jdbcType=VARCHAR},
`enable` = #{record.enable,jdbcType=BIT},
description = #{record.description,jdbcType=VARCHAR},
create_time = #{record.createTime,jdbcType=BIGINT},
update_time = #{record.updateTime,jdbcType=BIGINT}
<if test="_parameter != null">
<include refid="Update_By_Example_Where_Clause" />
</if>
</update>
<update id="updateByPrimaryKeySelective" parameterType="io.metersphere.base.domain.JarConfig">
update jar_config
<set>
<if test="name != null">
`name` = #{name,jdbcType=VARCHAR},
</if>
<if test="fileName != null">
file_name = #{fileName,jdbcType=VARCHAR},
</if>
<if test="creator != null">
creator = #{creator,jdbcType=VARCHAR},
</if>
<if test="modifier != null">
modifier = #{modifier,jdbcType=VARCHAR},
</if>
<if test="path != null">
`path` = #{path,jdbcType=VARCHAR},
</if>
<if test="enable != null">
`enable` = #{enable,jdbcType=BIT},
</if>
<if test="description != null">
description = #{description,jdbcType=VARCHAR},
</if>
<if test="createTime != null">
create_time = #{createTime,jdbcType=BIGINT},
</if>
<if test="updateTime != null">
update_time = #{updateTime,jdbcType=BIGINT},
</if>
</set>
where id = #{id,jdbcType=VARCHAR}
</update>
<update id="updateByPrimaryKey" parameterType="io.metersphere.base.domain.JarConfig">
update jar_config
set `name` = #{name,jdbcType=VARCHAR},
file_name = #{fileName,jdbcType=VARCHAR},
creator = #{creator,jdbcType=VARCHAR},
modifier = #{modifier,jdbcType=VARCHAR},
`path` = #{path,jdbcType=VARCHAR},
`enable` = #{enable,jdbcType=BIT},
description = #{description,jdbcType=VARCHAR},
create_time = #{createTime,jdbcType=BIGINT},
update_time = #{updateTime,jdbcType=BIGINT}
where id = #{id,jdbcType=VARCHAR}
</update>
</mapper>

View File

@ -1,8 +1,12 @@
package io.metersphere.controller;
import io.metersphere.api.service.JarConfigService;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import io.metersphere.base.domain.JarConfig;
import io.metersphere.commons.constants.RoleConstants;
import io.metersphere.commons.utils.PageUtils;
import io.metersphere.commons.utils.Pager;
import io.metersphere.service.JarConfigService;
import org.apache.shiro.authz.annotation.Logical;
import org.apache.shiro.authz.annotation.RequiresRoles;
import org.springframework.web.bind.annotation.*;
@ -12,16 +16,23 @@ import javax.annotation.Resource;
import java.util.List;
@RestController
@RequestMapping(value = "/api/jar")
@RequestMapping(value = "/jar")
@RequiresRoles(value = {RoleConstants.TEST_MANAGER, RoleConstants.TEST_USER, RoleConstants.TEST_VIEWER}, logical = Logical.OR)
public class JarConfigController {
@Resource
Jarc JarConfigService;
JarConfigService JarConfigService;
@GetMapping("/list/{projectId}")
public List<JarConfig> list(@PathVariable String projectId) {
return JarConfigService.list(projectId);
@PostMapping("list/{goPage}/{pageSize}")
@RequiresRoles(RoleConstants.ORG_ADMIN)
public Pager<List<JarConfig>> list(@PathVariable int goPage, @PathVariable int pageSize, @RequestBody JarConfig request) {
Page<Object> page = PageHelper.startPage(goPage, pageSize, true);
return PageUtils.setPageInfo(page, JarConfigService.list(request));
}
@GetMapping("list/all")
public List<JarConfig> listAll() {
return JarConfigService.list();
}
@GetMapping("/get/{id}")

View File

@ -1,15 +1,20 @@
package io.metersphere.listener;
import io.metersphere.api.jmeter.JMeterService;
import io.metersphere.api.jmeter.NewDriverManager;
import io.metersphere.base.domain.JarConfig;
import io.metersphere.commons.utils.LogUtil;
import io.metersphere.service.JarConfigService;
import io.metersphere.service.ScheduleService;
import org.python.core.Options;
import org.python.util.PythonInterpreter;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.context.event.ApplicationReadyEvent;
import org.springframework.context.ApplicationListener;
import org.springframework.stereotype.Component;
import javax.annotation.Resource;
import java.util.List;
@Component
public class AppStartListener implements ApplicationListener<ApplicationReadyEvent> {
@ -18,12 +23,20 @@ public class AppStartListener implements ApplicationListener<ApplicationReadyEve
private ScheduleService scheduleService;
@Resource
private JMeterService jMeterService;
@Resource
private JarConfigService jarConfigService;
@Value("${jmeter.home}")
private String jmeterHome;
@Override
public void onApplicationEvent(ApplicationReadyEvent applicationReadyEvent) {
System.out.println("================= 应用启动 =================");
System.setProperty("jmeter.home", jmeterHome);
loadJars();
initPythonEnv();
try {
@ -53,4 +66,19 @@ public class AppStartListener implements ApplicationListener<ApplicationReadyEve
LogUtil.error(e.getMessage(), e);
}
}
/**
* 加载jar包
*/
private void loadJars() {
List<JarConfig> jars = jarConfigService.list();
try {
jars.forEach(jarConfig -> {
NewDriverManager.loadJar(jarConfig.getPath());
});
} catch (Exception e) {
e.printStackTrace();
LogUtil.error(e.getMessage(), e);
}
}
}

View File

@ -1,8 +1,9 @@
package io.metersphere.api.service;
package io.metersphere.service;
import io.metersphere.base.domain.ApiTestJarConfig;
import io.metersphere.base.domain.ApiTestJarConfigExample;
import io.metersphere.base.mapper.ApiTestJarConfigMapper;
import io.metersphere.api.jmeter.NewDriverManager;
import io.metersphere.base.domain.JarConfig;
import io.metersphere.base.domain.JarConfigExample;
import io.metersphere.base.mapper.JarConfigMapper;
import io.metersphere.commons.exception.MSException;
import io.metersphere.commons.utils.LogUtil;
import io.metersphere.commons.utils.SessionUtils;
@ -20,56 +21,69 @@ import java.util.UUID;
@Service
@Transactional(rollbackFor = Exception.class)
public class ApiTestJarConfigService {
public class JarConfigService {
private static final String JAR_FILE_DIR = "/opt/metersphere/data/jar";
@Resource
private ApiTestJarConfigMapper apiTestJarConfigMapper;
private JarConfigMapper jarConfigMapper;
public List<ApiTestJarConfig> list(String projectId) {
ApiTestJarConfigExample example = new ApiTestJarConfigExample();
example.createCriteria().andProjectIdEqualTo(projectId);
return apiTestJarConfigMapper.selectByExample(example);
public List<JarConfig> list() {
JarConfigExample example = new JarConfigExample();
return jarConfigMapper.selectByExample(example);
}
public ApiTestJarConfig get(String id) {
return apiTestJarConfigMapper.selectByPrimaryKey(id);
public List<JarConfig> list(JarConfig jarConfig) {
JarConfigExample example = new JarConfigExample();
if (StringUtils.isNotBlank(jarConfig.getName())) {
example.createCriteria().andNameLike("%" + jarConfig.getName() + "%");
}
example.setOrderByClause("update_time desc");
return jarConfigMapper.selectByExample(example);
}
public JarConfig get(String id) {
return jarConfigMapper.selectByPrimaryKey(id);
}
public void delete(String id) {
ApiTestJarConfig apiTestJarConfig = apiTestJarConfigMapper.selectByPrimaryKey(id);
deleteJarFile(apiTestJarConfig.getPath());
apiTestJarConfigMapper.deleteByPrimaryKey(id);
JarConfig JarConfig = jarConfigMapper.selectByPrimaryKey(id);
deleteJarFile(JarConfig.getPath());
jarConfigMapper.deleteByPrimaryKey(id);
}
public void update(ApiTestJarConfig apiTestJarConfig, MultipartFile file) {
checkExist(apiTestJarConfig);
apiTestJarConfig.setOwner(SessionUtils.getUser().getId());
apiTestJarConfig.setUpdateTime(System.currentTimeMillis());
String deletePath = apiTestJarConfig.getPath();
public void update(JarConfig jarConfig, MultipartFile file) {
checkExist(jarConfig);
jarConfig.setEnable(true);// todo 审批机制时需修改
jarConfig.setModifier(SessionUtils.getUser().getId());
jarConfig.setUpdateTime(System.currentTimeMillis());
String deletePath = jarConfig.getPath();
if (file != null) {
apiTestJarConfig.setFileName(file.getOriginalFilename());
apiTestJarConfig.setPath(getJarPath(apiTestJarConfig, file));
jarConfig.setFileName(file.getOriginalFilename());
jarConfig.setPath(getJarPath(file));
}
apiTestJarConfigMapper.updateByPrimaryKey(apiTestJarConfig);
jarConfigMapper.updateByPrimaryKey(jarConfig);
if (file != null) {
deleteJarFile(deletePath);
createJarFiles(apiTestJarConfig.getProjectId(), file);
createJarFiles(file);
NewDriverManager.loadJar(jarConfig.getPath());
}
}
public String add(ApiTestJarConfig apiTestJarConfig, MultipartFile file) {
apiTestJarConfig.setId(UUID.randomUUID().toString());
apiTestJarConfig.setOwner(SessionUtils.getUser().getId());
checkExist(apiTestJarConfig);
apiTestJarConfig.setCreateTime(System.currentTimeMillis());
apiTestJarConfig.setUpdateTime(System.currentTimeMillis());
apiTestJarConfig.setPath(getJarPath(apiTestJarConfig, file));
apiTestJarConfig.setFileName(file.getOriginalFilename());
apiTestJarConfigMapper.insert(apiTestJarConfig);
createJarFiles(apiTestJarConfig.getProjectId(), file);
return apiTestJarConfig.getId();
public String add(JarConfig jarConfig, MultipartFile file) {
jarConfig.setId(UUID.randomUUID().toString());
jarConfig.setCreator(SessionUtils.getUser().getId());
jarConfig.setModifier(SessionUtils.getUser().getId());
checkExist(jarConfig);
jarConfig.setEnable(true);// todo 审批机制时需修改
jarConfig.setCreateTime(System.currentTimeMillis());
jarConfig.setUpdateTime(System.currentTimeMillis());
jarConfig.setPath(getJarPath(file));
jarConfig.setFileName(file.getOriginalFilename());
jarConfigMapper.insert(jarConfig);
createJarFiles(file);
NewDriverManager.loadJar(jarConfig.getPath());
return jarConfig.getId();
}
public void deleteJarFiles(String testId) {
@ -87,16 +101,15 @@ public class ApiTestJarConfigService {
}
}
public String getJarPath(ApiTestJarConfig apiTestJarConfig, MultipartFile file) {
return JAR_FILE_DIR + "/" + apiTestJarConfig.getProjectId() + "/" + file.getOriginalFilename();
public String getJarPath(MultipartFile file) {
return JAR_FILE_DIR + "/" + file.getOriginalFilename();
}
private String createJarFiles(String projectId, MultipartFile jar) {
private String createJarFiles(MultipartFile jar) {
if (jar == null) {
return null;
}
String dir = JAR_FILE_DIR + "/" + projectId;
File testDir = new File(dir);
File testDir = new File(JAR_FILE_DIR);
if (!testDir.exists()) {
testDir.mkdirs();
}
@ -112,18 +125,16 @@ public class ApiTestJarConfigService {
return filePath;
}
private void checkExist(ApiTestJarConfig jarConfig) {
private void checkExist(JarConfig jarConfig) {
if (jarConfig.getName() != null) {
ApiTestJarConfigExample example = new ApiTestJarConfigExample();
ApiTestJarConfigExample.Criteria criteria = example.createCriteria();
criteria.andNameEqualTo(jarConfig.getName())
.andProjectIdEqualTo(jarConfig.getProjectId());
JarConfigExample example = new JarConfigExample();
JarConfigExample.Criteria criteria = example.createCriteria();
criteria.andNameEqualTo(jarConfig.getName());
if (StringUtils.isNotBlank(jarConfig.getId())) {
criteria.andIdNotEqualTo(jarConfig.getId());
}
if (apiTestJarConfigMapper.selectByExample(example).size() > 0) {
MSException.throwException(Translator.get("api_test_jarConfig_already_exists"));
if (jarConfigMapper.selectByExample(example).size() > 0) {
MSException.throwException(Translator.get("already_exists"));
}
}
}

View File

@ -0,0 +1,387 @@
/*
* 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 org.apache.jmeter;
import java.io.File;
import java.io.IOException;
import java.io.PrintWriter;
import java.io.StringWriter;
import java.lang.reflect.Method;
import java.net.MalformedURLException;
import java.net.URL;
import java.security.AccessController;
import java.security.PrivilegedAction;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Date;
import java.util.LinkedList;
import java.util.List;
import java.util.StringTokenizer;
/**
* Main class for JMeter - sets up initial classpath and the loader.
*
*/
public final class NewDriver {
private static final String CLASSPATH_SEPARATOR = File.pathSeparator;
private static final String OS_NAME = System.getProperty("os.name");// $NON-NLS-1$
private static final String OS_NAME_LC = OS_NAME.toLowerCase(java.util.Locale.ENGLISH);
private static final String JAVA_CLASS_PATH = "java.class.path";// $NON-NLS-1$
private static final String JMETER_LOGFILE_SYSTEM_PROPERTY = "jmeter.logfile";// $NON-NLS-1$
private static final String HEADLESS_MODE_PROPERTY = "java.awt.headless";// $NON-NLS-1$
/** The class loader to use for loading JMeter classes. */
private static final DynamicClassLoader loader;
/** The directory JMeter is installed in. */
private static final String JMETER_INSTALLATION_DIRECTORY;
private static final List<Exception> EXCEPTIONS_IN_INIT = new ArrayList<>();
// 将当前类加载器设置为 loader 解决由系统类加载器加载的 JMeter 无法动态加载 jar 包问题
public static void setContextClassLoader() {
Thread.currentThread().setContextClassLoader(loader);
}
static {
final List<URL> jars = new LinkedList<>();
final String initiaClasspath = System.getProperty(JAVA_CLASS_PATH);
// Find JMeter home dir from the initial classpath
String tmpDir;
StringTokenizer tok = new StringTokenizer(initiaClasspath, File.pathSeparator);
if (tok.countTokens() == 1
|| (tok.countTokens() == 2 // Java on Mac OS can add a second entry to the initial classpath
&& OS_NAME_LC.startsWith("mac os x")// $NON-NLS-1$
)
) {
File jar = new File(tok.nextToken());
try {
tmpDir = jar.getCanonicalFile().getParentFile().getParent();
} catch (IOException e) {
tmpDir = null;
}
} else {// e.g. started from IDE with full classpath
tmpDir = System.getProperty("jmeter.home","");// Allow override $NON-NLS-1$ $NON-NLS-2$
if (tmpDir.length() == 0) {
File userDir = new File(System.getProperty("user.dir"));// $NON-NLS-1$
tmpDir = userDir.getAbsoluteFile().getParent();
}
}
JMETER_INSTALLATION_DIRECTORY=tmpDir;
/*
* Does the system support UNC paths? If so, may need to fix them up
* later
*/
boolean usesUNC = OS_NAME_LC.startsWith("windows");// $NON-NLS-1$
// Add standard jar locations to initial classpath
StringBuilder classpath = new StringBuilder();
File[] libDirs = new File[] { new File(JMETER_INSTALLATION_DIRECTORY + File.separator + "lib"),// $NON-NLS-1$ $NON-NLS-2$
new File(JMETER_INSTALLATION_DIRECTORY + File.separator + "lib" + File.separator + "ext"),// $NON-NLS-1$ $NON-NLS-2$
new File(JMETER_INSTALLATION_DIRECTORY + File.separator + "lib" + File.separator + "junit")};// $NON-NLS-1$ $NON-NLS-2$
for (File libDir : libDirs) {
File[] libJars = libDir.listFiles((dir, name) -> name.endsWith(".jar"));
if (libJars == null) {
new Throwable("Could not access " + libDir).printStackTrace(); // NOSONAR No logging here
continue;
}
Arrays.sort(libJars); // Bug 50708 Ensure predictable order of jars
for (File libJar : libJars) {
try {
String s = libJar.getPath();
// Fix path to allow the use of UNC URLs
if (usesUNC) {
if (s.startsWith("\\\\") && !s.startsWith("\\\\\\")) {// $NON-NLS-1$ $NON-NLS-2$
s = "\\\\" + s;// $NON-NLS-1$
} else if (s.startsWith("//") && !s.startsWith("///")) {// $NON-NLS-1$ $NON-NLS-2$
s = "//" + s;// $NON-NLS-1$
}
} // usesUNC
jars.add(new File(s).toURI().toURL());// See Java bug 4496398
classpath.append(CLASSPATH_SEPARATOR);
classpath.append(s);
} catch (MalformedURLException e) { // NOSONAR
EXCEPTIONS_IN_INIT.add(new Exception("Error adding jar:"+libJar.getAbsolutePath(), e));
}
}
}
// ClassFinder needs the classpath
System.setProperty(JAVA_CLASS_PATH, initiaClasspath + classpath.toString());
loader = AccessController.doPrivileged(
(PrivilegedAction<DynamicClassLoader>) () ->
new DynamicClassLoader(jars.toArray(new URL[jars.size()]))
);
}
/**
* Prevent instantiation.
*/
private NewDriver() {
}
/**
* Generate an array of jar files located in a directory.
* Jar files located in sub directories will not be added.
*
* @param dir to search for the jar files.
*/
private static File[] listJars(File dir) {
if (dir.isDirectory()) {
return dir.listFiles((f, name) -> {
if (name.endsWith(".jar")) {// $NON-NLS-1$
File jar = new File(f, name);
return jar.isFile() && jar.canRead();
}
return false;
});
}
return new File[0];
}
/**
* Add a URL to the loader classpath only; does not update the system classpath.
*
* @param path to be added.
* @throws MalformedURLException when <code>path</code> points to an invalid url
*/
public static void addURL(String path) throws MalformedURLException {
File furl = new File(path);
loader.addURL(furl.toURI().toURL()); // See Java bug 4496398
File[] jars = listJars(furl);
for (File jar : jars) {
loader.addURL(jar.toURI().toURL()); // See Java bug 4496398
}
}
/**
* Add a URL to the loader classpath only; does not update the system
* classpath.
*
* @param url
* The {@link URL} to add to the classpath
*/
public static void addURL(URL url) {
loader.addURL(url);
}
/**
* Add a directory or jar to the loader and system classpaths.
*
* @param path
* to add to the loader and system classpath
* @throws MalformedURLException
* if <code>path</code> can not be transformed to a valid
* {@link URL}
*/
public static void addPath(String path) throws MalformedURLException {
File file = new File(path);
// Ensure that directory URLs end in "/"
if (file.isDirectory() && !path.endsWith("/")) {// $NON-NLS-1$
file = new File(path + "/");// $NON-NLS-1$
}
loader.addURL(file.toURI().toURL()); // See Java bug 4496398
StringBuilder sb = new StringBuilder(System.getProperty(JAVA_CLASS_PATH));
sb.append(CLASSPATH_SEPARATOR);
sb.append(path);
File[] jars = listJars(file);
for (File jar : jars) {
loader.addURL(jar.toURI().toURL()); // See Java bug 4496398
sb.append(CLASSPATH_SEPARATOR);
sb.append(jar.getPath());
}
// ClassFinder needs this
System.setProperty(JAVA_CLASS_PATH,sb.toString());
}
/**
* Get the directory where JMeter is installed. This is the absolute path
* name.
*
* @return the directory where JMeter is installed.
*/
public static String getJMeterDir() {
return JMETER_INSTALLATION_DIRECTORY;
}
/**
* The main program which actually runs JMeter.
*
* @param args
* the command line arguments
*/
public static void main(String[] args) {
if(!EXCEPTIONS_IN_INIT.isEmpty()) {
System.err.println("Configuration error during init, see exceptions:"+exceptionsToString(EXCEPTIONS_IN_INIT)); // NOSONAR Intentional System.err use
} else {
Thread.currentThread().setContextClassLoader(loader);
setLoggingProperties(args);
try {
// Only set property if it has not been set explicitely
if(System.getProperty(HEADLESS_MODE_PROPERTY) == null && shouldBeHeadless(args)) {
System.setProperty(HEADLESS_MODE_PROPERTY, "true");
}
Class<?> initialClass = loader.loadClass("org.apache.jmeter.JMeter");// $NON-NLS-1$
Object instance = initialClass.getDeclaredConstructor().newInstance();
Method startup = initialClass.getMethod("start", new Class[] { new String[0].getClass() });// $NON-NLS-1$
startup.invoke(instance, new Object[] { args });
} catch(Throwable e){ // NOSONAR We want to log home directory in case of exception
e.printStackTrace(); // NOSONAR No logger at this step
System.err.println("JMeter home directory was detected as: "+JMETER_INSTALLATION_DIRECTORY); // NOSONAR Intentional System.err use
}
}
}
/**
* @param exceptionsInInit List of {@link Exception}
* @return String
*/
private static String exceptionsToString(List<Exception> exceptionsInInit) {
StringBuilder builder = new StringBuilder();
for (Exception exception : exceptionsInInit) {
StringWriter stringWriter = new StringWriter();
PrintWriter printWriter = new PrintWriter(stringWriter);
exception.printStackTrace(printWriter); // NOSONAR
builder.append(stringWriter.toString())
.append("\r\n");
}
return builder.toString();
}
/*
* Set logging related system properties.
*/
private static void setLoggingProperties(String[] args) {
String jmLogFile = getCommandLineArgument(args, 'j', "jmeterlogfile");// $NON-NLS-1$ $NON-NLS-2$
if (jmLogFile != null && !jmLogFile.isEmpty()) {
jmLogFile = replaceDateFormatInFileName(jmLogFile);
System.setProperty(JMETER_LOGFILE_SYSTEM_PROPERTY, jmLogFile);// $NON-NLS-1$
} else if (System.getProperty(JMETER_LOGFILE_SYSTEM_PROPERTY) == null) {// $NON-NLS-1$
System.setProperty(JMETER_LOGFILE_SYSTEM_PROPERTY, "jmeter.log");// $NON-NLS-1$ $NON-NLS-2$
}
String jmLogConf = getCommandLineArgument(args, 'i', "jmeterlogconf");// $NON-NLS-1$ $NON-NLS-2$
File logConfFile = null;
if (jmLogConf != null && !jmLogConf.isEmpty()) {
logConfFile = new File(jmLogConf);
} else if (System.getProperty("log4j.configurationFile") == null) {// $NON-NLS-1$
logConfFile = new File("log4j2.xml");// $NON-NLS-1$
if (!logConfFile.isFile()) {
logConfFile = new File(JMETER_INSTALLATION_DIRECTORY, "bin" + File.separator + "log4j2.xml");// $NON-NLS-1$ $NON-NLS-2$
}
}
if (logConfFile != null) {
System.setProperty("log4j.configurationFile", logConfFile.toURI().toString());// $NON-NLS-1$
}
}
private static boolean shouldBeHeadless(String[] args) {
for (String arg : args) {
if("-n".equals(arg) || "-s".equals(arg) || "-g".equals(arg)) {
return true;
}
}
return false;
}
/*
* Find command line argument option value by the id and name.
*/
private static String getCommandLineArgument(String[] args, int id, String name) {
final String shortArgName = "-" + ((char) id);// $NON-NLS-1$
final String longArgName = "--" + name;// $NON-NLS-1$
String value = null;
for (int i = 0; i < args.length; i++) {
if ((shortArgName.equals(args[i]) && i < args.length - 1)
|| longArgName.equals(args[i])) {
if (!args[i + 1].startsWith("-")) {// $NON-NLS-1$
value = args[i + 1];
}
break;
} else if (!shortArgName.equals(args[i]) && args[i].startsWith(shortArgName)) {
value = args[i].substring(shortArgName.length());
break;
}
}
return value;
}
/*
* If the fileName contains at least one set of paired single-quotes, reformat using DateFormat
*/
private static String replaceDateFormatInFileName(String fileName) {
try {
StringBuilder builder = new StringBuilder();
final Date date = new Date();
int fromIndex = 0;
int begin = fileName.indexOf('\'', fromIndex);// $NON-NLS-1$
int end;
String format;
SimpleDateFormat dateFormat;
while (begin != -1) {
builder.append(fileName.substring(fromIndex, begin));
fromIndex = begin + 1;
end = fileName.indexOf('\'', fromIndex);// $NON-NLS-1$
if (end == -1) {
throw new IllegalArgumentException("Invalid pairs of single-quotes in the file name: " + fileName);// $NON-NLS-1$
}
format = fileName.substring(begin + 1, end);
dateFormat = new SimpleDateFormat(format);
builder.append(dateFormat.format(date));
fromIndex = end + 1;
begin = fileName.indexOf('\'', fromIndex);// $NON-NLS-1$
}
if (fromIndex < fileName.length() - 1) {
builder.append(fileName.substring(fromIndex));
}
return builder.toString();
} catch (Exception ex) {
System.err.println("Error replacing date format in file name:"+fileName+", error:"+ex.getMessage()); // NOSONAR
}
return fileName;
}
}

View File

@ -1,12 +1,19 @@
CREATE TABLE IF NOT EXISTS `api_test_jar_config` (
CREATE TABLE IF NOT EXISTS `jar_config` (
`id` varchar(50) NOT NULL COMMENT 'ID',
`name` varchar(64) NOT NULL COMMENT 'Name',
`file_name` varchar(64) NOT NULL COMMENT 'File name',
`owner` varchar(50) NOT NULL COMMENT 'User ID',
`creator` varchar(50) NOT NULL COMMENT 'creator User ID',
`modifier` varchar(50) NOT NULL COMMENT 'Modifier User ID',
`path` varchar(255) NOT NULL COMMENT 'File path',
`project_id` varchar(50) NOT NULL COMMENT 'Project ID this jar belongs to',
`enable` tinyint(1) COMMENT 'Config enable',
`description` varchar(255) DEFAULT NULL COMMENT 'description',
`create_time` bigint(13) NOT NULL COMMENT 'Create timestamp',
`update_time` bigint(13) NOT NULL COMMENT 'Update timestamp',
PRIMARY KEY (`id`)
) ENGINE = InnoDB DEFAULT CHARSET = utf8mb4;
) ENGINE = InnoDB DEFAULT CHARSET = utf8mb4;
-- CREATE TABLE IF NOT EXISTS `jar_config_resource` ( todo1
-- `resource_id` varchar(64) NOT NULL,
-- `jar_config_id` varchar(64) NOT NULL,
-- UNIQUE KEY `jar_config_resource_unique_key` (`resource_id`, `jar_config_id`)
-- ) ENGINE = InnoDB DEFAULT CHARSET = utf8mb4 COMMENT ='Jar config relevance table';

View File

@ -64,7 +64,7 @@
<!--要生成的数据库表 -->
<table tableName="api_test_jar_config"/>
<table tableName="jar_config"/>
<!--<table tableName="notice"/>-->

View File

@ -40,6 +40,9 @@
<el-dropdown-item command="report">
{{ $t('api_report.title') }}
</el-dropdown-item>
<el-dropdown-item command="jar" :disabled="isReadOnly">
{{ $t('api_test.jar_config.title') }}
</el-dropdown-item>
<el-dropdown-item command="performance" :disabled="create || isReadOnly">
{{ $t('api_test.create_performance_test') }}
</el-dropdown-item>
@ -58,6 +61,9 @@
<ms-schedule-config :schedule="test.schedule" :is-read-only="isReadOnly" :save="saveCronExpression"
@scheduleChange="saveSchedule" :test-id="id" :check-open="checkScheduleEdit"/>
<ms-jar-config :is-read-only="isReadOnly" ref="jarConfig"/>
</el-row>
</el-header>
<ms-api-scenario-config :debug-report-id="debugReportId" @runDebug="runDebug" :is-read-only="isReadOnly"
@ -80,11 +86,13 @@
import {ApiEvent, LIST_CHANGE} from "@/business/components/common/head/ListEvent";
import MsContainer from "@/business/components/common/components/MsContainer";
import MsMainContainer from "@/business/components/common/components/MsMainContainer";
import MsJarConfig from "./components/jar/JarConfig";
export default {
name: "MsApiTestConfig",
components: {
MsJarConfig,
MsMainContainer,
MsContainer, ApiImport, MsScheduleConfig, MsApiReportDialog, MsApiReportStatus, MsApiScenarioConfig
},
@ -316,6 +324,9 @@
case "export":
downloadFile(this.test.name + ".json", this.test.export());
break;
case "jar":
this.$refs.jarConfig.open();
break;
case "import":
this.$refs.apiImport.open();
break;

View File

@ -2,7 +2,7 @@
<el-dialog width="50%" :close-on-click-modal="false" :title="$t('api_test.jar_config.title')" :visible.sync="visible" class="jar-import" @close="close">
<div v-loading="result.loading">
<ms-jar-config-from :config="currentConfig" :callback="saveConfig" ref="jarConfigFrom" :read-only="isReadOnly"/>
<ms-jar-config-list @refresh="getJarConfigs" v-if="configs.length > 0" @rowSelect="rowSelect" :table-data="configs"/>
<ms-jar-config-list @refresh="getJarConfigs" v-if="configs.length > 0" @rowSelect="rowSelect" :table-data="configs" ref="jarConfigList"/>
</div>
</el-dialog>
</template>
@ -20,7 +20,6 @@
return {
visible: false,
result: {},
projectId: "",
currentConfig: {},
configs: []
}
@ -32,9 +31,8 @@
},
},
methods: {
open(projectId) {
open() {
this.visible = true;
this.projectId = projectId;
this.getJarConfigs();
listenGoBack(this.close);
},
@ -49,15 +47,14 @@
return;
}
}
let url = config.id ? "/api/jar/update" : "/api/jar/add";
config.projectId = this.projectId;
let url = config.id ? "/jar/update" : "/jar/add";
this.result = this.$fileUpload(url, file, null, config, () => {
this.$success(this.$t('commons.save_success'));
this.getJarConfigs();
});
},
getJarConfigs() {
this.result = this.$get("/api/jar/list/" + this.projectId, response => {
this.result = this.$get("/jar/list/all", response => {
this.configs = response.data;
this.currentConfig = {};
})

View File

@ -9,13 +9,16 @@
<el-table-column prop="name" :label="$t('commons.name')" show-overflow-tooltip/>
<el-table-column prop="fileName" :label="$t('api_test.jar_config.jar_file')" show-overflow-tooltip/>
<el-table-column prop="description" :label="$t('commons.description')" show-overflow-tooltip/>
<!--<el-table-column prop="createTime" :label="$t('创建时间')" show-overflow-tooltip/>-->
<el-table-column prop="updateTime" :label="$t('commons.update_time')" show-overflow-tooltip/>
<el-table-column prop="owner" :label="$t('report.user_name')" show-overflow-tooltip/>
<el-table-column prop="updateTime" :label="$t('commons.update_time')" show-overflow-tooltip>
<template v-slot:default="scope">
<span>{{ scope.row.updateTime | timestampFormatDate }}</span>
</template>
</el-table-column>
<el-table-column prop="creator" :label="$t('report.user_name')" show-overflow-tooltip/>
<el-table-column prop="modifier" :label="$t('commons.modifier')" show-overflow-tooltip/>
<el-table-column :label="$t('commons.operating')" min-width="100">
<template v-slot:default="scope">
<ms-table-operator-button :is-tester-permission="true" :tip="$t('api_test.scenario.reference')" icon="el-icon-connection" type="success" @exec="handleCopy(scope.$index, scope.row)"/>
<ms-table-operator-button :isTesterPermission="true" :tip="$t('commons.delete')" icon="el-icon-delete" type="danger" @exec="handleDelete(scope.row.id)"/>
</template>
</el-table-column>
@ -27,41 +30,66 @@
<script>
import MsTableOperator from "../../../../common/components/MsTableOperator";
import MsTableOperatorButton from "../../../../common/components/MsTableOperatorButton";
export default {
name: "MsJarConfigList",
components: {MsTableOperatorButton, MsTableOperator},
components: {MsTableOperatorButton},
props: {
tableData: Array,
isReadOnly: {
type: Boolean,
default: false
}
},
},
data() {
return {
result: {},
// relevanceConfigSet: new Set()
}
},
// created() {
// this.listRelevance();
// },
methods: {
handleView(row) {
this.$emit('rowSelect', row);
},
handleDelete(id) {
this.result = this.$get("/api/jar/delete/" + id, () => {
this.result = this.$get("/jar/delete/" + id, () => {
this.$success(this.$t('commons.delete_success'));
this.$emit('refresh');
});
},
handleCopy(index, config) {
}
// handleRelevance(id, type) {
// let url = type === 'relevance' ? '/jar/relevance' : '/jar/unrelevance';
// let param = {
// jarConfigId: id
// };
// this.result = this.$post(url, param, () => {
// this.$success(this.$t('commons.save_success'));
// this.$emit('refresh');
// this.listRelevance();
// });
// },
// listRelevance() {
// if (this.testId) {
// this.result = this.$get("/jar/relevance/list/" + this.testId, (response) => {
// this.relevanceConfigSet = new Set(response.data);
// this.$emit('refresh');
// });
// }
// }
}
}
</script>
<style scoped>
.el-icon-check {
font-size: 20px;
font-weight: bold;
color: green;
margin-left: 20px;
}
</style>

View File

@ -39,8 +39,8 @@
<template v-if="baseUrl == 'api'" v-slot:behind>
<ms-table-operator-button :is-tester-permission="true" :tip="$t('api_test.environment.environment_config')" icon="el-icon-setting"
type="info" @exec="openEnvironmentConfig(scope.row)"/>
<ms-table-operator-button :is-tester-permission="true" :tip="$t('api_test.jar_config.title')" icon="el-icon-box"
type="info" @exec="openJarConfig(scope.row)"/>
<!--<ms-table-operator-button :is-tester-permission="true" :tip="$t('api_test.jar_config.title')" icon="el-icon-box"-->
<!--type="info" @exec="openJarConfig(scope.row)"/>-->
</template>
</ms-table-operator>
</template>

View File

@ -32,6 +32,11 @@ export default {
component: () => import('@/business/components/settings/system/SystemParameterSetting'),
meta: {system: true, title: 'commons.system_parameter_setting'}
},
// todo1 {
// path: 'systemjarsetting',
// component: () => import('@/business/components/settings/system/JarConfigSetting'),
// meta: {system: true, title: 'api_test.jar_config.title'}
// },
...requireContext.keys().map(key => requireContext(key).system),...requireContext.keys().map(key => requireContext(key).license),
{
path: 'organizationmember',

View File

@ -2,32 +2,12 @@
<div>
<el-card class="table-card" v-loading="result.loading">
<template v-slot:header>
<ms-table-header :condition.sync="condition" @search="list" @create="create"
:create-tip="$t('workspace.create')" :title="$t('commons.workspace')"/>
<ms-table-header :condition.sync="condition" @search="list" @create="create" :title="$t('api_test.jar_config.title')"/>
</template>
<!-- workspace table -->
<!--<el-table border class="adjust-table" :data="items" style="width: 100%">-->
<!--<el-table-column prop="name" :label="$t('commons.name')"/>-->
<!--<el-table-column prop="description" :label="$t('commons.description')"/>-->
<!--<el-table-column prop="organizationName" :label="$t('workspace.organization_name')"/>-->
<!--<el-table-column :label="$t('commons.member')">-->
<!--<template v-slot:default="scope">-->
<!--<el-link type="primary" class="member-size" @click="cellClick(scope.row)">-->
<!--{{scope.row.memberSize}}-->
<!--</el-link>-->
<!--</template>-->
<!--</el-table-column>-->
<!--<el-table-column :label="$t('commons.operating')">-->
<!--<template v-slot:default="scope">-->
<!--<ms-table-operator @editClick="edit(scope.row)" @deleteClick="handleDelete(scope.row)"/>-->
<!--</template>-->
<!--</el-table-column>-->
<!--</el-table>-->
<el-table border :data="items"
class="adjust-table table-content"
highlight-current-row
@row-click="handleView">
highlight-current-row>
<el-table-column prop="name" :label="$t('commons.name')" show-overflow-tooltip/>
<el-table-column prop="fileName" :label="$t('api_test.jar_config.jar_file')" show-overflow-tooltip/>
@ -36,11 +16,10 @@
<el-table-column prop="owner" :label="$t('report.user_name')" show-overflow-tooltip/>
<el-table-column :label="$t('commons.operating')" min-width="100">
<template v-slot:default="scope">
<ms-table-operator-button v-if="testId && !relevanceConfigSet.has(scope.row.id)" :is-tester-permission="true" :tip="$t('api_test.scenario.reference')" icon="el-icon-connection" type="success" @exec="handleRelevance(scope.row.id, 'relevance')"/>
<ms-table-operator-button v-if="testId && relevanceConfigSet.has(scope.row.id)" :is-tester-permission="true" :tip="$t('api_test.scenario.reference')" icon="el-icon-unlock" type="warning" @exec="handleRelevance(scope.row.id)"/>
<ms-table-operator-button :isTesterPermission="true" :tip="$t('commons.delete')" icon="el-icon-delete" type="danger" @exec="handleDelete(scope.row.id)"/>
<i v-if="testId && relevanceConfigSet.has(scope.row.id)" class="el-icon-check"/>
<ms-table-operator :is-tester-permission="true" @editClick="edit(scope.row)"
@deleteClick="handleDelete(scope.row.id)"/>
</template>
</el-table-column>
@ -49,75 +28,34 @@
<ms-table-pagination :change="list" :current-page.sync="currentPage" :page-size.sync="pageSize"
:total="total"/>
<ms-jar-config-edit @refresh="list" ref="jarConfigFrom"/>
</el-card>
<!-- update workspace member dialog -->
<el-dialog :close-on-click-modal="false" :title="$t('member.modify')" :visible.sync="dialogWsMemberUpdateVisible" width="30%"
:destroy-on-close="true"
@close="handleClose">
<el-form :model="memberForm" label-position="right" label-width="100px" size="small" ref="updateUserForm">
<el-form-item label="ID" prop="id">
<el-input v-model="memberForm.id" autocomplete="off" :disabled="true"/>
</el-form-item>
<el-form-item :label="$t('commons.username')" prop="name">
<el-input v-model="memberForm.name" autocomplete="off" :disabled="true"/>
</el-form-item>
<el-form-item :label="$t('commons.email')" prop="email">
<el-input v-model="memberForm.email" autocomplete="off" :disabled="true"/>
</el-form-item>
<el-form-item :label="$t('commons.phone')" prop="phone">
<el-input v-model="memberForm.phone" autocomplete="off" :disabled="true"/>
</el-form-item>
<el-form-item :label="$t('commons.role')" prop="roleIds" :rules="{required: true, message: $t('role.please_choose_role'), trigger: 'change'}">
<el-select filterable v-model="memberForm.roleIds" multiple :placeholder="$t('role.please_choose_role')"
class="select-width">
<el-option
v-for="item in memberForm.allroles"
:key="item.id"
:label="$t('role.' + item.id)"
:value="item.id">
</el-option>
</el-select>
</el-form-item>
</el-form>
<template v-slot:footer>
<ms-dialog-footer
@cancel="dialogWsMemberUpdateVisible = false"
@confirm="updateWorkspaceMember('updateUserForm')"/>
</template>
</el-dialog>
<ms-delete-confirm :title="$t('workspace.delete')" @delete="_handleDelete" ref="deleteConfirm"/>
</div>
</template>
<script>
import MsCreateBox from "../CreateBox";
import {Message} from "element-ui";
import MsTablePagination from "../../common/pagination/TablePagination";
import MsTableHeader from "../../common/components/MsTableHeader";
import MsRolesTag from "../../common/components/MsRolesTag";
import MsTableOperator from "../../common/components/MsTableOperator";
import MsTableOperatorButton from "../../common/components/MsTableOperatorButton";
import MsDialogFooter from "../../common/components/MsDialogFooter";
import {
getCurrentUser,
getCurrentWorkspaceId, listenGoBack,
refreshSessionAndCookies, removeGoBackListener
listenGoBack,removeGoBackListener
} from "@/common/js/utils";
import {DEFAULT, WORKSPACE} from "@/common/js/constants";
import MsDeleteConfirm from "../../common/components/MsDeleteConfirm";
import MsJarConfigEdit from "./edit/JarConfigEdit";
export default {
name: "MsJarConfigList",
name: "MsJarConfigSetting",
components: {
MsDeleteConfirm,
MsJarConfigEdit,
MsCreateBox,
MsTablePagination,
MsTableHeader,
MsRolesTag,
MsTableOperator,
MsDialogFooter,
MsTableOperatorButton
@ -126,36 +64,10 @@
return {
result: {},
condition: {},
dialogCondition: {},
items: [],
currentPage: 1,
pageSize: 5,
pageSize: 10,
total: 0,
dialogCurrentPage: 1,
dialogPageSize: 5,
dialogTotal: 0,
form: {
// name: "",
// description: ""
},
rules: {
name: [
{required: true, message: this.$t('workspace.input_name'), trigger: 'blur'},
{min: 2, max: 25, message: this.$t('commons.input_limit', [2, 25]), trigger: 'blur'},
{
required: true,
pattern: /^(?!-)(?!.*?-$)[a-zA-Z0-9\u4e00-\u9fa5-]+$/,
message: this.$t('workspace.special_characters_are_not_supported'),
trigger: 'blur'
}
],
description: [
{max: 50, message: this.$t('commons.input_limit', [0, 50]), trigger: 'blur'}
],
organizationId: [
{required: true, message: this.$t('organization.select_organization'), trigger: ['blur']}
]
},
}
},
activated() {
@ -163,60 +75,16 @@
},
methods: {
create() {
this.form = {};
this.$get("/organization/list", response => {
this.$set(this.form, "orgList", response.data);
})
listenGoBack(this.close);
this.$refs.jarConfigFrom.open();
},
getJarConfigs() {
this.result = this.$get("/jar/list/" + this.projectId, response => {
this.configs = response.data;
this.currentConfig = {};
})
},
submit(formName) {
this.$refs[formName].validate((valid) => {
if (valid) {
let saveType = 'special/add';
if (this.form.id) {
saveType = 'update'
}
this.result = this.$post("/workspace/" + saveType, this.form, () => {
this.dialogWsAddVisible = false;
this.list();
Message.success(this.$t('commons.save_success'));
});
} else {
return false;
}
});
},
edit(row) {
// copy user
this.form = Object.assign({}, row);
this.$get("/organization/list", response => {
this.$set(this.form, "orgList1", response.data);
})
listenGoBack(this.close);
this.$refs.jarConfigFrom.open(row);
},
close() {
removeGoBackListener(this.close);
},
updateWorkspace(updateForm) {
this.$refs[updateForm].validate(valid => {
if (valid) {
this.result = this.$post("/workspace/special/update", this.form, () => {
this.$success(this.$t('commons.modify_success'));
this.list();
});
} else {
return false;
}
})
},
list() {
let url = '/jar/list/' + this.currentPage + '/' + this.pageSize;
this.result = this.$post(url, this.condition, response => {
@ -225,41 +93,14 @@
this.total = data.itemCount;
});
},
submitForm(formName) {
this.$refs[formName].validate((valid) => {
if (valid) {
let param = {
userIds: this.memberForm.userIds,
roleIds: this.memberForm.roleIds,
workspaceId: this.currentWorkspaceRow.id
};
this.result = this.$post("user/special/ws/member/add", param, () => {
this.cellClick(this.currentWorkspaceRow);
this.dialogWsMemberAddVisible = false;
})
} else {
return false;
}
});
},
handleDelete(workspace) {
this.$refs.deleteConfirm.open(workspace);
},
_handleDelete(workspace) {
this.$confirm(this.$t('workspace.delete_confirm'), '', {
handleDelete(id) {
this.$confirm(this.$t('删除需重启服务后生效'), '', {
confirmButtonText: this.$t('commons.confirm'),
cancelButtonText: this.$t('commons.cancel'),
type: 'warning'
}).then(() => {
this.$get('/workspace/special/delete/' + workspace.id, () => {
let lastWorkspaceId = getCurrentWorkspaceId();
let sourceId = workspace.id;
if (lastWorkspaceId === sourceId) {
let sign = DEFAULT;
refreshSessionAndCookies(sign, sourceId);
}
Message.success(this.$t('commons.delete_success'));
this.result = this.$get("/jar/delete/" + id, () => {
this.$success(this.$t('commons.delete_success'));
this.list();
});
}).catch(() => {
@ -268,39 +109,11 @@
message: this.$t('commons.delete_cancelled')
});
});
}
},
}
}
</script>
<style scoped>
.el-table__row:hover .edit {
opacity: 1;
}
.member-size {
text-decoration: underline;
cursor: pointer;
}
.ws-member-id {
float: left;
}
.ws-member-email {
float: right;
color: #8492a6;
font-size: 13px;
}
.select-width {
width: 100%;
}
.dialog-css >>> .el-dialog__header {
padding: 0;
}
</style>

View File

@ -1,13 +1,195 @@
<template>
$END$
<el-dialog width="50%" :close-on-click-modal="false" :title="$t('api_test.jar_config.title')" :visible.sync="visible" class="jar-import" @close="close">
<div v-loading="result.loading">
<el-form :model="currentConfig" :rules="rules" label-width="100px" v-loading="result.loading" ref="form">
<el-row>
<el-col :span="12">
<el-form-item :label="$t('commons.name')" prop="name">
<el-input size="small" v-model="currentConfig.name" clearable show-word-limit/>
</el-form-item>
<el-form-item :label="$t('commons.project')" prop="description">
<el-input :disabled="readOnly" v-model="currentConfig.description"
type="textarea"
:autosize="{ minRows: 2, maxRows: 4}"
:rows="2"
:placeholder="$t('commons.input_content')"/>
</el-form-item>
</el-col>
<el-col :span="1">
<el-divider direction="vertical"/>
</el-col>
<el-col :span="11">
<el-upload
class="jar-upload"
drag
action="#"
:http-request="upload"
:limit="1"
:beforeUpload="uploadValidate"
:on-remove="handleRemove"
:on-exceed="handleExceed"
:file-list="fileList"
ref="fileUpload">
<i class="el-icon-upload"></i>
<div class="el-upload__text" v-html="$t('load_test.upload_tips')"></div>
<div class="el-upload__tip" slot="tip">{{$t('api_test.api_import.file_size_limit')}}</div>
</el-upload>
</el-col>
</el-row>
</el-form>
</div>
<template v-slot:footer>
<div class="dialog-footer">
<ms-dialog-footer @cancel="close" @confirm="save"/>
</div>
</template>
</el-dialog>
</template>
<script>
export default {
name: "JarConfigEdit"
import {listenGoBack, removeGoBackListener} from "../../../../../common/js/utils";
import MsDialogFooter from "../../../common/components/MsDialogFooter";
// todo
export default {
name: "MsJarConfigEdit",
components: {MsDialogFooter},
data() {
return {
visible: false,
result: {},
currentConfig: {
name: '',
description: '',
fileName: '',
},
rules: {
name: [
{required: true, message: this.$t('commons.input_name'), trigger: 'blur'},
{max: 60, message: this.$t('commons.input_limit', [1, 60]), trigger: 'blur'}
],
description: [
{max: 250, message: this.$t('commons.input_limit', [1, 250]), trigger: 'blur'}
],
},
fileList: []
}
},
props: {
readOnly: {
type: Boolean,
default: false
}
},
methods: {
open(config) {
this.currentConfig = {
name: '',
description: '',
fileName: '',
};
if (config) {
if (config.fileName) {
this.fileList = [{name: config.fileName}];
} else {
this.fileList = [];
}
Object.assign(this.currentConfig, config);
}
this.visible = true;
listenGoBack(this.close);
},
upload(file) {
this.fileList.push(file.file)
},
handleExceed(files, fileList) {
this.$warning(this.$t('test_track.case.import.upload_limit_count'));
},
handleRemove(file, fileList) {
this.fileList = [];
},
uploadValidate(file, fileList) {
let suffix = file.name.substring(file.name.lastIndexOf('.') + 1);
if (suffix != 'jar') {
this.$warning(this.$t('api_test.api_import.suffixFormatErr'));
return false;
}
if (file.size / 1024 / 1024 > 30) {
this.$warning(this.$t('jar_config.upload_limit_size'));
return false;
}
return true;
},
save() {
this.$refs['form'].validate((valid) => {
if (valid) {
if (this.fileList <= 0) {
this.$warning(this.$t('commons.please_upload'));
return false;
}
this._save();
} else {
return false;
}
});
},
_save() {
let url = this.currentConfig.id ? "/jar/update" : "/jar/add";
this.result = this.$fileUpload(url, this.fileList[0], null, this.currentConfig, () => {
this.$success(this.$t('commons.save_success'));
this.$emit("refresh");
this.close();
});
},
clear() {
this.$refs['form'].clearValidate();
this.fileList = [];
},
close() {
this.clear();
removeGoBackListener(this.close);
this.visible = false;
}
}
}
</script>
<style scoped>
.el-divider {
height: 200px;
}
.jar-upload {
text-align: center;
margin: auto 0;
}
.jar-upload >>> .el-upload {
width: 100%;
max-width: 350px;
}
.jar-upload >>> .el-upload-dragger {
width: 100%;
}
.el-form {
border: solid #E1E1E1 1px;
margin: 10px 0;
padding: 30px 10px;
border-radius: 3px;
}
.buttons {
margin-top: 10px;
margin-bottom: -10px;
float: right;
}
</style>

View File

@ -118,6 +118,7 @@ export default {
please_upload: 'Please upload file',
reference_documentation: "Reference documentation",
already_exists: 'The name already exists',
modifier: 'Modifier',
date: {
select_date: 'Select date',
start_date: 'Start date',

View File

@ -118,6 +118,7 @@ export default {
cannot_be_null: '不能为空',
required: "{0}是必填的",
already_exists: '名称不能重复',
modifier: '修改人',
date: {
select_date: '选择日期',
start_date: '开始日期',

View File

@ -118,6 +118,7 @@ export default {
cannot_be_null: '不能為空',
required: "{0}是必填的",
already_exists: '名稱不能重復',
modifier: '修改人',
date: {
select_date: '選擇日期',
start_date: '開始日期',