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.

ServletIntegrationWebsocketIT.java 2.5KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. /*
  2. * Copyright 2000-2018 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.integration.websocket;
  17. import static org.junit.Assert.assertEquals;
  18. import java.util.*;
  19. import org.junit.Assume;
  20. import org.junit.Test;
  21. import org.openqa.selenium.WebElement;
  22. import com.vaadin.testbench.By;
  23. import com.vaadin.tests.integration.AbstractServletIntegrationTest;
  24. public class ServletIntegrationWebsocketIT
  25. extends AbstractServletIntegrationTest {
  26. // Uses the test method declared in the super class
  27. private static final Set<String> nonWebsocketServers = new HashSet<String>();
  28. static {
  29. nonWebsocketServers.add("liberty-microprofile");
  30. }
  31. @Override
  32. public void setup() throws Exception {
  33. Assume.assumeFalse("This server does not support Websockets",
  34. nonWebsocketServers
  35. .contains(System.getProperty("server-name")));
  36. super.setup();
  37. }
  38. @Override
  39. protected String getTestPath() {
  40. return "/run/ServletIntegrationWebsocketUI";
  41. }
  42. @Test
  43. public void testWebsockedUsed() {
  44. List<String> params = new ArrayList<String>();
  45. for (String param : getParameters()) {
  46. params.add(param);
  47. }
  48. params.add("debug");
  49. // Reopen the page with debug window
  50. openTestURL(params.toArray(new String[params.size()]));
  51. // Make sure the correct debug window tab is open.
  52. findElements(By.className("v-debugwindow-tab")).get(1).click();
  53. try {
  54. // Wait to make sure correct tab is shown.
  55. Thread.sleep(1000);
  56. } catch (InterruptedException e) {
  57. }
  58. WebElement row = findElements(By.className("v-debugwindow-row")).get(7);
  59. assertEquals("Communication method",
  60. row.findElement(By.className("caption")).getAttribute("innerText"));
  61. assertEquals("Client to server: websocket, server to client: websocket",
  62. row.findElement(By.className("value")).getAttribute("innerText"));
  63. }
  64. }