Commit 79149350af8d6208b8edbfeaba846897133e5908
1 parent
27d9a429
开发梳理;
Showing
10 changed files
with
480 additions
and
66 deletions
Show diff stats
src/main/java/com/essa/framework/BrowserEngine.java
@@ -7,47 +7,20 @@ import org.openqa.selenium.ie.InternetExplorerDriver; | @@ -7,47 +7,20 @@ import org.openqa.selenium.ie.InternetExplorerDriver; | ||
7 | import org.openqa.selenium.remote.CapabilityType; | 7 | import org.openqa.selenium.remote.CapabilityType; |
8 | import org.openqa.selenium.remote.DesiredCapabilities; | 8 | import org.openqa.selenium.remote.DesiredCapabilities; |
9 | 9 | ||
10 | -import java.io.FileInputStream; | ||
11 | import java.io.IOException; | 10 | import java.io.IOException; |
12 | -import java.io.InputStream; | ||
13 | -import java.util.Properties; | ||
14 | import java.util.concurrent.TimeUnit; | 11 | import java.util.concurrent.TimeUnit; |
15 | 12 | ||
16 | public class BrowserEngine { | 13 | public class BrowserEngine { |
17 | 14 | ||
18 | - private static String browserName; | ||
19 | - private String serverURL; | ||
20 | - private String buyerURL; | ||
21 | - private static WebDriver driver; | ||
22 | - private static String env1; | ||
23 | - | ||
24 | - public void initConfigData() throws IOException{ | ||
25 | - Properties p = new Properties(); | ||
26 | - // 加载配置文件 | ||
27 | -// System.load("./config.properties"); | ||
28 | -// InputStream a = ClassLoader.getSystemResourceAsStream("config.properties"); | ||
29 | -// System.out.println("browserName + " + System.getProperty("browserName")); | ||
30 | - InputStream ips = new FileInputStream(".\\src\\main\\resources\\config.properties"); | ||
31 | - p.load(ips); | ||
32 | -// Logger.Output(LogType.LogTypeName.INFO, "开始从配置文件中选择浏览器"); | ||
33 | - browserName=p.getProperty("browserName");//使用jframe要注释 | ||
34 | - Logger.Output(LogType.LogTypeName.INFO, "所选择的浏览器类型为: "+ browserName); | ||
35 | - if (env1=="DIT") { | ||
36 | - serverURL = p.getProperty("DIT"); | ||
37 | - buyerURL = p.getProperty("BDIT"); | ||
38 | - }else if (env1 =="HOTFIX") { | ||
39 | - serverURL = p.getProperty("HOTFIX"); | ||
40 | - buyerURL = p.getProperty("BHOTFIX"); | ||
41 | - }else if (env1 == "UAT") { | ||
42 | - serverURL = p.getProperty("UAT"); | ||
43 | - buyerURL = p.getProperty("BUAT"); | ||
44 | - }else { | ||
45 | - serverURL = p.getProperty("SIT"); | ||
46 | - buyerURL = p.getProperty("BSIT"); | ||
47 | - } | ||
48 | - Logger.Output(LogType.LogTypeName.INFO, "所测试的环境为:"+ env1); | ||
49 | - Model.setEnv(env1);//我也不知道为什么执行完上面的代码后,env会变为sit | ||
50 | - ips.close(); | 15 | + private static BrowserEnum browserEnum; |
16 | + private WebDriver driver; | ||
17 | + private static EnvEnum env1; | ||
18 | + | ||
19 | + private ConfigProperties configProperties; | ||
20 | + | ||
21 | + public void initConfigData() throws IOException{ | ||
22 | + configProperties = ConfigProperties.getConfig(env1); | ||
23 | + Model.setEnv(env1.getCode());//我也不知道为什么执行完上面的代码后,env会变为sit | ||
51 | } | 24 | } |
52 | /** | 25 | /** |
53 | * bpms环境初始化 | 26 | * bpms环境初始化 |
@@ -55,35 +28,35 @@ public class BrowserEngine { | @@ -55,35 +28,35 @@ public class BrowserEngine { | ||
55 | * @param browser | 28 | * @param browser |
56 | */ | 29 | */ |
57 | public static void setInit(String environment,String browser) { | 30 | public static void setInit(String environment,String browser) { |
58 | - browserName = browser; | ||
59 | - env1 = environment; | 31 | + browserEnum = BrowserEnum.fromCode(browser); |
32 | + env1 = EnvEnum.fromCode(environment); | ||
60 | } | 33 | } |
61 | 34 | ||
62 | /** | 35 | /** |
63 | * bpms获取地址方法 | 36 | * bpms获取地址方法 |
64 | * @return | 37 | * @return |
65 | */ | 38 | */ |
66 | - public WebDriver getBrowser(){ | ||
67 | - | ||
68 | - if(browserName.equalsIgnoreCase("Firefox")){ | ||
69 | - System.setProperty("webdriver.gecko.driver", ".\\resources\\geckodriver.exe"); | ||
70 | - driver = new FirefoxDriver(); | ||
71 | - Logger.Output(LogType.LogTypeName.INFO, "正在启动FireFox浏览器"); | 39 | + private WebDriver getBrowser(BrowserEnum browser,String url,int waitTime){ |
40 | + switch(browser) { | ||
41 | + case Firefox:{ | ||
42 | + driver = new FirefoxDriver(); | ||
43 | + break; | ||
44 | + } | ||
45 | + case Chrome: { | ||
46 | + driver = new ChromeDriver(); | ||
47 | + break; | ||
48 | + } | ||
49 | + case IE: { | ||
50 | + driver = new InternetExplorerDriver(); | ||
51 | + } | ||
72 | } | 52 | } |
73 | - else if(browserName.equals("Chrome")){ | ||
74 | - System.setProperty("webdriver.chrome.driver", ".\\src\\main\\resources\\chromedriver.exe"); //图形界面 | ||
75 | - driver= new ChromeDriver(); | ||
76 | - Logger.Output(LogType.LogTypeName.INFO, "正在启动Chrome浏览器"); | ||
77 | - }else if(browserName.equalsIgnoreCase("IE")){ | ||
78 | - System.setProperty("webdriver.ie.driver", ".\\src\\main\resources\\IEDriverServer.exe"); | ||
79 | - driver= new InternetExplorerDriver(); | ||
80 | - Logger.Output(LogType.LogTypeName.INFO, "正在启动IE浏览器"); | ||
81 | - } | ||
82 | - driver.manage().window().maximize(); | 53 | + System.setProperty("webdriver.gecko.driver", ".\\src\\main\\resources\\" + browser.getDriver()); |
54 | + Logger.Output(LogType.LogTypeName.INFO, "正在启动" + browser.getCode() +"浏览器"); | ||
55 | + driver.manage().window().maximize(); | ||
83 | Logger.Output(LogType.LogTypeName.INFO, "窗口最大化"); | 56 | Logger.Output(LogType.LogTypeName.INFO, "窗口最大化"); |
84 | - driver.get(serverURL); | ||
85 | - Logger.Output(LogType.LogTypeName.INFO, "打开URL: "+ serverURL); | ||
86 | - callWait(5); | 57 | + driver.get(url); |
58 | + Logger.Output(LogType.LogTypeName.INFO, "打开URL: "+ url); | ||
59 | + callWait(waitTime); | ||
87 | return driver; | 60 | return driver; |
88 | } | 61 | } |
89 | 62 | ||
@@ -92,7 +65,7 @@ public class BrowserEngine { | @@ -92,7 +65,7 @@ public class BrowserEngine { | ||
92 | * @return | 65 | * @return |
93 | */ | 66 | */ |
94 | public WebDriver buyerGetBrowser() { | 67 | public WebDriver buyerGetBrowser() { |
95 | - if (browserName.equals("Chrome")) { | 68 | + /*if (browserName.equals("Chrome")) { |
96 | System.setProperty("webdriver.chrome.driver", ".\\resources\\chromedriver.exe"); //图形界面 | 69 | System.setProperty("webdriver.chrome.driver", ".\\resources\\chromedriver.exe"); //图形界面 |
97 | driver= new ChromeDriver(); | 70 | driver= new ChromeDriver(); |
98 | Logger.Output(LogType.LogTypeName.INFO, "正在启动Chrome浏览器"); | 71 | Logger.Output(LogType.LogTypeName.INFO, "正在启动Chrome浏览器"); |
@@ -105,8 +78,33 @@ public class BrowserEngine { | @@ -105,8 +78,33 @@ public class BrowserEngine { | ||
105 | Logger.Output(LogType.LogTypeName.INFO, "窗口最大化"); | 78 | Logger.Output(LogType.LogTypeName.INFO, "窗口最大化"); |
106 | driver.get(buyerURL); | 79 | driver.get(buyerURL); |
107 | Logger.Output(LogType.LogTypeName.INFO, "打开URL: "+ buyerURL); | 80 | Logger.Output(LogType.LogTypeName.INFO, "打开URL: "+ buyerURL); |
108 | - callWait(5); | ||
109 | - return driver; | 81 | + callWait(5); */ |
82 | + return getBrowser(browserEnum,configProperties.getBuyerURL(),5); | ||
83 | +// return driver; | ||
84 | + } | ||
85 | + | ||
86 | + public WebDriver getBrowser() { | ||
87 | + /*if(browserName.equalsIgnoreCase("Firefox")){ | ||
88 | + System.setProperty("webdriver.gecko.driver", ".\\resources\\geckodriver.exe"); | ||
89 | + driver = new FirefoxDriver(); | ||
90 | + Logger.Output(LogType.LogTypeName.INFO, "正在启动FireFox浏览器"); | ||
91 | + } | ||
92 | + else if(browserName.equals("Chrome")){ | ||
93 | + System.setProperty("webdriver.chrome.driver", ".\\src\\main\\resources\\chromedriver.exe"); //图形界面 | ||
94 | + driver= new ChromeDriver(); | ||
95 | + Logger.Output(LogType.LogTypeName.INFO, "正在启动Chrome浏览器"); | ||
96 | + }else if(browserName.equalsIgnoreCase("IE")){ | ||
97 | + System.setProperty("webdriver.ie.driver", ".\\src\\main\resources\\IEDriverServer.exe"); | ||
98 | + driver= new InternetExplorerDriver(); | ||
99 | + Logger.Output(LogType.LogTypeName.INFO, "正在启动IE浏览器"); | ||
100 | + } | ||
101 | + driver.manage().window().maximize(); | ||
102 | + Logger.Output(LogType.LogTypeName.INFO, "窗口最大化"); | ||
103 | + driver.get(serverURL); | ||
104 | + Logger.Output(LogType.LogTypeName.INFO, "打开URL: "+ serverURL); | ||
105 | + callWait(5);*/ | ||
106 | + return getBrowser(browserEnum,configProperties.getServerURL(),5); | ||
107 | +// return driver; | ||
110 | } | 108 | } |
111 | 109 | ||
112 | 110 |
@@ -0,0 +1,95 @@ | @@ -0,0 +1,95 @@ | ||
1 | +package com.essa.framework; | ||
2 | +/** | ||
3 | + * Created by weicheng on 2018/10/25. | ||
4 | + */ | ||
5 | + | ||
6 | +import java.util.List; | ||
7 | +import java.util.concurrent.ConcurrentHashMap; | ||
8 | +import java.util.concurrent.atomic.AtomicReference; | ||
9 | + | ||
10 | +public enum BrowserEnum { | ||
11 | + Firefox("Firefox","geckodriver.exe"), | ||
12 | + Chrome("Chrome","chromedriver.exe"), | ||
13 | + IE("IE","IEDriverServer.exe"); | ||
14 | + | ||
15 | + /** | ||
16 | + * 原子引用(全部) | ||
17 | + */ | ||
18 | + private static AtomicReference<ConcurrentHashMap<String, BrowserEnum>> mapAllRef = new AtomicReference<>(); | ||
19 | + | ||
20 | + private static AtomicReference<ConcurrentHashMap<String, BrowserEnum>> mapPartRef = new AtomicReference<>(); | ||
21 | + | ||
22 | + /** | ||
23 | + * 根据code获取 BrowserEnum | ||
24 | + * | ||
25 | + * @param code | ||
26 | + * @return | ||
27 | + */ | ||
28 | + public static BrowserEnum fromCode(String code) { | ||
29 | + buildConcurrentHashMap(); | ||
30 | + return mapAllRef.get().get(code); | ||
31 | + } | ||
32 | + | ||
33 | + /** | ||
34 | + * 如果map是空,就会构建Map | ||
35 | + */ | ||
36 | + private static void buildConcurrentHashMap() { | ||
37 | + //如果所有枚举的原子引用是空对象,就创建一个ConcurrentHashMap给原子引用 | ||
38 | + mapAllRef.compareAndSet(null, new ConcurrentHashMap<>()); | ||
39 | + //获取原子引用的currentHashMap对象 | ||
40 | + ConcurrentHashMap<String, BrowserEnum> concurrentHashAllMap = mapAllRef.get(); | ||
41 | + //如果ConcurrentHashMap里面没有一个枚举对象,需要初次化 | ||
42 | + if (concurrentHashAllMap.isEmpty()) { | ||
43 | + for (BrowserEnum e : BrowserEnum.values()) { | ||
44 | + concurrentHashAllMap.put(e.getCode(), e); | ||
45 | + } | ||
46 | + mapAllRef.set(concurrentHashAllMap); | ||
47 | + } | ||
48 | + } | ||
49 | + | ||
50 | + /** | ||
51 | + * 枚举代码 | ||
52 | + */ | ||
53 | + private String code; | ||
54 | + | ||
55 | + /** | ||
56 | + * 枚举描述 | ||
57 | + */ | ||
58 | + private String driver; | ||
59 | + | ||
60 | + public String getCode() { | ||
61 | + return code; | ||
62 | + } | ||
63 | + | ||
64 | + public void setCode(String code) { | ||
65 | + this.code = code; | ||
66 | + } | ||
67 | + | ||
68 | + public String getDriver() { | ||
69 | + return driver; | ||
70 | + } | ||
71 | + | ||
72 | + public void setDriver(String driver) { | ||
73 | + this.driver = driver; | ||
74 | + } | ||
75 | + | ||
76 | + BrowserEnum(String code, String driver) { | ||
77 | + this.code = code; | ||
78 | + this.driver = driver; | ||
79 | + } | ||
80 | + | ||
81 | + public static List<BrowserEnum> getAllEnum() { | ||
82 | + buildConcurrentHashMap(); | ||
83 | + return (List<BrowserEnum>) mapAllRef.get().values(); | ||
84 | + } | ||
85 | + | ||
86 | + /** | ||
87 | + * 只返回常用枚举 | ||
88 | + * | ||
89 | + * @return | ||
90 | + */ | ||
91 | + public static List<BrowserEnum> getEnumByDefault() { | ||
92 | + buildConcurrentHashMap(); | ||
93 | + return (List<BrowserEnum>) mapPartRef.get().values(); | ||
94 | + } | ||
95 | +} |
src/main/java/com/essa/framework/ConfigProperties.java
0 → 100644
@@ -0,0 +1,70 @@ | @@ -0,0 +1,70 @@ | ||
1 | +package com.essa.framework; | ||
2 | + | ||
3 | +import java.io.IOException; | ||
4 | +import java.io.InputStream; | ||
5 | +import java.util.HashMap; | ||
6 | +import java.util.Map; | ||
7 | +import java.util.Properties; | ||
8 | + | ||
9 | +/** | ||
10 | + * Created by weicheng on 2018/10/25. | ||
11 | + */ | ||
12 | +public class ConfigProperties { | ||
13 | + | ||
14 | + private String browserName; | ||
15 | + private String serverURL; | ||
16 | + private String buyerURL; | ||
17 | + | ||
18 | + private ConfigProperties() { | ||
19 | + | ||
20 | + } | ||
21 | + | ||
22 | + private static Map<String,ConfigProperties> configPropertiesMap = new HashMap<String,ConfigProperties>(); | ||
23 | + | ||
24 | + static { | ||
25 | + EnvEnum[] env = EnvEnum.values(); | ||
26 | + for (EnvEnum envEnum : env) { | ||
27 | + try { | ||
28 | + ConfigProperties configProperties = new ConfigProperties(); | ||
29 | + Properties p = new Properties(); | ||
30 | + InputStream ips = ClassLoader.getSystemResourceAsStream("conf/config_" + envEnum.getCode() +".properties"); | ||
31 | + p.load(ips); | ||
32 | + configProperties.setBrowserName(p.getProperty("browserName"));//使用jframe要注释 | ||
33 | + configProperties.setBuyerURL(p.getProperty("buyerURL")); | ||
34 | + configProperties.setServerURL(p.getProperty("serverURL")); | ||
35 | + configPropertiesMap.put(envEnum.getCode(),configProperties); | ||
36 | + ips.close(); | ||
37 | + } catch (IOException e) { | ||
38 | + e.printStackTrace(); | ||
39 | + } | ||
40 | + } | ||
41 | + } | ||
42 | + | ||
43 | + public static ConfigProperties getConfig(EnvEnum envEnum) { | ||
44 | + return configPropertiesMap.get(envEnum.getCode()); | ||
45 | + } | ||
46 | + | ||
47 | + public String getBrowserName() { | ||
48 | + return browserName; | ||
49 | + } | ||
50 | + | ||
51 | + public void setBrowserName(String browserName) { | ||
52 | + this.browserName = browserName; | ||
53 | + } | ||
54 | + | ||
55 | + public String getServerURL() { | ||
56 | + return serverURL; | ||
57 | + } | ||
58 | + | ||
59 | + public void setServerURL(String serverURL) { | ||
60 | + this.serverURL = serverURL; | ||
61 | + } | ||
62 | + | ||
63 | + public String getBuyerURL() { | ||
64 | + return buyerURL; | ||
65 | + } | ||
66 | + | ||
67 | + public void setBuyerURL(String buyerURL) { | ||
68 | + this.buyerURL = buyerURL; | ||
69 | + } | ||
70 | +} |
@@ -0,0 +1,96 @@ | @@ -0,0 +1,96 @@ | ||
1 | +package com.essa.framework; | ||
2 | +/** | ||
3 | + * Created by weicheng on 2018/10/25. | ||
4 | + */ | ||
5 | + | ||
6 | +import java.util.List; | ||
7 | +import java.util.concurrent.ConcurrentHashMap; | ||
8 | +import java.util.concurrent.atomic.AtomicReference; | ||
9 | + | ||
10 | +public enum EnvEnum { | ||
11 | + DIT("dit","DIT"), | ||
12 | + HOTFIX("hotfix","HOTFIX"), | ||
13 | + UAT("uat","UAT"), | ||
14 | + SIT("sit","SIT"); | ||
15 | + | ||
16 | + /** | ||
17 | + * 原子引用(全部) | ||
18 | + */ | ||
19 | + private static AtomicReference<ConcurrentHashMap<String, EnvEnum>> mapAllRef = new AtomicReference<>(); | ||
20 | + | ||
21 | + private static AtomicReference<ConcurrentHashMap<String, EnvEnum>> mapPartRef = new AtomicReference<>(); | ||
22 | + | ||
23 | + /** | ||
24 | + * 根据code获取 EnvEnum | ||
25 | + * | ||
26 | + * @param code | ||
27 | + * @return | ||
28 | + */ | ||
29 | + public static EnvEnum fromCode(String code) { | ||
30 | + buildConcurrentHashMap(); | ||
31 | + return mapAllRef.get().get(code); | ||
32 | + } | ||
33 | + | ||
34 | + /** | ||
35 | + * 如果map是空,就会构建Map | ||
36 | + */ | ||
37 | + private static void buildConcurrentHashMap() { | ||
38 | + //如果所有枚举的原子引用是空对象,就创建一个ConcurrentHashMap给原子引用 | ||
39 | + mapAllRef.compareAndSet(null, new ConcurrentHashMap<>()); | ||
40 | + //获取原子引用的currentHashMap对象 | ||
41 | + ConcurrentHashMap<String, EnvEnum> concurrentHashAllMap = mapAllRef.get(); | ||
42 | + //如果ConcurrentHashMap里面没有一个枚举对象,需要初次化 | ||
43 | + if (concurrentHashAllMap.isEmpty()) { | ||
44 | + for (EnvEnum e : EnvEnum.values()) { | ||
45 | + concurrentHashAllMap.put(e.getCode(), e); | ||
46 | + } | ||
47 | + mapAllRef.set(concurrentHashAllMap); | ||
48 | + } | ||
49 | + } | ||
50 | + | ||
51 | + /** | ||
52 | + * 枚举代码 | ||
53 | + */ | ||
54 | + private String code; | ||
55 | + | ||
56 | + /** | ||
57 | + * 枚举描述 | ||
58 | + */ | ||
59 | + private String desc; | ||
60 | + | ||
61 | + public String getCode() { | ||
62 | + return code; | ||
63 | + } | ||
64 | + | ||
65 | + public void setCode(String code) { | ||
66 | + this.code = code; | ||
67 | + } | ||
68 | + | ||
69 | + public String getDesc() { | ||
70 | + return desc; | ||
71 | + } | ||
72 | + | ||
73 | + public void setDesc(String desc) { | ||
74 | + this.desc = desc; | ||
75 | + } | ||
76 | + | ||
77 | + EnvEnum(String code, String desc) { | ||
78 | + this.code = code; | ||
79 | + this.desc = desc; | ||
80 | + } | ||
81 | + | ||
82 | + public static List<EnvEnum> getAllEnum() { | ||
83 | + buildConcurrentHashMap(); | ||
84 | + return (List<EnvEnum>) mapAllRef.get().values(); | ||
85 | + } | ||
86 | + | ||
87 | + /** | ||
88 | + * 只返回常用枚举 | ||
89 | + * | ||
90 | + * @return | ||
91 | + */ | ||
92 | + public static List<EnvEnum> getEnumByDefault() { | ||
93 | + buildConcurrentHashMap(); | ||
94 | + return (List<EnvEnum>) mapPartRef.get().values(); | ||
95 | + } | ||
96 | +} |
src/main/java/com/essa/framework/Logger.java
@@ -6,8 +6,6 @@ import java.io.OutputStreamWriter; | @@ -6,8 +6,6 @@ import java.io.OutputStreamWriter; | ||
6 | import java.text.SimpleDateFormat; | 6 | import java.text.SimpleDateFormat; |
7 | import java.util.Date; | 7 | import java.util.Date; |
8 | 8 | ||
9 | -import com.essa.framework.LogType; | ||
10 | - | ||
11 | public class Logger { | 9 | public class Logger { |
12 | 10 | ||
13 | public static String OutputFileName = getDateTimeByFormat(new Date(), "yyyyMMdd"); | 11 | public static String OutputFileName = getDateTimeByFormat(new Date(), "yyyyMMdd"); |
@@ -27,10 +25,13 @@ public class Logger { | @@ -27,10 +25,13 @@ public class Logger { | ||
27 | // 定义日志文件保存路径和日志文件名称 | 25 | // 定义日志文件保存路径和日志文件名称 |
28 | logFileName = ".\\Log" + "\\" + OutputFileName + ".log"; | 26 | logFileName = ".\\Log" + "\\" + OutputFileName + ".log"; |
29 | if (outputStreamWriter == null) { | 27 | if (outputStreamWriter == null) { |
30 | - File logFile = new File(logFileName); | ||
31 | - | ||
32 | - if (!logFile.exists()) | ||
33 | - logFile.createNewFile(); | 28 | + File logFile = new File(logFileName); |
29 | + | ||
30 | + if(!logFile.getParentFile().exists()){ | ||
31 | + logFile.getParentFile().mkdirs(); | ||
32 | + } | ||
33 | + if (!logFile.exists()) | ||
34 | + logFile.createNewFile(); | ||
34 | //利用OutputStreamWriter往日志文件写内容,字符编码是unicode | 35 | //利用OutputStreamWriter往日志文件写内容,字符编码是unicode |
35 | outputStreamWriter = new OutputStreamWriter(new FileOutputStream(logFileName), "utf-8"); | 36 | outputStreamWriter = new OutputStreamWriter(new FileOutputStream(logFileName), "utf-8"); |
36 | } | 37 | } |
@@ -0,0 +1,117 @@ | @@ -0,0 +1,117 @@ | ||
1 | +package com.essa.framework; | ||
2 | +/** | ||
3 | + * Created by weicheng on 2018/10/25. | ||
4 | + */ | ||
5 | + | ||
6 | +import java.util.List; | ||
7 | +import java.util.concurrent.ConcurrentHashMap; | ||
8 | +import java.util.concurrent.atomic.AtomicReference; | ||
9 | + | ||
10 | +public enum SuitesEnum { | ||
11 | + ADD_ORIGINAL_GOODS("ADD_ORIGIN_SKU","addOriginalGoods.xml","新增原厂商品"), | ||
12 | + ADD_MARKET_GOODS("ADD_MARKET_GOODS","addMarketGoods.xml","新增市场商品"), | ||
13 | + PUBLISH_GROUP_PURCHASE("PUBLISH_GROUP_PURCHASE","publishGroupPurchase.xml","发布团购"), | ||
14 | + BUYER_REGISTER("BUYER_REGISTER","buyerRegister.xml","采购商注册"), | ||
15 | + ADD_SKU_TO_CART("ADD_SKU_TO_CART","addSkuToCart.xml","添加SKU至购物车"), | ||
16 | + ACTIVITY_INQUIRY("ACTIVITY_INQUIRY","activityInquiry.xml","成品询价(活动)"), | ||
17 | + PRODUCT_INQUIRY("PRODUCT_INQUIRY","productInquiry.xml","成品询价(正常)"), | ||
18 | + ACTIVITY_SEND_PO("ACTIVITY_SEND_PO","activitySendPO.xml","生成PO(活动)"), | ||
19 | + SEND_PO("SEND_PO","sendPO.xml","生成PO(正常)"), | ||
20 | + PO_INQUIRY("PO_INQUIRY","POInquiry.xml","PO询价") | ||
21 | + ; | ||
22 | + | ||
23 | + /** | ||
24 | + * 原子引用(全部) | ||
25 | + */ | ||
26 | + private static AtomicReference<ConcurrentHashMap<String, SuitesEnum>> mapAllRef = new AtomicReference<>(); | ||
27 | + | ||
28 | + private static AtomicReference<ConcurrentHashMap<String, SuitesEnum>> mapPartRef = new AtomicReference<>(); | ||
29 | + | ||
30 | + /** | ||
31 | + * 根据code获取 SuitesEnum | ||
32 | + * | ||
33 | + * @param code | ||
34 | + * @return | ||
35 | + */ | ||
36 | + public static SuitesEnum fromCode(String code) { | ||
37 | + buildConcurrentHashMap(); | ||
38 | + return mapAllRef.get().get(code); | ||
39 | + } | ||
40 | + | ||
41 | + /** | ||
42 | + * 如果map是空,就会构建Map | ||
43 | + */ | ||
44 | + private static void buildConcurrentHashMap() { | ||
45 | + //如果所有枚举的原子引用是空对象,就创建一个ConcurrentHashMap给原子引用 | ||
46 | + mapAllRef.compareAndSet(null, new ConcurrentHashMap<>()); | ||
47 | + //获取原子引用的currentHashMap对象 | ||
48 | + ConcurrentHashMap<String, SuitesEnum> concurrentHashAllMap = mapAllRef.get(); | ||
49 | + //如果ConcurrentHashMap里面没有一个枚举对象,需要初次化 | ||
50 | + if (concurrentHashAllMap.isEmpty()) { | ||
51 | + for (SuitesEnum e : SuitesEnum.values()) { | ||
52 | + concurrentHashAllMap.put(e.getCode(), e); | ||
53 | + } | ||
54 | + mapAllRef.set(concurrentHashAllMap); | ||
55 | + } | ||
56 | + } | ||
57 | + | ||
58 | + /** | ||
59 | + * 枚举代码 | ||
60 | + */ | ||
61 | + private String code; | ||
62 | + | ||
63 | + /** | ||
64 | + * suite 文件名 | ||
65 | + */ | ||
66 | + private String suiteName; | ||
67 | + | ||
68 | + /** | ||
69 | + * 枚举描述 | ||
70 | + */ | ||
71 | + private String desc; | ||
72 | + | ||
73 | + public String getCode() { | ||
74 | + return code; | ||
75 | + } | ||
76 | + | ||
77 | + public void setCode(String code) { | ||
78 | + this.code = code; | ||
79 | + } | ||
80 | + | ||
81 | + public String getDesc() { | ||
82 | + return desc; | ||
83 | + } | ||
84 | + | ||
85 | + public void setDesc(String desc) { | ||
86 | + this.desc = desc; | ||
87 | + } | ||
88 | + | ||
89 | + public String getSuiteName() { | ||
90 | + return suiteName; | ||
91 | + } | ||
92 | + | ||
93 | + public void setSuiteName(String suiteName) { | ||
94 | + this.suiteName = suiteName; | ||
95 | + } | ||
96 | + | ||
97 | + SuitesEnum(String code, String suiteName, String desc) { | ||
98 | + this.code = code; | ||
99 | + this.suiteName = suiteName; | ||
100 | + this.desc = desc; | ||
101 | + } | ||
102 | + | ||
103 | + public static List<SuitesEnum> getAllEnum() { | ||
104 | + buildConcurrentHashMap(); | ||
105 | + return (List<SuitesEnum>) mapAllRef.get().values(); | ||
106 | + } | ||
107 | + | ||
108 | + /** | ||
109 | + * 只返回常用枚举 | ||
110 | + * | ||
111 | + * @return | ||
112 | + */ | ||
113 | + public static List<SuitesEnum> getEnumByDefault() { | ||
114 | + buildConcurrentHashMap(); | ||
115 | + return (List<SuitesEnum>) mapPartRef.get().values(); | ||
116 | + } | ||
117 | +} |
@@ -0,0 +1,16 @@ | @@ -0,0 +1,16 @@ | ||
1 | +#browserName=FireFox | ||
2 | +#browserName=IE | ||
3 | +browserName=Chrome | ||
4 | + | ||
5 | +SIT=http://bpms.sit.gz.essa | ||
6 | +BSIT=http://en.portalsit.cn | ||
7 | + | ||
8 | +HOTFIX=http://bpms.hotfix.gz.essa | ||
9 | +BHOTFIX=http://en.portalhotfix.cn | ||
10 | + | ||
11 | +UAT=http://bpms.spstoys.com:7291 | ||
12 | +BUAT=http://en.spstoys.com:889 | ||
13 | + | ||
14 | +DIT=http://bpms.dit.gz.essa | ||
15 | +BDIT=http://en.portaldit.cn | ||
16 | + |