|
18 | 18 |
|
19 | 19 | package org.suren.autotest.web.framework.settings; |
20 | 20 |
|
| 21 | +import net.sf.json.util.JSONUtils; |
21 | 22 | import org.dom4j.*; |
22 | 23 | import org.dom4j.io.SAXReader; |
23 | 24 | import org.dom4j.xpath.DefaultXPath; |
|
30 | 31 | import org.springframework.context.annotation.AnnotationConfigApplicationContext; |
31 | 32 | import org.springframework.context.support.AbstractApplicationContext; |
32 | 33 | import org.suren.autotest.web.framework.AutoApplicationConfig; |
| 34 | +import org.suren.autotest.web.framework.annotation.AutoApplication; |
33 | 35 | import org.suren.autotest.web.framework.annotation.AutoDataSource; |
34 | 36 | import org.suren.autotest.web.framework.annotation.AutoLocator; |
35 | 37 | import org.suren.autotest.web.framework.annotation.AutoPage; |
|
40 | 42 | import org.suren.autotest.web.framework.hook.ShutdownHook; |
41 | 43 | import org.suren.autotest.web.framework.page.Page; |
42 | 44 | import org.suren.autotest.web.framework.report.RecordReportWriter; |
| 45 | +import org.suren.autotest.web.framework.report.record.ProjectRecord; |
43 | 46 | import org.suren.autotest.web.framework.selenium.SeleniumEngine; |
44 | 47 | import org.suren.autotest.web.framework.spring.AutoModuleScope; |
45 | 48 | import org.suren.autotest.web.framework.spring.AutotestScope; |
46 | 49 | import org.suren.autotest.web.framework.util.BeanUtil; |
| 50 | +import org.suren.autotest.web.framework.util.NetUtil; |
47 | 51 | import org.suren.autotest.web.framework.util.StringUtils; |
48 | 52 | import org.suren.autotest.web.framework.validation.Validation; |
49 | 53 | import org.xml.sax.SAXException; |
@@ -136,6 +140,45 @@ public SettingUtil(Class<?> ... annotatedClasses) |
136 | 140 |
|
137 | 141 | shutdownHook = new ShutdownHook(this); |
138 | 142 | 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 | + } |
139 | 182 |
|
140 | 183 | logger.info("init process done."); |
141 | 184 | } |
|
0 commit comments