選択できるのは25トピックまでです。 トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。

OutOfSync.java 1.7KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. package com.vaadin.tests.components;
  2. import com.vaadin.server.VaadinRequest;
  3. import com.vaadin.ui.Button;
  4. import com.vaadin.ui.Button.ClickEvent;
  5. import com.vaadin.ui.Button.ClickListener;
  6. import com.vaadin.ui.Notification;
  7. public class OutOfSync extends AbstractReindeerTestUI {
  8. @Override
  9. protected void setup(VaadinRequest request) {
  10. // Without this, there is an extra request from the UI that changes the
  11. // request sequence compared to what the test expects
  12. setImmediate(false);
  13. Button b = new Button("Click me after 1s to be out of sync");
  14. b.addClickListener(new ClickListener() {
  15. @Override
  16. public void buttonClick(ClickEvent event) {
  17. Notification.show("This code will never be reached");
  18. }
  19. });
  20. setContent(b);
  21. Thread t = new Thread(new Runnable() {
  22. @Override
  23. public void run() {
  24. try {
  25. Thread.sleep(500);
  26. } catch (InterruptedException e) {
  27. e.printStackTrace();
  28. }
  29. // Remove button but prevent repaint -> causes out of sync
  30. // issues
  31. getSession().lock();
  32. try {
  33. setContent(null);
  34. getConnectorTracker().markClean(OutOfSync.this);
  35. } finally {
  36. getSession().unlock();
  37. }
  38. }
  39. });
  40. t.start();
  41. }
  42. @Override
  43. protected String getTestDescription() {
  44. return "Click the button after 1s when it has been removed server side (causing synchronization problems)";
  45. }
  46. @Override
  47. protected Integer getTicketNumber() {
  48. return 10780;
  49. }
  50. }