You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by da...@apache.org on 2009/09/28 14:12:56 UTC
svn commit: r819506 - in /camel/trunk/camel-core/src:
main/java/org/apache/camel/converter/ test/java/org/apache/camel/converter/
Author: davsclaus
Date: Mon Sep 28 12:12:55 2009
New Revision: 819506
URL: http://svn.apache.org/viewvc?rev=819506&view=rev
Log:
MR-187: Added more unit tests.
Added:
camel/trunk/camel-core/src/test/java/org/apache/camel/converter/CamelConverterTest.java (with props)
camel/trunk/camel-core/src/test/java/org/apache/camel/converter/NIOConverterTest.java (with props)
camel/trunk/camel-core/src/test/java/org/apache/camel/converter/ObjectConverterTest.java (with props)
Modified:
camel/trunk/camel-core/src/main/java/org/apache/camel/converter/NIOConverter.java
camel/trunk/camel-core/src/main/java/org/apache/camel/converter/ObjectConverter.java
camel/trunk/camel-core/src/test/java/org/apache/camel/converter/CollectionConverterTest.java
camel/trunk/camel-core/src/test/java/org/apache/camel/converter/IOConverterTest.java
Modified: camel/trunk/camel-core/src/main/java/org/apache/camel/converter/NIOConverter.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/main/java/org/apache/camel/converter/NIOConverter.java?rev=819506&r1=819505&r2=819506&view=diff
==============================================================================
--- camel/trunk/camel-core/src/main/java/org/apache/camel/converter/NIOConverter.java (original)
+++ camel/trunk/camel-core/src/main/java/org/apache/camel/converter/NIOConverter.java Mon Sep 28 12:12:55 2009
@@ -26,6 +26,7 @@
import org.apache.camel.Converter;
import org.apache.camel.Exchange;
+import org.apache.camel.util.ObjectHelper;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
@@ -75,13 +76,7 @@
}
return ByteBuffer.wrap(buf);
} finally {
- try {
- if (in != null) {
- in.close();
- }
- } catch (IOException e) {
- LOG.warn("Failed to close file stream: " + file.getPath(), e);
- }
+ ObjectHelper.close(in, "Failed to close file stream: " + file.getPath(), LOG);
}
}
@@ -105,30 +100,35 @@
buf.put(bytes);
return buf;
}
+
@Converter
public static ByteBuffer toByteBuffer(Short value) {
ByteBuffer buf = ByteBuffer.allocate(2);
buf.putShort(value);
return buf;
}
+
@Converter
public static ByteBuffer toByteBuffer(Integer value) {
ByteBuffer buf = ByteBuffer.allocate(4);
buf.putInt(value);
return buf;
}
+
@Converter
public static ByteBuffer toByteBuffer(Long value) {
ByteBuffer buf = ByteBuffer.allocate(8);
buf.putLong(value);
return buf;
}
+
@Converter
public static ByteBuffer toByteBuffer(Float value) {
ByteBuffer buf = ByteBuffer.allocate(4);
buf.putFloat(value);
return buf;
}
+
@Converter
public static ByteBuffer toByteBuffer(Double value) {
ByteBuffer buf = ByteBuffer.allocate(8);
Modified: camel/trunk/camel-core/src/main/java/org/apache/camel/converter/ObjectConverter.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/main/java/org/apache/camel/converter/ObjectConverter.java?rev=819506&r1=819505&r2=819506&view=diff
==============================================================================
--- camel/trunk/camel-core/src/main/java/org/apache/camel/converter/ObjectConverter.java (original)
+++ camel/trunk/camel-core/src/main/java/org/apache/camel/converter/ObjectConverter.java Mon Sep 28 12:12:55 2009
@@ -44,7 +44,6 @@
}
public static boolean isCollection(Object value) {
- // TODO we should handle primitive array types?
return value instanceof Collection || (value != null && value.getClass().isArray());
}
@@ -70,17 +69,6 @@
}
/**
- * Returns the boolean value, or null if the value is null
- */
- @Converter
- public static Boolean toBoolean(Boolean value) {
- if (value != null) {
- return value;
- }
- return Boolean.FALSE;
- }
-
- /**
* Creates an iterator over the value
*/
@SuppressWarnings("unchecked")
Added: camel/trunk/camel-core/src/test/java/org/apache/camel/converter/CamelConverterTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/test/java/org/apache/camel/converter/CamelConverterTest.java?rev=819506&view=auto
==============================================================================
--- camel/trunk/camel-core/src/test/java/org/apache/camel/converter/CamelConverterTest.java (added)
+++ camel/trunk/camel-core/src/test/java/org/apache/camel/converter/CamelConverterTest.java Mon Sep 28 12:12:55 2009
@@ -0,0 +1,65 @@
+/**
+ * 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.apache.camel.converter;
+
+import org.apache.camel.ContextTestSupport;
+import org.apache.camel.Exchange;
+import org.apache.camel.Expression;
+import org.apache.camel.Predicate;
+import org.apache.camel.Processor;
+import org.apache.camel.builder.ExpressionBuilder;
+import org.apache.camel.builder.PredicateBuilder;
+import org.apache.camel.impl.DefaultExchange;
+
+import static org.apache.camel.builder.Builder.constant;
+import static org.apache.camel.builder.ExpressionBuilder.headerExpression;
+
+/**
+ * @version $Revision$
+ */
+public class CamelConverterTest extends ContextTestSupport {
+
+ public void testToProcessorExpression() throws Exception {
+ Expression exp = ExpressionBuilder.headerExpression("foo");
+
+ Exchange exchange = new DefaultExchange(context);
+ exchange.getIn().setHeader("foo", "bar");
+ exchange.getIn().setBody("Hello World");
+
+ CamelConverter cc = new CamelConverter();
+ Processor pro = cc.toProcessor(exp);
+
+ pro.process(exchange);
+
+ assertEquals("bar", exchange.getOut().getBody());
+ }
+
+ public void testToProcessorPredicate() throws Exception {
+ Predicate pred = PredicateBuilder.isEqualTo(headerExpression("foo"), constant("bar"));
+
+ Exchange exchange = new DefaultExchange(context);
+ exchange.getIn().setHeader("foo", "bar");
+ exchange.getIn().setBody("Hello World");
+
+ CamelConverter cc = new CamelConverter();
+ Processor pro = cc.toProcessor(pred);
+
+ pro.process(exchange);
+
+ assertEquals(true, exchange.getOut().getBody());
+ }
+}
Propchange: camel/trunk/camel-core/src/test/java/org/apache/camel/converter/CamelConverterTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: camel/trunk/camel-core/src/test/java/org/apache/camel/converter/CamelConverterTest.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Modified: camel/trunk/camel-core/src/test/java/org/apache/camel/converter/CollectionConverterTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/test/java/org/apache/camel/converter/CollectionConverterTest.java?rev=819506&r1=819505&r2=819506&view=diff
==============================================================================
--- camel/trunk/camel-core/src/test/java/org/apache/camel/converter/CollectionConverterTest.java (original)
+++ camel/trunk/camel-core/src/test/java/org/apache/camel/converter/CollectionConverterTest.java Mon Sep 28 12:12:55 2009
@@ -18,10 +18,15 @@
import java.util.Arrays;
import java.util.Collection;
+import java.util.HashMap;
+import java.util.Hashtable;
import java.util.Iterator;
import java.util.List;
+import java.util.Map;
+import java.util.Set;
import junit.framework.TestCase;
+import org.apache.camel.util.CaseInsensitiveMap;
/**
* Test cases for {@link CollectionConverter}
@@ -51,4 +56,39 @@
assertTrue(SMURFS.contains(key));
}
}
+
+ public void testToArray() {
+ assertEquals(null, CollectionConverter.toArray(null));
+ Object[] data = CollectionConverter.toArray(SMURFS);
+ assertEquals(4, data.length);
+ }
+
+ public void testToList() {
+ List out = CollectionConverter.toList(SMURFS);
+ assertEquals(4, out.size());
+ }
+
+ public void testToSet() {
+ Map map = new HashMap();
+ map.put("foo", "bar");
+
+ Set out = CollectionConverter.toSet(map);
+ assertEquals(1, out.size());
+ }
+
+ public void testToHashMap() {
+ Map map = new CaseInsensitiveMap();
+ map.put("foo", "bar");
+
+ HashMap out = CollectionConverter.toHashMap(map);
+ assertEquals(1, out.size());
+ }
+
+ public void testToHashtable() {
+ Map map = new CaseInsensitiveMap();
+ map.put("foo", "bar");
+
+ Hashtable out = CollectionConverter.toHashtable(map);
+ assertEquals(1, out.size());
+ }
}
Modified: camel/trunk/camel-core/src/test/java/org/apache/camel/converter/IOConverterTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/test/java/org/apache/camel/converter/IOConverterTest.java?rev=819506&r1=819505&r2=819506&view=diff
==============================================================================
--- camel/trunk/camel-core/src/test/java/org/apache/camel/converter/IOConverterTest.java (original)
+++ camel/trunk/camel-core/src/test/java/org/apache/camel/converter/IOConverterTest.java Mon Sep 28 12:12:55 2009
@@ -16,18 +16,27 @@
*/
package org.apache.camel.converter;
+import java.io.BufferedReader;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.FileInputStream;
-
-import junit.framework.TestCase;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.io.Reader;
+import java.io.StringReader;
+import java.io.Writer;
+
+import org.apache.camel.ContextTestSupport;
+import org.apache.camel.Exchange;
+import org.apache.camel.impl.DefaultExchange;
import org.apache.camel.util.IOHelper;
+import org.apache.camel.util.ObjectHelper;
/**
* Test case for {@link IOConverter}
*/
-public class IOConverterTest extends TestCase {
+public class IOConverterTest extends ContextTestSupport {
private static final byte[] TESTDATA = "My test data".getBytes();
@@ -60,4 +69,99 @@
}
}
+ public void testToOutputStreamFile() throws Exception {
+ template.sendBodyAndHeader("file://target/test", "Hello World", Exchange.FILE_NAME, "hello.txt");
+ File file = new File("target/test/hello.txt");
+
+ OutputStream os = IOConverter.toOutputStream(file);
+ assertNotNull(os);
+ os.close();
+ }
+
+ public void testToWriterFile() throws Exception {
+ template.sendBodyAndHeader("file://target/test", "Hello World", Exchange.FILE_NAME, "hello.txt");
+ File file = new File("target/test/hello.txt");
+
+ Writer writer = IOConverter.toWriter(file);
+ assertNotNull(writer);
+ writer.close();
+ }
+
+ public void testToReader() throws Exception {
+ Reader reader = IOConverter.toReader("Hello");
+ assertEquals("Hello", IOConverter.toString(reader));
+ }
+
+ public void testToInputStreamExchange() {
+ Exchange exchange = new DefaultExchange(context);
+ exchange.setProperty(Exchange.CHARSET_NAME, ObjectHelper.getDefaultCharacterSet());
+
+ InputStream is = IOConverter.toInputStream("Hello World", exchange);
+ assertNotNull(is);
+ }
+
+ public void testToInputStreamBufferReader() throws Exception {
+ Exchange exchange = new DefaultExchange(context);
+ exchange.setProperty(Exchange.CHARSET_NAME, ObjectHelper.getDefaultCharacterSet());
+
+ BufferedReader br = new BufferedReader(new StringReader("Hello World"));
+ InputStream is = IOConverter.toInputStream(br, exchange);
+ assertNotNull(is);
+ }
+
+ public void testToByteArrayFile() throws Exception {
+ template.sendBodyAndHeader("file://target/test", "Hello World", Exchange.FILE_NAME, "hello.txt");
+ File file = new File("target/test/hello.txt");
+
+ byte[] data = IOConverter.toByteArray(file);
+ assertNotNull(data);
+ assertEquals(11, data.length);
+ }
+
+ public void testToStringBufferReader() throws Exception {
+ BufferedReader br = new BufferedReader(new StringReader("Hello World"));
+ String s = IOConverter.toString(br);
+ assertNotNull(s);
+ assertEquals("Hello World", s);
+ }
+
+ public void testToByteArrayBufferReader() throws Exception {
+ BufferedReader br = new BufferedReader(new StringReader("Hello World"));
+ byte[] bytes = IOConverter.toByteArray(br);
+ assertNotNull(bytes);
+ assertEquals(11, bytes.length);
+ }
+
+ public void testToByteArrayReader() throws Exception {
+ Reader br = new BufferedReader(new StringReader("Hello World"));
+ byte[] bytes = IOConverter.toByteArray(br);
+ assertNotNull(bytes);
+ assertEquals(11, bytes.length);
+ }
+
+ public void testToByteArrayOutputStream() throws Exception {
+ ByteArrayOutputStream os = new ByteArrayOutputStream();
+ os.write("Hello World".getBytes());
+ byte[] bytes = IOConverter.toByteArray(os);
+ assertNotNull(bytes);
+ assertEquals(11, bytes.length);
+ }
+
+ public void testToStringOutputStream() throws Exception {
+ ByteArrayOutputStream os = new ByteArrayOutputStream();
+ os.write("Hello World".getBytes());
+ String s = IOConverter.toString(os);
+ assertNotNull(s);
+ assertEquals("Hello World", s);
+ }
+
+ public void testToInputStreamOutputStream() throws Exception {
+ ByteArrayOutputStream os = new ByteArrayOutputStream();
+ os.write("Hello World".getBytes());
+
+ InputStream is = IOConverter.toInputStream(os);
+ assertNotNull(is);
+ assertEquals("Hello World", IOConverter.toString(is));
+ }
+
}
Added: camel/trunk/camel-core/src/test/java/org/apache/camel/converter/NIOConverterTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/test/java/org/apache/camel/converter/NIOConverterTest.java?rev=819506&view=auto
==============================================================================
--- camel/trunk/camel-core/src/test/java/org/apache/camel/converter/NIOConverterTest.java (added)
+++ camel/trunk/camel-core/src/test/java/org/apache/camel/converter/NIOConverterTest.java Mon Sep 28 12:12:55 2009
@@ -0,0 +1,113 @@
+/**
+ * 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.apache.camel.converter;
+
+import java.io.File;
+import java.io.InputStream;
+import java.nio.ByteBuffer;
+
+import org.apache.camel.ContextTestSupport;
+import org.apache.camel.Exchange;
+
+/**
+ * @version $Revision$
+ */
+public class NIOConverterTest extends ContextTestSupport {
+
+ public void testToByteArray() {
+ ByteBuffer bb = ByteBuffer.wrap("Hello".getBytes());
+ byte[] out = NIOConverter.toByteArray(bb);
+ assertNotNull(out);
+ assertEquals(5, out.length);
+ }
+
+ public void testToString() {
+ ByteBuffer bb = ByteBuffer.wrap("Hello".getBytes());
+ String out = NIOConverter.toString(bb, null);
+ assertNotNull(out);
+ assertEquals("Hello", out);
+ }
+
+ public void testToByteBuffer() {
+ ByteBuffer bb = NIOConverter.toByteBuffer("Hello".getBytes());
+ assertNotNull(bb);
+ }
+
+ public void testToByteBufferString() {
+ ByteBuffer bb = NIOConverter.toByteBuffer("Hello", null);
+ assertNotNull(bb);
+ }
+
+ public void testToByteBufferFile() throws Exception {
+ template.sendBodyAndHeader("file://target/nio", "Hello World", Exchange.FILE_NAME, "hello.txt");
+
+ ByteBuffer bb = NIOConverter.toByteBuffer(new File("target/nio/hello.txt"));
+ assertNotNull(bb);
+
+ assertEquals("Hello World", NIOConverter.toString(bb, null));
+ }
+
+ public void testToByteBufferShort() {
+ ByteBuffer bb = NIOConverter.toByteBuffer(Short.valueOf("2"));
+ assertNotNull(bb);
+
+ bb.position(0);
+ assertEquals(2, bb.getShort());
+ }
+
+ public void testToByteBufferInteger() {
+ ByteBuffer bb = NIOConverter.toByteBuffer(Integer.valueOf("2"));
+ assertNotNull(bb);
+
+ bb.position(0);
+ assertEquals(2, bb.getInt());
+ }
+
+ public void testToByteBufferLong() {
+ ByteBuffer bb = NIOConverter.toByteBuffer(Long.valueOf("2"));
+ assertNotNull(bb);
+
+ bb.position(0);
+ assertEquals(2, bb.getLong());
+ }
+
+ public void testToByteBufferDouble() {
+ ByteBuffer bb = NIOConverter.toByteBuffer(Double.valueOf("2"));
+ assertNotNull(bb);
+
+ bb.position(0);
+ assertEquals(2.0d, bb.getDouble());
+ }
+
+ public void testToByteBufferFloat() {
+ ByteBuffer bb = NIOConverter.toByteBuffer(Float.valueOf("2"));
+ assertNotNull(bb);
+
+ bb.position(0);
+ assertEquals(2.0f, bb.getFloat());
+ }
+
+ public void testToInputStream() throws Exception {
+ ByteBuffer bb = ByteBuffer.wrap("Hello".getBytes());
+
+ InputStream is = NIOConverter.toInputStream(bb);
+ assertNotNull(is);
+
+ assertEquals("Hello", IOConverter.toString(is));
+ }
+
+}
Propchange: camel/trunk/camel-core/src/test/java/org/apache/camel/converter/NIOConverterTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: camel/trunk/camel-core/src/test/java/org/apache/camel/converter/NIOConverterTest.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Added: camel/trunk/camel-core/src/test/java/org/apache/camel/converter/ObjectConverterTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/test/java/org/apache/camel/converter/ObjectConverterTest.java?rev=819506&view=auto
==============================================================================
--- camel/trunk/camel-core/src/test/java/org/apache/camel/converter/ObjectConverterTest.java (added)
+++ camel/trunk/camel-core/src/test/java/org/apache/camel/converter/ObjectConverterTest.java Mon Sep 28 12:12:55 2009
@@ -0,0 +1,86 @@
+/**
+ * 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.apache.camel.converter;
+
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.Iterator;
+
+import junit.framework.TestCase;
+
+/**
+ * @version $Revision$
+ */
+public class ObjectConverterTest extends TestCase {
+
+ public void testIsCollection() {
+ assertEquals(false, ObjectConverter.isCollection("String"));
+ assertEquals(false, ObjectConverter.isCollection(null));
+ assertEquals(true, ObjectConverter.isCollection(new ArrayList()));
+ assertEquals(true, ObjectConverter.isCollection(new String[]{"foo", "bar"}));
+ }
+
+ public void testIterator() {
+ Iterator it = ObjectConverter.iterator("Claus,Jonathan");
+ assertEquals("Claus", it.next());
+ assertEquals("Jonathan", it.next());
+ assertEquals(false, it.hasNext());
+ }
+
+ public void testToByte() {
+ assertEquals(Byte.valueOf("4"), ObjectConverter.toByte(Byte.valueOf("4")));
+ assertEquals(Byte.valueOf("4"), ObjectConverter.toByte(Integer.valueOf("4")));
+ assertEquals(Byte.valueOf("4"), ObjectConverter.toByte("4"));
+ assertEquals(null, ObjectConverter.toByte(new Date()));
+ }
+
+ public void testToShort() {
+ assertEquals(Short.valueOf("4"), ObjectConverter.toShort(Short.valueOf("4")));
+ assertEquals(Short.valueOf("4"), ObjectConverter.toShort(Integer.valueOf("4")));
+ assertEquals(Short.valueOf("4"), ObjectConverter.toShort("4"));
+ assertEquals(null, ObjectConverter.toShort(new Date()));
+ }
+
+ public void testToInteger() {
+ assertEquals(Integer.valueOf("4"), ObjectConverter.toInteger(Integer.valueOf("4")));
+ assertEquals(Integer.valueOf("4"), ObjectConverter.toInteger(Long.valueOf("4")));
+ assertEquals(Integer.valueOf("4"), ObjectConverter.toInteger("4"));
+ assertEquals(null, ObjectConverter.toInteger(new Date()));
+ }
+
+ public void testToLong() {
+ assertEquals(Long.valueOf("4"), ObjectConverter.toLong(Long.valueOf("4")));
+ assertEquals(Long.valueOf("4"), ObjectConverter.toLong(Integer.valueOf("4")));
+ assertEquals(Long.valueOf("4"), ObjectConverter.toLong("4"));
+ assertEquals(null, ObjectConverter.toLong(new Date()));
+ }
+
+ public void testToFloat() {
+ assertEquals(Float.valueOf("4"), ObjectConverter.toFloat(Float.valueOf("4")));
+ assertEquals(Float.valueOf("4"), ObjectConverter.toFloat(Integer.valueOf("4")));
+ assertEquals(Float.valueOf("4"), ObjectConverter.toFloat("4"));
+ assertEquals(null, ObjectConverter.toFloat(new Date()));
+ }
+
+ public void testToDouable() {
+ assertEquals(Double.valueOf("4"), ObjectConverter.toDouble(Double.valueOf("4")));
+ assertEquals(Double.valueOf("4"), ObjectConverter.toDouble(Integer.valueOf("4")));
+ assertEquals(Double.valueOf("4"), ObjectConverter.toDouble("4"));
+ assertEquals(null, ObjectConverter.toDouble(new Date()));
+ }
+
+}
Propchange: camel/trunk/camel-core/src/test/java/org/apache/camel/converter/ObjectConverterTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: camel/trunk/camel-core/src/test/java/org/apache/camel/converter/ObjectConverterTest.java
------------------------------------------------------------------------------
svn:keywords = Rev Date