[utilities COMMIT] in /spring-extensions/trunk/src/test/java/net/shibboleth/ext/spring/resource: HTTPResourceTest.jav...

noreply at shibboleth.net noreply at shibboleth.net
Fri Jan 17 07:13:34 EST 2014


Author: rdw
Date: Fri Jan 17 07:13:34 2014
New Revision: 519

URL: http://svn.shibboleth.net/view/utilities?rev=519&view=rev
Log:
IDP-304 Test for the HTTPResource

Added:
    spring-extensions/trunk/src/test/java/net/shibboleth/ext/spring/resource/HTTPResourceTest.java   (with props)
    spring-extensions/trunk/src/test/java/net/shibboleth/ext/spring/resource/ResourceTestHelper.java   (with props)
Modified:
    spring-extensions/trunk/src/test/java/net/shibboleth/ext/spring/resource/SVNResourceTest.java

Modified: spring-extensions/trunk/src/test/java/net/shibboleth/ext/spring/resource/SVNResourceTest.java
URL: http://svn.shibboleth.net/view/utilities/spring-extensions/trunk/src/test/java/net/shibboleth/ext/spring/resource/SVNResourceTest.java?rev=519&r1=518&r2=519&view=diff
==============================================================================
--- spring-extensions/trunk/src/test/java/net/shibboleth/ext/spring/resource/SVNResourceTest.java (original)
+++ spring-extensions/trunk/src/test/java/net/shibboleth/ext/spring/resource/SVNResourceTest.java Fri Jan 17 07:13:34 2014
@@ -19,7 +19,6 @@
 
 import java.io.File;
 import java.io.IOException;
-import java.io.InputStream;
 import java.nio.file.Files;
 import java.nio.file.Path;
 import java.text.ParseException;
@@ -42,8 +41,6 @@
 import org.tmatesoft.svn.core.auth.BasicAuthenticationManager;
 import org.tmatesoft.svn.core.auth.ISVNAuthenticationManager;
 import org.tmatesoft.svn.core.wc.SVNClientManager;
-
-import com.google.common.io.Closeables;
 
 /**
  * test,
@@ -99,31 +96,6 @@
         theDir = null;
     }
 
-    protected boolean compare(final Resource first, final Resource second) throws IOException {
-        final InputStream firstStream = first.getInputStream();
-        final InputStream secondStream = second.getInputStream();
-
-        try {
-            while (true) {
-    
-                final int firstInt = firstStream.read();
-                final int secondInt = secondStream.read();
-    
-                if (firstInt == -1) {
-                    return secondInt == -1;
-                }
-    
-                if (firstInt != secondInt) {
-                    return false;
-                }
-            }
-        }
-        finally {
-            Closeables.close(firstStream, true);
-            Closeables.close(secondStream, true);
-        }
-    }
-
     @Test public void testRevision() throws IOException, ParseException {
         final Resource resource = new SVNResource(clientManager, url, theDir, ORIGINAL_VERSION, FILENAME);
         Assert.assertTrue(resource.exists());
@@ -133,10 +105,10 @@
 
         final Resource other = new ByteArrayResource(ORIGINAL_TEXT.getBytes());
 
-        Assert.assertTrue(compare(other, resource));
+        Assert.assertTrue(ResourceTestHelper.compare(other, resource));
         // Check rewind and check the compare code
-        Assert.assertFalse(compare(comparer, resource));
-        Assert.assertTrue(compare(other, resource));
+        Assert.assertFalse(ResourceTestHelper.compare(comparer, resource));
+        Assert.assertTrue(ResourceTestHelper.compare(other, resource));
     }
 
     @Test public void testNotExist() {
@@ -153,7 +125,7 @@
         long delta = resource.lastModified() - new DateTime(2013, 12, 31, 16, 59, 06, 500, DateTimeZone.UTC).getMillis();
         Assert.assertTrue(delta < 501 && delta > -501);
 
-        Assert.assertTrue(compare(comparer, resource));
+        Assert.assertTrue(ResourceTestHelper.compare(comparer, resource));
 
     }
     



More information about the commits mailing list