diff --git a/src/test/java/ut/com/atlassian/plugins/confluence/MarkdownFromURLUnitTest.java b/src/test/java/ut/com/atlassian/plugins/confluence/MarkdownFromURLUnitTest.java
index aff79b5..fa299b2 100644
--- a/src/test/java/ut/com/atlassian/plugins/confluence/MarkdownFromURLUnitTest.java
+++ b/src/test/java/ut/com/atlassian/plugins/confluence/MarkdownFromURLUnitTest.java
@@ -1,5 +1,6 @@
package ut.com.atlassian.plugins.confluence;
+import org.junit.Before;
import org.junit.Ignore;
import org.junit.Test;
import org.junit.runner.RunWith;
@@ -37,11 +38,6 @@ public class MarkdownFromURLUnitTest {
@Test
public void testMarkdownRendering() throws MacroExecutionException, MalformedURLException {
- //Mock methods for pageBuilderService.assembler().resources().requireWebResource("com.atlassian.plugins.confluence.markdown.confluence-markdown-macro:highlightjs");
- Mockito.when(pageBuilderService.assembler()).thenReturn(webResourceAssembler);
- Mockito.when(webResourceAssembler.resources()).thenReturn(requiredResources);
- Mockito.when(requiredResources.requireWebResource("com.atlassian.plugins.confluence.markdown.confluence-markdown-macro:highlightjs")).thenReturn(requiredResources);
-
/*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 Italic
@@ -52,11 +48,6 @@ public class MarkdownFromURLUnitTest {
}
@Test
public void testErrorHandling() throws MacroExecutionException, MalformedURLException {
- //Mock methods for pageBuilderService.assembler().resources().requireWebResource("com.atlassian.plugins.confluence.markdown.confluence-markdown-macro:highlightjs");
- Mockito.when(pageBuilderService.assembler()).thenReturn(webResourceAssembler);
- Mockito.when(webResourceAssembler.resources()).thenReturn(requiredResources);
- Mockito.when(requiredResources.requireWebResource("com.atlassian.plugins.confluence.markdown.confluence-markdown-macro:highlightjs")).thenReturn(requiredResources);
-
/*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
@@ -87,4 +78,11 @@ public class MarkdownFromURLUnitTest {
String output3 = markdownMacro.execute(new HashMap(), input3, conversionContext);
assertThat(output3, is(not("")));
}
+ @Before
+ public void setup() {
+ //Mock methods for pageBuilderService.assembler().resources().requireWebResource("com.atlassian.plugins.confluence.markdown.confluence-markdown-macro:highlightjs");
+ Mockito.when(pageBuilderService.assembler()).thenReturn(webResourceAssembler);
+ Mockito.when(webResourceAssembler.resources()).thenReturn(requiredResources);
+ Mockito.when(requiredResources.requireWebResource("com.atlassian.plugins.confluence.markdown.confluence-markdown-macro:highlightjs")).thenReturn(requiredResources);
+ }
}
\ No newline at end of file
diff --git a/src/test/java/ut/com/atlassian/plugins/confluence/MarkdownUnitTest.java b/src/test/java/ut/com/atlassian/plugins/confluence/MarkdownUnitTest.java
index 81bfad7..191a422 100644
--- a/src/test/java/ut/com/atlassian/plugins/confluence/MarkdownUnitTest.java
+++ b/src/test/java/ut/com/atlassian/plugins/confluence/MarkdownUnitTest.java
@@ -1,5 +1,7 @@
package ut.com.atlassian.plugins.confluence;
+import org.junit.Before;
+import org.junit.Ignore;
import org.junit.Test;
import org.junit.runner.RunWith;
import static org.junit.Assert.assertTrue;
@@ -33,12 +35,6 @@ public class MarkdownUnitTest {
@Test
public void testMarkdownRendering() throws MacroExecutionException {
- //Mock methods for pageBuilderService.assembler().resources().requireWebResource("com.atlassian.plugins.confluence.markdown.confluence-markdown-macro:highlightjs");
- Mockito.when(pageBuilderService.assembler()).thenReturn(webResourceAssembler);
- Mockito.when(webResourceAssembler.resources()).thenReturn(requiredResources);
- Mockito.when(requiredResources.requireWebResource("com.atlassian.plugins.confluence.markdown.confluence-markdown-macro:highlightjs")).thenReturn(requiredResources);
-
-
/*Test that markdown is correctly rendered into HTML*/
// Run the macro using input text of *Italic*,
// then assert that *Italic* was correctly rendered into Italic
@@ -46,21 +42,24 @@ public class MarkdownUnitTest {
String output = markdownMacro.execute(new HashMap(), "*Italic*", conversionContext);
assertTrue(Pattern.matches("[\\S\\s]*Italic[\\S\\s]*", output)); //Uses [\S\s] (anything that is either whitespace or not whitespace) instead of . (any character) because . does not match newline characters.
}
-
@Test
public void testSyntaxHighlighting() throws MacroExecutionException {
+ /*Test that the correct JavaScript is returned for highlight.js to work*/
+ // Run the macro using input of a line of code in a code block,
+ // then assert that a block is returned.
+ // Intended only as a temporary test until I can program a better one
+ @SuppressWarnings({ "rawtypes", "unchecked" })
+ String output = markdownMacro.execute(new HashMap(), "`public class JavaClass {}`", conversionContext);
+ System.out.println(output);
+ assertTrue(Pattern.matches("[\\S\\s]*public class JavaClass \\{\\}<\\/code>[\\S\\s]*", output));
+ assertTrue(Pattern.matches("[\\S\\s]*