commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From s...@apache.org
Subject svn commit: r936824 - in /commons/proper/net/branches/NET_2_0/src/test/java/org/apache/commons/net: ntp/TimeStampTest.java pop3/POP3ClientCommandsTest.java telnet/TelnetClientTest.java time/TimeTCPClientTest.java
Date Thu, 22 Apr 2010 13:10:45 GMT
Author: sebb
Date: Thu Apr 22 13:10:45 2010
New Revision: 936824

URL: http://svn.apache.org/viewvc?rev=936824&view=rev
Log:
assertEquals gives more info than assertTrue on failure

Modified:
    commons/proper/net/branches/NET_2_0/src/test/java/org/apache/commons/net/ntp/TimeStampTest.java
    commons/proper/net/branches/NET_2_0/src/test/java/org/apache/commons/net/pop3/POP3ClientCommandsTest.java
    commons/proper/net/branches/NET_2_0/src/test/java/org/apache/commons/net/telnet/TelnetClientTest.java
    commons/proper/net/branches/NET_2_0/src/test/java/org/apache/commons/net/time/TimeTCPClientTest.java

Modified: commons/proper/net/branches/NET_2_0/src/test/java/org/apache/commons/net/ntp/TimeStampTest.java
URL: http://svn.apache.org/viewvc/commons/proper/net/branches/NET_2_0/src/test/java/org/apache/commons/net/ntp/TimeStampTest.java?rev=936824&r1=936823&r2=936824&view=diff
==============================================================================
--- commons/proper/net/branches/NET_2_0/src/test/java/org/apache/commons/net/ntp/TimeStampTest.java
(original)
+++ commons/proper/net/branches/NET_2_0/src/test/java/org/apache/commons/net/ntp/TimeStampTest.java
Thu Apr 22 13:10:45 2010
@@ -41,7 +41,7 @@ public class TimeStampTest extends TestC
 
         // do assertion tests on TimeStamp class
         assertEquals("equals(1,2)", ts1, ts2);
-        assertTrue("compareTo(1,2)", ts1.compareTo(ts2) == 0);
+        assertEquals("compareTo(1,2)", 0, ts1.compareTo(ts2));
         assertEquals("ntpValue(1,2)", ts1.ntpValue(), ts2.ntpValue());
         assertEquals("hashCode(1,2)", ts1.hashCode(), ts2.hashCode());
         assertEquals("ts1==ts1", ts1, ts1);
@@ -50,7 +50,7 @@ public class TimeStampTest extends TestC
     // fraction of a second (~200 picoseconds) so the times are not equal but
     // when converted to Java dates (in milliseconds) they will be equal.
         assertTrue("ts1 != ts3", !ts1.equals(ts3));
-        assertTrue("compareTo(1,3)", ts1.compareTo(ts3) == -1);
+        assertEquals("compareTo(1,3)", -1, ts1.compareTo(ts3));
         assertEquals("seconds", ts1.getSeconds(), ts3.getSeconds());
         assertTrue("fraction", ts1.getFraction() != ts3.getFraction());
         assertTrue("ntpValue(1,3)", ts1.ntpValue() != ts3.ntpValue());

Modified: commons/proper/net/branches/NET_2_0/src/test/java/org/apache/commons/net/pop3/POP3ClientCommandsTest.java
URL: http://svn.apache.org/viewvc/commons/proper/net/branches/NET_2_0/src/test/java/org/apache/commons/net/pop3/POP3ClientCommandsTest.java?rev=936824&r1=936823&r2=936824&view=diff
==============================================================================
--- commons/proper/net/branches/NET_2_0/src/test/java/org/apache/commons/net/pop3/POP3ClientCommandsTest.java
(original)
+++ commons/proper/net/branches/NET_2_0/src/test/java/org/apache/commons/net/pop3/POP3ClientCommandsTest.java
Thu Apr 22 13:10:45 2010
@@ -131,8 +131,8 @@ public class POP3ClientCommandsTest exte
         connect();
         assertTrue(p.login(emptyUser, password));
         POP3MessageInfo msg2 = p.status();
-        assertTrue(msg2.number == 0);
-        assertTrue(msg2.size == 0);
+        assertEquals(0, msg2.number);
+        assertEquals(0, msg2.size);
         assertNull(msg2.identifier);
         p.logout();
 
@@ -160,7 +160,7 @@ public class POP3ClientCommandsTest exte
         for(int i = 0; i < msg.length; i++)
         {
             assertNotNull(msg[i]);
-            assertTrue(msg[i].number == i + 1);
+            assertEquals(i+1, msg[i].number);
             assertTrue(msg[i].size > 0);
             assertNull(msg[i].identifier);
         }
@@ -184,7 +184,7 @@ public class POP3ClientCommandsTest exte
         //The first message is always at index 1
         POP3MessageInfo msg = p.listMessage(1);
         assertNotNull(msg);
-        assertTrue(msg.number == 1);
+        assertEquals(1, msg.number);
         assertTrue(msg.size > 0);
         assertNull(msg.identifier);
 
@@ -217,7 +217,7 @@ public class POP3ClientCommandsTest exte
         assertTrue(p.login(emptyUser, password));
 
         POP3MessageInfo[] msg = p.listMessages();
-        assertTrue(msg.length == 0);
+        assertEquals(0, msg.length);
 
         //Now test from the update state
         p.setState(POP3.UPDATE_STATE);
@@ -256,7 +256,7 @@ public class POP3ClientCommandsTest exte
         for(int i = 0; i < msg.length; i++)
         {
             assertNotNull(msg[i]);
-            assertTrue(msg[i].number == i + 1);
+            assertEquals(i + 1, msg[i].number);
             assertNotNull(msg[i].identifier);
         }
 
@@ -279,7 +279,7 @@ public class POP3ClientCommandsTest exte
         //The first message is always at index 1
         POP3MessageInfo msg = p.listUniqueIdentifier(1);
         assertNotNull(msg);
-        assertTrue(msg.number == 1);
+        assertEquals(1, msg.number);
         assertNotNull(msg.identifier);
 
         //Now retrieve a message from index 0
@@ -311,7 +311,7 @@ public class POP3ClientCommandsTest exte
         assertTrue(p.login(emptyUser, password));
 
         POP3MessageInfo[] msg = p.listUniqueIdentifiers();
-        assertTrue(msg.length == 0);
+        assertEquals(0, msg.length);
 
         //Now test from the update state
         p.setState(POP3.UPDATE_STATE);

Modified: commons/proper/net/branches/NET_2_0/src/test/java/org/apache/commons/net/telnet/TelnetClientTest.java
URL: http://svn.apache.org/viewvc/commons/proper/net/branches/NET_2_0/src/test/java/org/apache/commons/net/telnet/TelnetClientTest.java?rev=936824&r1=936823&r2=936824&view=diff
==============================================================================
--- commons/proper/net/branches/NET_2_0/src/test/java/org/apache/commons/net/telnet/TelnetClientTest.java
(original)
+++ commons/proper/net/branches/NET_2_0/src/test/java/org/apache/commons/net/telnet/TelnetClientTest.java
Thu Apr 22 13:10:45 2010
@@ -565,10 +565,10 @@ extends TestCase implements TelnetNotifi
         }
 
 
-        assertTrue(numdo == 2);
-        assertTrue(numdont == 1);
-        assertTrue(numwont == 1);
-        assertTrue(numwill == 0);
+        assertEquals(2, numdo);
+        assertEquals(1, numdont);
+        assertEquals(1, numwont);
+        assertEquals(0, numwill);
     }
 
 

Modified: commons/proper/net/branches/NET_2_0/src/test/java/org/apache/commons/net/time/TimeTCPClientTest.java
URL: http://svn.apache.org/viewvc/commons/proper/net/branches/NET_2_0/src/test/java/org/apache/commons/net/time/TimeTCPClientTest.java?rev=936824&r1=936823&r2=936824&view=diff
==============================================================================
--- commons/proper/net/branches/NET_2_0/src/test/java/org/apache/commons/net/time/TimeTCPClientTest.java
(original)
+++ commons/proper/net/branches/NET_2_0/src/test/java/org/apache/commons/net/time/TimeTCPClientTest.java
Thu Apr 22 13:10:45 2010
@@ -58,7 +58,7 @@ public class TimeTCPClientTest extends T
         calendar.set(Calendar.MILLISECOND, 0);
         long baseTime = calendar.getTime().getTime() / 1000L;
 
-        assertTrue(baseTime == -TimeTCPClient.SECONDS_1900_TO_1970);
+        assertEquals(baseTime, -TimeTCPClient.SECONDS_1900_TO_1970);
     }
 
     /***



Mime
View raw message