public void testFixUnderscores_StringFile() { String input, expected, actual; LinkParser parser = new LinkParser(); File file = new File( "sampleData/mindtouch/junit_resources/links/21_Mindtouch_subpages/" + "39_Sandbox_subpages/42_TestComments.xml"); input = "Test_Comments"; expected = "Test Comments"; actual = parser.fixUnderscores(input, file); assertNotNull(actual); assertEquals(expected, actual); file = new File( "sampleData/mindtouch/junit_resources/links/21_Mindtouch_subpages/" + "39_Sandbox_subpages/54_TestZ_underscores.xml"); input = "Test_Z_underscores"; expected = "Test Z_underscores"; actual = parser.fixUnderscores(input, file); assertNotNull(actual); assertEquals(expected, actual); file = new File( "sampleData/mindtouch/junit_resources/links/21_Mindtouch_subpages/" + "39_Sandbox_subpages/49_TestXYZBadChars.xml"); input = "Test_XYZ%3b_Bad_Chars"; expected = "Test XYZ%3b Bad Chars"; actual = parser.fixUnderscores(input, file); assertNotNull(actual); assertEquals(expected, actual); }
public void testFixUnderscore() { String input, href, expected, actual; LinkParser parser = new LinkParser(); Page page = new Page(null); // no exportdir input = "Test_Comments"; href = "http://192.168.2.247/Sandbox/Test_Comments"; expected = "Test_Comments"; actual = parser.fixUnderscores(input, href, page); assertNotNull(actual); assertEquals(expected, actual); Properties props = new Properties(); props.setProperty("exportdir", "sampleData/mindtouch/junit_resources/links"); parser.setProperties(props); input = "Sandbox"; href = "http://192.168.2.247/Sandbox"; expected = "Sandbox"; actual = parser.fixUnderscores(input, href, page); assertNotNull(actual); assertEquals(expected, actual); input = "Test_Comments"; href = "http://192.168.2.247/Sandbox/Test_Comments"; expected = "Test Comments"; actual = parser.fixUnderscores(input, href, page); assertNotNull(actual); assertEquals(expected, actual); input = "Test_Z_underscores"; href = "http://192.168.2.247/Sandbox/Test_Z_underscores"; expected = "Test Z_underscores"; actual = parser.fixUnderscores(input, href, page); assertNotNull(actual); assertEquals(expected, actual); input = "foo_bar"; // doesn't exist href = "http://192.168.2.247/Sandbox/foo_bar"; expected = input; actual = parser.fixUnderscores(input, href, page); assertNotNull(actual); assertEquals(expected, actual); input = "Test_XYZ%3b_Bad_Chars"; // bad chars href = "http://192.168.2.247/Sandbox/Test_XYZ%3b_Bad_Chars"; expected = "Test XYZ%3b Bad Chars"; // fixed by illegal page handling framework actual = parser.fixUnderscores(input, href, page); assertNotNull(actual); assertEquals(expected, actual); // bad exportdir props.setProperty("exportdir", "sampleData/mindtouch/junit_resources/linkity"); parser.setProperties(props); input = "Test_Comments"; href = "http://192.168.2.247/Sandbox/Test_Comments"; expected = "Test_Comments"; actual = parser.fixUnderscores(input, href, page); assertNotNull(actual); assertEquals(expected, actual); }