source: devel/testlink/automation2.0/src/test/java/br/gov/serpro/expresso/cte/common/Config.java @ 3745

Revision 3745, 1.8 KB checked in by luiz-fernando, 13 years ago (diff)

Ticket #1402 - Novos casos de teste implementados usando WebDriver?

Line 
1package br.gov.serpro.expresso.cte.common;
2
3import java.net.URL;
4import java.text.MessageFormat;
5import java.util.Properties;
6
7/**
8 * @author L.F.Estivalet (Serpro)
9 *
10 *         Created on Jan 4, 2011 at 3:53:14 PM
11 *
12 */
13public final class Config {
14        private static final Config INSTANCE = new Config();
15
16        private Properties config;
17        private Properties mensagens;
18        private Properties campos;
19        private Properties valores;
20        private Properties emailPreferences;
21
22        private Config() {
23                try {
24                        this.config = this
25                                        .load("br/gov/serpro/expresso/cte/common/config.properties");
26                        this.mensagens = this
27                                        .load("br/gov/serpro/expresso/cte/common/mensagens.properties");
28                        this.campos = this
29                                        .load("br/gov/serpro/expresso/cte/common/campos.properties");
30                        this.valores = this
31                                        .load("br/gov/serpro/expresso/cte/common/valores.properties");
32                        this.emailPreferences = this
33                                        .load("br/gov/serpro/expresso/cte/common/email.preferences.properties");
34                } catch (Exception e) {
35                        e.printStackTrace();
36                        System.exit(0);
37                }
38        }
39
40        public static Config getInstance() {
41                return INSTANCE;
42        }
43
44        public String getConfig(String key) {
45                return this.config.getProperty(key);
46        }
47
48        public String getMensagem(String key) {
49                return this.mensagens.getProperty(key);
50        }
51
52        public String getCampo(String key) {
53                return this.campos.getProperty(key);
54        }
55
56        public String getCampo(String key, Object... args) {
57                return MessageFormat.format(getCampo(key), args);
58        }
59
60        public String getValor(String key) {
61                return this.valores.getProperty(key);
62        }
63
64        public String getEmailPreference(String key) {
65                return this.emailPreferences.getProperty(key);
66        }
67
68        private Properties load(String propsName) throws Exception {
69                Properties props = new Properties();
70                URL url = ClassLoader.getSystemResource(propsName);
71                props.load(url.openStream());
72                return props;
73        }
74
75}
Note: See TracBrowser for help on using the repository browser.