summaryrefslogtreecommitdiffstats
path: root/uitest/src/com/vaadin/tests/components/OutOfSyncTest.java
blob: 0efb519e8dcf43a4fa7412f7607be3ffbb79ad08 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
package com.vaadin.tests.components;

import com.vaadin.server.VaadinRequest;
import com.vaadin.ui.Button;
import com.vaadin.ui.Button.ClickEvent;
import com.vaadin.ui.Button.ClickListener;
import com.vaadin.ui.Notification;

public class OutOfSyncTest extends AbstractTestUI {

    @Override
    protected void setup(VaadinRequest request) {
        Button b = new Button("Click me after 1s to be out of sync");
        b.addClickListener(new ClickListener() {

            @Override
            public void buttonClick(ClickEvent event) {
                Notification.show("This code will never be reached");
            }
        });
        setContent(b);
        Thread t = new Thread(new Runnable() {

            @Override
            public void run() {
                try {
                    Thread.sleep(500);
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
                // Remove button but prevent repaint -> causes out of sync
                // issues
                getSession().lock();
                try {
                    setContent(null);
                    getConnectorTracker().markClean(OutOfSyncTest.this);
                } finally {
                    getSession().unlock();
                }
            }
        });
        t.start();
    }

    @Override
    protected String getTestDescription() {
        return "Click the button after 1s when it has been removed server side (causing synchronization problems)";
    }

    @Override
    protected Integer getTicketNumber() {
        return 10780;
    }

}