From 38b3cc5a1332ad9871c4f7f189a23724d774a1ea Mon Sep 17 00:00:00 2001 From: simonbrandhof Date: Thu, 5 May 2011 15:19:52 +0200 Subject: [PATCH] Rename the class MarkdownEngine to Markdown --- .../{MarkdownEngine.java => Markdown.java} | 6 +- .../sonar/markdown/MarkdownEngineTest.java | 70 ------------------- .../java/org/sonar/markdown/MarkdownTest.java | 70 +++++++++++++++++++ .../java/org/sonar/server/ui/JRubyFacade.java | 4 +- 4 files changed, 75 insertions(+), 75 deletions(-) rename sonar-markdown/src/main/java/org/sonar/markdown/{MarkdownEngine.java => Markdown.java} (94%) delete mode 100644 sonar-markdown/src/test/java/org/sonar/markdown/MarkdownEngineTest.java create mode 100644 sonar-markdown/src/test/java/org/sonar/markdown/MarkdownTest.java diff --git a/sonar-markdown/src/main/java/org/sonar/markdown/MarkdownEngine.java b/sonar-markdown/src/main/java/org/sonar/markdown/Markdown.java similarity index 94% rename from sonar-markdown/src/main/java/org/sonar/markdown/MarkdownEngine.java rename to sonar-markdown/src/main/java/org/sonar/markdown/Markdown.java index 13c80ce39ff..9e7522cd692 100644 --- a/sonar-markdown/src/main/java/org/sonar/markdown/MarkdownEngine.java +++ b/sonar-markdown/src/main/java/org/sonar/markdown/Markdown.java @@ -29,11 +29,11 @@ import java.util.List; /** * Entry point of the Markdown library */ -public final class MarkdownEngine { +public final class Markdown { private ChannelDispatcher dispatcher; - private MarkdownEngine() { + private Markdown() { List markdownChannels = Arrays.asList( new HtmlUrlChannel(), new HtmlEndOfLineChannel(), @@ -58,6 +58,6 @@ public final class MarkdownEngine { } public static String convertToHtml(String input) { - return new MarkdownEngine().convert(input); + return new Markdown().convert(input); } } diff --git a/sonar-markdown/src/test/java/org/sonar/markdown/MarkdownEngineTest.java b/sonar-markdown/src/test/java/org/sonar/markdown/MarkdownEngineTest.java deleted file mode 100644 index b1979254828..00000000000 --- a/sonar-markdown/src/test/java/org/sonar/markdown/MarkdownEngineTest.java +++ /dev/null @@ -1,70 +0,0 @@ -/* - * Sonar, open source software quality management tool. - * Copyright (C) 2008-2011 SonarSource - * mailto:contact AT sonarsource DOT com - * - * Sonar is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * Sonar is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with Sonar; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02 - */ -package org.sonar.markdown; - -import static org.hamcrest.Matchers.is; -import static org.junit.Assert.assertThat; - -import org.junit.Test; - -public class MarkdownEngineTest { - - @Test - public void shouldDecorateUrl() { - assertThat(MarkdownEngine.convertToHtml("http://google.com"), - is("http://google.com")); - } - - @Test - public void shouldDecorateEndOfLine() { - assertThat(MarkdownEngine.convertToHtml("1\r2\r\n3\n"), is("1
2
3
")); - } - - @Test - public void shouldDecorateList() { - assertThat(MarkdownEngine.convertToHtml(" * one\r* two\r\n* three\n * \n *five"), - is("
  • one
  • \r
  • two
  • \r\n
  • three
  • \n
  • \n
*five")); - assertThat(MarkdownEngine.convertToHtml(" * one\r* two"), is("
  • one
  • \r
  • two
")); - } - - @Test - public void shouldDecorateCode() { - assertThat(MarkdownEngine.convertToHtml("This is a ``line of code``"), is("This is a line of code")); - assertThat(MarkdownEngine.convertToHtml("This is not a ``line of code"), is("This is not a ``line of code")); - } - - @Test - public void shouldEmphaseText() { - assertThat(MarkdownEngine.convertToHtml("This is *important*"), is("This is important")); - assertThat(MarkdownEngine.convertToHtml("This should not be * \n emphase"), is("This should not be *
emphase")); - assertThat(MarkdownEngine.convertToHtml("This is *very* very *important*"), is("This is very very important")); - assertThat(MarkdownEngine.convertToHtml("Not * emphase * because of whitespaces"), is("Not * emphase * because of whitespaces")); - assertThat(MarkdownEngine.convertToHtml("Not *emphase * because of whitespace"), is("Not *emphase * because of whitespace")); - assertThat(MarkdownEngine.convertToHtml("Not * emphase* because of whitespace"), is("Not * emphase* because of whitespace")); - assertThat(MarkdownEngine.convertToHtml("emphase*inside*word"), is("emphaseinsideword")); - assertThat(MarkdownEngine.convertToHtml("*Emphase many words*"), is("Emphase many words")); - } - - @Test - public void shouldNotChangeAnythingInTheText() { - assertThat(MarkdownEngine.convertToHtml("My text is $123 ''"), is("My text is $123 ''")); - } - -} diff --git a/sonar-markdown/src/test/java/org/sonar/markdown/MarkdownTest.java b/sonar-markdown/src/test/java/org/sonar/markdown/MarkdownTest.java new file mode 100644 index 00000000000..095263734db --- /dev/null +++ b/sonar-markdown/src/test/java/org/sonar/markdown/MarkdownTest.java @@ -0,0 +1,70 @@ +/* + * Sonar, open source software quality management tool. + * Copyright (C) 2008-2011 SonarSource + * mailto:contact AT sonarsource DOT com + * + * Sonar is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * Sonar is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with Sonar; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02 + */ +package org.sonar.markdown; + +import static org.hamcrest.Matchers.is; +import static org.junit.Assert.assertThat; + +import org.junit.Test; + +public class MarkdownTest { + + @Test + public void shouldDecorateUrl() { + assertThat(Markdown.convertToHtml("http://google.com"), + is("http://google.com")); + } + + @Test + public void shouldDecorateEndOfLine() { + assertThat(Markdown.convertToHtml("1\r2\r\n3\n"), is("1
2
3
")); + } + + @Test + public void shouldDecorateList() { + assertThat(Markdown.convertToHtml(" * one\r* two\r\n* three\n * \n *five"), + is("
  • one
  • \r
  • two
  • \r\n
  • three
  • \n
  • \n
*five")); + assertThat(Markdown.convertToHtml(" * one\r* two"), is("
  • one
  • \r
  • two
")); + } + + @Test + public void shouldDecorateCode() { + assertThat(Markdown.convertToHtml("This is a ``line of code``"), is("This is a line of code")); + assertThat(Markdown.convertToHtml("This is not a ``line of code"), is("This is not a ``line of code")); + } + + @Test + public void shouldEmphaseText() { + assertThat(Markdown.convertToHtml("This is *important*"), is("This is important")); + assertThat(Markdown.convertToHtml("This should not be * \n emphase"), is("This should not be *
emphase")); + assertThat(Markdown.convertToHtml("This is *very* very *important*"), is("This is very very important")); + assertThat(Markdown.convertToHtml("Not * emphase * because of whitespaces"), is("Not * emphase * because of whitespaces")); + assertThat(Markdown.convertToHtml("Not *emphase * because of whitespace"), is("Not *emphase * because of whitespace")); + assertThat(Markdown.convertToHtml("Not * emphase* because of whitespace"), is("Not * emphase* because of whitespace")); + assertThat(Markdown.convertToHtml("emphase*inside*word"), is("emphaseinsideword")); + assertThat(Markdown.convertToHtml("*Emphase many words*"), is("Emphase many words")); + } + + @Test + public void shouldNotChangeAnythingInTheText() { + assertThat(Markdown.convertToHtml("My text is $123 ''"), is("My text is $123 ''")); + } + +} diff --git a/sonar-server/src/main/java/org/sonar/server/ui/JRubyFacade.java b/sonar-server/src/main/java/org/sonar/server/ui/JRubyFacade.java index 7fae7b28124..dbadf5ac349 100644 --- a/sonar-server/src/main/java/org/sonar/server/ui/JRubyFacade.java +++ b/sonar-server/src/main/java/org/sonar/server/ui/JRubyFacade.java @@ -33,7 +33,7 @@ import org.sonar.api.web.*; import org.sonar.jpa.dao.AsyncMeasuresService; import org.sonar.jpa.dialect.Dialect; import org.sonar.jpa.session.DatabaseConnector; -import org.sonar.markdown.MarkdownEngine; +import org.sonar.markdown.Markdown; import org.sonar.server.configuration.Backup; import org.sonar.server.configuration.CoreConfiguration; import org.sonar.server.configuration.ProfilesManager; @@ -123,7 +123,7 @@ public final class JRubyFacade { } public static String markdownToHtml(String input) { - return MarkdownEngine.convertToHtml(input); + return Markdown.convertToHtml(input); } -- 2.39.5