source: devel/testlink/automation2.0/src/test/java/org/expressolivre/cte/common/Config.java @ 3799

Revision 3799, 1.7 KB checked in by luiz-fernando, 13 years ago (diff)

Ticket #1402 - Novos casos de teste para Salvar Email no Rascunho

Line 
1package org.expressolivre.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 valores;
19        private Properties emailPreferences;
20
21        private Config() {
22                try {
23                        this.config = this
24                                        .load("org/expressolivre/cte/common/config.properties");
25                        this.mensagens = this
26                                        .load("org/expressolivre/cte/common/mensagens.properties");
27                        this.valores = this
28                                        .load("org/expressolivre/cte/common/valores.properties");
29                        this.emailPreferences = this.load("org/expressolivre/cte/common/"
30                                        + getConfig("config.email"));
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 getMensagem(String key, Object... args) {
50                return MessageFormat.format(getMensagem(key), args);
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        public String getEmailPreference(String key) {
62                return this.emailPreferences.getProperty(key);
63        }
64
65        private Properties load(String propsName) throws Exception {
66                Properties props = new Properties();
67                URL url = ClassLoader.getSystemResource(propsName);
68                props.load(url.openStream());
69                return props;
70        }
71
72}
Note: See TracBrowser for help on using the repository browser.