增加数据库驱动方法
This commit is contained in:
parent
33ec5c0501
commit
f2797a2399
9
pom.xml
9
pom.xml
|
@ -251,9 +251,7 @@
|
|||
<artifactId>selenium-remote-driver</artifactId>
|
||||
</dependency>
|
||||
<!-- 暂不需求,怀疑是以前testlink API需要的 -->
|
||||
<!-- <dependency>
|
||||
<groupId>xml-apis</groupId>
|
||||
<artifactId>xml-apis</artifactId>
|
||||
<!-- <dependency> <groupId>xml-apis</groupId> <artifactId>xml-apis</artifactId>
|
||||
</dependency> -->
|
||||
<dependency>
|
||||
<groupId>io.appium</groupId>
|
||||
|
@ -311,5 +309,10 @@
|
|||
<artifactId>hutool-all</artifactId>
|
||||
<version>5.0.6</version>
|
||||
</dependency>
|
||||
<!-- mysql链接 用到数据库测试驱动的时候才需要 -->
|
||||
<dependency>
|
||||
<groupId>mysql</groupId>
|
||||
<artifactId>mysql-connector-java</artifactId>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>
|
||||
|
|
|
@ -0,0 +1,10 @@
|
|||
#===============================数据库驱动配置文件=====================================
|
||||
#当你需要用到内置的数据库测试驱动,才需要用到此配置文件
|
||||
#数据库驱动类,默认mysql
|
||||
db.ComboPooledDataSource.DriverClass=com.mysql.cj.jdbc.Driver
|
||||
#数据库URL,包括数据库名称
|
||||
db.url=jdbc:mysql://localhost:3306/luckyframe?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8
|
||||
#数据库用户名
|
||||
db.username=root
|
||||
#数据库密码
|
||||
db.password=
|
|
@ -0,0 +1,37 @@
|
|||
package luckyclient.driven;
|
||||
|
||||
import java.util.Properties;
|
||||
|
||||
import luckyclient.utils.DbOperation;
|
||||
import luckyclient.utils.config.DrivenConfig;
|
||||
|
||||
/**
|
||||
* 提供数据库查询操作的默认测试驱动
|
||||
* =================================================================
|
||||
* 这是一个受限制的自由软件!您不能在任何未经允许的前提下对程序代码进行修改和用于商业用途;也不允许对程序代码修改后以任何形式任何目的的再发布。
|
||||
* 为了尊重作者的劳动成果,LuckyFrame关键版权信息严禁篡改 有任何疑问欢迎联系作者讨论。 QQ:1573584944 Seagull
|
||||
* =================================================================
|
||||
* @author Seagull
|
||||
* @date 2020年2月17日
|
||||
*/
|
||||
public class DbDriven {
|
||||
|
||||
public String executeSql(String sql) throws Exception{
|
||||
Properties properties = DrivenConfig.getConfiguration();
|
||||
String url = properties.getProperty("db.url");
|
||||
String username = properties.getProperty("db.username");
|
||||
String password = properties.getProperty("db.password");
|
||||
DbOperation db=new DbOperation(url,username,password);
|
||||
return db.executeQuery(sql);
|
||||
}
|
||||
|
||||
public String executeQuery(String sql) throws Exception{
|
||||
Properties properties = DrivenConfig.getConfiguration();
|
||||
String url = properties.getProperty("db.url");
|
||||
String username = properties.getProperty("db.username");
|
||||
String password = properties.getProperty("db.password");
|
||||
DbOperation db=new DbOperation(url,username,password);
|
||||
return db.executeQuery(sql);
|
||||
}
|
||||
|
||||
}
|
|
@ -13,8 +13,8 @@ import luckyclient.execution.webdriver.ex.WebBatchExecute;
|
|||
import luckyclient.remote.api.GetServerApi;
|
||||
import luckyclient.remote.entity.TaskExecute;
|
||||
import luckyclient.remote.entity.TaskScheduling;
|
||||
import luckyclient.utils.AppiumConfig;
|
||||
import luckyclient.utils.LogUtil;
|
||||
import luckyclient.utils.config.AppiumConfig;
|
||||
|
||||
/**
|
||||
* =================================================================
|
||||
|
|
|
@ -13,8 +13,8 @@ import luckyclient.execution.webdriver.ex.WebOneCaseExecute;
|
|||
import luckyclient.remote.api.GetServerApi;
|
||||
import luckyclient.remote.entity.TaskExecute;
|
||||
import luckyclient.remote.entity.TaskScheduling;
|
||||
import luckyclient.utils.AppiumConfig;
|
||||
import luckyclient.utils.LogUtil;
|
||||
import luckyclient.utils.config.AppiumConfig;
|
||||
|
||||
/**
|
||||
* =================================================================
|
||||
|
|
|
@ -25,8 +25,8 @@ import luckyclient.tool.jenkins.BuildingInitialization;
|
|||
import luckyclient.tool.mail.HtmlMail;
|
||||
import luckyclient.tool.mail.MailSendInitialization;
|
||||
import luckyclient.tool.shell.RestartServerInitialization;
|
||||
import luckyclient.utils.AppiumConfig;
|
||||
import luckyclient.utils.LogUtil;
|
||||
import luckyclient.utils.config.AppiumConfig;
|
||||
|
||||
/**
|
||||
* =================================================================
|
||||
|
|
|
@ -6,8 +6,8 @@ import java.util.Properties;
|
|||
import io.appium.java_client.service.local.AppiumDriverLocalService;
|
||||
import io.appium.java_client.service.local.AppiumServiceBuilder;
|
||||
import io.appium.java_client.service.local.flags.GeneralServerFlag;
|
||||
import luckyclient.utils.AppiumConfig;
|
||||
import luckyclient.utils.LogUtil;
|
||||
import luckyclient.utils.config.AppiumConfig;
|
||||
|
||||
/**
|
||||
*
|
||||
|
|
|
@ -16,8 +16,8 @@ import luckyclient.remote.entity.ProjectCase;
|
|||
import luckyclient.remote.entity.ProjectCaseParams;
|
||||
import luckyclient.remote.entity.ProjectCaseSteps;
|
||||
import luckyclient.remote.entity.TaskExecute;
|
||||
import luckyclient.utils.AppiumConfig;
|
||||
import luckyclient.utils.LogUtil;
|
||||
import luckyclient.utils.config.AppiumConfig;
|
||||
|
||||
/**
|
||||
* =================================================================
|
||||
|
|
|
@ -14,8 +14,8 @@ import luckyclient.remote.api.serverOperation;
|
|||
import luckyclient.remote.entity.ProjectCase;
|
||||
import luckyclient.remote.entity.ProjectCaseParams;
|
||||
import luckyclient.remote.entity.ProjectCaseSteps;
|
||||
import luckyclient.utils.AppiumConfig;
|
||||
import luckyclient.utils.LogUtil;
|
||||
import luckyclient.utils.config.AppiumConfig;
|
||||
|
||||
/**
|
||||
* =================================================================
|
||||
|
|
|
@ -16,8 +16,8 @@ import luckyclient.remote.entity.ProjectCase;
|
|||
import luckyclient.remote.entity.ProjectCaseParams;
|
||||
import luckyclient.remote.entity.ProjectCaseSteps;
|
||||
import luckyclient.remote.entity.TaskExecute;
|
||||
import luckyclient.utils.AppiumConfig;
|
||||
import luckyclient.utils.LogUtil;
|
||||
import luckyclient.utils.config.AppiumConfig;
|
||||
|
||||
/**
|
||||
* =================================================================
|
||||
|
|
|
@ -14,8 +14,8 @@ import luckyclient.remote.api.serverOperation;
|
|||
import luckyclient.remote.entity.ProjectCase;
|
||||
import luckyclient.remote.entity.ProjectCaseParams;
|
||||
import luckyclient.remote.entity.ProjectCaseSteps;
|
||||
import luckyclient.utils.AppiumConfig;
|
||||
import luckyclient.utils.LogUtil;
|
||||
import luckyclient.utils.config.AppiumConfig;
|
||||
|
||||
/**
|
||||
* =================================================================
|
||||
|
|
|
@ -14,7 +14,7 @@ import org.openqa.selenium.remote.Augmenter;
|
|||
|
||||
import cn.hutool.core.util.BooleanUtil;
|
||||
import luckyclient.utils.LogUtil;
|
||||
import luckyclient.utils.SysConfig;
|
||||
import luckyclient.utils.config.SysConfig;
|
||||
|
||||
/**
|
||||
* =================================================================
|
||||
|
|
|
@ -258,8 +258,8 @@ public class EncapsulateOperation {
|
|||
LogUtil.APP.info("获取到的值是【{}】",we.isEnabled());
|
||||
break;
|
||||
case "isdisplayed":
|
||||
result = "获取到的值是【" + we.isDisplayed() + "】";
|
||||
LogUtil.APP.info("获取到的值是【{}】",we.isDisplayed());
|
||||
result = "获取到的值是【" + String.valueOf(we.isDisplayed()) + "】";
|
||||
LogUtil.APP.info("获取到的值是【{}】",String.valueOf(we.isDisplayed()));
|
||||
break;
|
||||
case "exjsob":
|
||||
JavascriptExecutor jse = (JavascriptExecutor) wd;
|
||||
|
|
|
@ -8,7 +8,7 @@ import com.offbytwo.jenkins.JenkinsServer;
|
|||
import com.offbytwo.jenkins.client.JenkinsHttpClient;
|
||||
|
||||
import luckyclient.utils.LogUtil;
|
||||
import luckyclient.utils.SysConfig;
|
||||
import luckyclient.utils.config.SysConfig;
|
||||
|
||||
/**
|
||||
* JenkinsÁ´½Ó
|
||||
|
|
|
@ -9,7 +9,7 @@ import freemarker.cache.ClassTemplateLoader;
|
|||
import freemarker.template.Configuration;
|
||||
import freemarker.template.Template;
|
||||
import luckyclient.utils.LogUtil;
|
||||
import luckyclient.utils.SysConfig;
|
||||
import luckyclient.utils.config.SysConfig;
|
||||
|
||||
/**
|
||||
* 基于Freemarker模板技术的邮件模板服务
|
||||
|
|
|
@ -6,7 +6,7 @@ import java.util.Properties;
|
|||
|
||||
import luckyclient.remote.entity.ProjectProtocolTemplate;
|
||||
import luckyclient.utils.LogUtil;
|
||||
import luckyclient.utils.SysConfig;
|
||||
import luckyclient.utils.config.SysConfig;
|
||||
import luckyclient.utils.httputils.HttpClientTools;
|
||||
|
||||
/**
|
||||
|
|
|
@ -5,7 +5,7 @@ import java.util.Properties;
|
|||
import luckyclient.remote.api.serverOperation;
|
||||
import luckyclient.remote.entity.TaskScheduling;
|
||||
import luckyclient.utils.LogUtil;
|
||||
import luckyclient.utils.SysConfig;
|
||||
import luckyclient.utils.config.SysConfig;
|
||||
|
||||
/**
|
||||
* =================================================================
|
||||
|
|
|
@ -82,7 +82,7 @@ public class DbOperation {
|
|||
}
|
||||
sb.append(rs.getObject(metaData.getColumnName(i)).toString()).append("%");
|
||||
}
|
||||
/* if(DBOperation.sumString(sb.toString(), "%")>500){
|
||||
/* if(DbOperation.sumString(sb.toString(), "%")>500){
|
||||
sb.delete(0,sb.length());
|
||||
sb.append("查询出来的数据太多啦(超过100项)!我显示不过来哦。。。。");
|
||||
break;
|
||||
|
|
|
@ -8,6 +8,8 @@ import java.sql.Statement;
|
|||
import java.util.List;
|
||||
|
||||
import com.mchange.v2.c3p0.ComboPooledDataSource;
|
||||
|
||||
import luckyclient.utils.config.DrivenConfig;
|
||||
/**
|
||||
* =================================================================
|
||||
* 这是一个受限制的自由软件!您不能在任何未经允许的前提下对程序代码进行修改和用于商业用途;也不允许对程序代码修改后以任何形式任何目的的再发布。
|
||||
|
@ -25,6 +27,7 @@ public class DbToolkit {
|
|||
* 建立数据库链接池
|
||||
*/
|
||||
public ComboPooledDataSource cpds=null;
|
||||
private static final String DRIVERCLASS = DrivenConfig.getConfiguration().getProperty("db.ComboPooledDataSource.DriverClass");
|
||||
|
||||
public DbToolkit(String urlBase,String usernameBase,String passwordBase){
|
||||
cpds=new ComboPooledDataSource();
|
||||
|
@ -32,7 +35,7 @@ public class DbToolkit {
|
|||
cpds.setPassword(passwordBase);
|
||||
cpds.setJdbcUrl(urlBase);
|
||||
try {
|
||||
cpds.setDriverClass("com.mysql.cj.jdbc.Driver");
|
||||
cpds.setDriverClass(DRIVERCLASS);
|
||||
} catch (PropertyVetoException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
|
@ -46,7 +49,7 @@ public class DbToolkit {
|
|||
static {
|
||||
//注册驱动类
|
||||
try {
|
||||
Class.forName("com.mysql.cj.jdbc.Driver");
|
||||
Class.forName(DRIVERCLASS);
|
||||
} catch (ClassNotFoundException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
package luckyclient.utils;
|
||||
package luckyclient.utils.config;
|
||||
|
||||
import java.io.BufferedInputStream;
|
||||
import java.io.IOException;
|
||||
|
@ -6,6 +6,8 @@ import java.io.InputStream;
|
|||
import java.io.InputStreamReader;
|
||||
import java.util.Properties;
|
||||
|
||||
import luckyclient.utils.LogUtil;
|
||||
|
||||
/**
|
||||
* 初始化Appium配置参数
|
||||
* @author seagull
|
|
@ -0,0 +1,35 @@
|
|||
package luckyclient.utils.config;
|
||||
|
||||
import java.io.BufferedInputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.InputStreamReader;
|
||||
import java.util.Properties;
|
||||
|
||||
import luckyclient.utils.LogUtil;
|
||||
|
||||
/**
|
||||
* 初始化数据库驱动配置
|
||||
* =================================================================
|
||||
* 这是一个受限制的自由软件!您不能在任何未经允许的前提下对程序代码进行修改和用于商业用途;也不允许对程序代码修改后以任何形式任何目的的再发布。
|
||||
* 为了尊重作者的劳动成果,LuckyFrame关键版权信息严禁篡改 有任何疑问欢迎联系作者讨论。 QQ:1573584944 Seagull
|
||||
* =================================================================
|
||||
* @author Seagull
|
||||
* @date 2020年2月17日
|
||||
*/
|
||||
public class DrivenConfig {
|
||||
private static final Properties SYS_CONFIG = new Properties();
|
||||
private static final String SYS_CONFIG_FILE = "/TestDriven/driven_config.properties";
|
||||
static{
|
||||
try {
|
||||
InputStream in = new BufferedInputStream(DrivenConfig.class.getResourceAsStream(SYS_CONFIG_FILE));
|
||||
SYS_CONFIG.load(new InputStreamReader(in, "UTF-8"));
|
||||
} catch (IOException e) {
|
||||
LogUtil.APP.error("读取测试驱动driven_config.properties配置文件出现异常,请检查!", e);
|
||||
}
|
||||
}
|
||||
private DrivenConfig(){}
|
||||
public static Properties getConfiguration(){
|
||||
return SYS_CONFIG;
|
||||
}
|
||||
}
|
|
@ -1,4 +1,4 @@
|
|||
package luckyclient.utils;
|
||||
package luckyclient.utils.config;
|
||||
|
||||
import java.io.BufferedInputStream;
|
||||
import java.io.IOException;
|
|
@ -21,7 +21,7 @@ import org.apache.http.impl.client.CloseableHttpClient;
|
|||
import org.apache.http.impl.client.HttpClients;
|
||||
|
||||
import luckyclient.utils.LogUtil;
|
||||
import luckyclient.utils.SysConfig;
|
||||
import luckyclient.utils.config.SysConfig;
|
||||
|
||||
/**
|
||||
* =================================================================
|
||||
|
|
|
@ -30,7 +30,7 @@ import com.alibaba.fastjson.JSON;
|
|||
import com.alibaba.fastjson.JSONObject;
|
||||
|
||||
import luckyclient.remote.entity.monitor.Server;
|
||||
import luckyclient.utils.SysConfig;
|
||||
import luckyclient.utils.config.SysConfig;
|
||||
import luckyclient.utils.httputils.HttpRequest;
|
||||
import springboot.model.RunBatchCaseEntity;
|
||||
import springboot.model.RunTaskEntity;
|
||||
|
|
Loading…
Reference in New Issue