Return-Path: X-Original-To: apmail-commons-commits-archive@minotaur.apache.org Delivered-To: apmail-commons-commits-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 21A4B721C for ; Tue, 18 Oct 2011 14:57:21 +0000 (UTC) Received: (qmail 23705 invoked by uid 500); 18 Oct 2011 14:57:20 -0000 Delivered-To: apmail-commons-commits-archive@commons.apache.org Received: (qmail 23635 invoked by uid 500); 18 Oct 2011 14:57:20 -0000 Mailing-List: contact commits-help@commons.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@commons.apache.org Delivered-To: mailing list commits@commons.apache.org Received: (qmail 23621 invoked by uid 99); 18 Oct 2011 14:57:20 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 18 Oct 2011 14:57:20 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 18 Oct 2011 14:57:17 +0000 Received: from eris.apache.org (localhost [127.0.0.1]) by eris.apache.org (Postfix) with ESMTP id 815E22388962 for ; Tue, 18 Oct 2011 14:56:56 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1185704 - /commons/proper/lang/trunk/src/test/java/org/apache/commons/lang3/builder/MultiLineToStringStyleTest.java Date: Tue, 18 Oct 2011 14:56:56 -0000 To: commits@commons.apache.org From: ggregory@apache.org X-Mailer: svnmailer-1.0.8-patched Message-Id: <20111018145656.815E22388962@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: ggregory Date: Tue Oct 18 14:56:56 2011 New Revision: 1185704 URL: http://svn.apache.org/viewvc?rev=1185704&view=rev Log: Port to JUnit 4. Modified: commons/proper/lang/trunk/src/test/java/org/apache/commons/lang3/builder/MultiLineToStringStyleTest.java Modified: commons/proper/lang/trunk/src/test/java/org/apache/commons/lang3/builder/MultiLineToStringStyleTest.java URL: http://svn.apache.org/viewvc/commons/proper/lang/trunk/src/test/java/org/apache/commons/lang3/builder/MultiLineToStringStyleTest.java?rev=1185704&r1=1185703&r2=1185704&view=diff ============================================================================== --- commons/proper/lang/trunk/src/test/java/org/apache/commons/lang3/builder/MultiLineToStringStyleTest.java (original) +++ commons/proper/lang/trunk/src/test/java/org/apache/commons/lang3/builder/MultiLineToStringStyleTest.java Tue Oct 18 14:56:56 2011 @@ -16,46 +16,45 @@ */ package org.apache.commons.lang3.builder; +import static org.junit.Assert.assertEquals; + import java.util.ArrayList; import java.util.HashMap; -import junit.framework.TestCase; - import org.apache.commons.lang3.SystemUtils; import org.apache.commons.lang3.builder.ToStringStyleTest.Person; +import org.junit.After; +import org.junit.Before; +import org.junit.Test; /** * Unit tests {@link org.apache.commons.lang3.builder.MultiLineToStringStyleTest}. * * @version $Id$ */ -public class MultiLineToStringStyleTest extends TestCase { +public class MultiLineToStringStyleTest { private final Integer base = Integer.valueOf(5); private final String baseStr = base.getClass().getName() + "@" + Integer.toHexString(System.identityHashCode(base)); - public MultiLineToStringStyleTest(String name) { - super(name); - } - - @Override - protected void setUp() throws Exception { - super.setUp(); + @Before + public void setUp() throws Exception { ToStringBuilder.setDefaultStyle(ToStringStyle.MULTI_LINE_STYLE); } - @Override - protected void tearDown() throws Exception { - super.tearDown(); + @After + public void tearDown() throws Exception { ToStringBuilder.setDefaultStyle(ToStringStyle.DEFAULT_STYLE); } //---------------------------------------------------------------- - + + @Test public void testBlank() { assertEquals(baseStr + "[" + SystemUtils.LINE_SEPARATOR + "]", new ToStringBuilder(base).toString()); } + @Test public void testAppendSuper() { assertEquals(baseStr + "[" + SystemUtils.LINE_SEPARATOR + "]", new ToStringBuilder(base).appendSuper("Integer@8888[" + SystemUtils.LINE_SEPARATOR + "]").toString()); assertEquals(baseStr + "[" + SystemUtils.LINE_SEPARATOR + " " + SystemUtils.LINE_SEPARATOR + "]", new ToStringBuilder(base).appendSuper("Integer@8888[" + SystemUtils.LINE_SEPARATOR + " " + SystemUtils.LINE_SEPARATOR + "]").toString()); @@ -65,6 +64,7 @@ public class MultiLineToStringStyleTest assertEquals(baseStr + "[" + SystemUtils.LINE_SEPARATOR + " a=hello" + SystemUtils.LINE_SEPARATOR + "]", new ToStringBuilder(base).appendSuper(null).append("a", "hello").toString()); } + @Test public void testObject() { Integer i3 = Integer.valueOf(3); Integer i4 = Integer.valueOf(4); @@ -82,6 +82,7 @@ public class MultiLineToStringStyleTest assertEquals(baseStr + "[" + SystemUtils.LINE_SEPARATOR + " a={}" + SystemUtils.LINE_SEPARATOR + "]", new ToStringBuilder(base).append("a", (Object) new String[0], true).toString()); } + @Test public void testPerson() { Person p = new Person(); p.name = "Jane Doe"; @@ -91,12 +92,14 @@ public class MultiLineToStringStyleTest assertEquals(pBaseStr + "[" + SystemUtils.LINE_SEPARATOR + " name=Jane Doe" + SystemUtils.LINE_SEPARATOR + " age=25" + SystemUtils.LINE_SEPARATOR + " smoker=true" + SystemUtils.LINE_SEPARATOR + "]", new ToStringBuilder(p).append("name", p.name).append("age", p.age).append("smoker", p.smoker).toString()); } + @Test public void testLong() { assertEquals(baseStr + "[" + SystemUtils.LINE_SEPARATOR + " 3" + SystemUtils.LINE_SEPARATOR + "]", new ToStringBuilder(base).append(3L).toString()); assertEquals(baseStr + "[" + SystemUtils.LINE_SEPARATOR + " a=3" + SystemUtils.LINE_SEPARATOR + "]", new ToStringBuilder(base).append("a", 3L).toString()); assertEquals(baseStr + "[" + SystemUtils.LINE_SEPARATOR + " a=3" + SystemUtils.LINE_SEPARATOR + " b=4" + SystemUtils.LINE_SEPARATOR + "]", new ToStringBuilder(base).append("a", 3L).append("b", 4L).toString()); } + @Test public void testObjectArray() { Object[] array = new Object[] {null, base, new int[] {3, 6}}; assertEquals(baseStr + "[" + SystemUtils.LINE_SEPARATOR + " {,5,{3,6}}" + SystemUtils.LINE_SEPARATOR + "]", new ToStringBuilder(base).append(array).toString()); @@ -106,6 +109,7 @@ public class MultiLineToStringStyleTest assertEquals(baseStr + "[" + SystemUtils.LINE_SEPARATOR + " " + SystemUtils.LINE_SEPARATOR + "]", new ToStringBuilder(base).append((Object) array).toString()); } + @Test public void testLongArray() { long[] array = new long[] {1, 2, -3, 4}; assertEquals(baseStr + "[" + SystemUtils.LINE_SEPARATOR + " {1,2,-3,4}" + SystemUtils.LINE_SEPARATOR + "]", new ToStringBuilder(base).append(array).toString()); @@ -115,6 +119,7 @@ public class MultiLineToStringStyleTest assertEquals(baseStr + "[" + SystemUtils.LINE_SEPARATOR + " " + SystemUtils.LINE_SEPARATOR + "]", new ToStringBuilder(base).append((Object) array).toString()); } + @Test public void testLongArrayArray() { long[][] array = new long[][] {{1, 2}, null, {5}}; assertEquals(baseStr + "[" + SystemUtils.LINE_SEPARATOR + " {{1,2},,{5}}" + SystemUtils.LINE_SEPARATOR + "]", new ToStringBuilder(base).append(array).toString());