Fixed test.
Made sure that read interest or upgrade only happen after the write has completed.
This commit is contained in:
parent
08c59628c9
commit
1ab64ed080
|
@ -146,7 +146,7 @@ public class HttpClientCustomProxyTest
|
|||
}
|
||||
}
|
||||
|
||||
private class CAFEBABEConnection extends AbstractConnection
|
||||
private class CAFEBABEConnection extends AbstractConnection implements Callback
|
||||
{
|
||||
private final ClientConnectionFactory connectionFactory;
|
||||
private final Map<String, Object> context;
|
||||
|
@ -162,8 +162,19 @@ public class HttpClientCustomProxyTest
|
|||
public void onOpen()
|
||||
{
|
||||
super.onOpen();
|
||||
getEndPoint().write(this, ByteBuffer.wrap(CAFE_BABE));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void succeeded()
|
||||
{
|
||||
fillInterested();
|
||||
getEndPoint().write(Callback.NOOP, ByteBuffer.wrap(CAFE_BABE));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void failed(Throwable x)
|
||||
{
|
||||
close();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -206,7 +217,7 @@ public class HttpClientCustomProxyTest
|
|||
}
|
||||
}
|
||||
|
||||
private class CAFEBABEServerConnection extends AbstractConnection
|
||||
private class CAFEBABEServerConnection extends AbstractConnection implements Callback
|
||||
{
|
||||
private final org.eclipse.jetty.server.ConnectionFactory connectionFactory;
|
||||
|
||||
|
@ -232,15 +243,25 @@ public class HttpClientCustomProxyTest
|
|||
int filled = getEndPoint().fill(buffer);
|
||||
Assert.assertEquals(4, filled);
|
||||
Assert.assertArrayEquals(CAFE_BABE, buffer.array());
|
||||
getEndPoint().write(Callback.NOOP, buffer);
|
||||
|
||||
// We are good, upgrade the connection
|
||||
getEndPoint().upgrade(connectionFactory.newConnection(connector, getEndPoint()));
|
||||
getEndPoint().write(this, buffer);
|
||||
}
|
||||
catch (Throwable x)
|
||||
{
|
||||
close();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void succeeded()
|
||||
{
|
||||
// We are good, upgrade the connection
|
||||
getEndPoint().upgrade(connectionFactory.newConnection(connector, getEndPoint()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void failed(Throwable x)
|
||||
{
|
||||
close();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue