@@ -35,7 +35,7 @@ | |||
<javax.portlet.version>2.0</javax.portlet.version> | |||
<vaadin.sass.version>0.9.13</vaadin.sass.version> | |||
<!-- Note that this should be kept in sync with the class Constants --> | |||
<atmosphere.runtime.version>2.4.24.vaadin1</atmosphere.runtime.version> | |||
<atmosphere.runtime.version>2.4.30.vaadin1</atmosphere.runtime.version> | |||
<!-- OSGi --> | |||
<osgi.execution.environment>JavaSE-1.8</osgi.execution.environment> | |||
@@ -281,11 +281,6 @@ | |||
<artifactId>jetty-proxy</artifactId> | |||
<version>${jetty.version}</version> | |||
</dependency> | |||
<dependency> | |||
<groupId>com.jcraft</groupId> | |||
<artifactId>jsch</artifactId> | |||
<version>0.1.52</version> | |||
</dependency> | |||
<dependency> | |||
<groupId>org.eclipse.jgit</groupId> | |||
<artifactId>org.eclipse.jgit</artifactId> |
@@ -66,7 +66,7 @@ public interface Constants { | |||
+ "================================================================="; | |||
// Keep the version number in sync with pom.xml | |||
static final String REQUIRED_ATMOSPHERE_RUNTIME_VERSION = "2.4.24.vaadin1"; | |||
static final String REQUIRED_ATMOSPHERE_RUNTIME_VERSION = "2.4.30.vaadin1"; | |||
static final String INVALID_ATMOSPHERE_VERSION_WARNING = "\n" | |||
+ "=================================================================\n" |
@@ -179,10 +179,6 @@ | |||
<scope>provided</scope> | |||
</dependency> | |||
<dependency> | |||
<groupId>com.jcraft</groupId> | |||
<artifactId>jsch</artifactId> | |||
</dependency> | |||
<dependency> | |||
<groupId>commons-codec</groupId> | |||
<artifactId>commons-codec</artifactId> |
@@ -8,16 +8,15 @@ import org.junit.Test; | |||
import org.openqa.selenium.By; | |||
import org.openqa.selenium.WebElement; | |||
import com.jcraft.jsch.JSchException; | |||
import com.vaadin.testbench.elements.ButtonElement; | |||
import com.vaadin.testbench.parallel.TestCategory; | |||
import com.vaadin.tests.tb3.MultiBrowserTestWithProxy; | |||
@TestCategory("needs-ssh") | |||
import java.io.IOException; | |||
public class ReconnectDialogUITest extends MultiBrowserTestWithProxy { | |||
@Test | |||
public void reconnectTogglesBodyStyle() throws JSchException { | |||
public void reconnectTogglesBodyStyle() throws IOException { | |||
openTestURL(); | |||
getButton().click(); | |||
disconnectProxy(); | |||
@@ -33,7 +32,7 @@ public class ReconnectDialogUITest extends MultiBrowserTestWithProxy { | |||
} | |||
@Test | |||
public void reconnectDialogShownAndDisappears() throws JSchException { | |||
public void reconnectDialogShownAndDisappears() throws IOException { | |||
openTestURL(); | |||
getButton().click(); | |||
assertEquals("1. Hello from the server", getLogRow(0)); |
@@ -21,11 +21,12 @@ import com.vaadin.tests.tb3.SingleBrowserTest; | |||
public class PushVersionInfoTest extends SingleBrowserTest { | |||
@Test | |||
public void testDisabledPush() { | |||
public void testDisabledPush() throws InterruptedException { | |||
setDebug(true); | |||
openTestURL(); | |||
selectInfoTab(); | |||
Thread.sleep(500); | |||
assertNull("Found push info server string for disabled Push", | |||
getPushRowValue("Push server version")); | |||
assertNull("Found push info client string for disabled Push", | |||
@@ -33,11 +34,12 @@ public class PushVersionInfoTest extends SingleBrowserTest { | |||
} | |||
@Test | |||
public void testEnabledPush() { | |||
public void testEnabledPush() throws InterruptedException { | |||
setDebug(true); | |||
openTestURL("enablePush=true"); | |||
selectInfoTab(); | |||
Thread.sleep(500); | |||
WebElement pushRow = getPushRowValue("Push server version"); | |||
String atmVersion = findElement(By.className("atmosphere-version")) | |||
.getText(); |
@@ -2,6 +2,7 @@ package com.vaadin.tests.push; | |||
import org.junit.Test; | |||
import org.openqa.selenium.By; | |||
import org.openqa.selenium.NoSuchElementException; | |||
import org.openqa.selenium.WebElement; | |||
import com.vaadin.testbench.parallel.TestCategory; | |||
@@ -68,9 +69,14 @@ public abstract class BasicPushTest extends MultiBrowserTest { | |||
} | |||
protected void waitUntilClientCounterChanges(final int expectedValue) { | |||
waitUntil( | |||
input -> BasicPushTest | |||
.getClientCounter(BasicPushTest.this) == expectedValue, | |||
waitUntil(input -> { | |||
try { | |||
return BasicPushTest | |||
.getClientCounter(BasicPushTest.this) == expectedValue; | |||
} catch (NoSuchElementException e) { | |||
return false; | |||
} | |||
}, | |||
10); | |||
} | |||
@@ -1,11 +1,13 @@ | |||
package com.vaadin.tests.push; | |||
import org.junit.Test; | |||
import org.openqa.selenium.NoSuchElementException; | |||
import org.openqa.selenium.WebElement; | |||
import com.jcraft.jsch.JSchException; | |||
import com.vaadin.tests.tb3.MultiBrowserTestWithProxy; | |||
import java.io.IOException; | |||
public abstract class ReconnectTest extends MultiBrowserTestWithProxy { | |||
@Override | |||
@@ -23,7 +25,7 @@ public abstract class ReconnectTest extends MultiBrowserTestWithProxy { | |||
} | |||
@Test | |||
public void messageIsQueuedOnDisconnect() throws JSchException { | |||
public void messageIsQueuedOnDisconnect() throws IOException { | |||
disconnectProxy(); | |||
clickButtonAndWaitForTwoReconnectAttempts(); | |||
@@ -34,7 +36,7 @@ public abstract class ReconnectTest extends MultiBrowserTestWithProxy { | |||
@Test | |||
public void messageIsNotSentBeforeConnectionIsEstablished() | |||
throws JSchException, InterruptedException { | |||
throws IOException, InterruptedException { | |||
disconnectProxy(); | |||
waitForNextReconnectionAttempt(); | |||
@@ -65,7 +67,7 @@ public abstract class ReconnectTest extends MultiBrowserTestWithProxy { | |||
waitForDebugMessage("Reopening push connection"); | |||
} | |||
private void connectAndVerifyConnectionEstablished() throws JSchException { | |||
private void connectAndVerifyConnectionEstablished() throws IOException { | |||
connectProxy(); | |||
waitUntilServerCounterChanges(); | |||
} | |||
@@ -76,8 +78,14 @@ public abstract class ReconnectTest extends MultiBrowserTestWithProxy { | |||
private void waitUntilServerCounterChanges() { | |||
final int counter = BasicPushTest.getServerCounter(this); | |||
waitUntil(input -> BasicPushTest | |||
.getServerCounter(ReconnectTest.this) > counter, 30); | |||
waitUntil(input -> { | |||
try { | |||
return BasicPushTest | |||
.getServerCounter(ReconnectTest.this) > counter; | |||
} catch (NoSuchElementException e) { | |||
return false; | |||
} | |||
}, 30); | |||
} | |||
private void waitUntilClientCounterChanges(final int expectedValue) { |
@@ -801,8 +801,12 @@ public abstract class AbstractTB3Test extends ParallelTest { | |||
protected void openDebugLogTab() { | |||
waitUntil(input -> { | |||
WebElement element = getDebugLogButton(); | |||
return element != null; | |||
try { | |||
WebElement element = getDebugLogButton(); | |||
return element != null; | |||
} catch (NoSuchElementException e) { | |||
return false; | |||
} | |||
}, 15); | |||
getDebugLogButton().click(); | |||
} |
@@ -1,25 +1,17 @@ | |||
package com.vaadin.tests.tb3; | |||
import java.io.File; | |||
import java.util.concurrent.atomic.AtomicInteger; | |||
import com.vaadin.testbench.parallel.TestCategory; | |||
import org.junit.After; | |||
import com.jcraft.jsch.JSch; | |||
import com.jcraft.jsch.JSchException; | |||
import com.jcraft.jsch.Session; | |||
import com.vaadin.testbench.parallel.TestCategory; | |||
import java.io.IOException; | |||
import java.util.concurrent.atomic.AtomicInteger; | |||
@TestCategory("push") | |||
public abstract class MultiBrowserTestWithProxy extends MultiBrowserTest { | |||
private static AtomicInteger availablePort = new AtomicInteger(2000); | |||
private Session proxySession; | |||
private SimpleProxy proxySession; | |||
private Integer proxyPort = null; | |||
private JSch jsch; | |||
private static String sshDir = System.getProperty("user.home") + "/.ssh/"; | |||
private String[] publicKeys = { System.getProperty("sshkey.file"), | |||
sshDir + "id_rsa", sshDir + "id_dsa", sshDir + "id_rsa2" }; | |||
@Override | |||
public void setup() throws Exception { | |||
@@ -60,7 +52,7 @@ public abstract class MultiBrowserTestWithProxy extends MultiBrowserTest { | |||
/** | |||
* Ensure the proxy is active. Does nothing if the proxy is already active. | |||
*/ | |||
protected void connectProxy() throws JSchException { | |||
protected void connectProxy() throws IOException { | |||
if (proxySession != null) { | |||
return; | |||
} | |||
@@ -70,7 +62,7 @@ public abstract class MultiBrowserTestWithProxy extends MultiBrowserTest { | |||
try { | |||
createProxy(getProxyPort()); | |||
break; | |||
} catch (JSchException e) { | |||
} catch (IOException e) { | |||
sleep(500); | |||
if (i == 9) { | |||
throw new RuntimeException( | |||
@@ -80,26 +72,10 @@ public abstract class MultiBrowserTestWithProxy extends MultiBrowserTest { | |||
} | |||
} | |||
private void createProxy(int proxyPort) throws JSchException { | |||
if (jsch == null) { | |||
jsch = new JSch(); | |||
String keyFile = null; | |||
for (String publicKey : publicKeys) { | |||
if (publicKey != null) { | |||
if (new File(publicKey).exists()) { | |||
keyFile = publicKey; | |||
break; | |||
} | |||
} | |||
} | |||
jsch.addIdentity(keyFile); | |||
} | |||
proxySession = jsch.getSession("localhost"); | |||
proxySession.setConfig("StrictHostKeyChecking", "no"); | |||
proxySession.setPortForwardingL("0.0.0.0", proxyPort, | |||
super.getDeploymentHostname(), super.getDeploymentPort()); | |||
proxySession.connect(); | |||
private void createProxy(int proxyPort) throws IOException { | |||
proxySession = new SimpleProxy(proxyPort, getDeploymentHostname(), | |||
getDeploymentPort()); | |||
proxySession.start(); | |||
} | |||
@Override |
@@ -0,0 +1,109 @@ | |||
package com.vaadin.tests.tb3; | |||
import java.io.IOException; | |||
import java.io.InputStream; | |||
import java.io.OutputStream; | |||
import java.net.InetAddress; | |||
import java.net.ServerSocket; | |||
import java.net.Socket; | |||
import java.net.SocketException; | |||
import java.util.Queue; | |||
import java.util.concurrent.ConcurrentLinkedQueue; | |||
public class SimpleProxy extends Thread { | |||
private final ThreadGroup proxyThreads; | |||
private final Queue<Socket> sockets = new ConcurrentLinkedQueue<>(); | |||
private final ServerSocket serverSocket; | |||
private final String remoteHost; | |||
private final int remotePort; | |||
public SimpleProxy(int localPort, String remoteHost, int remotePort) | |||
throws IOException { | |||
super(new ThreadGroup("proxy " + localPort), "server"); | |||
this.remoteHost = remoteHost; | |||
this.remotePort = remotePort; | |||
proxyThreads = getThreadGroup(); | |||
serverSocket = new ServerSocket(localPort, 100, | |||
InetAddress.getByName("0.0.0.0")); | |||
setDaemon(true); | |||
} | |||
@Override | |||
public void run() { | |||
try { | |||
while (!isInterrupted() && !serverSocket.isClosed()) { | |||
try { | |||
Socket proxySocket = serverSocket.accept(); | |||
sockets.add(proxySocket); | |||
Socket remoteSocket = new Socket(remoteHost, remotePort); | |||
sockets.add(remoteSocket); | |||
new CopySocket(proxyThreads, proxySocket, remoteSocket) | |||
.start(); | |||
new CopySocket(proxyThreads, remoteSocket, proxySocket) | |||
.start(); | |||
} catch (SocketException e) { | |||
if (!serverSocket.isClosed()) { | |||
throw new RuntimeException(e); | |||
} | |||
} catch (IOException e) { | |||
throw new RuntimeException(e); | |||
} | |||
} | |||
} finally { | |||
disconnect(); | |||
} | |||
} | |||
public void disconnect() { | |||
proxyThreads.interrupt(); | |||
for (Socket socket : sockets) { | |||
try { | |||
socket.close(); | |||
} catch (IOException ignored) { | |||
} | |||
} | |||
try { | |||
serverSocket.close(); | |||
} catch (IOException ignored) { | |||
} | |||
} | |||
private class CopySocket extends Thread { | |||
private final InputStream inputStream; | |||
private final OutputStream outputStream; | |||
private CopySocket(ThreadGroup proxyThreads, Socket srcSocket, | |||
Socket dstSocket) throws IOException { | |||
super(proxyThreads, "proxy worker"); | |||
setDaemon(true); | |||
inputStream = srcSocket.getInputStream(); | |||
outputStream = dstSocket.getOutputStream(); | |||
} | |||
@Override | |||
public void run() { | |||
try { | |||
for (int b; (b = inputStream.read()) >= 0;) { | |||
outputStream.write(b); | |||
} | |||
} catch (SocketException ignored) { | |||
} catch (IOException e) { | |||
e.printStackTrace(); | |||
} finally { | |||
try { | |||
inputStream.close(); | |||
} catch (IOException ignored) { | |||
} | |||
try { | |||
outputStream.close(); | |||
} catch (IOException ignored) { | |||
} | |||
} | |||
} | |||
} | |||
} |