Skip to content

Instantly share code, notes, and snippets.

@miguelaferreira
Created February 10, 2014 13:19
Show Gist options
  • Save miguelaferreira/8915777 to your computer and use it in GitHub Desktop.
Save miguelaferreira/8915777 to your computer and use it in GitHub Desktop.
Test for NfsUtils.url2Mount(String strUrl)
public class NfsUtilsTest {
@Test(expected = NullPointerException.class)
public void testUrl2MountWithExpectedWhenStringIsNull() throws Exception {
String urlStr = null;
NfsUtils.url2Mount(urlStr);
}
@Test
public void testUrl2MountWhenStringIsEmpty() throws Exception {
String urlStr = "";
String expected = "null:";
String actual = NfsUtils.url2Mount(urlStr);
assertEquals(expected, actual);
}
@Test
public void testUrl2MountWhenStringIsSomething() throws Exception {
String urlStr = "something";
String expected = "null:" + urlStr;
String actual = NfsUtils.url2Mount(urlStr);
assertEquals(expected, actual);
}
@Test
public void testUrl2MountWhenStringHasHostAndPath() throws Exception {
String urlStr = "host/path";
String expected = "null:" + urlStr;
String actual = NfsUtils.url2Mount(urlStr);
assertEquals(expected, actual);
}
@Test
public void testUrl2MountWhenStringHasProtocolHostAndPath() throws Exception {
String urlStr = "smb://host/path";
String expected = "host:/path";
String actual = NfsUtils.url2Mount(urlStr);
assertEquals(expected, actual);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment