Browse files

Fix buggy test: raw InputStream.read is not always guaranteed to read…

… the requested amount
  • Loading branch information...
1 parent 4272b2c commit 96ca1d13e098ac999708dbf7922c65d4722c4edb @mcculls mcculls committed Feb 13, 2012
View
4 ...-provider/src/test/java/org/sonatype/tests/http/server/jetty/impl/ClientSideCertTest.java
@@ -51,6 +51,8 @@
import org.sonatype.tests.http.server.jetty.impl.JettyServerProvider;
import org.sonatype.tests.http.server.jetty.impl.JettyServerProvider.CertificateHolder;
+import com.google.common.io.ByteStreams;
+
/**
* @author Benjamin Hanzelmann
*/
@@ -151,7 +153,7 @@ public void testClientSideCert()
content = (InputStream) connection.getContent();
Integer length = Integer.valueOf( connection.getHeaderField( "Content-Length" ) );
byte[] b = new byte[length];
- assertEquals( length.intValue(), content.read( b, 0, length ) );
+ assertEquals( length.intValue(), ByteStreams.read( content, b, 0, length ) );
assertEquals( "foo", new String( b ).trim() );
}

0 comments on commit 96ca1d1

Please sign in to comment.