You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by lo...@apache.org on 2010/06/11 19:19:30 UTC
svn commit: r953779 - in /myfaces/tobago/trunk:
tobago-core/src/test/java/org/apache/myfaces/tobago/model/
tobago-core/src/test/java/org/apache/myfaces/tobago/renderkit/
tobago-core/src/test/java/org/apache/myfaces/tobago/util/
tobago-core/src/test/jav...
Author: lofwyr
Date: Fri Jun 11 17:19:29 2010
New Revision: 953779
URL: http://svn.apache.org/viewvc?rev=953779&view=rev
Log:
clean up testing classes
- using JUnit 4 annotations instead of TestCase base class
Modified:
myfaces/tobago/trunk/tobago-core/src/test/java/org/apache/myfaces/tobago/model/MixedTreeModelUnitTest.java
myfaces/tobago/trunk/tobago-core/src/test/java/org/apache/myfaces/tobago/model/NodePathUnitTest.java
myfaces/tobago/trunk/tobago-core/src/test/java/org/apache/myfaces/tobago/model/NodeUnitTest.java
myfaces/tobago/trunk/tobago-core/src/test/java/org/apache/myfaces/tobago/renderkit/LabelWithAccessKeyUnitTest.java
myfaces/tobago/trunk/tobago-core/src/test/java/org/apache/myfaces/tobago/util/HtmlWriterUtilsUnitTest.java
myfaces/tobago/trunk/tobago-core/src/test/java/org/apache/myfaces/tobago/util/LayoutInfoUnitTest.java
myfaces/tobago/trunk/tobago-core/src/test/java/org/apache/myfaces/tobago/util/RangeParserUnitTest.java
myfaces/tobago/trunk/tobago-core/src/test/java/org/apache/myfaces/tobago/webapp/TobagoMultipartFormdataRequestUnitTest.java
myfaces/tobago/trunk/tobago-core/src/test/java/org/apache/myfaces/tobago/webapp/TobagoResponseWriterUnitTest.java
myfaces/tobago/trunk/tobago-theme/tobago-theme-scarborough/src/test/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/AbstractJavaScriptTestBase.java
myfaces/tobago/trunk/tobago-theme/tobago-theme-scarborough/src/test/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/TreeNodeRendererUnitTest.java
Modified: myfaces/tobago/trunk/tobago-core/src/test/java/org/apache/myfaces/tobago/model/MixedTreeModelUnitTest.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-core/src/test/java/org/apache/myfaces/tobago/model/MixedTreeModelUnitTest.java?rev=953779&r1=953778&r2=953779&view=diff
==============================================================================
--- myfaces/tobago/trunk/tobago-core/src/test/java/org/apache/myfaces/tobago/model/MixedTreeModelUnitTest.java (original)
+++ myfaces/tobago/trunk/tobago-core/src/test/java/org/apache/myfaces/tobago/model/MixedTreeModelUnitTest.java Fri Jun 11 17:19:29 2010
@@ -17,14 +17,16 @@ package org.apache.myfaces.tobago.model;
* limitations under the License.
*/
-import junit.framework.TestCase;
import org.apache.myfaces.tobago.component.UITreeData;
import org.apache.myfaces.tobago.component.UITreeNode;
+import org.junit.Assert;
+import org.junit.Test;
import javax.swing.tree.DefaultMutableTreeNode;
-public class MixedTreeModelUnitTest extends TestCase {
+public class MixedTreeModelUnitTest {
+ @Test
public void testLifecycleSmall() {
MixedTreeModel model = new MixedTreeModel();
@@ -35,10 +37,11 @@ public class MixedTreeModelUnitTest exte
model.endBuildNode(n1);
model.onEncodeBegin();
- assertEquals(new TreePath(0), model.getPath());
+ Assert.assertEquals(new TreePath(0), model.getPath());
model.onEncodeEnd();
}
+ @Test
public void testLifecycleStatic() {
MixedTreeModel model = new MixedTreeModel();
@@ -62,6 +65,7 @@ public class MixedTreeModelUnitTest exte
model.onEncodeEnd();
}
+ @Test
public void testLifecycleFromModel() {
MixedTreeModel model = new MixedTreeModel();
@@ -83,12 +87,12 @@ public class MixedTreeModelUnitTest exte
// model.endBuildNodeData(data);
model.onEncodeBegin();
- assertEquals(new TreePath(0), model.getPath());
+ Assert.assertEquals(new TreePath(0), model.getPath());
model.onEncodeBegin();
- assertEquals(new TreePath(0, 0), model.getPath());
+ Assert.assertEquals(new TreePath(0, 0), model.getPath());
model.onEncodeEnd();
model.onEncodeBegin();
- assertEquals(new TreePath(0, 1), model.getPath());
+ Assert.assertEquals(new TreePath(0, 1), model.getPath());
model.onEncodeEnd();
model.onEncodeEnd();
}
@@ -106,6 +110,7 @@ public class MixedTreeModelUnitTest exte
* * |
* * +--o Data Sub Sub Node 3 (0,1,1,0)
*/
+ @Test
public void testLifecycleMixed() {
MixedTreeModel model = new MixedTreeModel();
@@ -137,27 +142,27 @@ public class MixedTreeModelUnitTest exte
model.endBuildNode(root);
model.onEncodeBegin(); // root
- assertEquals(new TreePath(0), model.getPath());
+ Assert.assertEquals(new TreePath(0), model.getPath());
model.onEncodeBegin(); // individual
- assertEquals(new TreePath(0, 0), model.getPath());
+ Assert.assertEquals(new TreePath(0, 0), model.getPath());
model.onEncodeEnd(); // individual
- assertEquals(new TreePath(0), model.getPath());
+ Assert.assertEquals(new TreePath(0), model.getPath());
model.onEncodeBegin(); // data root node
- assertEquals(new TreePath(0, 1), model.getPath());
+ Assert.assertEquals(new TreePath(0, 1), model.getPath());
model.onEncodeBegin(); // data sub node 1
- assertEquals(new TreePath(0, 1, 0), model.getPath());
+ Assert.assertEquals(new TreePath(0, 1, 0), model.getPath());
model.onEncodeEnd(); // data sub node 1
- assertEquals(new TreePath(0, 1), model.getPath());
+ Assert.assertEquals(new TreePath(0, 1), model.getPath());
model.onEncodeBegin(); // data sub node 2
- assertEquals(new TreePath(0, 1, 1), model.getPath());
+ Assert.assertEquals(new TreePath(0, 1, 1), model.getPath());
model.onEncodeBegin(); // data sub node 3
- assertEquals(new TreePath(0, 1, 1, 0), model.getPath());
+ Assert.assertEquals(new TreePath(0, 1, 1, 0), model.getPath());
model.onEncodeEnd(); // data sub node 3
- assertEquals(new TreePath(0, 1, 1), model.getPath());
+ Assert.assertEquals(new TreePath(0, 1, 1), model.getPath());
model.onEncodeEnd(); // data sub node 2
- assertEquals(new TreePath(0, 1), model.getPath());
+ Assert.assertEquals(new TreePath(0, 1), model.getPath());
model.onEncodeEnd(); // data root node
- assertEquals(new TreePath(0), model.getPath());
+ Assert.assertEquals(new TreePath(0), model.getPath());
model.onEncodeEnd(); // root
}
Modified: myfaces/tobago/trunk/tobago-core/src/test/java/org/apache/myfaces/tobago/model/NodePathUnitTest.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-core/src/test/java/org/apache/myfaces/tobago/model/NodePathUnitTest.java?rev=953779&r1=953778&r2=953779&view=diff
==============================================================================
--- myfaces/tobago/trunk/tobago-core/src/test/java/org/apache/myfaces/tobago/model/NodePathUnitTest.java (original)
+++ myfaces/tobago/trunk/tobago-core/src/test/java/org/apache/myfaces/tobago/model/NodePathUnitTest.java Fri Jun 11 17:19:29 2010
@@ -17,27 +17,31 @@ package org.apache.myfaces.tobago.model;
* limitations under the License.
*/
-import junit.framework.TestCase;
+import org.junit.Assert;
+import org.junit.Test;
import javax.swing.tree.DefaultMutableTreeNode;
import java.util.Arrays;
-public class NodePathUnitTest extends TestCase {
+public class NodePathUnitTest {
+ @Test
public void testGetPath() {
TreePath nodePath = new TreePath(0, 1, 2);
- assertTrue(Arrays.equals(new int[]{0, 1, 2}, nodePath.getPath()));
+ Assert.assertTrue(Arrays.equals(new int[]{0, 1, 2}, nodePath.getPath()));
TreePath nodePath2 = new TreePath(nodePath, 3);
- assertTrue(Arrays.equals(new int[]{0, 1, 2, 3}, nodePath2.getPath()));
+ Assert.assertTrue(Arrays.equals(new int[]{0, 1, 2, 3}, nodePath2.getPath()));
}
+ @Test
public void testGetPathString() {
TreePath nodePath = new TreePath(0, 1, 2);
- assertEquals("_0_1_2", nodePath.getPathString());
+ Assert.assertEquals("_0_1_2", nodePath.getPathString());
TreePath nodePath2 = new TreePath(nodePath, 3);
- assertEquals("_0_1_2_3", nodePath2.getPathString());
+ Assert.assertEquals("_0_1_2_3", nodePath2.getPathString());
}
+ @Test
public void testGetNode() {
DefaultMutableTreeNode root = new DefaultMutableTreeNode("root");
@@ -48,12 +52,13 @@ public class NodePathUnitTest extends Te
node2.add(node3);
root.add(node2);
- assertEquals(root, new TreePath(0).getNode(root));
- assertEquals(node1, new TreePath(0, 0).getNode(root));
- assertEquals(node2, new TreePath(0, 1).getNode(root));
- assertEquals(node3, new TreePath(0, 1, 0).getNode(root));
+ Assert.assertEquals(root, new TreePath(0).getNode(root));
+ Assert.assertEquals(node1, new TreePath(0, 0).getNode(root));
+ Assert.assertEquals(node2, new TreePath(0, 1).getNode(root));
+ Assert.assertEquals(node3, new TreePath(0, 1, 0).getNode(root));
}
+ @Test
public void testGetNode2() {
DefaultMutableTreeNode tree = new DefaultMutableTreeNode("Category");
@@ -70,9 +75,9 @@ public class NodePathUnitTest extends Te
tree.add(new DefaultMutableTreeNode("Music"));
tree.add(new DefaultMutableTreeNode("Games"));
- assertEquals("Category", new TreePath(0).getNode(tree).getUserObject());
- assertEquals("Sports", new TreePath(0, 0).getNode(tree).getUserObject());
- assertEquals("Astronomy", new TreePath(0, 2, 2).getNode(tree).getUserObject());
- assertEquals("Games", new TreePath(0, 4).getNode(tree).getUserObject());
+ Assert.assertEquals("Category", new TreePath(0).getNode(tree).getUserObject());
+ Assert.assertEquals("Sports", new TreePath(0, 0).getNode(tree).getUserObject());
+ Assert.assertEquals("Astronomy", new TreePath(0, 2, 2).getNode(tree).getUserObject());
+ Assert.assertEquals("Games", new TreePath(0, 4).getNode(tree).getUserObject());
}
}
Modified: myfaces/tobago/trunk/tobago-core/src/test/java/org/apache/myfaces/tobago/model/NodeUnitTest.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-core/src/test/java/org/apache/myfaces/tobago/model/NodeUnitTest.java?rev=953779&r1=953778&r2=953779&view=diff
==============================================================================
--- myfaces/tobago/trunk/tobago-core/src/test/java/org/apache/myfaces/tobago/model/NodeUnitTest.java (original)
+++ myfaces/tobago/trunk/tobago-core/src/test/java/org/apache/myfaces/tobago/model/NodeUnitTest.java Fri Jun 11 17:19:29 2010
@@ -17,9 +17,11 @@ package org.apache.myfaces.tobago.model;
* limitations under the License.
*/
-import junit.framework.TestCase;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
-public class NodeUnitTest extends TestCase {
+public class NodeUnitTest {
private Node r;
private Node a;
@@ -44,6 +46,7 @@ public class NodeUnitTest extends TestCa
* * |
* * +--o c (0,1,1,0)
*/
+ @Before
public void setUp() {
r = new Node();
@@ -65,34 +68,37 @@ public class NodeUnitTest extends TestCa
}
+ @Test
public void testIsRoot() {
- assertTrue(r.isRoot());
- assertFalse(a.isRoot());
- assertFalse(b.isRoot());
- assertFalse(c.isRoot());
- assertFalse(x.isRoot());
- assertFalse(y.isRoot());
- assertFalse(pi.isRoot());
+ Assert.assertTrue(r.isRoot());
+ Assert.assertFalse(a.isRoot());
+ Assert.assertFalse(b.isRoot());
+ Assert.assertFalse(c.isRoot());
+ Assert.assertFalse(x.isRoot());
+ Assert.assertFalse(y.isRoot());
+ Assert.assertFalse(pi.isRoot());
}
+ @Test
public void testGetChildCount() {
- assertEquals(3, r.getChildCount());
- assertEquals(0, a.getChildCount());
- assertEquals(2, b.getChildCount());
- assertEquals(0, c.getChildCount());
- assertEquals(0, x.getChildCount());
- assertEquals(1, y.getChildCount());
- assertEquals(0, pi.getChildCount());
+ Assert.assertEquals(3, r.getChildCount());
+ Assert.assertEquals(0, a.getChildCount());
+ Assert.assertEquals(2, b.getChildCount());
+ Assert.assertEquals(0, c.getChildCount());
+ Assert.assertEquals(0, x.getChildCount());
+ Assert.assertEquals(1, y.getChildCount());
+ Assert.assertEquals(0, pi.getChildCount());
}
+ @Test
public void testHasNextSibling() {
- assertFalse(r.hasNextSibling());
- assertTrue(a.hasNextSibling());
- assertTrue(b.hasNextSibling());
- assertFalse(c.hasNextSibling());
- assertTrue(x.hasNextSibling());
- assertFalse(y.hasNextSibling());
- assertFalse(pi.hasNextSibling());
+ Assert.assertFalse(r.hasNextSibling());
+ Assert.assertTrue(a.hasNextSibling());
+ Assert.assertTrue(b.hasNextSibling());
+ Assert.assertFalse(c.hasNextSibling());
+ Assert.assertTrue(x.hasNextSibling());
+ Assert.assertFalse(y.hasNextSibling());
+ Assert.assertFalse(pi.hasNextSibling());
}
}
Modified: myfaces/tobago/trunk/tobago-core/src/test/java/org/apache/myfaces/tobago/renderkit/LabelWithAccessKeyUnitTest.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-core/src/test/java/org/apache/myfaces/tobago/renderkit/LabelWithAccessKeyUnitTest.java?rev=953779&r1=953778&r2=953779&view=diff
==============================================================================
--- myfaces/tobago/trunk/tobago-core/src/test/java/org/apache/myfaces/tobago/renderkit/LabelWithAccessKeyUnitTest.java (original)
+++ myfaces/tobago/trunk/tobago-core/src/test/java/org/apache/myfaces/tobago/renderkit/LabelWithAccessKeyUnitTest.java Fri Jun 11 17:19:29 2010
@@ -17,83 +17,61 @@ package org.apache.myfaces.tobago.render
* limitations under the License.
*/
-import junit.framework.TestCase;
+import org.junit.Assert;
+import org.junit.Test;
import javax.faces.component.UIComponent;
import javax.faces.component.UIOutput;
-public class LabelWithAccessKeyUnitTest extends TestCase {
+public class LabelWithAccessKeyUnitTest {
+ @Test
public void testSimple() {
UIComponent component = new UIOutput();
component.getAttributes().put("label", "Save");
LabelWithAccessKey label = new LabelWithAccessKey(component);
- assertEquals("Save", label.getText());
- assertEquals(-1, label.getPos());
- assertEquals(null, label.getAccessKey());
+ Assert.assertEquals("Save", label.getText());
+ Assert.assertEquals(-1, label.getPos());
+ Assert.assertEquals(null, label.getAccessKey());
}
-
+ @Test
public void testWithKeyFirstLetter() {
UIComponent component = new UIOutput();
component.getAttributes().put("label", "Save_");
LabelWithAccessKey label = new LabelWithAccessKey(component);
- assertEquals("Save", label.getText());
- assertNull(label.getAccessKey());
+ Assert.assertEquals("Save", label.getText());
+ Assert.assertNull(label.getAccessKey());
}
-
-
+ @Test
public void testWithKeyLastLetter() {
String result = "A_n_aly_ze";
UIComponent component = new UIOutput();
component.getAttributes().put("label", "A__n__a_ly__ze");
LabelWithAccessKey label = new LabelWithAccessKey(component);
- assertEquals(result, label.getText());
- assertEquals(5, label.getPos());
- assertEquals(new Character('l'), label.getAccessKey());
+ Assert.assertEquals(result, label.getText());
+ Assert.assertEquals(5, label.getPos());
+ Assert.assertEquals(new Character('l'), label.getAccessKey());
}
-
+ @Test
public void testAmpersand() {
UIComponent component = new UIOutput();
component.getAttributes().put("label", "_Save");
LabelWithAccessKey label = new LabelWithAccessKey(component);
- assertEquals("Save", label.getText());
- assertEquals(0, label.getPos());
- assertEquals(new Character('S'), label.getAccessKey());
+ Assert.assertEquals("Save", label.getText());
+ Assert.assertEquals(0, label.getPos());
+ Assert.assertEquals(new Character('S'), label.getAccessKey());
}
+ @Test
public void testAmpersandAtEnd() {
UIComponent component = new UIOutput();
component.getAttributes().put("label", "Save_");
LabelWithAccessKey label = new LabelWithAccessKey(component);
- assertEquals("Save", label.getText());
- assertEquals(-1, label.getPos());
- assertEquals(null, label.getAccessKey());
- }
-
-/*
- public void testAmpersandNo() {
- UIComponent component = new UIOutput();
- component.getAttributes().put("labelWithAccessKey", "Save");
- LabelWithAccessKey label = new LabelWithAccessKey(component);
- assertEquals("Save", label.getText());
- assertEquals(-1, label.getPos());
- assertEquals(null, label.getAccessKey());
+ Assert.assertEquals("Save", label.getText());
+ Assert.assertEquals(-1, label.getPos());
+ Assert.assertEquals(null, label.getAccessKey());
}
-
- public void testMixed() {
- UIComponent component = new UIOutput();
- component.getAttributes().put("label", "Cancel");
- component.getAttributes().put("labelWithAccessKey", "Sa_ve");
- component.getAttributes().put("accessKey", "a");
- LabelWithAccessKey label = new LabelWithAccessKey(component);
- assertEquals("Save", label.getText());
- assertEquals(2, label.getPos());
- assertEquals(new Character('v'), label.getAccessKey());
- }
-*/
-
}
-
Modified: myfaces/tobago/trunk/tobago-core/src/test/java/org/apache/myfaces/tobago/util/HtmlWriterUtilsUnitTest.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-core/src/test/java/org/apache/myfaces/tobago/util/HtmlWriterUtilsUnitTest.java?rev=953779&r1=953778&r2=953779&view=diff
==============================================================================
--- myfaces/tobago/trunk/tobago-core/src/test/java/org/apache/myfaces/tobago/util/HtmlWriterUtilsUnitTest.java (original)
+++ myfaces/tobago/trunk/tobago-core/src/test/java/org/apache/myfaces/tobago/util/HtmlWriterUtilsUnitTest.java Fri Jun 11 17:19:29 2010
@@ -17,18 +17,14 @@ package org.apache.myfaces.tobago.util;
* limitations under the License.
*/
-import junit.framework.TestCase;
import org.apache.myfaces.tobago.internal.util.HtmlWriterUtils;
+import org.junit.Assert;
+import org.junit.Test;
import java.io.CharArrayWriter;
import java.io.IOException;
-/**
- * User: weber
- * Date: Jul 11, 2005
- * Time: 11:50:03 AM
- */
-public class HtmlWriterUtilsUnitTest extends TestCase {
+public class HtmlWriterUtilsUnitTest {
// some chars must escaped in attribute values other than in text
// put them at beginning of raw texts and in both escaped texts
@@ -70,6 +66,7 @@ public class HtmlWriterUtilsUnitTest ext
RAW_TEXTS[2] // no escape needed
};
+ @Test
public void test() {
CharArrayWriter writer = new CharArrayWriter();
HtmlWriterUtils helper = new HtmlWriterUtils(writer, "");
@@ -87,7 +84,7 @@ public class HtmlWriterUtilsUnitTest ext
writer.reset();
writerUtil.writeText(text);
String result = String.valueOf(writer.toCharArray());
- assertEquals(result, escaped);
+ Assert.assertEquals(result, escaped);
} catch (IOException e) {
// could not occur with CharArrayWriter
@@ -99,7 +96,7 @@ public class HtmlWriterUtilsUnitTest ext
writer.reset();
writerUtil.writeAttributeValue(text);
String result = String.valueOf(writer.toCharArray());
- assertEquals(result, escaped);
+ Assert.assertEquals(result, escaped);
} catch (IOException e) {
// could not occur with CharArrayWriter
Modified: myfaces/tobago/trunk/tobago-core/src/test/java/org/apache/myfaces/tobago/util/LayoutInfoUnitTest.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-core/src/test/java/org/apache/myfaces/tobago/util/LayoutInfoUnitTest.java?rev=953779&r1=953778&r2=953779&view=diff
==============================================================================
--- myfaces/tobago/trunk/tobago-core/src/test/java/org/apache/myfaces/tobago/util/LayoutInfoUnitTest.java (original)
+++ myfaces/tobago/trunk/tobago-core/src/test/java/org/apache/myfaces/tobago/util/LayoutInfoUnitTest.java Fri Jun 11 17:19:29 2010
@@ -17,19 +17,15 @@ package org.apache.myfaces.tobago.util;
* limitations under the License.
*/
-import junit.framework.TestCase;
import org.apache.myfaces.tobago.layout.LayoutTokens;
+import org.junit.Test;
-/*
- * Date: Mar 22, 2007
- * Time: 8:31:04 PM
- */
-public class LayoutInfoUnitTest extends TestCase {
+public class LayoutInfoUnitTest {
+ @Test
public void test() {
LayoutInfo info = new LayoutInfo(5, 83, LayoutTokens.parse("284px;1*;180px;1*;75px"), "unittest");
info.getLayoutTokens();
info.parseColumnLayout(83);
-
}
}
Modified: myfaces/tobago/trunk/tobago-core/src/test/java/org/apache/myfaces/tobago/util/RangeParserUnitTest.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-core/src/test/java/org/apache/myfaces/tobago/util/RangeParserUnitTest.java?rev=953779&r1=953778&r2=953779&view=diff
==============================================================================
--- myfaces/tobago/trunk/tobago-core/src/test/java/org/apache/myfaces/tobago/util/RangeParserUnitTest.java (original)
+++ myfaces/tobago/trunk/tobago-core/src/test/java/org/apache/myfaces/tobago/util/RangeParserUnitTest.java Fri Jun 11 17:19:29 2010
@@ -17,11 +17,13 @@ package org.apache.myfaces.tobago.util;
* limitations under the License.
*/
-import junit.framework.TestCase;
import org.apache.myfaces.tobago.internal.util.StringUtils;
+import org.junit.Assert;
+import org.junit.Test;
-public class RangeParserUnitTest extends TestCase {
+public class RangeParserUnitTest {
+ @Test
public void test() {
int[] ints = {0, 5, 10};
@@ -45,14 +47,12 @@ public class RangeParserUnitTest extends
checkEquals(ints, StringUtils.getIndices(s));
s = "3 - 7, 15 - 13";
checkEquals(ints, StringUtils.getIndices(s));
-
-
}
private void checkEquals(int[] ints, int[] indices) {
- assertTrue(ints.length == indices.length);
+ Assert.assertTrue(ints.length == indices.length);
for (int i = 0; i < ints.length; i++) {
- assertTrue(ints[i] == indices[i]);
+ Assert.assertTrue(ints[i] == indices[i]);
}
}
}
Modified: myfaces/tobago/trunk/tobago-core/src/test/java/org/apache/myfaces/tobago/webapp/TobagoMultipartFormdataRequestUnitTest.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-core/src/test/java/org/apache/myfaces/tobago/webapp/TobagoMultipartFormdataRequestUnitTest.java?rev=953779&r1=953778&r2=953779&view=diff
==============================================================================
--- myfaces/tobago/trunk/tobago-core/src/test/java/org/apache/myfaces/tobago/webapp/TobagoMultipartFormdataRequestUnitTest.java (original)
+++ myfaces/tobago/trunk/tobago-core/src/test/java/org/apache/myfaces/tobago/webapp/TobagoMultipartFormdataRequestUnitTest.java Fri Jun 11 17:19:29 2010
@@ -17,10 +17,11 @@ package org.apache.myfaces.tobago.webapp
* limitations under the License.
*/
-import junit.framework.TestCase;
import org.apache.commons.fileupload.FileItem;
import org.apache.myfaces.tobago.internal.mock.servlet.MockHttpServletRequest;
import org.apache.myfaces.tobago.internal.webapp.TobagoMultipartFormdataRequest;
+import org.junit.Assert;
+import org.junit.Test;
import java.io.UnsupportedEncodingException;
import java.util.Arrays;
@@ -30,7 +31,7 @@ import java.util.HashSet;
import java.util.Map;
import java.util.Set;
-public class TobagoMultipartFormdataRequestUnitTest extends TestCase {
+public class TobagoMultipartFormdataRequestUnitTest {
private static final String SNIP = "--";
@@ -40,9 +41,7 @@ public class TobagoMultipartFormdataRequ
private TobagoMultipartFormdataRequest request;
- public TobagoMultipartFormdataRequestUnitTest(String reference)
- throws UnsupportedEncodingException {
- super(reference);
+ public TobagoMultipartFormdataRequestUnitTest() throws UnsupportedEncodingException {
String body
= SNIP + BOUNDARY + NEWLINE
+ parameter("color", "red")
@@ -79,22 +78,25 @@ public class TobagoMultipartFormdataRequ
+ value + NEWLINE;
}
+ @Test
public void testGetFileItem() {
FileItem item = request.getFileItem("file");
- assertNotNull(item);
- assertEquals("filename", "hello.txt", item.getName());
- assertEquals("content", "Hello World!", item.getString());
+ Assert.assertNotNull(item);
+ Assert.assertEquals("filename", "hello.txt", item.getName());
+ Assert.assertEquals("content", "Hello World!", item.getString());
}
+ @Test
public void testGetParameter() {
- assertEquals("red", request.getParameter("color"));
- assertEquals("Amsterdam", request.getParameter("city"));
- assertEquals("Trinidad & Tobago", request.getParameter("country"));
- assertEquals(null, request.getParameter("empty"));
+ Assert.assertEquals("red", request.getParameter("color"));
+ Assert.assertEquals("Amsterdam", request.getParameter("city"));
+ Assert.assertEquals("Trinidad & Tobago", request.getParameter("country"));
+ Assert.assertEquals(null, request.getParameter("empty"));
}
+ @Test
public void testGetParameterValues() {
Set<String> expectedSet;
@@ -104,22 +106,23 @@ public class TobagoMultipartFormdataRequ
Arrays.asList("red", "green", "blue", "yellow"));
actualSet
= new HashSet<String>(Arrays.asList(request.getParameterValues("color")));
- assertEquals("color", expectedSet, actualSet);
+ Assert.assertEquals("color", expectedSet, actualSet);
expectedSet = new HashSet<String>(
Arrays.asList("Amsterdam", "Bonn", "Pisa"));
actualSet = new HashSet<String>(Arrays.asList(request.getParameterValues("city")));
- assertEquals("city", expectedSet, actualSet);
+ Assert.assertEquals("city", expectedSet, actualSet);
expectedSet = new HashSet<String>(
Arrays.asList("Trinidad & Tobago"));
actualSet
= new HashSet<String>(Arrays.asList(request.getParameterValues("country")));
- assertEquals("country", expectedSet, actualSet);
+ Assert.assertEquals("country", expectedSet, actualSet);
- assertEquals("empty", null, request.getParameterValues("empty"));
+ Assert.assertEquals("empty", null, request.getParameterValues("empty"));
}
+ @Test
public void testGetParameterNames() {
Set<Object> actual = new HashSet<Object>();
@@ -131,9 +134,10 @@ public class TobagoMultipartFormdataRequ
Set<String> expected = new HashSet<String>(
Arrays.asList("color", "city", "country"));
- assertEquals(expected, actual);
+ Assert.assertEquals(expected, actual);
}
+ @Test
public void testGetParameterMap() {
Map actual = request.getParameterMap();
@@ -143,17 +147,17 @@ public class TobagoMultipartFormdataRequ
expected.put("city", new String[]{"Amsterdam", "Bonn", "Pisa"});
expected.put("country", new String[]{"Trinidad & Tobago"});
- assertEquals(expected.keySet(), actual.keySet());
+ Assert.assertEquals(expected.keySet(), actual.keySet());
Set keys = actual.keySet();
for (Object key1 : keys) {
String key = (String) key1;
String[] expectedStrings = expected.get(key);
String[] actualStrings = (String[]) actual.get(key);
- assertEquals(expectedStrings.length, actualStrings.length);
+ Assert.assertEquals(expectedStrings.length, actualStrings.length);
Set<String> expectedSet = new HashSet<String>(Arrays.asList(expectedStrings));
Set<String> actualSet = new HashSet<String>(Arrays.asList(actualStrings));
- assertEquals(expectedSet, actualSet);
+ Assert.assertEquals(expectedSet, actualSet);
}
}
}
Modified: myfaces/tobago/trunk/tobago-core/src/test/java/org/apache/myfaces/tobago/webapp/TobagoResponseWriterUnitTest.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-core/src/test/java/org/apache/myfaces/tobago/webapp/TobagoResponseWriterUnitTest.java?rev=953779&r1=953778&r2=953779&view=diff
==============================================================================
--- myfaces/tobago/trunk/tobago-core/src/test/java/org/apache/myfaces/tobago/webapp/TobagoResponseWriterUnitTest.java (original)
+++ myfaces/tobago/trunk/tobago-core/src/test/java/org/apache/myfaces/tobago/webapp/TobagoResponseWriterUnitTest.java Fri Jun 11 17:19:29 2010
@@ -17,71 +17,81 @@ package org.apache.myfaces.tobago.webapp
* limitations under the License.
*/
-import junit.framework.TestCase;
import org.apache.myfaces.tobago.internal.webapp.TobagoResponseWriterImpl;
import org.apache.myfaces.tobago.internal.webapp.TobagoResponseXmlWriterImpl;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
import java.io.IOException;
import java.io.StringWriter;
-public class TobagoResponseWriterUnitTest extends TestCase {
+public class TobagoResponseWriterUnitTest {
private StringWriter stringWriter;
private TobagoResponseWriter writer;
- protected void setUp() throws Exception {
- super.setUp();
+ @Before
+ public void setUp() throws Exception {
stringWriter = new StringWriter();
writer = new TobagoResponseWriterImpl(stringWriter, "", "UTF-8");
}
+ @Test
public void testDocument() throws IOException {
writer.startDocument();
writer.endDocument();
- assertEquals("content expected",
+ Assert.assertEquals("content expected",
"<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01//EN\" \"http://www.w3.org/TR/html4/strict.dtd\">\n"
+ "<html\n"
+ "></html>", stringWriter.toString());
}
+ @Test
public void testEmptyTag() throws IOException {
writer.startElement("input", null);
writer.endElement("input");
- assertEquals("empty tag", "<input\n>", stringWriter.toString());
+ Assert.assertEquals("empty tag", "<input\n>", stringWriter.toString());
}
+ @Test
public void testNormalTag() throws IOException {
writer.startElement("select", null);
writer.endElement("select");
- assertEquals("normal tag", "<select\n></select>", stringWriter.toString());
+ Assert.assertEquals("normal tag", "<select\n></select>", stringWriter.toString());
}
+ @Test
public void testAttribute() throws IOException {
writer.startElement("select", null);
writer.writeAttribute("value", "0", null);
writer.endElement("select");
- assertEquals("attr tag", "<select value=\"0\"\n></select>", stringWriter.toString());
+ Assert.assertEquals("attr tag", "<select value=\"0\"\n></select>", stringWriter.toString());
}
+ @Test
public void testAttributeQuoting() throws IOException {
writer.startElement("select", null);
writer.writeAttribute("value", "-<->-ü-â¬-", null);
writer.endElement("select");
- assertEquals("attr tag", "<select value=\"-<->-ü-â¬-\"\n></select>", stringWriter.toString());
+ Assert.assertEquals("attr tag", "<select value=\"-<->-ü-â¬-\"\n></select>", stringWriter.toString());
}
+ @Test
public void testTextQuoting() throws IOException {
writer.startElement("textarea", null);
writer.writeText("-<->-ü-â¬-", null);
writer.endElement("textarea");
- assertEquals("attr tag", "<textarea\n>-<->-ü-â¬-</textarea>", stringWriter.toString());
+ Assert.assertEquals("attr tag", "<textarea\n>-<->-ü-â¬-</textarea>", stringWriter.toString());
}
- public void testStringWriter() throws IOException {
+ @Test
+ public void testStringWriter() throws IOException {
stringWriter.write("-ü-â¬-");
- assertEquals("-ü-â¬-", stringWriter.toString());
+ Assert.assertEquals("-ü-â¬-", stringWriter.toString());
}
+ @Test
public void testManyChars() throws IOException {
writer.startElement("select", null);
StringBuffer buffer = new StringBuffer();
@@ -97,9 +107,10 @@ public class TobagoResponseWriterUnitTes
result = result.replace("\"", """);
result = result.replace("<", "<");
result = result.replace(">", ">");
- assertEquals("all chars", "<select value=\"" + result + "\"\n>" + result + "</select>", stringWriter.toString());
+ Assert.assertEquals("all chars", "<select value=\"" + result + "\"\n>" + result + "</select>", stringWriter.toString());
}
+ @Test
public void testNonUtf8() throws IOException {
TobagoResponseWriter writer1 = new TobagoResponseWriterImpl(stringWriter, "", "ISO-8859-1");
writer1.startElement("input", null);
@@ -107,12 +118,13 @@ public class TobagoResponseWriterUnitTes
writer1.writeAttribute("readonly", true);
writer1.endElement("input");
writer1.close();
- assertEquals("<input value=\"Gutschein über 100 €.\" readonly=\"readonly\"\n>", stringWriter.toString());
+ Assert.assertEquals("<input value=\"Gutschein über 100 €.\" readonly=\"readonly\"\n>", stringWriter.toString());
}
+ @Test
public void testCharArray() throws IOException {
TobagoResponseWriter writer = new TobagoResponseXmlWriterImpl(stringWriter, "text/xml", "ISO-8859-1");
writer.writeText("123".toCharArray(), 0, 3);
- assertEquals("123", stringWriter.toString());
+ Assert.assertEquals("123", stringWriter.toString());
}
}
Modified: myfaces/tobago/trunk/tobago-theme/tobago-theme-scarborough/src/test/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/AbstractJavaScriptTestBase.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-theme/tobago-theme-scarborough/src/test/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/AbstractJavaScriptTestBase.java?rev=953779&r1=953778&r2=953779&view=diff
==============================================================================
--- myfaces/tobago/trunk/tobago-theme/tobago-theme-scarborough/src/test/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/AbstractJavaScriptTestBase.java (original)
+++ myfaces/tobago/trunk/tobago-theme/tobago-theme-scarborough/src/test/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/AbstractJavaScriptTestBase.java Fri Jun 11 17:19:29 2010
@@ -17,7 +17,9 @@ package org.apache.myfaces.tobago.render
* limitations under the License.
*/
-import junit.framework.TestCase;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
import org.mozilla.javascript.Context;
import org.mozilla.javascript.JavaScriptException;
import org.mozilla.javascript.Scriptable;
@@ -26,21 +28,23 @@ import java.io.File;
import java.io.FileReader;
import java.io.IOException;
-public abstract class AbstractJavaScriptTestBase extends TestCase {
+public abstract class AbstractJavaScriptTestBase {
private Context cx;
private Scriptable scope;
+ @Before
protected void setUp() throws Exception {
- super.setUp();
cx = Context.enter();
scope = cx.initStandardObjects(null);
}
+ @After
protected void tearDown() throws Exception {
Context.exit();
}
+ @Test
public void testDummy() {
}
Modified: myfaces/tobago/trunk/tobago-theme/tobago-theme-scarborough/src/test/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/TreeNodeRendererUnitTest.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-theme/tobago-theme-scarborough/src/test/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/TreeNodeRendererUnitTest.java?rev=953779&r1=953778&r2=953779&view=diff
==============================================================================
--- myfaces/tobago/trunk/tobago-theme/tobago-theme-scarborough/src/test/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/TreeNodeRendererUnitTest.java (original)
+++ myfaces/tobago/trunk/tobago-theme/tobago-theme-scarborough/src/test/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/TreeNodeRendererUnitTest.java Fri Jun 11 17:19:29 2010
@@ -17,13 +17,15 @@ package org.apache.myfaces.tobago.render
* limitations under the License.
*/
-import junit.framework.TestCase;
+import org.junit.Assert;
+import org.junit.Test;
-public class TreeNodeRendererUnitTest extends TestCase {
+public class TreeNodeRendererUnitTest {
+ @Test
public void testConstants() {
- assertEquals("image/treeNode-icon-open.gif", TreeNodeRenderer.OPEN_FOLDER);
- assertEquals("image/treeNode-icon.gif", TreeNodeRenderer.CLOSED_FOLDER);
- assertEquals("image/treeNode-icon-leaf.gif", TreeNodeRenderer.LEAF);
+ Assert.assertEquals("image/treeNode-icon-open.gif", TreeNodeRenderer.OPEN_FOLDER);
+ Assert.assertEquals("image/treeNode-icon.gif", TreeNodeRenderer.CLOSED_FOLDER);
+ Assert.assertEquals("image/treeNode-icon-leaf.gif", TreeNodeRenderer.LEAF);
}
}