优化兼容linux下部署客户端
1:更换UI驱动文件路径 2:解决日志框架冲突导致linux下不生成日志的问题(修改pom.xml) 3:废弃testlink相关的方法 4:增加兼容linux下各种.sh文件 5:增加兼容linux下各种web ui的驱动 6:分离spring boot与测试执行的LOG4J日志 7:删除无用的部分类
This commit is contained in:
parent
606b14c501
commit
89dad9c8ed
89
pom.xml
89
pom.xml
|
@ -50,6 +50,19 @@
|
|||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-jar-plugin</artifactId>
|
||||
<configuration>
|
||||
<excludes>
|
||||
<exclude>*.cmd</exclude>
|
||||
<exclude>*.bat</exclude>
|
||||
<exclude>*.exe</exclude>
|
||||
<exclude>*.conf</exclude>
|
||||
<exclude>*.sh</exclude>
|
||||
<exclude>**/BrowserDriven/*</exclude>
|
||||
<exclude>**/email_template/*</exclude>
|
||||
<exclude>**/TestDriven/*</exclude>
|
||||
<exclude>appium_config.properties</exclude>
|
||||
<exclude>sys_config.properties</exclude>
|
||||
<exclude>testlinkjavaapi.properties</exclude>
|
||||
</excludes>
|
||||
<archive>
|
||||
<manifest>
|
||||
<addClasspath>true</addClasspath>
|
||||
|
@ -96,6 +109,9 @@
|
|||
<plugin>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-maven-plugin</artifactId>
|
||||
<configuration>
|
||||
<mainClass>springboot.RunService</mainClass>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
|
@ -215,10 +231,11 @@
|
|||
<artifactId>slf4j-api</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>br.eti.kinoshita</groupId>
|
||||
<artifactId>testlink-java-api</artifactId>
|
||||
<version>1.9.16-0</version>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-log4j</artifactId>
|
||||
<version>1.3.8.RELEASE</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.apache.xmlrpc</groupId>
|
||||
<artifactId>xmlrpc-client</artifactId>
|
||||
|
@ -246,31 +263,71 @@
|
|||
<artifactId>mysql-connector-java</artifactId>
|
||||
<version>8.0.11</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.fasterxml.jackson.core</groupId>
|
||||
<artifactId>jackson-databind</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>io.appium</groupId>
|
||||
<artifactId>java-client</artifactId>
|
||||
<version>6.0.0-BETA2</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.freemarker</groupId>
|
||||
<artifactId>freemarker</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>br.eti.kinoshita</groupId>
|
||||
<artifactId>testlink-java-api</artifactId>
|
||||
<version>1.9.16-0</version>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<artifactId>log4j-api</artifactId>
|
||||
<groupId>org.apache.logging.log4j</groupId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<artifactId>commons-configuration2</artifactId>
|
||||
<groupId>org.apache.commons</groupId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<artifactId>log4j-core</artifactId>
|
||||
<groupId>org.apache.logging.log4j</groupId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<artifactId>commons-httpclient</artifactId>
|
||||
<groupId>commons-httpclient</groupId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.httpcomponents</groupId>
|
||||
<artifactId>httpmime</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.alibaba</groupId>
|
||||
<artifactId>fastjson</artifactId>
|
||||
<version>1.2.47</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.fasterxml.jackson.core</groupId>
|
||||
<artifactId>jackson-databind</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>io.appium</groupId>
|
||||
<artifactId>java-client</artifactId>
|
||||
<version>6.0.0-BETA2</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.httpcomponents</groupId>
|
||||
<artifactId>httpmime</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-web</artifactId>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-logging</artifactId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
<!-- <dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter</artifactId>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-logging</artifactId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency> -->
|
||||
</dependencies>
|
||||
</project>
|
||||
|
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
@ -0,0 +1,48 @@
|
|||
log4j.rootLogger=INFO,stdout,app,error
|
||||
|
||||
log4j.logger.app=info
|
||||
log4j.logger.error=info,error
|
||||
|
||||
log4j.additivity.msg=false
|
||||
log4j.additivity.monitor=false
|
||||
log4j.additivity.error=false
|
||||
|
||||
log4j.logger.org.springframework=warn
|
||||
log4j.logger.org.apache=info,error
|
||||
log4j.logger.org.aspectj.weaver=warn
|
||||
log4j.logger.org.hibernate=off
|
||||
log4j.logger.com.mchange=off
|
||||
log4j.logger.java.sql.Connection=info
|
||||
log4j.logger.java.sql.Statement=info
|
||||
log4j.logger.java.sql.ResultSet=info
|
||||
log4j.logger.java.sql.PreparedStatement=info
|
||||
|
||||
#log4j.logger.httpclient.wire.header=off
|
||||
#log4j.logger.httpclient.wire.content=off
|
||||
#log4j.logger.org.apache.commons.httpclient=off
|
||||
#log4j.logger.org.apache.commons.httpclient.Wire=off
|
||||
|
||||
|
||||
################
|
||||
log4j.appender.stdout=org.apache.log4j.ConsoleAppender
|
||||
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
|
||||
log4j.appender.stdout.layout.ConversionPattern = %d{yyyy-MM-dd HH\:mm\:ss\:SSS}\:%l - \n%p\: %m%n
|
||||
|
||||
################
|
||||
log4j.appender.app=org.apache.log4j.DailyRollingFileAppender
|
||||
log4j.appender.app.File=bootlog/APP.log
|
||||
log4j.appender.app.layout=org.apache.log4j.PatternLayout
|
||||
log4j.appender.app.layout.ConversionPattern=%d{yyyy-MM-dd HH:mm:ss:SSS}:%p %l - %m%n
|
||||
log4j.appender.app.DatePattern = '.'yyyy-MM-dd
|
||||
log4j.appender.app.encoding=UTF-8
|
||||
#log4j.appender.app.encoding=UTF-8
|
||||
################
|
||||
|
||||
################error
|
||||
log4j.appender.error=org.apache.log4j.DailyRollingFileAppender
|
||||
log4j.appender.error.File=bootlog/ERROR.log
|
||||
log4j.appender.error.layout=org.apache.log4j.PatternLayout
|
||||
log4j.appender.error.layout.ConversionPattern=%d{yyyy-MM-dd HH:mm:ss:SSS}:%p %l - %m%n
|
||||
log4j.appender.error.DatePattern = '.'yyyy-MM-dd
|
||||
log4j.appender.error.encoding=UTF-8
|
||||
|
Binary file not shown.
Binary file not shown.
|
@ -26,13 +26,13 @@ log4j.logger.java.sql.PreparedStatement=info
|
|||
################
|
||||
log4j.appender.stdout=org.apache.log4j.ConsoleAppender
|
||||
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
|
||||
log4j.appender.stdout.layout.ConversionPattern = %d{yyyy-MM-dd HH\:mm\:ss\:SSS}\:%t %l - \n%p\: %m%n
|
||||
log4j.appender.stdout.layout.ConversionPattern = %d{yyyy-MM-dd HH\:mm\:ss\:SSS}\:%l - \n%p\: %m%n
|
||||
|
||||
################
|
||||
log4j.appender.app=org.apache.log4j.DailyRollingFileAppender
|
||||
log4j.appender.app.File=log/APP.log
|
||||
log4j.appender.app.layout=org.apache.log4j.PatternLayout
|
||||
log4j.appender.app.layout.ConversionPattern=%d{yyyy-MM-dd HH:mm:ss:SSS}:%p %t %l - %m%n
|
||||
log4j.appender.app.layout.ConversionPattern=%d{yyyy-MM-dd HH:mm:ss:SSS}:%p %l - %m%n
|
||||
log4j.appender.app.DatePattern = '.'yyyy-MM-dd
|
||||
log4j.appender.app.encoding=UTF-8
|
||||
#log4j.appender.app.encoding=UTF-8
|
||||
|
@ -42,7 +42,7 @@ log4j.appender.app.encoding=UTF-8
|
|||
log4j.appender.error=org.apache.log4j.DailyRollingFileAppender
|
||||
log4j.appender.error.File=log/ERROR.log
|
||||
log4j.appender.error.layout=org.apache.log4j.PatternLayout
|
||||
log4j.appender.error.layout.ConversionPattern=%d{yyyy-MM-dd HH:mm:ss:SSS}:%p %t %l - %m%n
|
||||
log4j.appender.error.layout.ConversionPattern=%d{yyyy-MM-dd HH:mm:ss:SSS}:%p %l - %m%n
|
||||
log4j.appender.error.DatePattern = '.'yyyy-MM-dd
|
||||
log4j.appender.error.encoding=UTF-8
|
||||
|
||||
|
|
|
@ -0,0 +1,17 @@
|
|||
#!/bin/sh
|
||||
BASE_DIR="."
|
||||
LIB="${BASE_DIR}/lib"
|
||||
JAVA_OPTS=" -Xmx2048m -XX:PermSize=64m -XX:MaxPermSize=512m -XX:+PrintGCDateStamps -XX:+PrintGCDetails -Xloggc:logs/gc.log -XX:+UseGCLogFileRotation -XX:NumberOfGCLogFiles=1 -XX:GCLogFileSize=1024k -XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath=logs/mtdperf.hprof -server -Dfile.encoding=UTF-8"
|
||||
START_CLASS="springboot.RunService"
|
||||
|
||||
echo ${LIB}
|
||||
|
||||
for libfile in ${LIB}/*.jar ; do
|
||||
if [ -f $libfile ] ; then
|
||||
CLASSPATH=$libfile:${CLASSPATH}
|
||||
fi
|
||||
done
|
||||
|
||||
CLASSPATH=${BASE_DIR}:${CLASSPATH}
|
||||
echo .:${CLASSPATH} ${START_CLASS}
|
||||
java -cp .:${CLASSPATH} ${START_CLASS} &
|
|
@ -0,0 +1,24 @@
|
|||
#!/bin/sh
|
||||
BASE_DIR="."
|
||||
LIB="${BASE_DIR}/lib"
|
||||
DRIVENPATH="${BASE_DIR}/$2"
|
||||
JAVA_OPTS=" -Xmx2048m -XX:PermSize=64m -XX:MaxPermSize=512m -XX:+PrintGCDateStamps -XX:+PrintGCDetails -Xloggc:logs/gc.log -XX:+UseGCLogFileRotation -XX:NumberOfGCLogFiles=1 -XX:GCLogFileSize=1024k -XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath=logs/mtdperf.hprof -server -Dfile.encoding=UTF-8"
|
||||
START_CLASS="luckyclient.caserun.RunAutomationTest $1"
|
||||
|
||||
echo ${LIB}
|
||||
|
||||
for libfile in ${LIB}/*.jar ; do
|
||||
if [ -f $libfile ] ; then
|
||||
CLASSPATH=$libfile:${CLASSPATH}
|
||||
fi
|
||||
done
|
||||
|
||||
for libfile in ${DRIVENPATH}/*.jar ; do
|
||||
if [ -f $libfile ] ; then
|
||||
CLASSPATH=$libfile:${CLASSPATH}
|
||||
fi
|
||||
done
|
||||
|
||||
CLASSPATH=${BASE_DIR}:${CLASSPATH}
|
||||
echo .:${CLASSPATH} ${START_CLASS}
|
||||
java -cp .:${CLASSPATH} ${START_CLASS} &
|
|
@ -0,0 +1,24 @@
|
|||
#!/bin/sh
|
||||
BASE_DIR="."
|
||||
LIB="${BASE_DIR}/lib"
|
||||
DRIVENPATH="${BASE_DIR}/$3"
|
||||
JAVA_OPTS=" -Xmx2048m -XX:PermSize=64m -XX:MaxPermSize=512m -XX:+PrintGCDateStamps -XX:+PrintGCDetails -Xloggc:logs/gc.log -XX:+UseGCLogFileRotation -XX:NumberOfGCLogFiles=1 -XX:GCLogFileSize=1024k -XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath=logs/mtdperf.hprof -server -Dfile.encoding=UTF-8"
|
||||
START_CLASS="luckyclient.caserun.BatchCaseExecute $1 $2"
|
||||
|
||||
echo ${LIB}
|
||||
|
||||
for libfile in ${LIB}/*.jar ; do
|
||||
if [ -f $libfile ] ; then
|
||||
CLASSPATH=$libfile:${CLASSPATH}
|
||||
fi
|
||||
done
|
||||
|
||||
for libfile in ${DRIVENPATH}/*.jar ; do
|
||||
if [ -f $libfile ] ; then
|
||||
CLASSPATH=$libfile:${CLASSPATH}
|
||||
fi
|
||||
done
|
||||
|
||||
CLASSPATH=${BASE_DIR}:${CLASSPATH}
|
||||
echo .:${CLASSPATH} ${START_CLASS}
|
||||
java -cp .:${CLASSPATH} ${START_CLASS} &
|
|
@ -0,0 +1,24 @@
|
|||
#!/bin/sh
|
||||
BASE_DIR="."
|
||||
LIB="${BASE_DIR}/lib"
|
||||
DRIVENPATH="${BASE_DIR}/$4"
|
||||
JAVA_OPTS=" -Xmx2048m -XX:PermSize=64m -XX:MaxPermSize=512m -XX:+PrintGCDateStamps -XX:+PrintGCDetails -Xloggc:logs/gc.log -XX:+UseGCLogFileRotation -XX:NumberOfGCLogFiles=1 -XX:GCLogFileSize=1024k -XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath=logs/mtdperf.hprof -server -Dfile.encoding=UTF-8"
|
||||
START_CLASS="luckyclient.caserun.OneCaseExecute $1 $2 $3"
|
||||
|
||||
echo ${LIB}
|
||||
|
||||
for libfile in ${LIB}/*.jar ; do
|
||||
if [ -f $libfile ] ; then
|
||||
CLASSPATH=$libfile:${CLASSPATH}
|
||||
fi
|
||||
done
|
||||
|
||||
for libfile in ${DRIVENPATH}/*.jar ; do
|
||||
if [ -f $libfile ] ; then
|
||||
CLASSPATH=$libfile:${CLASSPATH}
|
||||
fi
|
||||
done
|
||||
|
||||
CLASSPATH=${BASE_DIR}:${CLASSPATH}
|
||||
echo .:${CLASSPATH} ${START_CLASS}
|
||||
java -cp .:${CLASSPATH} ${START_CLASS} &
|
|
@ -0,0 +1,24 @@
|
|||
#!/bin/sh
|
||||
BASE_DIR="."
|
||||
LIB="${BASE_DIR}/lib"
|
||||
DRIVENPATH="${BASE_DIR}/$3"
|
||||
JAVA_OPTS=" -Xmx2048m -XX:PermSize=64m -XX:MaxPermSize=512m -XX:+PrintGCDateStamps -XX:+PrintGCDetails -Xloggc:logs/gc.log -XX:+UseGCLogFileRotation -XX:NumberOfGCLogFiles=1 -XX:GCLogFileSize=1024k -XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath=logs/mtdperf.hprof -server -Dfile.encoding=UTF-8"
|
||||
START_CLASS="luckyclient.caserun.WebDebugExecute $1 $2"
|
||||
|
||||
echo ${LIB}
|
||||
|
||||
for libfile in ${LIB}/*.jar ; do
|
||||
if [ -f $libfile ] ; then
|
||||
CLASSPATH=$libfile:${CLASSPATH}
|
||||
fi
|
||||
done
|
||||
|
||||
for libfile in ${DRIVENPATH}/*.jar ; do
|
||||
if [ -f $libfile ] ; then
|
||||
CLASSPATH=$libfile:${CLASSPATH}
|
||||
fi
|
||||
done
|
||||
|
||||
CLASSPATH=${BASE_DIR}:${CLASSPATH}
|
||||
echo .:${CLASSPATH} ${START_CLASS}
|
||||
java -cp .:${CLASSPATH} ${START_CLASS} &
|
|
@ -1,5 +1,6 @@
|
|||
package luckyclient.caserun;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.Properties;
|
||||
|
||||
import org.apache.log4j.PropertyConfigurator;
|
||||
|
@ -30,7 +31,7 @@ public class BatchCaseExecute extends TestControl {
|
|||
public static void main(String[] args) {
|
||||
// TODO Auto-generated method stub
|
||||
try {
|
||||
PropertyConfigurator.configure(System.getProperty("user.dir") + "\\log4j.conf");
|
||||
PropertyConfigurator.configure(System.getProperty("user.dir") + File.separator + "log4j.conf");
|
||||
String taskid = args[0];
|
||||
String batchcase = args[1];
|
||||
TestTaskexcute task = GetServerAPI.cgetTaskbyid(Integer.valueOf(taskid));
|
||||
|
@ -56,6 +57,7 @@ public class BatchCaseExecute extends TestControl {
|
|||
|
||||
} else if (task.getTestJob().getExtype() == 2) {
|
||||
Properties properties = luckyclient.publicclass.AppiumConfig.getConfiguration();
|
||||
|
||||
if ("Android".equals(properties.getProperty("platformName"))) {
|
||||
AndroidBatchExecute.batchCaseExecuteForTast(task.getTestJob().getPlanproj(),
|
||||
String.valueOf(task.getId()), batchcase);
|
||||
|
@ -63,6 +65,7 @@ public class BatchCaseExecute extends TestControl {
|
|||
IosBatchExecute.batchCaseExecuteForTast(task.getTestJob().getPlanproj(),
|
||||
String.valueOf(task.getId()), batchcase);
|
||||
}
|
||||
|
||||
}
|
||||
} catch (Exception e) {
|
||||
// TODO Auto-generated catch block
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
package luckyclient.caserun;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.Properties;
|
||||
|
||||
import org.apache.log4j.PropertyConfigurator;
|
||||
|
@ -29,7 +30,7 @@ public class OneCaseExecute extends TestControl {
|
|||
|
||||
public static void main(String[] args) throws Exception {
|
||||
// TODO Auto-generated method stub
|
||||
PropertyConfigurator.configure(System.getProperty("user.dir") + "\\log4j.conf");
|
||||
PropertyConfigurator.configure(System.getProperty("user.dir")+ File.separator +"log4j.conf");
|
||||
String taskid = args[0];
|
||||
String testCaseExternalId = args[1];
|
||||
int version = Integer.parseInt(args[2]);
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
package luckyclient.caserun;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
import org.apache.log4j.PropertyConfigurator;
|
||||
|
||||
import luckyclient.caserun.exappium.AppTestControl;
|
||||
|
@ -23,7 +25,7 @@ public class RunAutomationTest extends TestControl {
|
|||
public static void main(String[] args) {
|
||||
// TODO Auto-generated method stub
|
||||
try {
|
||||
PropertyConfigurator.configure(System.getProperty("user.dir") + "\\log4j.conf");
|
||||
PropertyConfigurator.configure(System.getProperty("user.dir") + File.separator + "log4j.conf");
|
||||
String taskid = args[0];
|
||||
TestTaskexcute task = GetServerAPI.cgetTaskbyid(Integer.valueOf(taskid));
|
||||
|
||||
|
@ -36,7 +38,6 @@ public class RunAutomationTest extends TestControl {
|
|||
} else if (task.getTestJob().getExtype() == 2) {
|
||||
AppTestControl.taskExecutionPlan(taskid, task);
|
||||
}
|
||||
|
||||
} catch (Exception e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
package luckyclient.caserun;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
import org.apache.log4j.PropertyConfigurator;
|
||||
|
||||
import luckyclient.caserun.exinterface.TestControl;
|
||||
|
@ -20,8 +22,7 @@ public class WebDebugExecute extends TestControl{
|
|||
|
||||
public static void main(String[] args) throws Exception {
|
||||
// TODO Auto-generated method stub
|
||||
PropertyConfigurator.configure(System.getProperty("user.dir")
|
||||
+ "\\log4j.conf");
|
||||
PropertyConfigurator.configure(System.getProperty("user.dir") + File.separator + "log4j.conf");
|
||||
String sign = args[0];
|
||||
String executor = args[1];
|
||||
WebTestCaseDebug.oneCaseDebug(sign,executor);
|
||||
|
|
|
@ -35,7 +35,7 @@ public class AppiumInitialization {
|
|||
Properties properties = luckyclient.publicclass.AppiumConfig.getConfiguration();
|
||||
DesiredCapabilities capabilities = new DesiredCapabilities();
|
||||
File directory = new File("");
|
||||
File app = new File(directory.getCanonicalPath() + "//" + properties.getProperty("appname"));
|
||||
File app = new File(directory.getCanonicalPath() + File.separator + properties.getProperty("appname"));
|
||||
capabilities.setCapability("app", app.getAbsolutePath());
|
||||
// 自动化测试服务
|
||||
capabilities.setCapability("automationName", properties.getProperty("automationName"));
|
||||
|
@ -74,7 +74,7 @@ public class AppiumInitialization {
|
|||
Properties properties = luckyclient.publicclass.AppiumConfig.getConfiguration();
|
||||
DesiredCapabilities capabilities = new DesiredCapabilities();
|
||||
File directory = new File("");
|
||||
File app = new File(directory.getCanonicalPath() + "//" + properties.getProperty("appname"));
|
||||
File app = new File(directory.getCanonicalPath() + File.separator + properties.getProperty("appname"));
|
||||
capabilities.setCapability("app", app.getAbsolutePath());
|
||||
// 自动化测试服务
|
||||
capabilities.setCapability("automationName", properties.getProperty("automationName"));
|
||||
|
|
|
@ -199,7 +199,7 @@ public class AndroidCaseExecution extends TestCaseExecution{
|
|||
//调用接口用例
|
||||
if(null != operation&&null != operationValue&&"runcase".equals(operation)){
|
||||
String[] temp=operationValue.split(",",-1);
|
||||
String ex = TestCaseExecution.oneCaseExecuteForWebDriver(temp[0],taskid,caselog);
|
||||
String ex = TestCaseExecution.oneCaseExecuteForWebCase(temp[0], taskid, caselog, appium);
|
||||
if(ex.indexOf("CallCase调用出错!")<=-1&&ex.indexOf("解析出错啦!")<=-1&&ex.indexOf("匹配失败")<=-1){
|
||||
return ex;
|
||||
}else{
|
||||
|
|
|
@ -199,7 +199,7 @@ public class IosCaseExecution extends TestCaseExecution{
|
|||
//调用接口用例
|
||||
if(null != operation&&null != operationValue&&"runcase".equals(operation)){
|
||||
String[] temp=operationValue.split(",",-1);
|
||||
String ex = TestCaseExecution.oneCaseExecuteForWebDriver(temp[0],taskid,caselog);
|
||||
String ex = TestCaseExecution.oneCaseExecuteForWebCase(temp[0], taskid, caselog, appium);
|
||||
if(ex.indexOf("CallCase调用出错!")<=-1&&ex.indexOf("解析出错啦!")<=-1&&ex.indexOf("匹配失败")<=-1){
|
||||
return ex;
|
||||
}else{
|
||||
|
|
|
@ -131,7 +131,7 @@ public class TestControl {
|
|||
* 计划任务模式调度计划执行用例
|
||||
*/
|
||||
|
||||
protected static void taskExecutionPlan(String taskid,TestTaskexcute task) throws Exception {
|
||||
public static void taskExecutionPlan(String taskid,TestTaskexcute task) throws Exception {
|
||||
DbLink.exetype = 0;
|
||||
TestControl.TASKID = taskid;
|
||||
String restartstatus = RestartServerInitialization.restartServerRun(taskid);
|
||||
|
|
|
@ -98,7 +98,6 @@ public class WebTestCaseDebug {
|
|||
testnote = InvokeMethod.callCase(packagename, functionname, getParameterValues, steps.get(i).getSteptype(), steps.get(i).getAction());
|
||||
|
||||
if (null != expectedresults && !expectedresults.isEmpty()) {
|
||||
luckyclient.publicclass.LogUtil.APP.info("expectedResults=¡¾" + expectedresults + "¡¿");
|
||||
// ¸³Öµ´«²Î
|
||||
if (expectedresults.length() > ASSIGNMENT_SIGN.length() && expectedresults.startsWith(ASSIGNMENT_SIGN)) {
|
||||
variable.put(expectedresults.substring(ASSIGNMENT_SIGN.length()), testnote);
|
||||
|
@ -171,5 +170,6 @@ public class WebTestCaseDebug {
|
|||
}
|
||||
|
||||
public static void main(String[] args) throws Exception {
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,8 +1,6 @@
|
|||
package luckyclient.caserun.exwebdriver;
|
||||
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.openqa.selenium.WebDriver;
|
||||
|
||||
|
@ -40,7 +38,7 @@ public class CaseLocalDebug{
|
|||
WebCaseExecution.caseExcution(testcase,steps, "888888",wd,caselog,pcplist);
|
||||
luckyclient.publicclass.LogUtil.APP.info("当前用例:【"+testcase.getSign()+"】执行完成......进入下一条");
|
||||
} catch (Exception e) {
|
||||
luckyclient.publicclass.LogUtil.APP.error("用户执行过程中抛出异常!", e);
|
||||
luckyclient.publicclass.LogUtil.ERROR.info("用户执行过程中抛出异常!", e);
|
||||
e.printStackTrace();
|
||||
}
|
||||
//关闭浏览器
|
||||
|
|
|
@ -23,34 +23,56 @@ import org.openqa.selenium.ie.InternetExplorerDriver;
|
|||
*
|
||||
*/
|
||||
public class WebDriverInitialization{
|
||||
private static final String os=System.getProperty("os.name").toLowerCase();
|
||||
/**
|
||||
* @param args
|
||||
* 初始化WebDriver
|
||||
* @param drivertype
|
||||
* @return
|
||||
* @throws WebDriverException
|
||||
* @throws IOException
|
||||
*/
|
||||
public static WebDriver setWebDriverForTask(int drivertype) throws WebDriverException,IOException{
|
||||
// 参数为空
|
||||
File directory = new File("");
|
||||
/* System.setProperty("webdriver.ie.driver",directory.getCanonicalPath()+"\\IEDriverServer.exe");
|
||||
DesiredCapabilities ieCapabilities = DesiredCapabilities.internetExplorer();
|
||||
ieCapabilities.setCapability(InternetExplorerDriver.INTRODUCE_FLAKINESS_BY_IGNORING_SECURITY_DOMAINS,true);
|
||||
WebDriver webDriver = new InternetExplorerDriver(ieCapabilities);*/
|
||||
String drivenpath=directory.getCanonicalPath()+File.separator+"BrowserDriven"+File.separator;
|
||||
WebDriver webDriver = null;
|
||||
|
||||
luckyclient.publicclass.LogUtil.APP.info("准备初始化WebDriver对象...检查到当前操作系统是:"+os);
|
||||
if(drivertype==0){
|
||||
System.setProperty("webdriver.ie.driver",directory.getCanonicalPath()+"\\IEDriverServer.exe");
|
||||
if(os.startsWith("win")){
|
||||
System.setProperty("webdriver.ie.driver",drivenpath+"IEDriverServer.exe");
|
||||
webDriver = new InternetExplorerDriver();
|
||||
}else{
|
||||
luckyclient.publicclass.LogUtil.ERROR.info("当前操作系统无法进行IE浏览器的Web UI测试,请选择火狐或是谷歌浏览器!");
|
||||
}
|
||||
}else if(drivertype==1){
|
||||
System.setProperty("webdriver.gecko.driver",directory.getCanonicalPath()+"\\geckodriver.exe");
|
||||
if(os.startsWith("win")){
|
||||
System.setProperty("webdriver.gecko.driver",drivenpath+"geckodriver.exe");
|
||||
}else if(os.indexOf("mac")>=0){
|
||||
System.setProperty("webdriver.gecko.driver",drivenpath+"geckodriver_mac");
|
||||
}else{
|
||||
System.setProperty("webdriver.gecko.driver",drivenpath+"geckodriver_linux64");
|
||||
}
|
||||
webDriver = new FirefoxDriver();
|
||||
}else if(drivertype==2){
|
||||
System.setProperty("webdriver.chrome.driver",directory.getCanonicalPath()+"\\chromedriver.exe");
|
||||
if(os.startsWith("win")){
|
||||
System.setProperty("webdriver.chrome.driver",drivenpath+"chromedriver.exe");
|
||||
}else if(os.indexOf("mac")>=0){
|
||||
System.setProperty("webdriver.gecko.driver",drivenpath+"chromedriver_mac");
|
||||
}else{
|
||||
System.setProperty("webdriver.gecko.driver",drivenpath+"chromedriver_linux64");
|
||||
}
|
||||
webDriver = new ChromeDriver();
|
||||
}else if(drivertype==3){
|
||||
System.setProperty("webdriver.edge.driver",directory.getCanonicalPath()+"\\MicrosoftWebDriver.exe");
|
||||
if(os.startsWith("win")){
|
||||
System.setProperty("webdriver.edge.driver",drivenpath+"MicrosoftWebDriver.exe");
|
||||
webDriver = new EdgeDriver();
|
||||
}else{
|
||||
System.setProperty("webdriver.ie.driver",directory.getCanonicalPath()+"\\IEDriverServer.exe");
|
||||
luckyclient.publicclass.LogUtil.ERROR.info("当前操作系统无法进行Edge浏览器的Web UI测试,请选择火狐或是谷歌浏览器!");
|
||||
}
|
||||
}else{
|
||||
luckyclient.publicclass.LogUtil.ERROR.info("浏览器类型标识:"+drivertype);
|
||||
luckyclient.publicclass.LogUtil.ERROR.info("获取到的浏览器类型标识未定义,默认IE浏览器进行执行....");
|
||||
System.setProperty("webdriver.ie.driver",drivenpath+"IEDriverServer.exe");
|
||||
webDriver = new InternetExplorerDriver();
|
||||
}
|
||||
|
||||
|
@ -70,7 +92,8 @@ public class WebDriverInitialization{
|
|||
*/
|
||||
public static WebDriver setWebDriverForLocal() throws IOException{
|
||||
File directory = new File("");
|
||||
System.setProperty("webdriver.ie.driver",directory.getCanonicalPath()+"\\IEDriverServer.exe");
|
||||
String drivenpath=directory.getCanonicalPath()+File.separator+"BrowserDriven"+File.separator;
|
||||
System.setProperty("webdriver.ie.driver",drivenpath+"IEDriverServer.exe");
|
||||
WebDriver webDriver = new InternetExplorerDriver();
|
||||
webDriver.manage().window().maximize();
|
||||
//设置页面加载最大时长30秒
|
||||
|
|
|
@ -25,7 +25,6 @@ import luckyclient.publicclass.remoterinterface.HttpRequest;
|
|||
*
|
||||
*/
|
||||
public class GetServerAPI {
|
||||
|
||||
/**
|
||||
* 通过计划ID获取测试用例对象集
|
||||
* @param planid
|
||||
|
|
|
@ -15,6 +15,13 @@ import java.util.regex.Pattern;
|
|||
*/
|
||||
public class ChangString {
|
||||
|
||||
/**
|
||||
* 替换变量中的字符
|
||||
* @param str
|
||||
* @param variable
|
||||
* @param changname
|
||||
* @return
|
||||
*/
|
||||
public static String changparams(String str, Map<String, String> variable, String changname) {
|
||||
try {
|
||||
if (null == str) {
|
||||
|
@ -61,6 +68,12 @@ public class ChangString {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 统计字符
|
||||
* @param str1
|
||||
* @param str2
|
||||
* @return
|
||||
*/
|
||||
public static int counter(String str1, String str2) {
|
||||
int total = 0;
|
||||
for (String tmp = str1; tmp != null && tmp.length() >= str2.length(); ) {
|
||||
|
@ -74,6 +87,11 @@ public class ChangString {
|
|||
return total;
|
||||
}
|
||||
|
||||
/**
|
||||
* 判断是否是数字
|
||||
* @param str
|
||||
* @return
|
||||
*/
|
||||
public static boolean isNumeric(String str) {
|
||||
for (int i = 0; i < str.length(); i++) {
|
||||
if (!Character.isDigit(str.charAt(i))) {
|
||||
|
@ -83,6 +101,11 @@ public class ChangString {
|
|||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* 判断是否是整数
|
||||
* @param str
|
||||
* @return
|
||||
*/
|
||||
public static boolean isInteger(String str) {
|
||||
Pattern pattern = Pattern.compile("^[-\\+]?[\\d]*$");
|
||||
return pattern.matcher(str).matches();
|
||||
|
|
|
@ -3,6 +3,7 @@ package luckyclient.publicclass.remoterinterface;
|
|||
import java.io.BufferedReader;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStreamReader;
|
||||
import java.io.OutputStreamWriter;
|
||||
import java.io.PrintWriter;
|
||||
import java.net.URL;
|
||||
import java.net.URLConnection;
|
||||
|
@ -36,6 +37,7 @@ public class HttpRequest {
|
|||
* @return
|
||||
*/
|
||||
public static String loadJSON(String repath) {
|
||||
String charset="GBK";
|
||||
StringBuffer resultBuffer = null;
|
||||
CloseableHttpClient httpclient = HttpClients.createDefault();
|
||||
BufferedReader br = null;
|
||||
|
@ -44,7 +46,7 @@ public class HttpRequest {
|
|||
try {
|
||||
HttpResponse response = httpclient.execute(httpGet);
|
||||
// 读取服务器响应数据
|
||||
br = new BufferedReader(new InputStreamReader(response.getEntity().getContent(), "GBK"));
|
||||
br = new BufferedReader(new InputStreamReader(response.getEntity().getContent(), charset));
|
||||
String temp;
|
||||
resultBuffer = new StringBuffer();
|
||||
while ((temp = br.readLine()) != null) {
|
||||
|
@ -92,15 +94,14 @@ public class HttpRequest {
|
|||
// 发送POST请求必须设置如下两行
|
||||
conn.setDoOutput(true);
|
||||
conn.setDoInput(true);
|
||||
// 获取URLConnection对象对应的输出流
|
||||
out = new PrintWriter(conn.getOutputStream());
|
||||
// 获取URLConnection对象对应的输出流,设置utf-8编码
|
||||
out = new PrintWriter(new OutputStreamWriter(conn.getOutputStream(), "GBK"));
|
||||
// 发送请求参数
|
||||
out.print(param);
|
||||
// flush输出流的缓冲
|
||||
out.flush();
|
||||
// 定义BufferedReader输入流来读取URL的响应
|
||||
in = new BufferedReader(
|
||||
new InputStreamReader(conn.getInputStream()));
|
||||
// 定义BufferedReader输入流来读取URL的响应,设置utf-8编码
|
||||
in = new BufferedReader(new InputStreamReader(conn.getInputStream(), "GBK"));
|
||||
String line;
|
||||
while ((line = in.readLine()) != null) {
|
||||
result += line;
|
||||
|
|
|
@ -1,90 +0,0 @@
|
|||
package luckyclient.publicclass.remoterinterface;
|
||||
|
||||
/**
|
||||
* =================================================================
|
||||
* 这是一个受限制的自由软件!您不能在任何未经允许的前提下对程序代码进行修改和用于商业用途;也不允许对程序代码修改后以任何形式任何目的的再发布。
|
||||
* 为了尊重作者的劳动成果,LuckyFrame关键版权信息严禁篡改
|
||||
* 有任何疑问欢迎联系作者讨论。 QQ:1573584944 seagull1985
|
||||
* =================================================================
|
||||
*
|
||||
* @author: seagull
|
||||
* @date 2017年12月1日 上午9:29:40
|
||||
*
|
||||
*/
|
||||
public class InterfaceObject {
|
||||
/**
|
||||
* 接口类
|
||||
*/
|
||||
String interfaceClass;
|
||||
/**
|
||||
* 接口方法
|
||||
*/
|
||||
String interfaceMethod;
|
||||
/**
|
||||
* 远程调用地址
|
||||
*/
|
||||
String remoteUrl;
|
||||
/**
|
||||
* 接口参数类型和值的json串,数组结构,有多个按顺序传
|
||||
*/
|
||||
String params;
|
||||
/**
|
||||
* 接口rpc协议类型
|
||||
*/
|
||||
String testProtocolType;
|
||||
|
||||
public String getInterfaceClass() {
|
||||
return interfaceClass;
|
||||
}
|
||||
|
||||
public void setInterfaceClass(String interfaceClass) {
|
||||
this.interfaceClass = interfaceClass;
|
||||
}
|
||||
|
||||
public String getInterfaceMethod() {
|
||||
return interfaceMethod;
|
||||
}
|
||||
|
||||
public void setInterfaceMethod(String interfaceMethod) {
|
||||
this.interfaceMethod = interfaceMethod;
|
||||
}
|
||||
|
||||
public String getRemoteUrl() {
|
||||
return remoteUrl;
|
||||
}
|
||||
|
||||
public void setRemoteUrl(String remoteUrl) {
|
||||
this.remoteUrl = remoteUrl;
|
||||
}
|
||||
|
||||
public String getParams() {
|
||||
return params;
|
||||
}
|
||||
|
||||
public void setParams(String params) {
|
||||
this.params = params;
|
||||
}
|
||||
|
||||
public String getTestProtocolType() {
|
||||
return testProtocolType;
|
||||
}
|
||||
|
||||
public void setTestProtocolType(String testProtocolType) {
|
||||
this.testProtocolType = testProtocolType;
|
||||
}
|
||||
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see java.lang.Object#toString()
|
||||
*/
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "InterfaceObject [interfaceClass=" + interfaceClass
|
||||
+ ", interfaceMethod=" + interfaceMethod + ", remoteUrl="
|
||||
+ remoteUrl + ", params=" + params + ", testProtocolType="
|
||||
+ testProtocolType + "]";
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -1,52 +0,0 @@
|
|||
package luckyclient.publicclass.remoterinterface;
|
||||
|
||||
/**
|
||||
* =================================================================
|
||||
* 这是一个受限制的自由软件!您不能在任何未经允许的前提下对程序代码进行修改和用于商业用途;也不允许对程序代码修改后以任何形式任何目的的再发布。
|
||||
* 为了尊重作者的劳动成果,LuckyFrame关键版权信息严禁篡改
|
||||
* 有任何疑问欢迎联系作者讨论。 QQ:1573584944 seagull1985
|
||||
* =================================================================
|
||||
*
|
||||
* @author: seagull
|
||||
* @date 2017年12月1日 上午9:29:40
|
||||
*
|
||||
*/
|
||||
public class InterfaceParamObject {
|
||||
/**
|
||||
* 参数类
|
||||
*/
|
||||
String classname;
|
||||
/**
|
||||
* 参数json value
|
||||
*/
|
||||
String value;
|
||||
|
||||
public String getClassname() {
|
||||
return classname;
|
||||
}
|
||||
|
||||
public void setClassname(String classname) {
|
||||
this.classname = classname;
|
||||
}
|
||||
|
||||
public String getValue() {
|
||||
return value;
|
||||
}
|
||||
|
||||
public void setValue(String value) {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see java.lang.Object#toString()
|
||||
*/
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "InterfaceParamObject [classname=" + classname + ", value="
|
||||
+ value + "]";
|
||||
}
|
||||
|
||||
}
|
|
@ -1,220 +0,0 @@
|
|||
package luckyclient.publicclass.remoterinterface;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||
import com.fasterxml.jackson.databind.DeserializationFeature;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
|
||||
/**
|
||||
* =================================================================
|
||||
* 这是一个受限制的自由软件!您不能在任何未经允许的前提下对程序代码进行修改和用于商业用途;也不允许对程序代码修改后以任何形式任何目的的再发布。
|
||||
* 为了尊重作者的劳动成果,LuckyFrame关键版权信息严禁篡改
|
||||
* 有任何疑问欢迎联系作者讨论。 QQ:1573584944 seagull1985
|
||||
* =================================================================
|
||||
*
|
||||
* @author: seagull
|
||||
* @date 2017年12月1日 上午9:29:40
|
||||
*
|
||||
*/
|
||||
public class InterfaceTestUtil {
|
||||
private static Logger log = LoggerFactory
|
||||
.getLogger(InterfaceTestUtil.class);
|
||||
private static final ObjectMapper MAP = new ObjectMapper();
|
||||
private static final int READ_TIME_OUT = 30 * 1000;
|
||||
private static final Map<String, Class<?>> BASE_TYPE = new HashMap<String, Class<?>>();
|
||||
static {
|
||||
BASE_TYPE.put("long", long.class);
|
||||
BASE_TYPE.put("double", double.class);
|
||||
BASE_TYPE.put("float", float.class);
|
||||
BASE_TYPE.put("bool", boolean.class);
|
||||
BASE_TYPE.put("char", char.class);
|
||||
BASE_TYPE.put("byte", byte.class);
|
||||
BASE_TYPE.put("void", void.class);
|
||||
BASE_TYPE.put("short", short.class);
|
||||
}
|
||||
|
||||
/* public static Map<String, Object> doTest(InterfaceObject object)
|
||||
throws Exception {
|
||||
// 获取带请求参数列表将(参数类型,参数值)数组转成InterfaceParamObject数组
|
||||
InterfaceParamObject[] paramContent = MAP.readValue(object.getParams(),
|
||||
InterfaceParamObject[].class);
|
||||
Object result = hessian(object.getRemoteUrl(),
|
||||
object.getInterfaceClass(), object.getInterfaceMethod(),
|
||||
paramContent);
|
||||
|
||||
if (result != null) {
|
||||
log.info("返回结果对象是{},返回原始结果是{}", result.getClass(),
|
||||
result.toString());
|
||||
return objectToMap(result);
|
||||
}
|
||||
log.info("返回结果对象是null");
|
||||
return null;
|
||||
|
||||
}
|
||||
|
||||
public static Map<String, Object> objectToMap(Object obj) throws Exception {
|
||||
Map<String, Object> map = new HashMap<String, Object>(0);
|
||||
String objClass = obj.getClass().getName();
|
||||
if (isBaseTypeForArray(objClass)) {
|
||||
map.put(objClass, obj.toString());
|
||||
} else {
|
||||
// Field[] allField = obj.getClass().getDeclaredFields();
|
||||
Field[] allField = getAllFields(obj);
|
||||
for (Field field : allField) {
|
||||
field.setAccessible(true);
|
||||
map.put(field.getName(), field.get(obj));
|
||||
}
|
||||
|
||||
}
|
||||
for (Object key : map.keySet()) {
|
||||
System.out.println("KEY:" + key + ", VALUE:" + map.get(key));
|
||||
}
|
||||
return map;
|
||||
}
|
||||
|
||||
private static Field[] getAllFields(Object object) {
|
||||
Class<?> clazz = object.getClass();
|
||||
List<Field> fieldList = new ArrayList<>();
|
||||
while (clazz != null) {
|
||||
fieldList.addAll(
|
||||
new ArrayList<>(Arrays.asList(clazz.getDeclaredFields())));
|
||||
clazz = clazz.getSuperclass();
|
||||
}
|
||||
Field[] fields = new Field[fieldList.size()];
|
||||
fieldList.toArray(fields);
|
||||
return fields;
|
||||
}
|
||||
|
||||
private static boolean isBaseTypeForArray(String objClassName) {
|
||||
|
||||
boolean isBase = false;
|
||||
if (objClassName != null) {
|
||||
isBase = BASE_TYPE.get(objClassName) != null ? true : false;
|
||||
}
|
||||
return isBase;
|
||||
}
|
||||
|
||||
public static String genJsonStr(Object object)
|
||||
throws JsonProcessingException {
|
||||
return MAP.writeValueAsString(object);
|
||||
}
|
||||
|
||||
private static Object hessian(String remoteUrl, String className,
|
||||
String methodName, InterfaceParamObject[] paramContent)
|
||||
throws Exception {
|
||||
HessianProxyFactory factory = new HessianProxyFactory();
|
||||
factory.setReadTimeout(READ_TIME_OUT);
|
||||
Object interfaceObj = null;
|
||||
Class<?> interfaceClassName = null;
|
||||
|
||||
try {
|
||||
interfaceClassName = Class.forName(className);
|
||||
interfaceObj = factory.create(interfaceClassName, remoteUrl);
|
||||
log.info("调用MyHessianProxyFactory返回的hessian代理对象为:{}",
|
||||
interfaceObj.getClass());
|
||||
} catch (Exception ex) {
|
||||
log.info("程序在反射获取接口的hesian代理对象时出现问题。异常信息:{}", ex.getMessage());
|
||||
}
|
||||
Object[] allRequstParas = new Object[paramContent.length];
|
||||
for (int i = 0; i < paramContent.length; i++) {
|
||||
InterfaceParamObject paramObject = paramContent[i];
|
||||
Class<?> paramClass = null;
|
||||
|
||||
try {
|
||||
String paramClassName = paramObject.getClassname();
|
||||
|
||||
paramClass = getBaseTypeClassByName(paramClassName);
|
||||
if (paramClass == null) {
|
||||
paramClass = Class.forName(paramObject.getClassname());
|
||||
}
|
||||
} catch (Exception ex) {
|
||||
log.info("程序在反射获取接口的参数类类型时出现问题。异常信息{}", ex.getMessage());
|
||||
}
|
||||
ObjectMapper objectMapper = new ObjectMapper();
|
||||
objectMapper.configure(
|
||||
DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
|
||||
Object requestParamObject = null;
|
||||
if (paramObject.getValue() != null
|
||||
&& paramObject.getValue().trim().length() > 0) {
|
||||
try {
|
||||
|
||||
requestParamObject = objectMapper
|
||||
.readValue(paramObject.getValue(), paramClass);
|
||||
} catch (Exception ex) {
|
||||
log.info("根据Json字符串参数转成类%s对象时发生异常,对象预期值为%s",
|
||||
requestParamObject.getClass(),
|
||||
paramObject.getValue());
|
||||
}
|
||||
} else {
|
||||
requestParamObject = paramClass.getInterfaces();
|
||||
}
|
||||
allRequstParas[i] = requestParamObject;
|
||||
}
|
||||
|
||||
if (interfaceObj != null && allRequstParas.length > 0) {
|
||||
return getMethod(methodName, interfaceObj, allRequstParas);
|
||||
}
|
||||
log.info("没有请求参数,返回空对象");
|
||||
return null;
|
||||
}
|
||||
|
||||
private static Object getMethod(String methodName, Object o,
|
||||
Object[] allRequstParas) {
|
||||
int totalRequestParam = allRequstParas.length;
|
||||
|
||||
Class<?>[] allRequstParasClass = null;
|
||||
// 存在
|
||||
if (allRequstParas != null) {
|
||||
int len = allRequstParas.length;
|
||||
allRequstParasClass = new Class[len];
|
||||
for (int i = 0; i < len; ++i) {
|
||||
allRequstParasClass[i] = allRequstParas[i].getClass();
|
||||
}
|
||||
}
|
||||
Object result = new Object[totalRequestParam];
|
||||
Method method = null;
|
||||
try {
|
||||
// 根据方法名以及方法参数列表获取方法对象
|
||||
method = o.getClass().getDeclaredMethod(methodName,
|
||||
allRequstParasClass);
|
||||
} catch (NoSuchMethodException ex) {
|
||||
log.error(String.format("获取方法对象发生找不到方法,方法的类为%s,异常信息:%s",
|
||||
o.getClass(), ex.getMessage()));
|
||||
} catch (SecurityException ex) {
|
||||
log.error(String.format("获取方法对象发生发生安全异常,方法的类为%s,异常信息:%s",
|
||||
o.getClass(), ex.getMessage()));
|
||||
}
|
||||
try {
|
||||
result = method.invoke(o, allRequstParas);
|
||||
} catch (Exception ex) {
|
||||
log.error(String.format("调用方法对象执行调用发生异常,方法的类为%s,异常信息:%s",
|
||||
o.getClass(), ex.getMessage()));
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
*//**
|
||||
* 1、转换基本数据类型为包装类型<br>
|
||||
* 2、…<br>
|
||||
*
|
||||
* @param className
|
||||
* @return
|
||||
* @see
|
||||
*//*
|
||||
private static Class<?> getBaseTypeClassByName(String className) {
|
||||
return BASE_TYPE.get(className);
|
||||
}
|
||||
|
||||
private static Boolean isBaseType(String className) {
|
||||
Boolean istrue = false;
|
||||
for (String key : BASE_TYPE.keySet()) {
|
||||
istrue = className.equals(key) ? true : false;
|
||||
}
|
||||
return istrue;
|
||||
}*/
|
||||
}
|
|
@ -19,7 +19,7 @@ import luckyclient.dblog.LogOperation;
|
|||
* @Description: 解析单个用例中描述部分的脚本
|
||||
* @author: seagull
|
||||
* @date 2014年6月24日 上午9:29:40
|
||||
*
|
||||
* @deprecated
|
||||
*/
|
||||
public class InterfaceAnalyticTestLinkCase{
|
||||
private static String splitFlag = "\\|";
|
||||
|
|
|
@ -18,7 +18,7 @@ import luckyclient.dblog.LogOperation;
|
|||
* @Description: 二次封装关于测试版本部分的API
|
||||
* @author: seagull
|
||||
* @date 2014年6月24日 上午9:29:40
|
||||
*
|
||||
* @deprecated
|
||||
*/
|
||||
public class TestBuildApi extends TestLinkBaseApi {
|
||||
/**
|
||||
|
|
|
@ -29,7 +29,7 @@ import luckyclient.publicclass.remoterinterface.HttpRequest;
|
|||
* @Description: 二次封装关于测试用例部分的API
|
||||
* @author: seagull
|
||||
* @date 2014年6月24日 上午9:29:40
|
||||
*
|
||||
* @deprecated
|
||||
*/
|
||||
public class TestCaseApi extends TestLinkBaseApi {
|
||||
|
||||
|
|
|
@ -16,7 +16,7 @@ import br.eti.kinoshita.testlinkjavaapi.TestLinkAPI;
|
|||
* @Description: 初始化TESTLINK接口
|
||||
* @author: seagull
|
||||
* @date 2014年6月24日 上午9:29:40
|
||||
*
|
||||
* @deprecated
|
||||
*/
|
||||
class TestLinkBaseApi{
|
||||
|
||||
|
|
|
@ -19,7 +19,7 @@ import luckyclient.dblog.LogOperation;
|
|||
* @Description: 解析单个用例中描述部分的脚本
|
||||
* @author: seagull
|
||||
* @date 2016年9月18日
|
||||
*
|
||||
* @deprecated
|
||||
*/
|
||||
public class WebDriverAnalyticTestLinkCase {
|
||||
private static String splitFlag = "\\|";
|
||||
|
|
|
@ -38,6 +38,7 @@ import com.alibaba.fastjson.JSONObject;
|
|||
@RestController
|
||||
public class HttpImpl {
|
||||
|
||||
private static final String os=System.getProperty("os.name").toLowerCase();
|
||||
/**
|
||||
* 运行自动化任务
|
||||
* @param req
|
||||
|
@ -61,20 +62,24 @@ public class HttpImpl {
|
|||
String projectname = jsonObject.getString("projectname");
|
||||
String taskid = jsonObject.getString("taskid");
|
||||
String loadpath = jsonObject.getString("loadpath");
|
||||
System.out.println("启动任务模式测试程序...测试项目:"+projectname+" 任务ID:"+taskid);
|
||||
luckyclient.publicclass.LogUtil.APP.info("启动任务模式测试程序...测试项目:"+projectname+" 任务ID:"+taskid);
|
||||
try{
|
||||
File file =new File(System.getProperty("user.dir")+loadpath);
|
||||
if (!file .isDirectory())
|
||||
{
|
||||
System.out.println("客户端测试驱动桩路径不存在,请检查【"+file.getPath()+"】");
|
||||
luckyclient.publicclass.LogUtil.APP.info("客户端测试驱动桩路径不存在,请检查【"+file.getPath()+"】");
|
||||
return "客户端测试驱动桩路径不存在,请检查【"+file.getPath()+"】";
|
||||
}
|
||||
Runtime run = Runtime.getRuntime();
|
||||
StringBuffer sbf=new StringBuffer();
|
||||
sbf.append(taskid).append(" ");
|
||||
sbf.append(loadpath);
|
||||
run.exec("cmd.exe /k start " + "task.cmd" +" "+ sbf.toString(), null,new File(System.getProperty("user.dir")+"\\"));
|
||||
|
||||
if(os.startsWith("win")){
|
||||
run.exec("cmd.exe /k start " + "task.cmd" +" "+ sbf.toString(), null,new File(System.getProperty("user.dir")+File.separator));
|
||||
}else{
|
||||
Process ps = Runtime.getRuntime().exec(System.getProperty("user.dir")+File.separator+"task.sh"+ " " +sbf.toString());
|
||||
ps.waitFor();
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
return "启动任务模式测试程序异常!!!";
|
||||
|
@ -107,13 +112,13 @@ public class HttpImpl {
|
|||
String loadpath = jsonObject.getString("loadpath");
|
||||
String testCaseExternalId = jsonObject.getString("testCaseExternalId");
|
||||
String version = jsonObject.getString("version");
|
||||
System.out.println("启动单用例模式测试程序...测试项目:"+projectname+" 任务ID:"+taskid);
|
||||
System.out.println("测试用例编号:"+testCaseExternalId+" 用例版本:"+version);
|
||||
luckyclient.publicclass.LogUtil.APP.info("启动单用例模式测试程序...测试项目:"+projectname+" 任务ID:"+taskid);
|
||||
luckyclient.publicclass.LogUtil.APP.info("测试用例编号:"+testCaseExternalId+" 用例版本:"+version);
|
||||
try{
|
||||
File file =new File(System.getProperty("user.dir")+loadpath);
|
||||
if (!file .isDirectory())
|
||||
{
|
||||
System.out.println("客户端测试驱动桩路径不存在,请检查【"+file.getPath()+"】");
|
||||
luckyclient.publicclass.LogUtil.APP.info("客户端测试驱动桩路径不存在,请检查【"+file.getPath()+"】");
|
||||
return "客户端测试驱动桩路径不存在,请检查【"+file.getPath()+"】";
|
||||
}
|
||||
Runtime run = Runtime.getRuntime();
|
||||
|
@ -122,7 +127,12 @@ public class HttpImpl {
|
|||
sb.append(testCaseExternalId).append(" ");
|
||||
sb.append(version).append(" ");
|
||||
sb.append(loadpath);
|
||||
run.exec("cmd.exe /k start " + "task_onecase.cmd" + " " +sb.toString(), null,new File(System.getProperty("user.dir")+"\\"));
|
||||
if(os.startsWith("win")){
|
||||
run.exec("cmd.exe /k start " + "task_onecase.cmd" + " " +sb.toString(), null,new File(System.getProperty("user.dir")+File.separator));
|
||||
}else{
|
||||
Process ps = Runtime.getRuntime().exec(System.getProperty("user.dir")+File.separator+"task_onecase.sh"+ " " +sb.toString());
|
||||
ps.waitFor();
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
return "启动单用例模式测试程序异常!!!";
|
||||
|
@ -153,13 +163,13 @@ public class HttpImpl {
|
|||
String taskid = jsonObject.getString("taskid");
|
||||
String loadpath = jsonObject.getString("loadpath");
|
||||
String batchcase = jsonObject.getString("batchcase");
|
||||
System.out.println("启动批量用例模式测试程序...测试项目:"+projectname+" 任务ID:"+taskid);
|
||||
System.out.println("批量测试用例:"+batchcase);
|
||||
luckyclient.publicclass.LogUtil.APP.info("启动批量用例模式测试程序...测试项目:"+projectname+" 任务ID:"+taskid);
|
||||
luckyclient.publicclass.LogUtil.APP.info("批量测试用例:"+batchcase);
|
||||
try{
|
||||
File file =new File(System.getProperty("user.dir")+loadpath);
|
||||
if (!file .isDirectory())
|
||||
{
|
||||
System.out.println("客户端测试驱动桩路径不存在,请检查【"+file.getPath()+"】");
|
||||
luckyclient.publicclass.LogUtil.APP.info("客户端测试驱动桩路径不存在,请检查【"+file.getPath()+"】");
|
||||
return "客户端测试驱动桩路径不存在,请检查【"+file.getPath()+"】";
|
||||
}
|
||||
Runtime run = Runtime.getRuntime();
|
||||
|
@ -167,8 +177,12 @@ public class HttpImpl {
|
|||
sb.append(taskid).append(" ");
|
||||
sb.append(batchcase).append(" ");
|
||||
sb.append(loadpath);
|
||||
System.out.println(sb.toString());
|
||||
run.exec("cmd.exe /k start " + "task_batch.cmd" + " " +sb.toString(), null,new File(System.getProperty("user.dir")+"\\"));
|
||||
if(os.startsWith("win")){
|
||||
run.exec("cmd.exe /k start " + "task_batch.cmd" + " " +sb.toString(), null,new File(System.getProperty("user.dir")+File.separator));
|
||||
}else{
|
||||
Process ps = Runtime.getRuntime().exec(System.getProperty("user.dir")+File.separator+"task_batch.sh"+ " " +sb.toString());
|
||||
ps.waitFor();
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
return "启动批量用例模式测试程序异常!!!";
|
||||
|
@ -198,12 +212,12 @@ public class HttpImpl {
|
|||
String sign = jsonObject.getString("sign");
|
||||
String executor = jsonObject.getString("executor");
|
||||
String loadpath = jsonObject.getString("loadpath");
|
||||
System.out.println("Web端调试用例:"+sign+" 发起人:"+executor);
|
||||
luckyclient.publicclass.LogUtil.APP.info("Web端调试用例:"+sign+" 发起人:"+executor);
|
||||
try{
|
||||
File file =new File(System.getProperty("user.dir")+loadpath);
|
||||
if (!file .isDirectory())
|
||||
{
|
||||
System.out.println("客户端测试驱动桩路径不存在,请检查【"+file.getPath()+"】");
|
||||
luckyclient.publicclass.LogUtil.APP.info("客户端测试驱动桩路径不存在,请检查【"+file.getPath()+"】");
|
||||
return "客户端测试驱动桩路径不存在,请检查【"+file.getPath()+"】";
|
||||
}
|
||||
Runtime run = Runtime.getRuntime();
|
||||
|
@ -211,7 +225,12 @@ public class HttpImpl {
|
|||
sb.append(sign).append(" ");
|
||||
sb.append(executor).append(" ");
|
||||
sb.append(loadpath);
|
||||
run.exec("cmd.exe /k start " + "web_debugcase.cmd" + " " +sb.toString(), null,new File(System.getProperty("user.dir")+"\\"));
|
||||
if(os.startsWith("win")){
|
||||
run.exec("cmd.exe /k start " + "web_debugcase.cmd" + " " +sb.toString(), null,new File(System.getProperty("user.dir")+File.separator));
|
||||
}else{
|
||||
Process ps = Runtime.getRuntime().exec(System.getProperty("user.dir")+File.separator+"web_debugcase.sh"+ " " +sb.toString());
|
||||
ps.waitFor();
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
return "启动Web调试模式测试程序异常!!!";
|
||||
|
@ -228,8 +247,8 @@ public class HttpImpl {
|
|||
@GetMapping("/getlogdetail")
|
||||
public String getlogdetail(HttpServletRequest req) throws RemoteException{
|
||||
String fileName=req.getParameter("filename");
|
||||
String ctxPath = System.getProperty("user.dir")+"\\log\\";
|
||||
String downLoadPath = ctxPath + fileName;
|
||||
String ctxPath = System.getProperty("user.dir")+File.separator+"log";
|
||||
String downLoadPath = ctxPath +File.separator+ fileName;
|
||||
|
||||
String str = "";
|
||||
InputStreamReader isr=null;
|
||||
|
@ -251,7 +270,7 @@ public class HttpImpl {
|
|||
sb.append(str).append("##n##");
|
||||
}
|
||||
bos.close();
|
||||
System.out.println("服务端读取本地日志成功!");
|
||||
luckyclient.publicclass.LogUtil.APP.info("服务端读取本地日志成功!");
|
||||
} catch (IOException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
|
@ -269,8 +288,8 @@ public class HttpImpl {
|
|||
@GetMapping("/getlogimg")
|
||||
public byte[] getlogimg(HttpServletRequest req,HttpServletResponse res) throws RemoteException{
|
||||
String imgName=req.getParameter("imgName");
|
||||
String ctxPath = System.getProperty("user.dir")+"\\log\\ScreenShot\\";
|
||||
String downLoadPath = ctxPath+imgName;
|
||||
String ctxPath = System.getProperty("user.dir")+File.separator+"log"+File.separator+"ScreenShot";
|
||||
String downLoadPath = ctxPath+File.separator+imgName;
|
||||
byte[] b = null;
|
||||
try {
|
||||
File file = new File(downLoadPath);
|
||||
|
@ -278,7 +297,7 @@ public class HttpImpl {
|
|||
BufferedInputStream is = new BufferedInputStream(new FileInputStream(file));
|
||||
is.read(b);
|
||||
is.close();
|
||||
System.out.println("服务端获取本地图片:"+downLoadPath);
|
||||
luckyclient.publicclass.LogUtil.APP.info("服务端获取本地图片:"+downLoadPath);
|
||||
} catch (FileNotFoundException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
|
@ -307,10 +326,11 @@ public class HttpImpl {
|
|||
String path = System.getProperty("user.dir")+loadpath;
|
||||
if (!new File(path) .isDirectory())
|
||||
{
|
||||
System.out.println("客户端测试驱动桩路径不存在,请检查【"+path+"】");
|
||||
luckyclient.publicclass.LogUtil.APP.info("客户端测试驱动桩路径不存在,请检查【"+path+"】");
|
||||
return "客户端测试驱动桩路径不存在,请检查【"+path+"】";
|
||||
}
|
||||
String pathName = path +"\\"+ name;
|
||||
String pathName = path +File.separator+ name;
|
||||
|
||||
File file = new File(pathName);
|
||||
try {
|
||||
if (file.exists()){
|
||||
|
@ -322,16 +342,16 @@ public class HttpImpl {
|
|||
os.write(jarfileByte);
|
||||
os.flush();
|
||||
os.close();
|
||||
System.out.println("上传JAR包【"+name+"】到客户端驱动目录【"+path+"】成功!");
|
||||
return "上传JAR包【"+name+"】到客户端驱动目录【"+path+"】成功!";
|
||||
luckyclient.publicclass.LogUtil.APP.info("上传JAR包【"+name+"】到客户端驱动目录【"+file.getAbsolutePath()+"】成功!");
|
||||
return "上传JAR包【"+name+"】到客户端驱动目录【"+file.getAbsolutePath()+"】成功!";
|
||||
} catch (FileNotFoundException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
return "客户端未找到正确路径或文件,上传失败!";
|
||||
return "客户端未找到正确路径或文件,上传失败!文件路径名称:"+pathName;
|
||||
} catch (IOException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
return "客户端IOException";
|
||||
return "客户端IOExceptiona或是未找到驱动路径!文件路径名称:"+pathName;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
package springboot;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
import org.apache.log4j.PropertyConfigurator;
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
|
@ -18,7 +20,8 @@ public class RunService {
|
|||
|
||||
public static void main(String[] args) {
|
||||
// TODO Auto-generated method stub
|
||||
PropertyConfigurator.configure(System.getProperty("user.dir") + "\\log4j.conf");
|
||||
PropertyConfigurator.configure(System.getProperty("user.dir") + File.separator +"bootlog4j.conf");
|
||||
luckyclient.publicclass.LogUtil.APP.info("启动客户端监听>>>>>>>>>>>>>>>>>>>>>");
|
||||
SpringApplication.run(RunService.class, args);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue