Search in sources :

Example 26 with Ignore

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"));
}
Also used : InputStream(java.io.InputStream) OutputStream(java.io.OutputStream) Socket(java.net.Socket) ServletException(javax.servlet.ServletException) SocketException(java.net.SocketException) IOException(java.io.IOException) SSLException(javax.net.ssl.SSLException) Ignore(org.junit.Ignore) Test(org.junit.Test)

Example 27 with Ignore

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));
}
Also used : SocketTimeoutException(java.net.SocketTimeoutException) IBlockheadServerConnection(org.eclipse.jetty.websocket.common.test.IBlockheadServerConnection) EndPoint(org.eclipse.jetty.io.EndPoint) SocketChannelEndPoint(org.eclipse.jetty.io.SocketChannelEndPoint) EndPoint(org.eclipse.jetty.io.EndPoint) SocketChannelEndPoint(org.eclipse.jetty.io.SocketChannelEndPoint) Session(org.eclipse.jetty.websocket.api.Session) WebSocketSession(org.eclipse.jetty.websocket.common.WebSocketSession) Ignore(org.junit.Ignore) Test(org.junit.Test)

Example 28 with Ignore

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();
    }
}
Also used : IBlockheadServerConnection(org.eclipse.jetty.websocket.common.test.IBlockheadServerConnection) RemoteEndpoint(org.eclipse.jetty.websocket.api.RemoteEndpoint) URI(java.net.URI) WebSocketSession(org.eclipse.jetty.websocket.common.WebSocketSession) Session(org.eclipse.jetty.websocket.api.Session) WebSocketSession(org.eclipse.jetty.websocket.common.WebSocketSession) Ignore(org.junit.Ignore) Test(org.junit.Test)

Example 29 with Ignore

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);
}
Also used : JMXServiceURL(javax.management.remote.JMXServiceURL) Ignore(org.junit.Ignore) Test(org.junit.Test)

Example 30 with Ignore

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)));
}
Also used : JMXServiceURL(javax.management.remote.JMXServiceURL) Ignore(org.junit.Ignore) Test(org.junit.Test)

Aggregations

Ignore (org.junit.Ignore)5092 Test (org.junit.Test)4807 File (java.io.File)445 ArrayList (java.util.ArrayList)374 IOException (java.io.IOException)217 HashMap (java.util.HashMap)187 List (java.util.List)171 CountDownLatch (java.util.concurrent.CountDownLatch)118 Map (java.util.Map)103 LocalDate (java.time.LocalDate)94 Dataset (org.apache.jena.query.Dataset)93 InputStream (java.io.InputStream)89 Date (java.util.Date)88 Random (java.util.Random)85 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)83 Properties (java.util.Properties)78 DistributedTest (org.apache.geode.test.junit.categories.DistributedTest)78 HashSet (java.util.HashSet)71 ByteArrayOutputStream (java.io.ByteArrayOutputStream)70 ExecutorService (java.util.concurrent.ExecutorService)70