package com.aperture_software.glados_wiki.tests; import com.aperture_software.glados_wiki.junit.MyTestcase; import com.aperture_software.glados_wiki.markdown.WikiLinkToMarkdownFunction; import com.google.common.base.Charsets; import junit.framework.Assert; import org.junit.Test; import java.io.UnsupportedEncodingException; import java.net.URLEncoder; /** * Created by jhyun on 14. 2. 7. */ public class WikiLinkToMarkdownTests extends MyTestcase { @Test public void t_01() throws UnsupportedEncodingException { final String e = URLEncoder.encode("한글 링크?", Charsets.UTF_8.name()).replaceAll("\\+", "%20"); final String s = "foobar \\[[not a link]] [[link1]] spam [[link2]] eggs. [[한글 링크?]]"; final String expected = "foobar [[not a link]] [link1](link1) spam [link2](link2) eggs. [한글 링크?](" + e + ")"; WikiLinkToMarkdownFunction f = new WikiLinkToMarkdownFunction(); String result = f.apply(s); Assert.assertEquals(result, expected); LOG.debug(result); } @Test public void t_02() { final String s = "[[foobar]] abc"; final String expected = "[foobar](foobar) abc"; WikiLinkToMarkdownFunction f = new WikiLinkToMarkdownFunction(); String result = f.apply(s); Assert.assertEquals(result, expected); LOG.debug(result); } }