@Test public void testConfig() throws EtiqetException { Config config = new Config(); assertTrue(config.isEmpty()); String configPath = System.getProperty("user.dir") + "/src/test/resources/properties/test.properties"; config = PropertiesFileReader.loadPropertiesFile(configPath); assertFalse(config.isEmpty()); assertEquals(12, config.getKeySet().size()); assertEquals("config.properties", config.getString("fix.config.file.path")); assertEquals("server.cfg", config.getString("fix.server.config.file.path")); assertEquals("database.properties", config.getString("shell.database.properties.path")); assertEquals("remoteshell.properties", config.getString("shell.remoteshell.properties.path")); assertEquals("protocolConfig.properties", config.getString("config.protocol.file.path")); assertTrue(config.getBoolean("test.boolean.true")); assertTrue(config.getBoolean("test.boolean.convert.true")); assertFalse(config.getBoolean("test.boolean.false")); assertFalse(config.getBoolean("test.boolean.convert.false")); assertEquals(Integer.valueOf(20), config.getInteger("test.int")); assertEquals(Long.valueOf(20L), config.getLong("test.int")); assertEquals(Double.valueOf(25.3), config.getDouble("test.double")); assertEquals("etiqet-core/src/test/resources/properties/testConfig.properties", config.getString("config.client.file.path")); assertEquals(Config.DEFAULT_STRING, config.getString("property.does.not.exist")); assertEquals(Config.DEFAULT_DOUBLE, config.getDouble("property.does.not.exist")); assertEquals(Config.DEFAULT_INTEGER, config.getInteger("property.does.not.exist")); assertEquals(Config.DEFAULT_LONG, config.getLong("property.does.not.exist")); assertEquals(Config.DEFAULT_DOUBLE, config.getDouble("fix.config.file.path")); assertEquals(Config.DEFAULT_INTEGER, config.getInteger("fix.config.file.path")); assertEquals(Config.DEFAULT_LONG, config.getLong("fix.config.file.path")); }
public Config() { properties = new HashMap<>(); }
Config { public Config() { properties = new HashMap<>(); } }
Config { public Config() { properties = new HashMap<>(); } Config(); }
Config { public Config() { properties = new HashMap<>(); } Config(); @Override boolean equals(Object obj); void setProperties(Map<String, String> properties); void addProperty(String key, Object value); Collection<String> getKeySet(); boolean isEmpty(); String getString(String key); Integer getInteger(String key); Long getLong(String key); Double getDouble(String key); boolean getBoolean(String key); }
Config { public Config() { properties = new HashMap<>(); } Config(); @Override boolean equals(Object obj); void setProperties(Map<String, String> properties); void addProperty(String key, Object value); Collection<String> getKeySet(); boolean isEmpty(); String getString(String key); Integer getInteger(String key); Long getLong(String key); Double getDouble(String key); boolean getBoolean(String key); static final String DEFAULT_STRING; static final Integer DEFAULT_INTEGER; static final Long DEFAULT_LONG; static final Double DEFAULT_DOUBLE; }