use of org.junit.Ignore in project jetty.project by eclipse.
the class ConnectorTimeoutTest method testNoBlockingTimeoutRead.
@Test(timeout = 60000)
// TODO make more stable
@Ignore
public void testNoBlockingTimeoutRead() throws Exception {
_httpConfiguration.setBlockingTimeout(-1L);
configureServer(new EchoHandler());
Socket client = newSocket(_serverURI.getHost(), _serverURI.getPort());
client.setSoTimeout(10000);
InputStream is = client.getInputStream();
Assert.assertFalse(client.isClosed());
OutputStream os = client.getOutputStream();
os.write(("GET / HTTP/1.1\r\n" + "host: " + _serverURI.getHost() + ":" + _serverURI.getPort() + "\r\n" + "Transfer-Encoding: chunked\r\n" + "Content-Type: text/plain\r\n" + "Connection: close\r\n" + "\r\n" + "5\r\n" + "LMNOP\r\n").getBytes("utf-8"));
os.flush();
long start = System.currentTimeMillis();
try {
Thread.sleep(250);
os.write("1".getBytes("utf-8"));
os.flush();
Thread.sleep(250);
os.write("0".getBytes("utf-8"));
os.flush();
Thread.sleep(250);
os.write("\r".getBytes("utf-8"));
os.flush();
Thread.sleep(250);
os.write("\n".getBytes("utf-8"));
os.flush();
Thread.sleep(250);
os.write("0123456789ABCDEF\r\n".getBytes("utf-8"));
os.write("0\r\n".getBytes("utf-8"));
os.write("\r\n".getBytes("utf-8"));
os.flush();
} catch (Exception e) {
e.printStackTrace();
}
long duration = System.currentTimeMillis() - start;
Assert.assertThat(duration, Matchers.greaterThan(500L));
// read the response
String response = IO.toString(is);
Assert.assertThat(response, Matchers.startsWith("HTTP/1.1 200 OK"));
Assert.assertThat(response, Matchers.containsString("LMNOP0123456789ABCDEF"));
}
use of org.junit.Ignore in project jetty.project by eclipse.
the class ClientCloseTest method testNetworkCongestion.
@Ignore("Need sbordet's help here")
@Test
public void testNetworkCongestion() throws Exception {
// Set client timeout
final int timeout = 1000;
client.setMaxIdleTimeout(timeout);
// Client connects
CloseTrackingSocket clientSocket = new CloseTrackingSocket();
Future<Session> clientConnectFuture = client.connect(clientSocket, server.getWsUri());
// Server accepts connect
IBlockheadServerConnection serverConn = server.accept();
serverConn.upgrade();
// client confirms connection via echo
confirmConnection(clientSocket, clientConnectFuture, serverConn);
// client sends BIG frames (until it cannot write anymore)
// server must not read (for test purpose, in order to congest connection)
// when write is congested, client enqueue close frame
// client initiate write, but write never completes
EndPoint endp = clientSocket.getEndPoint();
assertThat("EndPoint is testable", endp, instanceOf(TestEndPoint.class));
TestEndPoint testendp = (TestEndPoint) endp;
char[] msg = new char[10240];
int writeCount = 0;
long writeSize = 0;
int i = 0;
while (!testendp.congestedFlush.get()) {
int z = i - ((i / 26) * 26);
char c = (char) ('a' + z);
Arrays.fill(msg, c);
clientSocket.getRemote().sendStringByFuture(String.valueOf(msg));
writeCount++;
writeSize += msg.length;
}
LOG.info("Wrote {} frames totalling {} bytes of payload before congestion kicked in", writeCount, writeSize);
// Verify timeout error
assertThat("OnError Latch", clientSocket.errorLatch.await(2, TimeUnit.SECONDS), is(true));
assertThat("OnError", clientSocket.error.get(), instanceOf(SocketTimeoutException.class));
}
use of org.junit.Ignore in project jetty.project by eclipse.
the class SessionTest method testBasicEcho_FromClient.
@Test
// TODO fix frequent failure
@Ignore
public void testBasicEcho_FromClient() throws Exception {
WebSocketClient client = new WebSocketClient();
client.start();
try {
JettyTrackingSocket cliSock = new JettyTrackingSocket();
client.getPolicy().setIdleTimeout(10000);
URI wsUri = server.getWsUri();
ClientUpgradeRequest request = new ClientUpgradeRequest();
request.setSubProtocols("echo");
Future<Session> future = client.connect(cliSock, wsUri, request);
final IBlockheadServerConnection srvSock = server.accept();
srvSock.upgrade();
Session sess = future.get(30000, TimeUnit.MILLISECONDS);
Assert.assertThat("Session", sess, notNullValue());
Assert.assertThat("Session.open", sess.isOpen(), is(true));
Assert.assertThat("Session.upgradeRequest", sess.getUpgradeRequest(), notNullValue());
Assert.assertThat("Session.upgradeResponse", sess.getUpgradeResponse(), notNullValue());
cliSock.assertWasOpened();
cliSock.assertNotClosed();
Collection<WebSocketSession> sessions = client.getBeans(WebSocketSession.class);
Assert.assertThat("client.connectionManager.sessions.size", sessions.size(), is(1));
RemoteEndpoint remote = cliSock.getSession().getRemote();
remote.sendStringByFuture("Hello World!");
if (remote.getBatchMode() == BatchMode.ON) {
remote.flush();
}
srvSock.echoMessage(1, 30000, TimeUnit.MILLISECONDS);
// wait for response from server
cliSock.waitForMessage(30000, TimeUnit.MILLISECONDS);
Set<WebSocketSession> open = client.getOpenSessions();
Assert.assertThat("(Before Close) Open Sessions.size", open.size(), is(1));
cliSock.assertMessage("Hello World!");
cliSock.close();
srvSock.close();
cliSock.waitForClose(30000, TimeUnit.MILLISECONDS);
open = client.getOpenSessions();
// TODO this sometimes fails!
Assert.assertThat("(After Close) Open Sessions.size", open.size(), is(0));
} finally {
client.stop();
}
}
use of org.junit.Ignore in project jetty.project by eclipse.
the class ConnectorServerTest method testIsLoopbackAddressWithWrongValue.
@Test
@Ignore
public void testIsLoopbackAddressWithWrongValue() throws Exception {
// given
JMXServiceURL serviceURLWithOutPort = new JMXServiceURL("service:jmx:rmi:///jndi/rmi://" + InetAddress.getLocalHost() + ":1199/jmxrmi");
// when
connectorServer = new ConnectorServer(serviceURLWithOutPort, " domain: key5 = value5");
// then
assertNull("As loopback address returns false...registry must be null", connectorServer._registry);
}
use of org.junit.Ignore in project jetty.project by eclipse.
the class ConnectorServerTest method testConnServerWithRmiDefaultPort.
@Test
// collides on ci server
@Ignore
public void testConnServerWithRmiDefaultPort() throws Exception {
// given
LocateRegistry.createRegistry(1099);
JMXServiceURL serviceURLWithOutPort = new JMXServiceURL("service:jmx:rmi:///jndi/rmi://localhost:1099/jmxrmi");
connectorServer = new ConnectorServer(serviceURLWithOutPort, " domain: key3 = value3");
// when
connectorServer.start();
// then
assertThat("Server status must be in started or starting", connectorServer.getState(), anyOf(is(ConnectorServer.STARTED), is(ConnectorServer.STARTING)));
}
Aggregations