Commit b0672e5d authored by 马博's avatar 马博

控制互斥功能

parent 14af10f0
......@@ -21,9 +21,11 @@ import static io.restassured.RestAssured.given;
* Created by hanzhanli on 2017/11/9.
*/
public class Postman {
static String dingdingUrl="https://shark.dui88.com/test/integration";
static String testPlatformUrl = "http://101.37.27.82:8080/insert";
static String miriaUrl = "http://miria-aliyun.duibatest.com.cn/autoTest/finish";
final static String dingdingUrl="https://shark.dui88.com/test/integration";
final static String testPlatformUrl = "http://101.37.27.82:8080/insert";
final static String miriaUrl = "http://miria-aliyun.duibatest.com.cn/autoTest/finish";
final static String miriaUrlTesting = "http://miria-aliyun.duibatest.com.cn/autoTest/testing";
//dingdingUrl="http://www.json.cn/";
private static Logger logger = LogManager.getLogger(Postman.class);
public static void send2Dingding(Map result){
......@@ -58,6 +60,13 @@ public class Postman {
System.out.println("miriaUrl:"+miriaUrl);
System.out.println("miria响应结果:"+response.asString());
}
public static void sendTesting(Map result){
Response response=given().params(result).get(miriaUrl);
System.out.println("jobName:"+result.get("jobName"));
System.out.println("miriaUrl:"+miriaUrlTesting);
System.out.println("miria响应结果:"+response.asString());
}
public static Boolean getName(){
Calendar c = Calendar.getInstance();
Date date = new Date();
......
package base;
import java.io.UnsupportedEncodingException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import org.springframework.core.env.Environment;
import org.testng.*;
/**
......@@ -12,6 +18,12 @@ import org.testng.*;
public class TestListener implements ITestListener {
public DuibaLog logger = DuibaLog.getLogger();
String run = System.getProperty("run");
ApplicationContext context = new AnnotationConfigApplicationContext(Config.class);
Environment env=context.getBean(Environment.class);
public TestListener() throws UnsupportedEncodingException {
}
public void onFinish(ITestContext context) {
Iterator<ITestResult> listOfFailedTests = context.getFailedTests().getAllResults().iterator();
while (listOfFailedTests.hasNext()) {
......@@ -65,16 +77,26 @@ public class TestListener implements ITestListener {
// TODO Auto-generated method stub
logger.info("onStart~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~");
//服务检查
boolean ServiceDoctor=Boolean.parseBoolean(System.getProperty("ServiceDoctor"));
if(ServiceDoctor){
try{
serviceDoctor();
}catch (SkipException e){
SFExpress.skip = context.getAllTestMethods().length;
// throw e;
}
}
//运行开始,触发互斥功能,用于定时任务
Map<String,String> mapJob = new HashMap<>();
try {
mapJob.put("jobName",getJob());
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
}
Postman.sendTesting(mapJob);
}
public void serviceDoctor(){
logger.info("duiba-server开始检测");
......@@ -107,4 +129,13 @@ public class TestListener implements ITestListener {
res = simpleDateFormat.format(date);
return res;
}
public String getJob() throws UnsupportedEncodingException {
return getByRun(run,"job");
}
public String getByRun(String run,String type) throws UnsupportedEncodingException {
run = run.substring(run.indexOf("_")+1, run.indexOf("."));
run =this.env.getProperty(run+"."+type);
return new String(run.getBytes("ISO-8859-1"), "UTF-8");//ISO-8859-1
}
}
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment