PageRenderTime 26ms CodeModel.GetById 12ms RepoModel.GetById 0ms app.codeStats 0ms

/src/com/atlassian/uwc/converters/twiki/TWikLinkiPostProcessorTest.java

https://bitbucket.org/dodok1/uwc
Java | 144 lines | 125 code | 19 blank | 0 comment | 0 complexity | 38b44c9a48c99cbae4e90d99f434ca71 MD5 | raw file
  1. package com.atlassian.uwc.converters.twiki;
  2. import junit.framework.TestCase;
  3. import org.apache.log4j.Logger;
  4. import org.apache.log4j.PropertyConfigurator;
  5. public class TWikLinkiPostProcessorTest extends TestCase {
  6. TWikLinkiPostProcessor tester = null;
  7. Logger log = Logger.getLogger(this.getClass());
  8. protected void setUp() throws Exception {
  9. tester = new TWikLinkiPostProcessor();
  10. PropertyConfigurator.configure("log4j.properties");
  11. }
  12. public void testFixLinksWithSpaces() {
  13. String input, expected, actual;
  14. input = "UWC_TOKEN_OL|Testing Images From Other PageUWC_TOKEN_CL\n" +
  15. "with alias: UWC_TOKEN_OLalias|Testing Images From Other PageUWC_TOKEN_CL\n" +
  16. "\n" +
  17. "External:\n" +
  18. "http://www.google.com\n" +
  19. "laura.kolker@gmail.com\n" +
  20. "UWC_TOKEN_OLGoogle Alias 1|http://www.google.comUWC_TOKEN_CL\n" +
  21. "UWC_TOKEN_OLGoogle Alias 2|http://www.google.comUWC_TOKEN_CL\n" +
  22. "UWC_TOKEN_OLGoogle Alias 2|https://www.google.comUWC_TOKEN_CL\n" +
  23. "";
  24. expected = "UWC_TOKEN_OLTesting Images From Other Page|TestingImagesFromOtherPageUWC_TOKEN_CL\n" +
  25. "with alias: UWC_TOKEN_OLalias|TestingImagesFromOtherPageUWC_TOKEN_CL\n" +
  26. "\n" +
  27. "External:\n" +
  28. "http://www.google.com\n" +
  29. "laura.kolker@gmail.com\n" +
  30. "UWC_TOKEN_OLGoogle Alias 1|http://www.google.comUWC_TOKEN_CL\n" +
  31. "UWC_TOKEN_OLGoogle Alias 2|http://www.google.comUWC_TOKEN_CL\n" +
  32. "UWC_TOKEN_OLGoogle Alias 2|https://www.google.comUWC_TOKEN_CL\n" +
  33. "";
  34. actual = tester.fixLinksWithSpaces(input);
  35. assertNotNull(actual);
  36. assertEquals(expected, actual);
  37. }
  38. public void testIgnoreSpacekeyAndAttachments() {
  39. String input, expected, actual;
  40. input = "UWC_TOKEN_OL|uwctest:Pagename^cow.jpgUWC_TOKEN_CL\n" +
  41. "";
  42. expected = input;
  43. actual = tester.fixLinksWithSpaces(input);
  44. assertNotNull(actual);
  45. assertEquals(expected, actual);
  46. }
  47. public void testFindAllLinkParts_Simple() {
  48. String input, expected, actual;
  49. input = "UWC_TOKEN_OL|Foo BarUWC_TOKEN_CL\n" +
  50. "";
  51. expected = "UWC_TOKEN_OLFoo Bar|FooBarUWC_TOKEN_CL\n";
  52. actual = tester.fixLinksWithSpaces(input);
  53. assertNotNull(actual);
  54. assertEquals(expected, actual);
  55. }
  56. public void testFindAllLinkParts_Alias() {
  57. String input, expected, actual;
  58. input = "UWC_TOKEN_OLalias|Foo BarUWC_TOKEN_CL\n" +
  59. "";
  60. expected = "UWC_TOKEN_OLalias|FooBarUWC_TOKEN_CL\n";
  61. actual = tester.fixLinksWithSpaces(input);
  62. assertNotNull(actual);
  63. assertEquals(expected, actual);
  64. }
  65. public void testFindAllLinkParts_Spacekey() {
  66. String input, expected, actual;
  67. input = "UWC_TOKEN_OL|uwctest:Foo Bar2UWC_TOKEN_CL";
  68. expected = "UWC_TOKEN_OLFoo Bar2|uwctest:FooBar2UWC_TOKEN_CL";
  69. actual = tester.fixLinksWithSpaces(input);
  70. assertNotNull(actual);
  71. assertEquals(expected, actual);
  72. }
  73. public void testFindAllLinkParts_File() {
  74. String input, expected, actual;
  75. input = "UWC_TOKEN_OL|Foo Bar2^cow.jpgUWC_TOKEN_CL";
  76. expected = "UWC_TOKEN_OL|FooBar2^cow.jpgUWC_TOKEN_CL";
  77. actual = tester.fixLinksWithSpaces(input);
  78. assertNotNull(actual);
  79. assertEquals(expected, actual);
  80. }
  81. public void testFindAllLinkParts_both() {
  82. String input, expected, actual;
  83. input = "UWC_TOKEN_OL|uwctest:Foo Bar2^cow.jpgUWC_TOKEN_CL";
  84. expected = "UWC_TOKEN_OL|uwctest:FooBar2^cow.jpgUWC_TOKEN_CL";
  85. actual = tester.fixLinksWithSpaces(input);
  86. assertNotNull(actual);
  87. assertEquals(expected, actual);
  88. }
  89. public void testFindAllLinkParts_all() {
  90. String input, expected, actual;
  91. input = "UWC_TOKEN_OLalias|uwctest:Foo Bar2^cow.jpgUWC_TOKEN_CL";
  92. expected = "UWC_TOKEN_OLalias|uwctest:FooBar2^cow.jpgUWC_TOKEN_CL";
  93. actual = tester.fixLinksWithSpaces(input);
  94. assertNotNull(actual);
  95. assertEquals(expected, actual);
  96. }
  97. public void testFindAllLinkParts_justfile() {
  98. String input, expected, actual;
  99. input = "UWC_TOKEN_OL|^cow.jpgUWC_TOKEN_CL";
  100. expected = "UWC_TOKEN_OL|^cow.jpgUWC_TOKEN_CL";
  101. actual = tester.fixLinksWithSpaces(input);
  102. assertNotNull(actual);
  103. assertEquals(expected, actual);
  104. }
  105. public void testFindAllLinkParts_aliasfile() {
  106. String input, expected, actual;
  107. input = "UWC_TOKEN_OLalias|^cow.jpgUWC_TOKEN_CL";
  108. expected = "UWC_TOKEN_OLalias|^cow.jpgUWC_TOKEN_CL";
  109. actual = tester.fixLinksWithSpaces(input);
  110. assertNotNull(actual);
  111. assertEquals(expected, actual);
  112. }
  113. public void testFixLinksWithDollars() {
  114. String input, expected, actual;
  115. input = "UWC_TOKEN_OLDollar in Alias $10|http://www.google.comUWC_TOKEN_CL\n" +
  116. "UWC_TOKEN_OLGoogle Alias 2|$dollarinlinkUWC_TOKEN_CL\n" +
  117. "";
  118. expected = "UWC_TOKEN_OLDollar in Alias $10|http://www.google.comUWC_TOKEN_CL\n" +
  119. "UWC_TOKEN_OLGoogle Alias 2|dollarinlinkUWC_TOKEN_CL\n" +
  120. "";
  121. actual = tester.fixLinksWithSpaces(input);
  122. assertNotNull(actual);
  123. assertEquals(expected, actual);
  124. }
  125. }