aboutsummaryrefslogtreecommitdiffstats
path: root/uitest/src/main/java/com/vaadin/tests/push
diff options
context:
space:
mode:
Diffstat (limited to 'uitest/src/main/java/com/vaadin/tests/push')
-rw-r--r--uitest/src/main/java/com/vaadin/tests/push/BarInUIDL.java11
-rw-r--r--uitest/src/main/java/com/vaadin/tests/push/BasicPush.java22
-rw-r--r--uitest/src/main/java/com/vaadin/tests/push/EnableDisablePush.java80
-rw-r--r--uitest/src/main/java/com/vaadin/tests/push/ManualLongPollingPushUI.java72
-rw-r--r--uitest/src/main/java/com/vaadin/tests/push/PushConfiguration.java29
-rw-r--r--uitest/src/main/java/com/vaadin/tests/push/PushConfigurator.java49
-rw-r--r--uitest/src/main/java/com/vaadin/tests/push/PushErrorHandling.java43
-rw-r--r--uitest/src/main/java/com/vaadin/tests/push/PushFromInit.java14
-rw-r--r--uitest/src/main/java/com/vaadin/tests/push/PushLargeData.java51
-rw-r--r--uitest/src/main/java/com/vaadin/tests/push/PushWebsocketDeadlockUI.java99
-rw-r--r--uitest/src/main/java/com/vaadin/tests/push/PushWithPreserveOnRefresh.java11
-rw-r--r--uitest/src/main/java/com/vaadin/tests/push/RefreshCloseConnection.java7
-rw-r--r--uitest/src/main/java/com/vaadin/tests/push/RoundTripTest.java14
-rw-r--r--uitest/src/main/java/com/vaadin/tests/push/TablePushStreaming.java29
-rw-r--r--uitest/src/main/java/com/vaadin/tests/push/TogglePush.java30
15 files changed, 184 insertions, 377 deletions
diff --git a/uitest/src/main/java/com/vaadin/tests/push/BarInUIDL.java b/uitest/src/main/java/com/vaadin/tests/push/BarInUIDL.java
index 738315cc7f..1e526d3d43 100644
--- a/uitest/src/main/java/com/vaadin/tests/push/BarInUIDL.java
+++ b/uitest/src/main/java/com/vaadin/tests/push/BarInUIDL.java
@@ -20,8 +20,6 @@ import com.vaadin.annotations.Push;
import com.vaadin.server.VaadinRequest;
import com.vaadin.shared.ui.ui.Transport;
import com.vaadin.tests.components.AbstractReindeerTestUI;
-import com.vaadin.ui.Button;
-import com.vaadin.ui.Button.ClickEvent;
import com.vaadin.ui.Label;
@Push(transport = Transport.STREAMING)
@@ -35,13 +33,8 @@ public class BarInUIDL extends AbstractReindeerTestUI {
*/
@Override
protected void setup(VaadinRequest request) {
- addButton("Click Me", new Button.ClickListener() {
- @Override
- public void buttonClick(ClickEvent event) {
- addComponent(new Label("Thank you for clicking | bar"));
- }
- });
-
+ addButton("Click Me", event -> addComponent(
+ new Label("Thank you for clicking | bar")));
}
/*
diff --git a/uitest/src/main/java/com/vaadin/tests/push/BasicPush.java b/uitest/src/main/java/com/vaadin/tests/push/BasicPush.java
index 5b807092c3..c973bba648 100644
--- a/uitest/src/main/java/com/vaadin/tests/push/BasicPush.java
+++ b/uitest/src/main/java/com/vaadin/tests/push/BasicPush.java
@@ -23,7 +23,6 @@ import com.vaadin.server.VaadinRequest;
import com.vaadin.shared.ui.ContentMode;
import com.vaadin.tests.components.AbstractReindeerTestUI;
import com.vaadin.ui.Button;
-import com.vaadin.ui.Button.ClickEvent;
import com.vaadin.ui.Button.ClickListener;
import com.vaadin.ui.Label;
@@ -60,13 +59,9 @@ public class BasicPush extends AbstractReindeerTestUI {
addComponent(lbl);
Button incrementButton = new Button("Increment",
- new Button.ClickListener() {
-
- @Override
- public void buttonClick(ClickEvent event) {
- clientCounter++;
- lbl.setValue(String.valueOf(clientCounter));
- }
+ event -> {
+ clientCounter++;
+ lbl.setValue(String.valueOf(clientCounter));
});
incrementButton.setId(INCREMENT_BUTTON_ID);
addComponent(incrementButton);
@@ -104,13 +99,10 @@ public class BasicPush extends AbstractReindeerTestUI {
startTimer.setId(START_TIMER_ID);
addComponent(startTimer);
- Button stopTimer = new Button("Stop timer", new Button.ClickListener() {
- @Override
- public void buttonClick(ClickEvent event) {
- if (task != null) {
- task.cancel();
- task = null;
- }
+ Button stopTimer = new Button("Stop timer", event -> {
+ if (task != null) {
+ task.cancel();
+ task = null;
}
});
stopTimer.setId(STOP_TIMER_ID);
diff --git a/uitest/src/main/java/com/vaadin/tests/push/EnableDisablePush.java b/uitest/src/main/java/com/vaadin/tests/push/EnableDisablePush.java
index cf7c1eba80..3202e86bf9 100644
--- a/uitest/src/main/java/com/vaadin/tests/push/EnableDisablePush.java
+++ b/uitest/src/main/java/com/vaadin/tests/push/EnableDisablePush.java
@@ -29,17 +29,14 @@ public class EnableDisablePush extends AbstractReindeerTestUI {
while (true) {
TimeUnit.MILLISECONDS.sleep(500);
- access(new Runnable() {
- @Override
- public void run() {
- log.log("Counter = " + c++);
- if (c == 3) {
- log.log("Disabling polling, enabling push");
- getPushConfiguration()
- .setPushMode(PushMode.AUTOMATIC);
- setPollInterval(-1);
- log.log("Polling disabled, push enabled");
- }
+ access(() -> {
+ log.log("Counter = " + c++);
+ if (c == 3) {
+ log.log("Disabling polling, enabling push");
+ getPushConfiguration()
+ .setPushMode(PushMode.AUTOMATIC);
+ setPollInterval(-1);
+ log.log("Polling disabled, push enabled");
}
});
if (c == 3) {
@@ -58,54 +55,39 @@ public class EnableDisablePush extends AbstractReindeerTestUI {
getPushConfiguration().setPushMode(PushMode.AUTOMATIC);
log.log("Push enabled");
- addComponent(new Button("Disable push", new Button.ClickListener() {
- @Override
- public void buttonClick(Button.ClickEvent event) {
- log.log("Disabling push");
- getPushConfiguration().setPushMode(PushMode.DISABLED);
- log.log("Push disabled");
- }
+ addComponent(new Button("Disable push", event -> {
+ log.log("Disabling push");
+ getPushConfiguration().setPushMode(PushMode.DISABLED);
+ log.log("Push disabled");
}));
- addComponent(new Button("Enable push", new Button.ClickListener() {
- @Override
- public void buttonClick(Button.ClickEvent event) {
- log.log("Enabling push");
- getPushConfiguration().setPushMode(PushMode.AUTOMATIC);
- log.log("Push enabled");
- }
+ addComponent(new Button("Enable push", event -> {
+ log.log("Enabling push");
+ getPushConfiguration().setPushMode(PushMode.AUTOMATIC);
+ log.log("Push enabled");
}));
- addComponent(new Button("Disable polling", new Button.ClickListener() {
- @Override
- public void buttonClick(Button.ClickEvent event) {
- log.log("Disabling poll");
- setPollInterval(-1);
- log.log("Poll disabled");
- }
+ addComponent(new Button("Disable polling", even -> {
+ log.log("Disabling poll");
+ setPollInterval(-1);
+ log.log("Poll disabled");
}));
- addComponent(new Button("Enable polling", new Button.ClickListener() {
- @Override
- public void buttonClick(Button.ClickEvent event) {
- log.log("Enabling poll");
- setPollInterval(1000);
- log.log("Poll enabled");
- }
+ addComponent(new Button("Enable polling", event -> {
+ log.log("Enabling poll");
+ setPollInterval(1000);
+ log.log("Poll enabled");
}));
addComponent(
new Button("Disable push, re-enable from background thread",
- new Button.ClickListener() {
- @Override
- public void buttonClick(Button.ClickEvent event) {
- log.log("Disabling push, enabling polling");
- getPushConfiguration()
- .setPushMode(PushMode.DISABLED);
- setPollInterval(1000);
- timer.schedule(new CounterTask(), new Date());
- log.log("Push disabled, polling enabled");
- }
+ event -> {
+ log.log("Disabling push, enabling polling");
+ getPushConfiguration()
+ .setPushMode(PushMode.DISABLED);
+ setPollInterval(1000);
+ timer.schedule(new CounterTask(), new Date());
+ log.log("Push disabled, polling enabled");
}));
addComponent(log);
diff --git a/uitest/src/main/java/com/vaadin/tests/push/ManualLongPollingPushUI.java b/uitest/src/main/java/com/vaadin/tests/push/ManualLongPollingPushUI.java
index 3908c7a48b..fcc4b5d018 100644
--- a/uitest/src/main/java/com/vaadin/tests/push/ManualLongPollingPushUI.java
+++ b/uitest/src/main/java/com/vaadin/tests/push/ManualLongPollingPushUI.java
@@ -24,7 +24,6 @@ import com.vaadin.shared.communication.PushMode;
import com.vaadin.shared.ui.ui.Transport;
import com.vaadin.tests.components.AbstractTestUIWithLog;
import com.vaadin.ui.Button;
-import com.vaadin.ui.Button.ClickEvent;
@Push(value = PushMode.MANUAL, transport = Transport.LONG_POLLING)
public class ManualLongPollingPushUI extends AbstractTestUIWithLog {
@@ -34,61 +33,38 @@ public class ManualLongPollingPushUI extends AbstractTestUIWithLog {
@Override
protected void setup(VaadinRequest request) {
Button b = new Button("Manual push after 1s",
- new Button.ClickListener() {
- @Override
- public void buttonClick(ClickEvent event) {
- executor.submit(new Runnable() {
- @Override
- public void run() {
- try {
- Thread.sleep(1000);
- } catch (InterruptedException e) {
- e.printStackTrace();
- }
- access(new Runnable() {
-
- @Override
- public void run() {
- log("Logged after 1s, followed by manual push");
- push();
- }
- });
-
- }
+ event -> {
+ executor.submit(() -> {
+ try {
+ Thread.sleep(1000);
+ } catch (InterruptedException e) {
+ e.printStackTrace();
+ }
+ access(() -> {
+ log("Logged after 1s, followed by manual push");
+ push();
});
- }
+ });
});
addComponent(b);
b = new Button("Double manual push after 1s",
- new Button.ClickListener() {
- @Override
- public void buttonClick(ClickEvent event) {
- executor.submit(new Runnable() {
- @Override
- public void run() {
- try {
- Thread.sleep(1000);
- } catch (InterruptedException e) {
- e.printStackTrace();
- }
- access(new Runnable() {
-
- @Override
- public void run() {
- log("First message logged after 1s, followed by manual push");
- push();
- log("Second message logged after 1s, followed by manual push");
- push();
- }
- });
-
- }
+ event -> {
+ executor.submit(() -> {
+ try {
+ Thread.sleep(1000);
+ } catch (InterruptedException e) {
+ e.printStackTrace();
+ }
+ access(() -> {
+ log("First message logged after 1s, followed by manual push");
+ push();
+ log("Second message logged after 1s, followed by manual push");
+ push();
});
- }
+ });
});
addComponent(b);
-
}
}
diff --git a/uitest/src/main/java/com/vaadin/tests/push/PushConfiguration.java b/uitest/src/main/java/com/vaadin/tests/push/PushConfiguration.java
index b4a23ba5d5..3367859fe1 100644
--- a/uitest/src/main/java/com/vaadin/tests/push/PushConfiguration.java
+++ b/uitest/src/main/java/com/vaadin/tests/push/PushConfiguration.java
@@ -23,7 +23,6 @@ import com.vaadin.server.VaadinRequest;
import com.vaadin.shared.ui.ContentMode;
import com.vaadin.tests.components.AbstractReindeerTestUI;
import com.vaadin.ui.Button;
-import com.vaadin.ui.Button.ClickEvent;
import com.vaadin.ui.Label;
public class PushConfiguration extends AbstractReindeerTestUI {
@@ -36,12 +35,9 @@ public class PushConfiguration extends AbstractReindeerTestUI {
@Override
public void run() {
- access(new Runnable() {
- @Override
- public void run() {
- counter2++;
- serverCounterLabel.setValue("" + counter2);
- }
+ access(() -> {
+ counter2++;
+ serverCounterLabel.setValue("" + counter2);
});
}
};
@@ -60,13 +56,8 @@ public class PushConfiguration extends AbstractReindeerTestUI {
.setCaption("Client counter (click 'increment' to update):");
addComponent(clientCounterLabel);
- addComponent(new Button("Increment", new Button.ClickListener() {
-
- @Override
- public void buttonClick(ClickEvent event) {
- clientCounterLabel.setValue("" + counter++);
- }
- }));
+ addComponent(new Button("Increment",
+ event -> clientCounterLabel.setValue("" + counter++)));
spacer();
@@ -75,13 +66,9 @@ public class PushConfiguration extends AbstractReindeerTestUI {
"Server counter (updates each 1s by server thread) :");
addComponent(serverCounterLabel);
- addComponent(new Button("Reset", new Button.ClickListener() {
-
- @Override
- public void buttonClick(ClickEvent event) {
- counter2 = 0;
- serverCounterLabel.setValue("0");
- }
+ addComponent(new Button("Reset", event ->{
+ counter2 = 0;
+ serverCounterLabel.setValue("0");
}));
}
diff --git a/uitest/src/main/java/com/vaadin/tests/push/PushConfigurator.java b/uitest/src/main/java/com/vaadin/tests/push/PushConfigurator.java
index 34c4449556..63a380b991 100644
--- a/uitest/src/main/java/com/vaadin/tests/push/PushConfigurator.java
+++ b/uitest/src/main/java/com/vaadin/tests/push/PushConfigurator.java
@@ -28,15 +28,11 @@ import com.vaadin.shared.ui.ContentMode;
import com.vaadin.shared.ui.ui.Transport;
import com.vaadin.ui.Alignment;
import com.vaadin.ui.Button;
-import com.vaadin.ui.Button.ClickEvent;
-import com.vaadin.ui.Button.ClickListener;
import com.vaadin.ui.HorizontalLayout;
import com.vaadin.ui.Label;
import com.vaadin.ui.PushConfiguration;
import com.vaadin.ui.UI;
import com.vaadin.ui.VerticalLayout;
-import com.vaadin.v7.data.Property.ValueChangeEvent;
-import com.vaadin.v7.data.Property.ValueChangeListener;
import com.vaadin.v7.ui.NativeSelect;
import com.vaadin.v7.ui.TextField;
@@ -111,41 +107,28 @@ public class PushConfigurator extends VerticalLayout {
* @since
*/
private void listeners() {
- pushMode.addValueChangeListener(new ValueChangeListener() {
- @Override
- public void valueChange(ValueChangeEvent event) {
- ui.getPushConfiguration()
- .setPushMode((PushMode) pushMode.getValue());
- refreshStatus();
- }
+ pushMode.addValueChangeListener(event -> {
+ ui.getPushConfiguration()
+ .setPushMode((PushMode) pushMode.getValue());
+ refreshStatus();
});
- transport.addValueChangeListener(new ValueChangeListener() {
- @Override
- public void valueChange(ValueChangeEvent event) {
- Transport t = (Transport) transport.getValue();
- ui.getPushConfiguration().setTransport(t);
- refreshStatus();
- }
+ transport.addValueChangeListener(event -> {
+ Transport t = (Transport) transport.getValue();
+ ui.getPushConfiguration().setTransport(t);
+ refreshStatus();
});
- fallbackTransport.addValueChangeListener(new ValueChangeListener() {
- @Override
- public void valueChange(ValueChangeEvent event) {
- Transport t = (Transport) fallbackTransport.getValue();
- ui.getPushConfiguration().setFallbackTransport(t);
- refreshStatus();
- }
+ fallbackTransport.addValueChangeListener(event -> {
+ Transport t = (Transport) fallbackTransport.getValue();
+ ui.getPushConfiguration().setFallbackTransport(t);
+ refreshStatus();
});
- set.addClickListener(new ClickListener() {
- @Override
- public void buttonClick(ClickEvent event) {
- ui.getPushConfiguration().setParameter(parameter.getValue(),
- value.getValue());
- refreshStatus();
- }
+ set.addClickListener(event -> {
+ ui.getPushConfiguration().setParameter(parameter.getValue(),
+ value.getValue());
+ refreshStatus();
});
-
}
}
diff --git a/uitest/src/main/java/com/vaadin/tests/push/PushErrorHandling.java b/uitest/src/main/java/com/vaadin/tests/push/PushErrorHandling.java
index 82b922db37..a94c3c0698 100644
--- a/uitest/src/main/java/com/vaadin/tests/push/PushErrorHandling.java
+++ b/uitest/src/main/java/com/vaadin/tests/push/PushErrorHandling.java
@@ -12,8 +12,6 @@ import com.vaadin.ui.Button;
import com.vaadin.ui.Label;
import com.vaadin.v7.data.util.AbstractInMemoryContainer;
import com.vaadin.v7.data.util.BeanContainer;
-import com.vaadin.v7.event.ItemClickEvent;
-import com.vaadin.v7.event.ItemClickEvent.ItemClickListener;
import com.vaadin.v7.ui.Table;
public class PushErrorHandling extends AbstractReindeerTestUI {
@@ -43,36 +41,29 @@ public class PushErrorHandling extends AbstractReindeerTestUI {
view.setImmediate(true);
view.setSizeFull();
- view.addItemClickListener(new ItemClickListener() {
+ view.addItemClickListener(event -> {
+ BeanContainer<String, AbstractInMemoryContainer<?, ?, ?>> metaContainer = new BeanContainer<String, AbstractInMemoryContainer<?, ?, ?>>(
+ AbstractInMemoryContainer.class) {
+ @Override
+ public Collection<String> getContainerPropertyIds() {
+ List<String> cpropIds = new ArrayList<>(
+ super.getContainerPropertyIds());
+ cpropIds.add("testid");
+ return cpropIds;
+ }
- @Override
- public void itemClick(ItemClickEvent event) {
- BeanContainer<String, AbstractInMemoryContainer<?, ?, ?>> metaContainer
- = new BeanContainer<String, AbstractInMemoryContainer<?, ?, ?>>(
- AbstractInMemoryContainer.class) {
- @Override
- public Collection<String> getContainerPropertyIds() {
- List<String> cpropIds = new ArrayList<>(
- super.getContainerPropertyIds());
- cpropIds.add("testid");
- return cpropIds;
- }
-
- @Override
- public Class<?> getType(Object propertyId) {
- ((Object) null).hashCode();
- return super.getType(propertyId);
- }
- };
- view.setContainerDataSource(metaContainer);
-
- }
+ @Override
+ public Class<?> getType(Object propertyId) {
+ ((Object) null).hashCode();
+ return super.getType(propertyId);
+ }
+ };
+ view.setContainerDataSource(metaContainer);
});
view.addContainerProperty("Column", String.class, "Click for NPE");
view.addItem(new Object());
addComponent(view);
-
}
@Override
diff --git a/uitest/src/main/java/com/vaadin/tests/push/PushFromInit.java b/uitest/src/main/java/com/vaadin/tests/push/PushFromInit.java
index b7ce646526..30de763aa4 100644
--- a/uitest/src/main/java/com/vaadin/tests/push/PushFromInit.java
+++ b/uitest/src/main/java/com/vaadin/tests/push/PushFromInit.java
@@ -43,12 +43,7 @@ public class PushFromInit extends AbstractTestUIWithLog {
class RunBeforeInitEnds implements Runnable {
@Override
public void run() {
- access(new Runnable() {
- @Override
- public void run() {
- log(LOG_DURING_INIT);
- }
- });
+ access(() -> log(LOG_DURING_INIT));
}
}
@@ -60,12 +55,7 @@ public class PushFromInit extends AbstractTestUIWithLog {
} catch (InterruptedException e) {
e.printStackTrace();
}
- access(new Runnable() {
- @Override
- public void run() {
- log(LOG_AFTER_INIT);
- }
- });
+ access(() -> log(LOG_AFTER_INIT));
}
}
diff --git a/uitest/src/main/java/com/vaadin/tests/push/PushLargeData.java b/uitest/src/main/java/com/vaadin/tests/push/PushLargeData.java
index 8617d8f88d..c8d3e4b79a 100644
--- a/uitest/src/main/java/com/vaadin/tests/push/PushLargeData.java
+++ b/uitest/src/main/java/com/vaadin/tests/push/PushLargeData.java
@@ -26,8 +26,6 @@ import com.vaadin.server.VaadinRequest;
import com.vaadin.tests.components.AbstractTestUIWithLog;
import com.vaadin.tests.util.LoremIpsum;
import com.vaadin.ui.Button;
-import com.vaadin.ui.Button.ClickEvent;
-import com.vaadin.ui.Button.ClickListener;
import com.vaadin.ui.Label;
import com.vaadin.ui.UI;
import com.vaadin.v7.ui.TextField;
@@ -77,20 +75,15 @@ public abstract class PushLargeData extends AbstractTestUIWithLog {
Button b = new Button("Start pushing");
b.setId("startButton");
- b.addClickListener(new ClickListener() {
-
- @Override
- public void buttonClick(ClickEvent event) {
- Integer pushSize = (Integer) dataSize.getConvertedValue();
- Integer pushInterval = (Integer) interval.getConvertedValue();
- Integer pushDuration = (Integer) duration.getConvertedValue();
- PushRunnable r = new PushRunnable(getUI(), pushSize,
- pushInterval, pushDuration);
- executor.execute(r);
- log.log("Starting push, size: " + pushSize + ", interval: "
- + pushInterval + "ms, duration: " + pushDuration
- + "ms");
- }
+ b.addClickListener(event -> {
+ Integer pushSize = (Integer) dataSize.getConvertedValue();
+ Integer pushInterval = (Integer) interval.getConvertedValue();
+ Integer pushDuration = (Integer) duration.getConvertedValue();
+ PushRunnable r = new PushRunnable(getUI(), pushSize, pushInterval,
+ pushDuration);
+ executor.execute(r);
+ log.log("Starting push, size: " + pushSize + ", interval: "
+ + pushInterval + "ms, duration: " + pushDuration + "ms");
});
addComponent(b);
addComponent(dataLabel);
@@ -132,16 +125,13 @@ public abstract class PushLargeData extends AbstractTestUIWithLog {
int packageIndex = 1;
while (System.currentTimeMillis() < endTime) {
final int idx = packageIndex++;
- ui.access(new Runnable() {
- @Override
- public void run() {
- PushLargeData pushUi = (PushLargeData) ui;
- // Using description as it is not rendered to the DOM
- // immediately
- pushUi.getDataLabel().setDescription(
- System.currentTimeMillis() + ": " + data);
- pushUi.log("Package " + idx + " pushed");
- }
+ ui.access(() -> {
+ PushLargeData pushUi = (PushLargeData) ui;
+ // Using description as it is not rendered to the DOM
+ // immediately
+ pushUi.getDataLabel().setDescription(
+ System.currentTimeMillis() + ": " + data);
+ pushUi.log("Package " + idx + " pushed");
});
try {
Thread.sleep(interval);
@@ -149,12 +139,9 @@ public abstract class PushLargeData extends AbstractTestUIWithLog {
return;
}
}
- ui.access(new Runnable() {
- @Override
- public void run() {
- PushLargeData pushUi = (PushLargeData) ui;
- pushUi.log("Push complete");
- }
+ ui.access(() -> {
+ PushLargeData pushUi = (PushLargeData) ui;
+ pushUi.log("Push complete");
});
}
diff --git a/uitest/src/main/java/com/vaadin/tests/push/PushWebsocketDeadlockUI.java b/uitest/src/main/java/com/vaadin/tests/push/PushWebsocketDeadlockUI.java
index ff2389b5a4..b8163e09c8 100644
--- a/uitest/src/main/java/com/vaadin/tests/push/PushWebsocketDeadlockUI.java
+++ b/uitest/src/main/java/com/vaadin/tests/push/PushWebsocketDeadlockUI.java
@@ -1,15 +1,11 @@
package com.vaadin.tests.push;
import com.vaadin.annotations.Push;
-import com.vaadin.server.SessionDestroyEvent;
-import com.vaadin.server.SessionDestroyListener;
import com.vaadin.server.VaadinRequest;
import com.vaadin.server.WrappedSession;
import com.vaadin.shared.ui.ui.Transport;
import com.vaadin.tests.components.AbstractTestUIWithLog;
import com.vaadin.ui.Button;
-import com.vaadin.ui.Button.ClickEvent;
-import com.vaadin.ui.Button.ClickListener;
import com.vaadin.ui.Label;
@Push(transport = Transport.WEBSOCKET)
@@ -35,85 +31,58 @@ public class PushWebsocketDeadlockUI extends AbstractTestUIWithLog {
protected void setup(VaadinRequest request) {
WrappedSession wrappedSession = getSession().getSession();
request.getService()
- .addSessionDestroyListener(new SessionDestroyListener() {
- @Override
- public void sessionDestroy(SessionDestroyEvent e) {
- System.out.println(
- "Session " + e.getSession() + " destroyed");
- }
- });
+ .addSessionDestroyListener(event -> System.out.println(
+ "Session " + event.getSession() + " destroyed"));
final Label l = new Label("Session timeout is "
+ wrappedSession.getMaxInactiveInterval() + "s");
addComponents(l);
Button button = new Button("Invalidate session");
- button.addClickListener(new ClickListener() {
- @Override
- public void buttonClick(ClickEvent e) {
- System.out.println(
- "invalidating " + getSession() + " for http session "
- + getSession().getSession().getId());
- getSession().getSession().invalidate();
- System.out.println("invalidated " + getSession());
- }
+ button.addClickListener(event -> {
+ System.out.println("invalidating " + getSession()
+ + " for http session " + getSession().getSession().getId());
+ getSession().getSession().invalidate();
+ System.out.println("invalidated " + getSession());
});
addComponents(button);
button = new Button("Close UI");
- button.addClickListener(new ClickListener() {
- @Override
- public void buttonClick(ClickEvent e) {
- System.out.println("closing UI " + getUIId() + " in session "
- + getSession() + " for http session "
- + getSession().getSession().getId());
- close();
- }
+ button.addClickListener(event -> {
+ System.out.println("closing UI " + getUIId() + " in session "
+ + getSession() + " for http session "
+ + getSession().getSession().getId());
+ close();
});
addComponents(button);
button = new Button("Schedule Close UI (5s delay)");
- button.addClickListener(new ClickListener() {
- @Override
- public void buttonClick(ClickEvent e) {
- new Thread(new Runnable() {
- @Override
- public void run() {
- try {
- Thread.sleep(5000);
- } catch (InterruptedException e1) {
- e1.printStackTrace();
- }
- // Breakpoint here
- access(new Runnable() {
- @Override
- public void run() {
- close();
- System.out.println("closing UI " + getUIId()
- + " in session " + getSession()
- + " for http session "
- + getSession().getSession().getId());
-
- }
- });
-
- }
- }).start();
- }
- });
- addComponents(button);
- button = new Button("Slow (5s) operation");
- button.addClickListener(new ClickListener() {
- @Override
- public void buttonClick(ClickEvent e) {
+ button.addClickListener(event -> {
+ new Thread(() -> {
try {
Thread.sleep(5000);
- } catch (InterruptedException e1) {
- e1.printStackTrace();
+ } catch (InterruptedException e) {
+ e.printStackTrace();
}
- addComponent(new Label("Slow operation done"));
+ // Breakpoint here
+ access(() -> {
+ close();
+ System.out
+ .println("closing UI " + getUIId() + " in session "
+ + getSession() + " for http session "
+ + getSession().getSession().getId());
+ });
+ }).start();
+ });
+ addComponents(button);
+ button = new Button("Slow (5s) operation");
+ button.addClickListener(event -> {
+ try {
+ Thread.sleep(5000);
+ } catch (InterruptedException e) {
+ e.printStackTrace();
}
+ addComponent(new Label("Slow operation done"));
});
addComponents(button);
-
}
}
diff --git a/uitest/src/main/java/com/vaadin/tests/push/PushWithPreserveOnRefresh.java b/uitest/src/main/java/com/vaadin/tests/push/PushWithPreserveOnRefresh.java
index f7d36980c0..a9b688626a 100644
--- a/uitest/src/main/java/com/vaadin/tests/push/PushWithPreserveOnRefresh.java
+++ b/uitest/src/main/java/com/vaadin/tests/push/PushWithPreserveOnRefresh.java
@@ -5,8 +5,6 @@ import com.vaadin.annotations.Push;
import com.vaadin.server.VaadinRequest;
import com.vaadin.tests.components.AbstractReindeerTestUI;
import com.vaadin.tests.util.Log;
-import com.vaadin.ui.Button.ClickEvent;
-import com.vaadin.ui.Button.ClickListener;
import com.vaadin.ui.Label;
@PreserveOnRefresh
@@ -23,13 +21,8 @@ public class PushWithPreserveOnRefresh extends AbstractReindeerTestUI {
addComponent(new Label("UI id: " + getUIId()));
addComponent(log);
- addButton("click me", new ClickListener() {
-
- @Override
- public void buttonClick(ClickEvent event) {
- log.log("Button has been clicked " + (++times) + " times");
- }
- });
+ addButton("click me", event -> log
+ .log("Button has been clicked " + (++times) + " times"));
}
@Override
diff --git a/uitest/src/main/java/com/vaadin/tests/push/RefreshCloseConnection.java b/uitest/src/main/java/com/vaadin/tests/push/RefreshCloseConnection.java
index 1bfc95254b..74b0711eb2 100644
--- a/uitest/src/main/java/com/vaadin/tests/push/RefreshCloseConnection.java
+++ b/uitest/src/main/java/com/vaadin/tests/push/RefreshCloseConnection.java
@@ -38,12 +38,7 @@ public class RefreshCloseConnection extends AbstractTestUIWithLog {
new Thread() {
@Override
public void run() {
- accessSynchronously(new Runnable() {
- @Override
- public void run() {
- log("Push");
- }
- });
+ accessSynchronously(() -> log("Push"));
}
}.start();
}
diff --git a/uitest/src/main/java/com/vaadin/tests/push/RoundTripTest.java b/uitest/src/main/java/com/vaadin/tests/push/RoundTripTest.java
index 72119a18a6..31bb2f34bf 100644
--- a/uitest/src/main/java/com/vaadin/tests/push/RoundTripTest.java
+++ b/uitest/src/main/java/com/vaadin/tests/push/RoundTripTest.java
@@ -21,8 +21,6 @@ import com.vaadin.tests.components.AbstractReindeerTestUI;
import com.vaadin.tests.widgetset.TestingWidgetSet;
import com.vaadin.tests.widgetset.server.RoundTripTester;
import com.vaadin.ui.Button;
-import com.vaadin.ui.Button.ClickEvent;
-import com.vaadin.ui.Button.ClickListener;
import com.vaadin.v7.ui.TextField;
@Widgetset(TestingWidgetSet.NAME)
@@ -47,15 +45,9 @@ public class RoundTripTest extends AbstractReindeerTestUI {
}
Button start = new Button("Start test");
- start.addClickListener(new ClickListener() {
-
- @Override
- public void buttonClick(ClickEvent event) {
- roundTripTester.start(
- (Integer) testDuration.getConvertedValue(),
- (Integer) payloadSize.getConvertedValue());
- }
- });
+ start.addClickListener(event -> roundTripTester.start(
+ (Integer) testDuration.getConvertedValue(),
+ (Integer) payloadSize.getConvertedValue()));
addComponent(roundTripTester);
addComponent(start);
diff --git a/uitest/src/main/java/com/vaadin/tests/push/TablePushStreaming.java b/uitest/src/main/java/com/vaadin/tests/push/TablePushStreaming.java
index f27845e478..37b893bcd4 100644
--- a/uitest/src/main/java/com/vaadin/tests/push/TablePushStreaming.java
+++ b/uitest/src/main/java/com/vaadin/tests/push/TablePushStreaming.java
@@ -49,26 +49,17 @@ public class TablePushStreaming extends AbstractReindeerTestUI {
final Table t = new Table("The table");
t.setContainerDataSource(generateContainer(10, 10, iteration++));
t.setSizeFull();
- Runnable r = new Runnable() {
-
- @Override
- public void run() {
- for (int i = 0; i < 99; i++) {
- try {
- Thread.sleep(200);
- } catch (InterruptedException e) {
- e.printStackTrace();
- }
- access(new Runnable() {
-
- @Override
- public void run() {
- t.setContainerDataSource(generateContainer(
- t.getVisibleColumns().length, t.size(),
- iteration++));
- }
- });
+ Runnable r = () -> {
+ for (int i = 0; i < 99; i++) {
+ try {
+ Thread.sleep(200);
+ } catch (InterruptedException e) {
+ e.printStackTrace();
}
+ access(() ->
+ t.setContainerDataSource(
+ generateContainer(t.getVisibleColumns().length,
+ t.size(), iteration++)));
}
};
Thread tr = new Thread(r);
diff --git a/uitest/src/main/java/com/vaadin/tests/push/TogglePush.java b/uitest/src/main/java/com/vaadin/tests/push/TogglePush.java
index bd022cae76..2a7c6bd163 100644
--- a/uitest/src/main/java/com/vaadin/tests/push/TogglePush.java
+++ b/uitest/src/main/java/com/vaadin/tests/push/TogglePush.java
@@ -22,7 +22,6 @@ import com.vaadin.server.VaadinRequest;
import com.vaadin.shared.communication.PushMode;
import com.vaadin.tests.components.AbstractReindeerTestUI;
import com.vaadin.ui.Button;
-import com.vaadin.ui.Button.ClickEvent;
import com.vaadin.ui.CheckBox;
import com.vaadin.ui.Label;
@@ -52,29 +51,16 @@ public class TogglePush extends AbstractReindeerTestUI {
addComponent(pushSetting);
addComponent(
- new Button("Update counter now", new Button.ClickListener() {
- @Override
- public void buttonClick(ClickEvent event) {
- updateCounter();
- }
- }));
+ new Button("Update counter now", event -> updateCounter()));
addComponent(new Button("Update counter in 1 sec",
- new Button.ClickListener() {
- @Override
- public void buttonClick(ClickEvent event) {
- new Timer().schedule(new TimerTask() {
- @Override
- public void run() {
- access(new Runnable() {
- @Override
- public void run() {
- updateCounter();
- }
- });
- }
- }, 1000);
- }
+ event -> {
+ new Timer().schedule(new TimerTask() {
+ @Override
+ public void run() {
+ access(() -> updateCounter());
+ }
+ }, 1000);
}));
}