Skip to content
This repository was archived by the owner on Nov 27, 2023. It is now read-only.

Commit 7f95835

Browse files
committed
增加报告信息
1 parent 97015b3 commit 7f95835

File tree

2 files changed

+111
-7
lines changed

2 files changed

+111
-7
lines changed

src/main/java/org/suren/autotest/web/framework/report/record/ProjectRecord.java

Lines changed: 68 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -26,21 +26,82 @@
2626
*/
2727
public class ProjectRecord
2828
{
29-
private String osInfo;
29+
private String name;
30+
private String description;
31+
private String osName;
32+
private String osArch;
33+
private String osVersion;
34+
private String country;
35+
private String language;
36+
private String timezone;
3037
private String browserInfo;
3138
private String addressInfo;
3239
private Map<String, String> userInfo;
3340

3441
private List<SuiteRecord> suiteRecordList;
3542

36-
public String getOsInfo()
37-
{
38-
return osInfo;
43+
public String getName() {
44+
return name;
3945
}
4046

41-
public void setOsInfo(String osInfo)
42-
{
43-
this.osInfo = osInfo;
47+
public void setName(String name) {
48+
this.name = name;
49+
}
50+
51+
public String getDescription() {
52+
return description;
53+
}
54+
55+
public void setDescription(String description) {
56+
this.description = description;
57+
}
58+
59+
public String getOsName() {
60+
return osName;
61+
}
62+
63+
public void setOsName(String osName) {
64+
this.osName = osName;
65+
}
66+
67+
public String getOsArch() {
68+
return osArch;
69+
}
70+
71+
public void setOsArch(String osArch) {
72+
this.osArch = osArch;
73+
}
74+
75+
public String getOsVersion() {
76+
return osVersion;
77+
}
78+
79+
public void setOsVersion(String osVersion) {
80+
this.osVersion = osVersion;
81+
}
82+
83+
public String getCountry() {
84+
return country;
85+
}
86+
87+
public void setCountry(String country) {
88+
this.country = country;
89+
}
90+
91+
public String getLanguage() {
92+
return language;
93+
}
94+
95+
public void setLanguage(String language) {
96+
this.language = language;
97+
}
98+
99+
public String getTimezone() {
100+
return timezone;
101+
}
102+
103+
public void setTimezone(String timezone) {
104+
this.timezone = timezone;
44105
}
45106

46107
public String getBrowserInfo()

src/main/java/org/suren/autotest/web/framework/settings/SettingUtil.java

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818

1919
package org.suren.autotest.web.framework.settings;
2020

21+
import net.sf.json.util.JSONUtils;
2122
import org.dom4j.*;
2223
import org.dom4j.io.SAXReader;
2324
import org.dom4j.xpath.DefaultXPath;
@@ -30,6 +31,7 @@
3031
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
3132
import org.springframework.context.support.AbstractApplicationContext;
3233
import org.suren.autotest.web.framework.AutoApplicationConfig;
34+
import org.suren.autotest.web.framework.annotation.AutoApplication;
3335
import org.suren.autotest.web.framework.annotation.AutoDataSource;
3436
import org.suren.autotest.web.framework.annotation.AutoLocator;
3537
import org.suren.autotest.web.framework.annotation.AutoPage;
@@ -40,10 +42,12 @@
4042
import org.suren.autotest.web.framework.hook.ShutdownHook;
4143
import org.suren.autotest.web.framework.page.Page;
4244
import org.suren.autotest.web.framework.report.RecordReportWriter;
45+
import org.suren.autotest.web.framework.report.record.ProjectRecord;
4346
import org.suren.autotest.web.framework.selenium.SeleniumEngine;
4447
import org.suren.autotest.web.framework.spring.AutoModuleScope;
4548
import org.suren.autotest.web.framework.spring.AutotestScope;
4649
import org.suren.autotest.web.framework.util.BeanUtil;
50+
import org.suren.autotest.web.framework.util.NetUtil;
4751
import org.suren.autotest.web.framework.util.StringUtils;
4852
import org.suren.autotest.web.framework.validation.Validation;
4953
import org.xml.sax.SAXException;
@@ -136,6 +140,45 @@ public SettingUtil(Class<?> ... annotatedClasses)
136140

137141
shutdownHook = new ShutdownHook(this);
138142
Runtime.getRuntime().addShutdownHook(shutdownHook);
143+
144+
Map<String, Object> autoApp = context.getBeansWithAnnotation(AutoApplication.class);
145+
final String projectName;
146+
final String projectDesc;
147+
if(autoApp != null && autoApp.size() > 0)
148+
{
149+
Object appObj = autoApp.values().iterator().next();
150+
AutoApplication autoApplication = appObj.getClass().getAnnotation(AutoApplication.class);
151+
if(autoApplication == null)
152+
{
153+
autoApplication = appObj.getClass().getSuperclass().getAnnotation(AutoApplication.class);
154+
}
155+
projectName = autoApplication.name();
156+
projectDesc = autoApplication.description();
157+
}
158+
else
159+
{
160+
projectName = "none";
161+
projectDesc = "none";
162+
}
163+
164+
Map<String, RecordReportWriter> writers = context.getBeansOfType(RecordReportWriter.class);
165+
if(writers != null)
166+
{
167+
writers.forEach((name, writer) -> {
168+
ProjectRecord projectRecord = new ProjectRecord();
169+
projectRecord.setName(projectName);
170+
projectRecord.setDescription(projectDesc);
171+
projectRecord.setBrowserInfo("browserInfo");
172+
projectRecord.setOsName(System.getProperty("os.name"));
173+
projectRecord.setOsArch(System.getProperty("os.arch"));
174+
projectRecord.setOsVersion(System.getProperty("os.version"));
175+
projectRecord.setCountry(System.getProperty("user.country"));
176+
projectRecord.setLanguage(System.getProperty("user.language"));
177+
projectRecord.setTimezone(System.getProperty("user.timezone"));
178+
projectRecord.setAddressInfo(JSONUtils.valueToString(NetUtil.allIP()));
179+
writer.write(projectRecord);
180+
});
181+
}
139182

140183
logger.info("init process done.");
141184
}

0 commit comments

Comments
 (0)