-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathProps.java
74 lines (61 loc) · 1.98 KB
/
Props.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
package com.fs.app.automation.Misc;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.util.Properties;
import java.util.ResourceBundle;
import static java.lang.System.out;
public class Props {
private static final Logger LOG = LoggerFactory.getLogger(Props.class);
private static Properties properties;
private static InputStream input = null;
/**
* Gets the key from messages.properties for a Site
*
* @param key
**/
public static String getMessage(String key) {
if ((key == null) || key.isEmpty()) {
return "";
} else {
return ResourceBundle.getBundle("props/messages").getString(key);
}
}
/**
* Gets the key from Config.properties related to chosen profile
*
* @param key
**/
public static String getProp(String key) {
if ((key == null) || key.isEmpty()) {
return "";
} else {
return properties.getProperty(key);
}
}
/**
* Gets the key from System properties defined
*
* @param key
**/
public static String getSystemProp(String key) {
if ((key == null) || key.isEmpty()) {
return "";
} else {
return System.getProperty(key);
}
}
public static void loadRunConfigProps() {
properties = new Properties();
//try (InputStream inputStream = Props.class.getResourceAsStream(properties.getProperty("/profiles/local/config.properties"))) {
try {
input = new FileInputStream("C:\\Users\\Vinay.Misra\\Automation\\fs-master\\src\\main\\resources\\profiles\\local\\config.properties");
properties.load(input);
properties.list(out);
} catch (IOException e) {
LOG.error(e.getMessage());
}
}
}