##### Coverage Report - com.ctrip.apollo.env.ClientEnvironment

Classes in this File | Line Coverage | Branch Coverage | Complexity
ClientEnvironment |
0% | 0/24
0% | 0/31
| 3.25;3.25

1 |  |
     package com.ctrip.apollo.env;
2 |  |
3 |  |
     import com.google.common.base.Strings;
4 |  |
5 |  |
     import com.ctrip.apollo.core.enums.Env;
6 |  |
     import com.ctrip.framework.foundation.Foundation;
7 |  |
8 | 0 |
     public class ClientEnvironment {
9 |  |
       private static Env s_env;
10 |  |
       private static String s_appId;
11 |  |
       private static String s_cluster;
12 |  |
13 |  |
       static {
14 | 0 |
         setEnv(Foundation.server().getEnvType());
15 |  |
16 | 0 |
         s_appId = Foundation.app().getAppId();
17 |  |
18 | 0 |
         s_cluster = System.getProperty("apollo.cluster");
19 | 0 |
       }
20 |  |
21 |  |
       public static String getAppId() {
22 | 0 |
         return s_appId;
23 |  |
       }
24 |  |
25 |  |
       public static Env getEnv() {
26 | 0 |
         return s_env;
27 |  |
       }
28 |  |
29 |  |
       public static String getCluster() {
30 | 0 |
         return s_cluster;
31 |  |
       }
32 |  |
33 |  |
       private static void setEnv(String envName) {
34 | 0 |
         if (Strings.isNullOrEmpty(envName)) {
35 | 0 |
           return;
36 |  |
         }
37 | 0 |
         switch (envName.toUpperCase()) {
38 |  |
           case "LPT":
39 | 0 |
             s_env = Env.LPT;
40 | 0 |
             break;
41 |  |
           case "FAT":
42 |  |
           case "FWS":
43 | 0 |
             s_env = Env.FAT;
44 | 0 |
             break;
45 |  |
           case "UAT":
46 | 0 |
             s_env = Env.UAT;
47 | 0 |
             break;
48 |  |
           case "PRO":
49 | 0 |
             s_env = Env.PRO;
50 | 0 |
             break;
51 |  |
           case "DEV":
52 | 0 |
             s_env = Env.DEV;
53 | 0 |
             break;
54 |  |
           case "LOCAL":
55 | 0 |
             s_env = Env.LOCAL;
56 | 0 |
             break;
57 |  |
           default:
58 |  |
             //do nothing
59 |  |
             break;
60 |  |
         }
61 | 0 |
       }
62 |  |
63 |  |
     }