You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

StreamingReconnectWhilePushing.java 2.2KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. /*
  2. * Copyright 2000-2016 Vaadin Ltd.
  3. *
  4. * Licensed under the Apache License, Version 2.0 (the "License"); you may not
  5. * use this file except in compliance with the License. You may obtain a copy of
  6. * the License at
  7. *
  8. * http://www.apache.org/licenses/LICENSE-2.0
  9. *
  10. * Unless required by applicable law or agreed to in writing, software
  11. * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
  12. * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
  13. * License for the specific language governing permissions and limitations under
  14. * the License.
  15. */
  16. package com.vaadin.tests.push;
  17. import com.vaadin.annotations.Push;
  18. import com.vaadin.server.VaadinRequest;
  19. import com.vaadin.shared.ui.ui.Transport;
  20. import com.vaadin.tests.components.AbstractReindeerTestUI;
  21. import com.vaadin.ui.Button;
  22. import com.vaadin.ui.Button.ClickEvent;
  23. import com.vaadin.ui.Label;
  24. @Push(transport = Transport.STREAMING)
  25. public class StreamingReconnectWhilePushing extends AbstractReindeerTestUI {
  26. @Override
  27. protected void setup(VaadinRequest request) {
  28. Button button = new Button("Click Me");
  29. button.addClickListener(new Button.ClickListener() {
  30. private Label label;
  31. @Override
  32. public void buttonClick(ClickEvent event) {
  33. if (label == null) {
  34. label = new Label();
  35. label.setValue(getString(1000000));
  36. addComponent(label);
  37. } else {
  38. label.setValue("." + label.getValue());
  39. }
  40. }
  41. });
  42. addComponent(button);
  43. }
  44. protected String getString(int len) {
  45. StringBuilder b = new StringBuilder();
  46. for (int i = 0; i < len; i++) {
  47. if (i % 100 == 0) {
  48. b.append("\n");
  49. } else {
  50. b.append('A');
  51. }
  52. }
  53. return b.toString();
  54. }
  55. @Override
  56. protected String getTestDescription() {
  57. return "Each push of the button sends about 1MB to the client. Press it a couple of times and a spinner will appear forever if reconnecting does not work.";
  58. }
  59. @Override
  60. protected Integer getTicketNumber() {
  61. return 13435;
  62. }
  63. }