From 84b544b7e32ac0ba99dc349bd9952adb9e4fd98f Mon Sep 17 00:00:00 2001 From: nash Date: Wed, 20 Oct 2010 21:59:32 +0000 Subject: TUSCANY-3742: Fix time comparison for If-Modified-Since and If-Unmodified-Since git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@1025776 13f79535-47bb-0310-9956-ffa450edef68 --- .../binding/atom/ProviderFeedEntityTagsTestCase.java | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) (limited to 'sca-java-1.x/branches/sca-java-1.6.1/modules/binding-atom-abdera/src/test/java/org/apache/tuscany') diff --git a/sca-java-1.x/branches/sca-java-1.6.1/modules/binding-atom-abdera/src/test/java/org/apache/tuscany/sca/binding/atom/ProviderFeedEntityTagsTestCase.java b/sca-java-1.x/branches/sca-java-1.6.1/modules/binding-atom-abdera/src/test/java/org/apache/tuscany/sca/binding/atom/ProviderFeedEntityTagsTestCase.java index b6957d7e5e..fd60ec447e 100644 --- a/sca-java-1.x/branches/sca-java-1.6.1/modules/binding-atom-abdera/src/test/java/org/apache/tuscany/sca/binding/atom/ProviderFeedEntityTagsTestCase.java +++ b/sca-java-1.x/branches/sca-java-1.6.1/modules/binding-atom-abdera/src/test/java/org/apache/tuscany/sca/binding/atom/ProviderFeedEntityTagsTestCase.java @@ -176,8 +176,9 @@ public class ProviderFeedEntityTagsTestCase { ClientResponse res = client.get(providerURI, opts); Assert.assertNotNull(res); try { - // Should return 304 - Feed not provided since feed is modified since. - Assert.assertEquals(304, res.getStatus()); + // Should return 200 - Feed provided since feed is unmodified since. + Assert.assertEquals(200, res.getStatus()); + Assert.assertEquals(ResponseType.SUCCESS, res.getType()); } finally { res.release(); } @@ -265,7 +266,7 @@ public class ProviderFeedEntityTagsTestCase { Date thisLastModified = res.getLastModified(); Assert.assertNotNull( thisLastModified ); - // Should return 200 - value since feed is changed + // Should return 200 - value since feed matches eTag Assert.assertEquals(200, res.getStatus()); Assert.assertEquals(ResponseType.SUCCESS, res.getType()); @@ -284,7 +285,7 @@ public class ProviderFeedEntityTagsTestCase { RequestOptions opts = new RequestOptions(); final String contentType = "application/atom+xml"; opts.setContentType(contentType); - opts.setHeader( "If-Unmodified-Since", dateFormat.format( new Date() )); + opts.setHeader( "If-Unmodified-Since", dateFormat.format( previousSecond(lastModified) )); ClientResponse res = client.get(providerURI, opts); Assert.assertNotNull(res); @@ -303,7 +304,7 @@ public class ProviderFeedEntityTagsTestCase { RequestOptions opts = new RequestOptions(); final String contentType = "application/atom+xml"; opts.setContentType(contentType); - opts.setHeader( "If-Modified-Since", dateFormat.format( lastModified )); + opts.setHeader( "If-Modified-Since", dateFormat.format( previousSecond(lastModified) )); ClientResponse res = client.get(providerURI, opts); Assert.assertNotNull(res); @@ -372,4 +373,13 @@ public class ProviderFeedEntityTagsTestCase { } } } + + /** + * Subtract one second from a date + * @param date with millisecond precision + * @return date with one second subtracted + */ + private Date previousSecond(Date date) { + return new Date(date.getTime() - 1000); + } } -- cgit v1.2.3