### Question:
AuthenticationTokenUtils { public static String extractHostname(final AuthenticationToken token) { if (isUsernamePasswordToken(token)) { final UsernamePasswordToken upt = (UsernamePasswordToken) token; return extractField(upt.getHost(), DEFAULT_HOSTNAME); } return DEFAULT_HOSTNAME; } private  AuthenticationTokenUtils(); static boolean isUsernamePasswordToken(final AuthenticationToken token); static String extractUsername(final AuthenticationToken token); static String extractHostname(final AuthenticationToken token); static String generateUnsuccessfulAuthenticationMessage(final AuthenticationToken token); static String generateSuccessfulAuthenticationMessage(final AuthenticationToken token);  }### Answer:
@Test public void testExtractHostname() throws Exception { final AuthenticationToken nullAuthenticationToken = null; assertEquals(AuthenticationTokenUtils.DEFAULT_HOSTNAME, AuthenticationTokenUtils.extractHostname(nullAuthenticationToken)); final AuthenticationToken notUsernamePasswordToken = new NotUsernamePasswordToken(); assertEquals(AuthenticationTokenUtils.DEFAULT_HOSTNAME, AuthenticationTokenUtils.extractHostname(notUsernamePasswordToken)); final UsernamePasswordToken nullHostname = new UsernamePasswordToken(); nullHostname.setHost(null); assertEquals(AuthenticationTokenUtils.DEFAULT_HOSTNAME, AuthenticationTokenUtils.extractHostname(nullHostname)); final UsernamePasswordToken positiveUsernamePasswordToken = new UsernamePasswordToken(); final String testUsername = "testHostname1"; positiveUsernamePasswordToken.setHost(testUsername); assertEquals(testUsername, AuthenticationTokenUtils.extractHostname(positiveUsernamePasswordToken)); }