### Question:
SystemServiceImpl extends ServiceSupport implements SystemService { public String getUrl() { String url = getHudson().getRootUrl(); if (url == null) { log.warn("Underlying Hudson root url is null; using DEFAULT_URL"); url = DEFAULT_URL; } else if (url.endsWith("/")) { url = url.substring(0, url.length() - 1); } return url; } @Inject  SystemServiceImpl(final SecurityService securityService); File getInstallationDirectory(); File getLogDirectory(); File getWorkingDirectory(); XmlFile getConfigFile(); String getUrl(); String getVersion(); InitMilestone getInitLevel(); boolean isQuietingDown(); boolean isTerminating(); String getSystemMessage(); void doQuietDown(); void doQuietDown(boolean toggle); void doCancelQuietDown(); void doReload(); void doRestart(boolean safely); void doRestart(); void doRestartSafely();  }### Answer:
@Test public void getUrlReturnsValidWhenHudsonInstanceExists() { assertEquals(SystemService.DEFAULT_URL, system.getUrl()); }
@Test public void getUrlFromHudson() { when(system.getUrl()).thenReturn("http: assertEquals("http: }
@Test public void getUrlFromHudsonWithSlashAtEnd() { when(system.getUrl()).thenReturn("http: assertEquals("http: }