Updated unit test for error handling to be more specific, deleted unnecessary comments
This commit is contained in:
@@ -42,8 +42,6 @@ public class MarkdownFromURLUnitTest {
|
||||
@Test
|
||||
public void testMarkdownRendering() throws MacroExecutionException, MalformedURLException {
|
||||
/*Test that markdown is correctly retrieved from a URL and rendered into HTML*/
|
||||
// Run the macro using a URL that points to a file containing test markdown,
|
||||
// then assert that *Italic* was correctly rendered into <em>Italic</em>
|
||||
String file = new File("src/test/resources/testMarkdown.md").toURI().toURL().toString();
|
||||
@SuppressWarnings({ "rawtypes", "unchecked" })
|
||||
String output = markdownMacro.execute(new HashMap(), file, conversionContext);
|
||||
@@ -52,34 +50,26 @@ public class MarkdownFromURLUnitTest {
|
||||
@Test
|
||||
public void testErrorHandling() throws MacroExecutionException, MalformedURLException {
|
||||
/*Test error handling of nonexistent URLs*/
|
||||
// Run the macro using a URL pointing to a file that does not exist,
|
||||
// then assert that the output of the macro is not an empty string
|
||||
// i.e. that it returned an error message instead of simply breaking.
|
||||
String input1 = new File("src/test/resources/nonexistentfile.md").toURI().toURL().toString();
|
||||
@SuppressWarnings({ "rawtypes", "unchecked" })
|
||||
String output1 = markdownMacro.execute(new HashMap(), input1, conversionContext);
|
||||
assertThat(output1, is(not("")));
|
||||
assertTrue(output1.contains("URL does not exist"));
|
||||
assertTrue(output1.contains(input1));
|
||||
|
||||
|
||||
/*Test error handling of invalid URLs*/
|
||||
// Run the macro using a string that is not a URL,
|
||||
// then assert that the output of the macro is not an empty string
|
||||
// i.e. that it returned an error message instead of simply breaking.
|
||||
String input2 = "not_a_URL";
|
||||
@SuppressWarnings({ "rawtypes", "unchecked" })
|
||||
String output2 = markdownMacro.execute(new HashMap(), input2, conversionContext);
|
||||
assertThat(output2, is(not("")));
|
||||
assertTrue(output2.contains("Invalid URL"));
|
||||
|
||||
|
||||
/*Test error handling of importing from a private Bitbucket repository*/
|
||||
// Run the macro using a URL pointing to a file that mimics the text
|
||||
// returned when trying to import from a private Bitbucket repository,
|
||||
// then assert that the output of the macro is not an empty string
|
||||
// i.e. that it returned an error message instead of simply breaking.
|
||||
String input3 = new File("src/test/resources/testPrivateBitbucket.html").toURI().toURL().toString();
|
||||
@SuppressWarnings({ "rawtypes", "unchecked" })
|
||||
String output3 = markdownMacro.execute(new HashMap(), input3, conversionContext);
|
||||
assertThat(output3, is(not("")));
|
||||
assertTrue(output3.contains("Importing from private Bitbucket repositories is not supported"));
|
||||
assertTrue(output3.contains(input3));
|
||||
}
|
||||
@Test
|
||||
public void testSyntaxHighlighting() throws MacroExecutionException {
|
||||
|
||||
@@ -38,8 +38,6 @@ public class MarkdownUnitTest {
|
||||
@Test
|
||||
public void testMarkdownRendering() throws MacroExecutionException {
|
||||
/*Test that markdown is correctly rendered into HTML*/
|
||||
// Run the macro using input text of *Italic*,
|
||||
// then assert that *Italic* was correctly rendered into <em>Italic</em>
|
||||
@SuppressWarnings({ "rawtypes", "unchecked" })
|
||||
String output = markdownMacro.execute(new HashMap(), "*Italic*", conversionContext);
|
||||
assertTrue(output.contains("<em>Italic</em>"));
|
||||
|
||||
Reference in New Issue
Block a user