### Question:
XmppStringUtils { public static String parseDomain(String jid) { if (jid == null) return null; int atIndex = jid.indexOf('@'); int slashIndex = jid.indexOf('/'); if (slashIndex >= 0) { if (slashIndex > atIndex) { return jid.substring(atIndex + 1, slashIndex); } else { return jid.substring(0, slashIndex); } } else { return jid.substring(atIndex + 1); } }  static String parseLocalpart(String jid); static String parseDomain(String jid); static String parseResource(String jid); static String parseBareJid(String jid); static boolean isFullJID(String jid); static boolean isBareJid(String jid); static String escapeLocalpart(String localpart); static String unescapeLocalpart(String localpart); static String completeJidFrom(CharSequence localpart, CharSequence domainpart); static String completeJidFrom(String localpart, String domainpart); static String completeJidFrom(CharSequence localpart, CharSequence domainpart, CharSequence resource); static String completeJidFrom(String localpart, String domainpart, String resource); static String generateKey(String element, String namespace);  }### Answer:
@Test public void parseDomainTest() { final String error = "Error parsing domain"; final String result = "yahoo.myjabber.net"; assertEquals(error, result, parseDomain("yahoo.myjabber.net")); assertEquals(error, result, parseDomain("yahoo.myjabber.net/registred")); assertEquals(error, result, parseDomain("user@yahoo.myjabber.net/registred")); assertEquals(error, result, parseDomain("user@yahoo.myjabber.net")); }
@Test public void parseDomainCornerCases() { assertEquals("", parseDomain("/foo@")); assertEquals("", parseDomain("localpart@")); assertEquals("example.org", parseDomain("example.org/foo@")); assertEquals("foo.jxmpp.org", parseDomain("foo.jxmpp.org/resOne@resTwo")); }