package com.vaadin.tests.requesthandlers;

import org.junit.Assert;
import org.junit.Test;

import com.vaadin.testbench.elements.LinkElement;
import com.vaadin.tests.tb3.MultiBrowserTest;

public class AppResource404Test extends MultiBrowserTest {
    @Test
    public void testOpenExistingResource() throws Exception {
        openTestURL();
        $(LinkElement.class).first().click(5, 5);
        disableWaitingAndWait();
        Assert.assertFalse("Page contains the given text",
                driver.getPageSource().contains("404"));
    }

    @Test
    public void testOpenNonExistingResource() {
        openTestURL();
        $(LinkElement.class).get(1).click(5, 5);
        disableWaitingAndWait();
        Assert.assertTrue("Page does not contain the given text",
                driver.getPageSource().contains(
                        "/APP/connector/0/4/asdfasdf can not be found"));
    }

    @Test
    public void testOpenResourceWith404() {
        openTestURL();
        $(LinkElement.class).get(2).click(5, 5);
        disableWaitingAndWait();
        Assert.assertTrue("Page does not contain the given text",
                driver.getPageSource().contains("HTTP ERROR 404"));
        Assert.assertTrue("Page does not contain the given text",
                driver.getPageSource().contains("Problem accessing /run/APP/"));
    }

    @Test
    public void testOpenResourceToUIProvider() {
        openTestURL();
        $(LinkElement.class).get(3).click(5, 5);
        disableWaitingAndWait();
        Assert.assertFalse("Page contains the given text",
                driver.getPageSource().contains("can not be found"));
    }

    protected void disableWaitingAndWait() {
        testBench().disableWaitForVaadin();
        sleep(500);
    }
}

@@ -36,16 +36,40 @@
 dlers;%0A%0A
+import java.util.List;%0A%0A
 import o
@@ -107,16 +107,71 @@
 it.Test;
+%0Aimport org.openqa.selenium.remote.DesiredCapabilities;
 %0A%0Aimport
@@ -1841,11 +1841,196 @@
 );%0A    %7D
+%0A%0A    @Override%0A    public List%3CDesiredCapabilities%3E getBrowsersToTest() %7B%0A        // IE11 does not show the details on the 404 page%0A        return super.getBrowsersExcludingIE();%0A    %7D
 %0A%7D%0A

Exclude IE11 from AppResource404Test