summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--pom.xml7
-rw-r--r--server/src/main/java/com/vaadin/server/Constants.java2
-rw-r--r--uitest/pom.xml4
-rw-r--r--uitest/src/test/java/com/vaadin/tests/application/ReconnectDialogUITest.java9
-rw-r--r--uitest/src/test/java/com/vaadin/tests/debug/PushVersionInfoTest.java6
-rw-r--r--uitest/src/test/java/com/vaadin/tests/push/BasicPushTest.java12
-rw-r--r--uitest/src/test/java/com/vaadin/tests/push/ReconnectTest.java20
-rw-r--r--uitest/src/test/java/com/vaadin/tests/tb3/AbstractTB3Test.java8
-rw-r--r--uitest/src/test/java/com/vaadin/tests/tb3/MultiBrowserTestWithProxy.java44
-rw-r--r--uitest/src/test/java/com/vaadin/tests/tb3/SimpleProxy.java109
10 files changed, 158 insertions, 63 deletions
diff --git a/pom.xml b/pom.xml
index 51eccd4f29..4ac52153ea 100644
--- a/pom.xml
+++ b/pom.xml
@@ -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>
@@ -282,11 +282,6 @@
<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>
<version>3.5.1.201410131835-r</version>
diff --git a/server/src/main/java/com/vaadin/server/Constants.java b/server/src/main/java/com/vaadin/server/Constants.java
index 2623f80dfe..16b685a24e 100644
--- a/server/src/main/java/com/vaadin/server/Constants.java
+++ b/server/src/main/java/com/vaadin/server/Constants.java
@@ -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"
diff --git a/uitest/pom.xml b/uitest/pom.xml
index 3b547b4d43..aa4f1f041e 100644
--- a/uitest/pom.xml
+++ b/uitest/pom.xml
@@ -180,10 +180,6 @@
</dependency>
<dependency>
- <groupId>com.jcraft</groupId>
- <artifactId>jsch</artifactId>
- </dependency>
- <dependency>
<groupId>commons-codec</groupId>
<artifactId>commons-codec</artifactId>
</dependency>
diff --git a/uitest/src/test/java/com/vaadin/tests/application/ReconnectDialogUITest.java b/uitest/src/test/java/com/vaadin/tests/application/ReconnectDialogUITest.java
index a0971e2c2e..647f116e02 100644
--- a/uitest/src/test/java/com/vaadin/tests/application/ReconnectDialogUITest.java
+++ b/uitest/src/test/java/com/vaadin/tests/application/ReconnectDialogUITest.java
@@ -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));
diff --git a/uitest/src/test/java/com/vaadin/tests/debug/PushVersionInfoTest.java b/uitest/src/test/java/com/vaadin/tests/debug/PushVersionInfoTest.java
index 5ea4fc1743..6e6893d3be 100644
--- a/uitest/src/test/java/com/vaadin/tests/debug/PushVersionInfoTest.java
+++ b/uitest/src/test/java/com/vaadin/tests/debug/PushVersionInfoTest.java
@@ -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();
diff --git a/uitest/src/test/java/com/vaadin/tests/push/BasicPushTest.java b/uitest/src/test/java/com/vaadin/tests/push/BasicPushTest.java
index ab0fcf7c0f..1264affcf2 100644
--- a/uitest/src/test/java/com/vaadin/tests/push/BasicPushTest.java
+++ b/uitest/src/test/java/com/vaadin/tests/push/BasicPushTest.java
@@ -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);
}
diff --git a/uitest/src/test/java/com/vaadin/tests/push/ReconnectTest.java b/uitest/src/test/java/com/vaadin/tests/push/ReconnectTest.java
index f3559d0574..8551d8eeea 100644
--- a/uitest/src/test/java/com/vaadin/tests/push/ReconnectTest.java
+++ b/uitest/src/test/java/com/vaadin/tests/push/ReconnectTest.java
@@ -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) {
diff --git a/uitest/src/test/java/com/vaadin/tests/tb3/AbstractTB3Test.java b/uitest/src/test/java/com/vaadin/tests/tb3/AbstractTB3Test.java
index b8ae59b4c8..1e054ca404 100644
--- a/uitest/src/test/java/com/vaadin/tests/tb3/AbstractTB3Test.java
+++ b/uitest/src/test/java/com/vaadin/tests/tb3/AbstractTB3Test.java
@@ -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();
}
diff --git a/uitest/src/test/java/com/vaadin/tests/tb3/MultiBrowserTestWithProxy.java b/uitest/src/test/java/com/vaadin/tests/tb3/MultiBrowserTestWithProxy.java
index 4b852ba534..314c02759e 100644
--- a/uitest/src/test/java/com/vaadin/tests/tb3/MultiBrowserTestWithProxy.java
+++ b/uitest/src/test/java/com/vaadin/tests/tb3/MultiBrowserTestWithProxy.java
@@ -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
diff --git a/uitest/src/test/java/com/vaadin/tests/tb3/SimpleProxy.java b/uitest/src/test/java/com/vaadin/tests/tb3/SimpleProxy.java
new file mode 100644
index 0000000000..4c72d7eb6d
--- /dev/null
+++ b/uitest/src/test/java/com/vaadin/tests/tb3/SimpleProxy.java
@@ -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) {
+
+ }
+ }
+ }
+ }
+
+}