EnvironmentUtil { public static String[] splitHostFQDN(String fqdn) { String[] result = new String[2]; if (StringUtil.isEmpty(fqdn)) { return result; } int pos = fqdn.indexOf('.'); if (pos >= 0) { result[0] = fqdn.substring(0, pos); if (pos+1 < fqdn.length()) { result[1] = fqdn.substring(pos+1); } } else { result[0] = fqdn; } return result; }  static Properties createCommonSystemProperties(); static String getHostFQDN(); static String[] splitHostFQDN(String fqdn); static final String HOST_NAME; static final String HOST_DOMAIN; static final String HOST_FQDN; }
@Test public void splitHostFQDN() throws Exception { String[] result = EnvironmentUtil.splitHostFQDN("joelauer-02"); Assert.assertEquals("joelauer-02", result[0]); Assert.assertEquals(null, result[1]); result = EnvironmentUtil.splitHostFQDN("joelauer-02."); Assert.assertEquals("joelauer-02", result[0]); Assert.assertEquals(null, result[1]); result = EnvironmentUtil.splitHostFQDN("joelauer-02.c"); Assert.assertEquals("joelauer-02", result[0]); Assert.assertEquals("c", result[1]); result = EnvironmentUtil.splitHostFQDN(null); Assert.assertEquals(null, result[0]); Assert.assertEquals(null, result[1]); result = EnvironmentUtil.splitHostFQDN(""); Assert.assertEquals(null, result[0]); Assert.assertEquals(null, result[1]); result = EnvironmentUtil.splitHostFQDN("."); Assert.assertEquals("", result[0]); Assert.assertEquals(null, result[1]); }