### Question:
GenericURLConnection extends URLConnection { protected String getUsername() { String userInfo = this.m_url.getUserInfo(); if (userInfo != null) { if (userInfo.contains(USERINFO_DELIMITER)) { String[] userName = userInfo.split(USERINFO_DELIMITER); return userName[0]; } else { logger.warn("Only user name without password configured. Return user info: '{}'", userInfo); return userInfo; } } else { logger.warn("No credentials for URL connection configured."); return null; } } protected  GenericURLConnection(URL url);   }### Answer:
@Test public void testBaseUrlUsername() { m_genericURLConnection = new StubGenericURLConnection(m_baseUrl); assertNull("Test user URL", m_genericURLConnection.getUsername()); }
@Test public void testUserOnlyUrlUsername() { m_genericURLConnection = new StubGenericURLConnection(m_userOnlyUrl); assertEquals("Test user only URL", m_genericURLConnection.getUsername(), "user"); }
@Test public void testUserPassUrlUsername() { m_genericURLConnection = new StubGenericURLConnection(m_userPassUrl); assertEquals("Test user pass URL", m_genericURLConnection.getUsername(), "user"); }