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

Revision 3663, 1.6 KB checked in by luiz-fernando, 13 years ago (diff)

Ticket #1402 - Nova versão dos casos de testes, agora implementados com WebDriver? (Selenium 2.0)

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
21        private Config() {
22                try {
23                        this.config = this
24                                        .load("br/gov/serpro/expresso/cte/common/config.properties");
25                        this.mensagens = this
26                                        .load("br/gov/serpro/expresso/cte/common/mensagens.properties");
27                        this.campos = this
28                                        .load("br/gov/serpro/expresso/cte/common/campos.properties");
29                        this.valores = this
30                                        .load("br/gov/serpro/expresso/cte/common/valores.properties");
31                } catch (Exception e) {
32                        e.printStackTrace();
33                        System.exit(0);
34                }
35        }
36
37        public static Config getInstance() {
38                return INSTANCE;
39        }
40
41        public String getConfig(String key) {
42                return this.config.getProperty(key);
43        }
44
45        public String getMensagem(String key) {
46                return this.mensagens.getProperty(key);
47        }
48
49        public String getCampo(String key) {
50                return this.campos.getProperty(key);
51        }
52
53        public String getCampo(String key, Object... args) {
54                return MessageFormat.format(getCampo(key), args);
55        }
56
57        public String getValor(String key) {
58                return this.valores.getProperty(key);
59        }
60
61        private Properties load(String propsName) throws Exception {
62                Properties props = new Properties();
63                URL url = ClassLoader.getSystemResource(propsName);
64                props.load(url.openStream());
65                return props;
66        }
67
68}
Note: See TracBrowser for help on using the repository browser.