You are viewing a plain text version of this content. The canonical link for it is here.
Posted to awf-commits@incubator.apache.org by el...@apache.org on 2011/07/27 07:32:10 UTC

svn commit: r1151366 - /incubator/deft/sandbox/src/test/java/org/deftserver/util/DateUtilTest.java

Author: elecharny
Date: Wed Jul 27 07:32:09 2011
New Revision: 1151366

URL: http://svn.apache.org/viewvc?rev=1151366&view=rev
Log:
Applied patch fro DEFT-96

Added:
    incubator/deft/sandbox/src/test/java/org/deftserver/util/DateUtilTest.java

Added: incubator/deft/sandbox/src/test/java/org/deftserver/util/DateUtilTest.java
URL: http://svn.apache.org/viewvc/incubator/deft/sandbox/src/test/java/org/deftserver/util/DateUtilTest.java?rev=1151366&view=auto
==============================================================================
--- incubator/deft/sandbox/src/test/java/org/deftserver/util/DateUtilTest.java (added)
+++ incubator/deft/sandbox/src/test/java/org/deftserver/util/DateUtilTest.java Wed Jul 27 07:32:09 2011
@@ -0,0 +1,61 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *  
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *  
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License. 
+ *  
+ */
+package org.deftserver.util;
+
+import static org.junit.Assert.assertEquals;
+
+import org.junit.Test;
+
+/**
+ * Test cases for {@link DateUtil}.
+ * 
+ * @author <a href="johnathan.meehan@phasevariance.com">Johnathan Meehan</a>
+ * @since 0.3.0
+ */
+public class DateUtilTest {
+
+	@Test
+	public void testParseToMillisecondsForLong() {
+
+		final long actual = DateUtil.parseToMilliseconds("123");
+		assertEquals(123, actual);
+	}
+
+	@Test
+	public void testParseToMillisecondsForRFC1123String() {
+
+		final long actual = DateUtil.parseToMilliseconds("Sat, 20 Feb 2010 18:12:38 GMT");
+		assertEquals(1266689558000L, actual);
+	}
+
+	@Test
+	public void testParseToMillisecondsForInvalidString() {
+
+		final long actual = DateUtil.parseToMilliseconds("INVALID");
+		assertEquals(0, actual);
+	}
+
+	@Test
+	public void testParseToRFC1123() {
+
+		final String actual = DateUtil.parseToRFC1123(1266689558000L);
+		assertEquals("Sat, 20 Feb 2010 18:12:38 GMT", actual);
+	}
+}
\ No newline at end of file