Commit 20be3766 authored by Guus der Kinderen's avatar Guus der Kinderen

OF-898: Adding unit test that tests for the problem.

parent 8ce12c9f
package org.jivesoftware.util; package org.jivesoftware.util;
import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import java.text.DateFormat; import java.text.DateFormat;
import java.text.ParseException; import java.text.ParseException;
...@@ -27,4 +28,46 @@ public class XMPPDateTimeFormatTest { ...@@ -27,4 +28,46 @@ public class XMPPDateTimeFormatTest {
String date = df.format(parsedDate); String date = df.format(parsedDate);
assertEquals(date, "2013-01-25T18:07:22.768+0000"); assertEquals(date, "2013-01-25T18:07:22.768+0000");
} }
@Test
public void testFormatNoSecondFractions() throws Exception
{
// Setup fixture
final String testValue = "2015-03-19T22:54:15+00:00"; // Thu, 19 Mar 2015 22:54:15 GMT
// Execute system under test
final Date result = xmppDateTimeFormat.parseString(testValue);
// Verify results
long expected = 1426805655000L; // Epoch value of Thu, 19 Mar 2015 22:54:15 GMT
assertEquals( expected, result.getTime() );
}
@Test
public void testFormatThreeSecondFractions() throws Exception
{
// Setup fixture
final String testValue = "2015-03-19T22:54:15.841+00:00"; // Thu, 19 Mar 2015 22:54:15.841 GMT
// Execute system under test
final Date result = xmppDateTimeFormat.parseString(testValue);
// Verify results
long expected = 1426805655841L; // Epoch value of Thu, 19 Mar 2015 22:54:15.841 GMT
assertEquals( expected, result.getTime() );
}
@Test
public void testFormatManySecondFractions() throws Exception
{
// Setup fixture
final String testValue = "2015-03-19T22:54:15.841473+00:00"; // Thu, 19 Mar 2015 22:54:15.841473 GMT
// Execute system under test
final Date result = xmppDateTimeFormat.parseString(testValue);
// Verify results
long expected = 1426805655841L; // Epoch value of Thu, 19 Mar 2015 22:54:15 GMT
assertEquals( expected, result.getTime() );
}
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment