294563 fixed race in test

git-svn-id: svn+ssh://dev.eclipse.org/svnroot/rt/org.eclipse.jetty/jetty/trunk@1509 7e9141cc-0065-0410-87d8-b60c137991c4
This commit is contained in:
Greg Wilkins 2010-04-13 16:34:08 +00:00
parent 2daf72ff1e
commit fcd0c6a119
1 changed files with 17 additions and 11 deletions

View File

@ -109,6 +109,7 @@ public class WebSocketUpgradeTest extends TestCase
@Override
protected void onResponseStatus(Buffer version, int status, Buffer reason) throws IOException
{
waitFor(2);
_results.add(new Integer(status));
super.onResponseStatus(version,status,reason);
}
@ -120,22 +121,27 @@ public class WebSocketUpgradeTest extends TestCase
@Override
protected Connection onSwitchProtocol(EndPoint endp) throws IOException
{
waitFor(3);
WebSocketConnection connection = new WebSocketConnection(clientWS,endp);
// wait for 101.
_results.add("onSwitchProtocol");
_results.add(connection);
clientWS.onConnect(connection);
return connection;
}
private void waitFor(int results)
{
try
{
int c=10;
while(_results.size()==0 && c-->0)
Thread.sleep(100);
while(_results.size()<results && c-->0)
Thread.sleep(10);
}
catch(InterruptedException e)
{
e.printStackTrace();
}
_results.add("onSwitchProtocol");
_results.add(connection);
clientWS.onConnect(connection);
return connection;
}
};