You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mina.apache.org by gn...@apache.org on 2009/08/19 10:32:31 UTC
svn commit: r805699 -
/mina/sshd/trunk/sshd-core/src/test/java/org/apache/sshd/ScpTest.java
Author: gnodet
Date: Wed Aug 19 08:32:30 2009
New Revision: 805699
URL: http://svn.apache.org/viewvc?rev=805699&view=rev
Log:
Fix the ScpTest to wait longer until the file is ok
Modified:
mina/sshd/trunk/sshd-core/src/test/java/org/apache/sshd/ScpTest.java
Modified: mina/sshd/trunk/sshd-core/src/test/java/org/apache/sshd/ScpTest.java
URL: http://svn.apache.org/viewvc/mina/sshd/trunk/sshd-core/src/test/java/org/apache/sshd/ScpTest.java?rev=805699&r1=805698&r2=805699&view=diff
==============================================================================
--- mina/sshd/trunk/sshd-core/src/test/java/org/apache/sshd/ScpTest.java (original)
+++ mina/sshd/trunk/sshd-core/src/test/java/org/apache/sshd/ScpTest.java Wed Aug 19 08:32:30 2009
@@ -116,16 +116,12 @@
target.delete();
assertFalse(target.exists());
sendFile("target/scp/out.txt", "out.txt", data);
- Thread.sleep(100);
- assertTrue(target.exists());
- assertEquals(data.length(), target.length());
+ assertFileLength(target, data.length(), 5000);
target.delete();
assertFalse(target.exists());
sendFile("target/scp", "out.txt", data);
- Thread.sleep(100);
- assertTrue(target.exists());
- assertEquals(data.length(), target.length());
+ assertFileLength(target, data.length(), 5000);
sendFileError("target", "scp", "0123456789\n");
@@ -139,9 +135,26 @@
root.delete();
sendDir("target", "scp", "out.txt", data);
- Thread.sleep(100);
- assertTrue(target.exists());
- assertEquals(data.length(), target.length());
+ assertFileLength(target, data.length(), 5000);
+ }
+
+ protected void assertFileLength(File file, long length, long timeout) throws Exception{
+ boolean ok = false;
+ while (timeout > 0) {
+ if (file.exists() && file.length() == length) {
+ if (!ok) {
+ ok = true;
+ } else {
+ return;
+ }
+ } else {
+ ok = false;
+ }
+ Thread.sleep(100);
+ timeout -= 100;
+ }
+ assertTrue(file.exists());
+ assertEquals(length, file.length());
}
protected String readFile(String path) throws Exception {