initial code;
authoraxelcl <axelcl>
Sun, 13 Feb 2005 18:23:59 +0000 (18:23 +0000)
committeraxelcl <axelcl>
Sun, 13 Feb 2005 18:23:59 +0000 (18:23 +0000)
junit tests and code generation

archive/org.plog4u.wiki.test/.classpath [new file with mode: 0644]
archive/org.plog4u.wiki.test/.project [new file with mode: 0644]
archive/org.plog4u.wiki.test/lib/junit.jar [new file with mode: 0644]
archive/org.plog4u.wiki.test/src/org/plog4u/wiki/test/filter/BoldFilterTest.java [new file with mode: 0644]
archive/org.plog4u.wiki.test/src/org/plog4u/wiki/test/filter/FilterTestSupport.java [new file with mode: 0644]
archive/org.plog4u.wiki.test/src/org/plog4u/wiki/test/filter/HRBRTest.java [new file with mode: 0644]
archive/org.plog4u.wiki.test/src/org/plog4u/wiki/test/filter/HeaderFilterTest.java [new file with mode: 0644]
archive/org.plog4u.wiki.test/src/org/plog4u/wiki/test/filter/ItalicFilterTest.java [new file with mode: 0644]

diff --git a/archive/org.plog4u.wiki.test/.classpath b/archive/org.plog4u.wiki.test/.classpath
new file mode 100644 (file)
index 0000000..b74c046
--- /dev/null
@@ -0,0 +1,10 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+       <classpathentry kind="src" path="src"/>
+       <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
+       <classpathentry kind="lib" path="lib/junit.jar"/>
+       <classpathentry kind="src" path="/org.plog4u.wiki"/>
+       <classpathentry kind="lib" path="/net.sourceforge.phpeclipse.wiki/lib/radeox.jar"/>
+       <classpathentry kind="lib" path="/net.sourceforge.phpeclipse.wiki/lib/commons-logging.jar"/>
+       <classpathentry kind="output" path="bin"/>
+</classpath>
diff --git a/archive/org.plog4u.wiki.test/.project b/archive/org.plog4u.wiki.test/.project
new file mode 100644 (file)
index 0000000..d32116c
--- /dev/null
@@ -0,0 +1,17 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+       <name>org.plog4u.wiki.test</name>
+       <comment></comment>
+       <projects>
+       </projects>
+       <buildSpec>
+               <buildCommand>
+                       <name>org.eclipse.jdt.core.javabuilder</name>
+                       <arguments>
+                       </arguments>
+               </buildCommand>
+       </buildSpec>
+       <natures>
+               <nature>org.eclipse.jdt.core.javanature</nature>
+       </natures>
+</projectDescription>
diff --git a/archive/org.plog4u.wiki.test/lib/junit.jar b/archive/org.plog4u.wiki.test/lib/junit.jar
new file mode 100644 (file)
index 0000000..674d71e
Binary files /dev/null and b/archive/org.plog4u.wiki.test/lib/junit.jar differ
diff --git a/archive/org.plog4u.wiki.test/src/org/plog4u/wiki/test/filter/BoldFilterTest.java b/archive/org.plog4u.wiki.test/src/org/plog4u/wiki/test/filter/BoldFilterTest.java
new file mode 100644 (file)
index 0000000..82ac4f4
--- /dev/null
@@ -0,0 +1,39 @@
+package org.plog4u.wiki.test.filter;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+
+import org.plog4u.wiki.filter.WikipediaFilter;
+
+public class BoldFilterTest extends FilterTestSupport {
+  public BoldFilterTest(String name) {
+    super(name);
+  }
+
+  protected void setUp() throws Exception {
+    filter = new WikipediaFilter();
+    super.setUp();
+  }
+
+  public static Test suite() {
+    return new TestSuite(BoldFilterTest.class);
+  }
+
+  public void testBold() {
+    assertEquals("<strong>Text</strong>", filter.filter("'''Text'''", context));
+  }
+
+  public void testBold2() {
+    //  close tags if user forget it:
+    assertEquals("<strong>Text<em></em></strong>", filter.filter("'''Text''", context));
+  }
+
+  public void testBoldItalicStack() {
+    // close tags if user forget it:
+    assertEquals("<b>Text<i>hallo</i></b>", filter.filter("<b>Text<i>hallo", context));
+  }
+
+  public void testBoldWithPunctuation() {
+    assertEquals("<strong>Text</strong>:", filter.filter("'''Text''':", context));
+  }
+}
\ No newline at end of file
diff --git a/archive/org.plog4u.wiki.test/src/org/plog4u/wiki/test/filter/FilterTestSupport.java b/archive/org.plog4u.wiki.test/src/org/plog4u/wiki/test/filter/FilterTestSupport.java
new file mode 100644 (file)
index 0000000..abb21a0
--- /dev/null
@@ -0,0 +1,31 @@
+package org.plog4u.wiki.test.filter;
+
+import junit.framework.TestCase;
+import org.radeox.engine.context.BaseInitialRenderContext;
+import org.radeox.engine.context.BaseRenderContext;
+import org.radeox.filter.Filter;
+import org.radeox.filter.context.BaseFilterContext;
+import org.radeox.filter.context.FilterContext;
+
+/**
+ * Support class for defning JUnit FilterTests.
+ *
+ */
+
+public class FilterTestSupport extends TestCase {
+  protected Filter filter;
+  protected FilterContext context;
+
+  public FilterTestSupport(String s) {
+    super(s);
+    context = new BaseFilterContext();
+    context.setRenderContext(new BaseRenderContext());
+  }
+
+  protected void setUp() throws Exception {
+    super.setUp();
+    if (null != filter) {
+      filter.setInitialContext(new BaseInitialRenderContext());
+    }
+  }
+}
diff --git a/archive/org.plog4u.wiki.test/src/org/plog4u/wiki/test/filter/HRBRTest.java b/archive/org.plog4u.wiki.test/src/org/plog4u/wiki/test/filter/HRBRTest.java
new file mode 100644 (file)
index 0000000..3cc70bd
--- /dev/null
@@ -0,0 +1,40 @@
+package org.plog4u.wiki.test.filter;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+
+import org.plog4u.wiki.filter.WikipediaFilter;
+
+public class HRBRTest extends FilterTestSupport {
+  public HRBRTest(String name) {
+    super(name);
+  }
+
+  protected void setUp() throws Exception {
+    filter = new WikipediaFilter();
+    super.setUp();
+  }
+
+  public static Test suite() {
+    return new TestSuite(HRBRTest.class);
+  }
+  
+  public void testNewline0() {
+    assertEquals("&lt;br ===", filter.filter("<br ===", context));
+  }
+  
+  public void testNewline1() {
+    assertEquals("<br />", filter.filter("<br>", context));
+  }
+  public void testNewline2() {
+    assertEquals("<br />", filter.filter("<br/>", context));
+  }
+  public void testNewline3() {
+    assertEquals("&lt; br &gt;", filter.filter("< br >", context));
+  }
+  public void testNewline4() {
+    assertEquals("&lt; br / &gt;", filter.filter("< br / >", context));
+  }
+
+
+}
\ No newline at end of file
diff --git a/archive/org.plog4u.wiki.test/src/org/plog4u/wiki/test/filter/HeaderFilterTest.java b/archive/org.plog4u.wiki.test/src/org/plog4u/wiki/test/filter/HeaderFilterTest.java
new file mode 100644 (file)
index 0000000..adbdfa7
--- /dev/null
@@ -0,0 +1,29 @@
+package org.plog4u.wiki.test.filter;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+
+import org.plog4u.wiki.filter.WikipediaFilter;
+public class HeaderFilterTest extends FilterTestSupport {
+  public HeaderFilterTest(String name) {
+    super(name);
+  }
+
+  protected void setUp() throws Exception {
+    filter = new WikipediaFilter();
+    super.setUp();
+  }
+
+  public static Test suite() {
+    return new TestSuite(HeaderFilterTest.class);
+  }
+
+  public void testH2() {
+    assertEquals("<h2><a name=\"aText\">Text</a></h2>", filter.filter("==Text==", context));
+  }
+
+  public void testH2WithPunctuation() {
+    assertEquals("<h2><a name=\"aText\">Text</a></h2>:", filter.filter("==Text==:", context));
+  }
+}
diff --git a/archive/org.plog4u.wiki.test/src/org/plog4u/wiki/test/filter/ItalicFilterTest.java b/archive/org.plog4u.wiki.test/src/org/plog4u/wiki/test/filter/ItalicFilterTest.java
new file mode 100644 (file)
index 0000000..b2bca89
--- /dev/null
@@ -0,0 +1,29 @@
+package org.plog4u.wiki.test.filter;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+
+import org.plog4u.wiki.filter.WikipediaFilter;
+public class ItalicFilterTest extends FilterTestSupport {
+  public ItalicFilterTest(String name) {
+    super(name);
+  }
+
+  protected void setUp() throws Exception {
+    filter = new WikipediaFilter();
+    super.setUp();
+  }
+
+  public static Test suite() {
+    return new TestSuite(ItalicFilterTest.class);
+  }
+
+  public void testItalic() {
+    assertEquals("<em>Text</em>", filter.filter("''Text''", context));
+  }
+
+  public void testItalicWithPunctuation() {
+    assertEquals("<em>Text</em>:", filter.filter("''Text'':", context));
+  }
+}