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.

ServletWithResourcesTest.java 1.6KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. package com.vaadin.tests.applicationservlet;
  2. import static org.junit.Assert.assertEquals;
  3. import static org.junit.Assert.assertTrue;
  4. import java.util.List;
  5. import org.junit.Test;
  6. import org.openqa.selenium.By;
  7. import org.openqa.selenium.WebElement;
  8. import com.vaadin.testbench.elements.CheckBoxElement;
  9. import com.vaadin.tests.components.label.LabelModes;
  10. import com.vaadin.tests.tb3.SingleBrowserTest;
  11. public class ServletWithResourcesTest extends SingleBrowserTest {
  12. @Override
  13. protected Class<?> getUIClass() {
  14. return LabelModes.class;
  15. }
  16. @Override
  17. protected String getDeploymentPath(Class<?> uiClass) {
  18. return super.getDeploymentPath(uiClass).replaceAll("/run/",
  19. "/servlet-with-resources/");
  20. }
  21. @Test
  22. public void servletServesResources() {
  23. openTestURL();
  24. assertEquals("Enabled", $(CheckBoxElement.class).first().getCaption());
  25. List<WebElement> links = findElements(By.xpath("//head/link"));
  26. for (WebElement link : links) {
  27. String href = link.getAttribute("href");
  28. assertTrue("href '" + href
  29. + "' should contain '/servlet-with-resources/VAADIN'",
  30. href.contains("/servlet-with-resources/VAADIN"));
  31. }
  32. List<WebElement> scripts = findElements(By.xpath("//head/script"));
  33. for (WebElement script : scripts) {
  34. String src = script.getAttribute("src");
  35. assertTrue("src '" + src
  36. + "' should contain '/servlet-with-resources/VAADIN'",
  37. src.contains("/servlet-with-resources/VAADIN"));
  38. }
  39. }
  40. }