@Test public final void testSetFromPropertyFile() { testGetInstance(); final ServerIdentity serverIdentity = ServerIdentity.getInstance(); final File file = ResourcesPrivateUtilTest.getInstance().getServerIdentityPropertiesFile(); if (file == null) { LOGGER.error(ResourcesPrivateUtilTest.CANNOT_FIND_RESOURCES_TEST_FILE); } Assume.assumeTrue(ResourcesPrivateUtilTest.CANNOT_FIND_RESOURCES_TEST_FILE, file != null); try { serverIdentity.setFromPropertyFile(file); } catch (final FileNotFoundException e) { LOGGER.error("Property file not found", e); fail("Should find the property file: " + e.getMessage()); } assertEquals("Name still the same", "test1", serverIdentity.getName()); assertEquals("Role still the same", "test2", serverIdentity.getRole()); assertEquals("Pid still the same", 1000, serverIdentity.getSiteId()); }
@JsonIgnore public final ServerIdentity setFromPropertyFile(File propertiesFile) throws FileNotFoundException { try { final Properties properties = PropertiesUtils.readProperties(propertiesFile); String svalue = properties.getProperty(MAP_KEYNAME.NAME.name()); if (svalue != null) { name = svalue; } svalue = properties.getProperty(MAP_KEYNAME.ROLE.name()); if (svalue != null) { role = svalue; } svalue = properties.getProperty(MAP_KEYNAME.SERVERID.name()); if (svalue != null) { setServerId(Integer.parseInt(svalue)); } svalue = properties.getProperty(MAP_KEYNAME.SITEID.name()); if (svalue != null) { setSiteId(Integer.parseInt(svalue)); } } catch (final IOException | NumberFormatException e) { SysErrLogger.FAKE_LOGGER.ignoreLog(e); } initializeCommentFormat(); return this; }
ServerIdentity implements ServerIdentityInterface { @JsonIgnore public final ServerIdentity setFromPropertyFile(File propertiesFile) throws FileNotFoundException { try { final Properties properties = PropertiesUtils.readProperties(propertiesFile); String svalue = properties.getProperty(MAP_KEYNAME.NAME.name()); if (svalue != null) { name = svalue; } svalue = properties.getProperty(MAP_KEYNAME.ROLE.name()); if (svalue != null) { role = svalue; } svalue = properties.getProperty(MAP_KEYNAME.SERVERID.name()); if (svalue != null) { setServerId(Integer.parseInt(svalue)); } svalue = properties.getProperty(MAP_KEYNAME.SITEID.name()); if (svalue != null) { setSiteId(Integer.parseInt(svalue)); } } catch (final IOException | NumberFormatException e) { SysErrLogger.FAKE_LOGGER.ignoreLog(e); } initializeCommentFormat(); return this; } }
ServerIdentity implements ServerIdentityInterface { @JsonIgnore public final ServerIdentity setFromPropertyFile(File propertiesFile) throws FileNotFoundException { try { final Properties properties = PropertiesUtils.readProperties(propertiesFile); String svalue = properties.getProperty(MAP_KEYNAME.NAME.name()); if (svalue != null) { name = svalue; } svalue = properties.getProperty(MAP_KEYNAME.ROLE.name()); if (svalue != null) { role = svalue; } svalue = properties.getProperty(MAP_KEYNAME.SERVERID.name()); if (svalue != null) { setServerId(Integer.parseInt(svalue)); } svalue = properties.getProperty(MAP_KEYNAME.SITEID.name()); if (svalue != null) { setSiteId(Integer.parseInt(svalue)); } } catch (final IOException | NumberFormatException e) { SysErrLogger.FAKE_LOGGER.ignoreLog(e); } initializeCommentFormat(); return this; } private  ServerIdentity(); }
ServerIdentity implements ServerIdentityInterface { @JsonIgnore public final ServerIdentity setFromPropertyFile(File propertiesFile) throws FileNotFoundException { try { final Properties properties = PropertiesUtils.readProperties(propertiesFile); String svalue = properties.getProperty(MAP_KEYNAME.NAME.name()); if (svalue != null) { name = svalue; } svalue = properties.getProperty(MAP_KEYNAME.ROLE.name()); if (svalue != null) { role = svalue; } svalue = properties.getProperty(MAP_KEYNAME.SERVERID.name()); if (svalue != null) { setServerId(Integer.parseInt(svalue)); } svalue = properties.getProperty(MAP_KEYNAME.SITEID.name()); if (svalue != null) { setSiteId(Integer.parseInt(svalue)); } } catch (final IOException | NumberFormatException e) { SysErrLogger.FAKE_LOGGER.ignoreLog(e); } initializeCommentFormat(); return this; } private  ServerIdentity(); @JsonIgnore @Override final String getLoggerMessagePrepend(); @JsonIgnore final String getJsonIdentity(); static final ServerIdentity getInstance(); @JsonIgnore final ServerIdentity setFromPropertyFile(File propertiesFile); @JsonIgnore final ServerIdentity setFromYamlFile(File yamlFile); @JsonIgnore final ServerIdentity setFromMap(Map<String, Object> map); @Override final String getName(); final ServerIdentity setName(String name); @Override final String getRole(); final ServerIdentity setRole(String role); @Override final int getGlobalPlatformId(); final ServerIdentity setServerId(int serverId); @Override final int getServerId(); @Override final int getSiteId(); final ServerIdentity setSiteId(int siteId); }
ServerIdentity implements ServerIdentityInterface { @JsonIgnore public final ServerIdentity setFromPropertyFile(File propertiesFile) throws FileNotFoundException { try { final Properties properties = PropertiesUtils.readProperties(propertiesFile); String svalue = properties.getProperty(MAP_KEYNAME.NAME.name()); if (svalue != null) { name = svalue; } svalue = properties.getProperty(MAP_KEYNAME.ROLE.name()); if (svalue != null) { role = svalue; } svalue = properties.getProperty(MAP_KEYNAME.SERVERID.name()); if (svalue != null) { setServerId(Integer.parseInt(svalue)); } svalue = properties.getProperty(MAP_KEYNAME.SITEID.name()); if (svalue != null) { setSiteId(Integer.parseInt(svalue)); } } catch (final IOException | NumberFormatException e) { SysErrLogger.FAKE_LOGGER.ignoreLog(e); } initializeCommentFormat(); return this; } private  ServerIdentity(); @JsonIgnore @Override final String getLoggerMessagePrepend(); @JsonIgnore final String getJsonIdentity(); static final ServerIdentity getInstance(); @JsonIgnore final ServerIdentity setFromPropertyFile(File propertiesFile); @JsonIgnore final ServerIdentity setFromYamlFile(File yamlFile); @JsonIgnore final ServerIdentity setFromMap(Map<String, Object> map); @Override final String getName(); final ServerIdentity setName(String name); @Override final String getRole(); final ServerIdentity setRole(String role); @Override final int getGlobalPlatformId(); final ServerIdentity setServerId(int serverId); @Override final int getServerId(); @Override final int getSiteId(); final ServerIdentity setSiteId(int siteId);  }