cocoon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From vgritse...@apache.org
Subject svn commit: r515913 - /cocoon/trunk/blocks/cocoon-repository/cocoon-repository-impl/src/test/java/org/apache/cocoon/components/source/impl/CachingSourceTestCase.java
Date Thu, 08 Mar 2007 04:17:22 GMT
Author: vgritsenko
Date: Wed Mar  7 20:17:21 2007
New Revision: 515913

URL: http://svn.apache.org/viewvc?view=rev&rev=515913
Log:
google's content-type is inconsistent between requests causing test to fail sometimes.
use assertSame, assertEquals where appropriate.

Modified:
    cocoon/trunk/blocks/cocoon-repository/cocoon-repository-impl/src/test/java/org/apache/cocoon/components/source/impl/CachingSourceTestCase.java

Modified: cocoon/trunk/blocks/cocoon-repository/cocoon-repository-impl/src/test/java/org/apache/cocoon/components/source/impl/CachingSourceTestCase.java
URL: http://svn.apache.org/viewvc/cocoon/trunk/blocks/cocoon-repository/cocoon-repository-impl/src/test/java/org/apache/cocoon/components/source/impl/CachingSourceTestCase.java?view=diff&rev=515913&r1=515912&r2=515913
==============================================================================
--- cocoon/trunk/blocks/cocoon-repository/cocoon-repository-impl/src/test/java/org/apache/cocoon/components/source/impl/CachingSourceTestCase.java
(original)
+++ cocoon/trunk/blocks/cocoon-repository/cocoon-repository-impl/src/test/java/org/apache/cocoon/components/source/impl/CachingSourceTestCase.java
Wed Mar  7 20:17:21 2007
@@ -70,7 +70,7 @@
     }
 
     public void testCachingURI() throws Exception {
-        String uri = "caching:http://www.google.com/?cocoon:cache-expires=1";
+        String uri = "caching:http://slashdot.org/?cocoon:cache-expires=1";
 
         CachingSource source;
 
@@ -82,18 +82,16 @@
         CachingSource.SourceMeta meta2 = source.getResponseMeta();
         resolver.release(source);
 
-        assertTrue(meta1.getMimeType() == meta2.getMimeType());
-        assertTrue(meta1.getContentLength() == meta2.getContentLength());
-        assertTrue(meta1.getLastModified() == meta2.getLastModified());
+        // Source is cached -- same meta data
+        assertSame(meta1, meta2);
 
         source = (CachingSource) resolver.resolveURI(uri);
         source.refresh();
         CachingSource.SourceMeta meta3 = source.getResponseMeta();
         resolver.release(source);
 
-        assertTrue(meta1.getMimeType() == meta3.getMimeType());
-        assertTrue(meta1.getContentLength() == meta3.getContentLength());
-        assertTrue(meta1.getLastModified() == meta3.getLastModified());
+        // Source is still cached -- still same meta data
+        assertSame(meta1, meta3);
 
         Thread.sleep(1100);
 
@@ -101,18 +99,20 @@
         source.refresh();
         CachingSource.SourceMeta meta4 = source.getResponseMeta();
         resolver.release(source);
-        assertTrue(meta1 != meta4);
-        assertTrue(meta1.getContentLength() == meta4.getContentLength());
+
+        // Source is refreshed -- but meta data should not change
+        assertNotSame(meta1, meta4);
+        assertEquals(meta1.getContentLength(), meta4.getContentLength());
         assertTrue(meta1.getLastModified() != meta4.getLastModified());
         assertEquals(meta1.getMimeType(), meta4.getMimeType());
     }
 
     public void testRefreshSyncURI() throws Exception {
-        testRefreshURI("caching", "http://www.google.com/");
+        testRefreshURI("caching", "http://slashdot.org/");
     }
 
 //    public void testRefreshAsyncURI() throws Exception {
-//        testRefreshURI("async-caching", "http://www.google.com/");
+//        testRefreshURI("async-caching", "http://slashdot.org/");
 //    }
 
     private void testRefreshURI(final String scheme, final String uri) throws Exception {
@@ -126,9 +126,9 @@
         CachingSource.SourceMeta meta2 = source.getResponseMeta();
         resolver.release(source);
 
-        assertTrue(meta1 == meta2);
-        assertTrue(meta1.getContentLength() == meta2.getContentLength());
-        assertTrue(meta1.getLastModified() == meta2.getLastModified());
+        assertSame(meta1, meta2);
+        assertEquals(meta1.getContentLength(), meta2.getContentLength());
+        assertEquals(meta1.getLastModified(), meta2.getLastModified());
 
         Thread.sleep(1200);
 
@@ -136,8 +136,8 @@
         CachingSource.SourceMeta meta3 = source.getResponseMeta();
         resolver.release(source);
 
-        assertTrue(meta1 != meta3);
-        assertTrue(meta1.getContentLength() == meta3.getContentLength());
+        assertNotSame(meta1, meta3);
+        assertEquals(meta1.getContentLength(), meta3.getContentLength());
         assertTrue(meta1.getLastModified() != meta3.getLastModified());
         assertEquals(meta1.getMimeType(), meta3.getMimeType());
     }



Mime
View raw message