oglueck 2002/10/21 07:39:23
Modified: httpclient/src/java/org/apache/commons/httpclient
Cookie.java
httpclient/src/test/org/apache/commons/httpclient
TestCookie.java
Log:
added more date format
added date tests
Revision Changes Path
1.24 +7 -5
jakarta-commons/httpclient/src/java/org/apache/commons/httpclient/Cookie.java
Index: Cookie.java
===================================================================
RCS file:
/home/cvs/jakarta-commons/httpclient/src/java/org/apache/commons/httpclient/Cookie.java,v
retrieving revision 1.23
retrieving revision 1.24
diff -u -r1.23 -r1.24
--- Cookie.java 11 Oct 2002 07:37:46 -0000 1.23
+++ Cookie.java 21 Oct 2002 14:39:22 -0000 1.24
@@ -1099,7 +1099,9 @@
new SimpleDateFormat("EEE dd MMM yy HH:mm:ss z", Locale.US),
new SimpleDateFormat("EEE dd MMM yyyy HH:mm:ss z", Locale.US),
new SimpleDateFormat("EEE, dd MMM yy HH:mm:ss z", Locale.US),
- new SimpleDateFormat("EEE, dd MMM yyyy HH:mm:ss z", Locale.US)
+ new SimpleDateFormat("EEE, dd MMM yyyy HH:mm:ss z", Locale.US),
+ new SimpleDateFormat("EEE, dd-MMM-yyyy HH-mm-ss z", Locale.US),
+ new SimpleDateFormat("EEE dd-MMM-yyyy HH-mm-ss z", Locale.US)
};
/** Collator for Cookie comparisons. Could be replaced with references to
specific Locales. */
1.11 +37 -4
jakarta-commons/httpclient/src/test/org/apache/commons/httpclient/TestCookie.java
Index: TestCookie.java
===================================================================
RCS file:
/home/cvs/jakarta-commons/httpclient/src/test/org/apache/commons/httpclient/TestCookie.java,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -r1.10 -r1.11
--- TestCookie.java 1 May 2002 07:07:50 -0000 1.10
+++ TestCookie.java 21 Oct 2002 14:39:22 -0000 1.11
@@ -633,5 +633,38 @@
fail("Threw wrong type of exception. Expected
IllegalArgumentException.");
}
}
+
+ /**
+ * Tests several date formats.
+ */
+ public void testDateFormats() throws Exception {
+ //comma, dashes
+ checkDate("Thu, 01-Jan-70 00:00:10 GMT");
+ checkDate("Thu, 01-Jan-2070 00:00:10 GMT");
+ //no comma, dashes
+ checkDate("Thu 01-Jan-70 00:00:10 GMT");
+ checkDate("Thu 01-Jan-2070 00:00:10 GMT");
+ //comma, spaces
+ checkDate("Thu, 01 Jan 70 00:00:10 GMT");
+ checkDate("Thu, 01 Jan 2070 00:00:10 GMT");
+ //no comma, spaces
+ checkDate("Thu 01 Jan 70 00:00:10 GMT");
+ checkDate("Thu 01 Jan 2070 00:00:10 GMT");
+ //weird stuff
+ checkDate("Wed, 20-Nov-2002 09-38-33 GMT");
+
+
+ try {
+ checkDate("this aint a date");
+ fail("Date check is bogous");
+ } catch(Exception e) {
+ /* must fail */
+ }
+ }
+
+ private void checkDate(String date) throws Exception {
+ Header setCookie = new Header("Set-Cookie",
"custno=12345;Expires='"+date+"'");
+ Cookie.parse("localhost","/",setCookie);
+ }
}
--
To unsubscribe, e-mail: <mailto:commons-dev-unsubscribe@;jakarta.apache.org>
For additional commands, e-mail: <mailto:commons-dev-help@;jakarta.apache.org>