diff options
author | Artur Signell <artur@vaadin.com> | 2013-09-16 14:37:20 +0300 |
---|---|---|
committer | Artur Signell <artur@vaadin.com> | 2013-09-24 11:25:12 +0300 |
commit | e5566429bf0dfb7e9a85148a152cee0445bd40f9 (patch) | |
tree | e78f1411fc67c286d2f9cce8b393207d25c39de3 | |
parent | a682e3b5341e5cf21e84c1dbbb2bc98743674392 (diff) | |
download | vaadin-framework-e5566429bf0dfb7e9a85148a152cee0445bd40f9.tar.gz vaadin-framework-e5566429bf0dfb7e9a85148a152cee0445bd40f9.zip |
Converted servlet integration tests to TB3 (#12573)
Change-Id: I964be2ef805875f36a2f0f8139feaa353c9aaee0
8 files changed, 298 insertions, 5 deletions
diff --git a/uitest/src/com/vaadin/tests/integration/AbstractIntegrationTestTB3.java b/uitest/src/com/vaadin/tests/integration/AbstractIntegrationTestTB3.java new file mode 100644 index 0000000000..e170450619 --- /dev/null +++ b/uitest/src/com/vaadin/tests/integration/AbstractIntegrationTestTB3.java @@ -0,0 +1,53 @@ +/* + * Copyright 2000-2013 Vaadin Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not + * use this file except in compliance with the License. You may obtain a copy of + * the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations under + * the License. + */ +package com.vaadin.tests.integration; + +import java.util.Collection; +import java.util.Collections; + +import org.junit.runner.RunWith; +import org.junit.runners.Parameterized.Parameters; +import org.openqa.selenium.remote.DesiredCapabilities; + +import com.vaadin.tests.tb3.PrivateTB3Configuration; + +/** + * Base class for integration tests. Integration tests use the + * {@literal deployment.url} parameter to determine the base deployment url + * (http://hostname:123) + * + * @author Vaadin Ltd + */ +@RunWith(IntegrationTestRunner.class) +public abstract class AbstractIntegrationTestTB3 extends + PrivateTB3Configuration { + @Override + protected String getBaseURL() { + String deploymentUrl = System.getProperty("deployment.url"); + if (deploymentUrl == null || deploymentUrl.equals("")) { + throw new RuntimeException( + "Deployment url must be given as deployment.url"); + } + + return deploymentUrl; + } + + @Parameters + public static Collection<DesiredCapabilities> getBrowsersForTest() { + return Collections.singleton(BrowserUtil.firefox(17)); + } + +} diff --git a/uitest/src/com/vaadin/tests/integration/IntegrationTestRunner.java b/uitest/src/com/vaadin/tests/integration/IntegrationTestRunner.java new file mode 100644 index 0000000000..29ee4e6023 --- /dev/null +++ b/uitest/src/com/vaadin/tests/integration/IntegrationTestRunner.java @@ -0,0 +1,54 @@ +/* + * Copyright 2000-2013 Vaadin Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not + * use this file except in compliance with the License. You may obtain a copy of + * the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations under + * the License. + */ + +package com.vaadin.tests.integration; + +import org.junit.runners.model.FrameworkMethod; +import org.junit.runners.model.InitializationError; + +import com.vaadin.tests.tb3.TB3Runner; + +/** + * JUnit runner for integration tests. Replaces the actual method name with the + * server-name property when generating the test name. + * + * @author Vaadin Ltd + */ +public class IntegrationTestRunner extends TB3Runner { + + private Class<?> testClass; + + public IntegrationTestRunner(Class<?> klass) throws InitializationError { + super(klass); + testClass = klass; + } + + /* + * (non-Javadoc) + * + * @see + * org.junit.runners.BlockJUnit4ClassRunner#testName(org.junit.runners.model + * .FrameworkMethod) + */ + @Override + protected String testName(FrameworkMethod method) { + if (AbstractIntegrationTestTB3.class.isAssignableFrom(testClass)) { + return System.getProperty("server-name"); + } else { + return super.testName(method); + } + } +} diff --git a/uitest/src/com/vaadin/tests/integration/IntegrationTestStreaming.java b/uitest/src/com/vaadin/tests/integration/IntegrationTestStreaming.java new file mode 100644 index 0000000000..20ddac9dd1 --- /dev/null +++ b/uitest/src/com/vaadin/tests/integration/IntegrationTestStreaming.java @@ -0,0 +1,35 @@ +/* + * Copyright 2000-2013 Vaadin Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not + * use this file except in compliance with the License. You may obtain a copy of + * the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations under + * the License. + */ +package com.vaadin.tests.integration; + +import com.vaadin.annotations.Push; +import com.vaadin.shared.ui.ui.Transport; + +/** + * Server test which uses streaming + * + * @since 7.1 + * @author Vaadin Ltd + */ +@Push(transport = Transport.STREAMING) +public class IntegrationTestStreaming extends IntegrationTestUI { + + public static class IntegrationTestStreamingTB3 extends + ServletIntegrationTestTB3 { + // Uses the test method declared in the super class + } + +} diff --git a/uitest/src/com/vaadin/tests/integration/IntegrationTestUI.java b/uitest/src/com/vaadin/tests/integration/IntegrationTestUI.java index 0e6cb19b30..3d0a338bba 100755 --- a/uitest/src/com/vaadin/tests/integration/IntegrationTestUI.java +++ b/uitest/src/com/vaadin/tests/integration/IntegrationTestUI.java @@ -12,6 +12,11 @@ import com.vaadin.ui.UI; import com.vaadin.ui.VerticalLayout; public class IntegrationTestUI extends UI { + + public class IntegrationTestXhrTB3 extends ServletIntegrationTestTB3 { + // Uses the test method declared in the super class + } + @Override protected void init(VaadinRequest request) { VerticalLayout layout = new VerticalLayout(); diff --git a/uitest/src/com/vaadin/tests/integration/IntegrationTestWebsocket.java b/uitest/src/com/vaadin/tests/integration/IntegrationTestWebsocket.java new file mode 100644 index 0000000000..eaa23de3cf --- /dev/null +++ b/uitest/src/com/vaadin/tests/integration/IntegrationTestWebsocket.java @@ -0,0 +1,49 @@ +/* + * Copyright 2000-2013 Vaadin Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not + * use this file except in compliance with the License. You may obtain a copy of + * the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations under + * the License. + */ +package com.vaadin.tests.integration; + +import com.vaadin.annotations.Push; +import com.vaadin.server.VaadinRequest; +import com.vaadin.shared.ui.ui.Transport; + +/** + * Server test which uses websockets + * + * @since 7.1 + * @author Vaadin Ltd + */ +@Push(transport = Transport.WEBSOCKET) +public class IntegrationTestWebsocket extends IntegrationTestUI { + + public class IntegrationTestWebsocketTB3 extends ServletIntegrationTestTB3 { + // Uses the test method declared in the super class + } + + /* + * (non-Javadoc) + * + * @see + * com.vaadin.tests.integration.IntegrationTestUI#init(com.vaadin.server + * .VaadinRequest) + */ + @Override + protected void init(VaadinRequest request) { + super.init(request); + // Ensure no fallback is used + getPushConfiguration().setFallbackTransport(Transport.WEBSOCKET); + } + +} diff --git a/uitest/src/com/vaadin/tests/integration/ServletIntegrationTestTB3.java b/uitest/src/com/vaadin/tests/integration/ServletIntegrationTestTB3.java new file mode 100644 index 0000000000..ae83083d85 --- /dev/null +++ b/uitest/src/com/vaadin/tests/integration/ServletIntegrationTestTB3.java @@ -0,0 +1,62 @@ +/* + * Copyright 2000-2013 Vaadin Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not + * use this file except in compliance with the License. You may obtain a copy of + * the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations under + * the License. + */ +package com.vaadin.tests.integration; + +import java.io.IOException; + +import org.junit.Test; +import org.openqa.selenium.WebElement; + +/** + * Base class for servlet integration tests. Automatically prepends "/demo" to + * the deployment path + * + * @author Vaadin Ltd + */ +public abstract class ServletIntegrationTestTB3 extends + AbstractIntegrationTestTB3 { + + @Test + public void runTest() throws IOException, AssertionError { + compareScreen("initial"); + + WebElement cell = vaadinElement(getTableCell(getTable(), 0, 1)); + testBenchElement(cell).click(51, 13); + + compareScreen("finland"); + } + + private String getTableCell(String tableLocator, int row, int col) { + return tableLocator + + "/domChild[1]/domChild[0]/domChild[1]/domChild[0]/domChild[" + + row + "]/domChild[" + col + "]/domChild[0]"; + } + + protected String getTable() { + return "/VVerticalLayout[0]/ChildComponentContainer[0]/VScrollTable[0]"; + } + + /* + * (non-Javadoc) + * + * @see com.vaadin.tests.tb3.AbstractTB3Test#getDeploymentPath() + */ + @Override + protected String getDeploymentPath() { + return "/demo" + super.getDeploymentPath(); + } + +} diff --git a/uitest/src/com/vaadin/tests/tb3/AbstractTB3Test.java b/uitest/src/com/vaadin/tests/tb3/AbstractTB3Test.java index 966be1a692..b3520e5326 100644 --- a/uitest/src/com/vaadin/tests/tb3/AbstractTB3Test.java +++ b/uitest/src/com/vaadin/tests/tb3/AbstractTB3Test.java @@ -364,7 +364,7 @@ public abstract class AbstractTB3Test extends TestBenchTestCase { * @return an object describing the capabilities required for running a * test on the given Safari version */ - protected static DesiredCapabilities safari(int version) { + public static DesiredCapabilities safari(int version) { DesiredCapabilities c = DesiredCapabilities.safari(); c.setVersion("" + version); return c; @@ -378,7 +378,7 @@ public abstract class AbstractTB3Test extends TestBenchTestCase { * @return an object describing the capabilities required for running a * test on the given Chrome version */ - protected static DesiredCapabilities chrome(int version) { + public static DesiredCapabilities chrome(int version) { DesiredCapabilities c = DesiredCapabilities.chrome(); c.setVersion("" + version); c.setPlatform(Platform.XP); @@ -393,7 +393,7 @@ public abstract class AbstractTB3Test extends TestBenchTestCase { * @return an object describing the capabilities required for running a * test on the given Opera version */ - protected static DesiredCapabilities opera(int version) { + public static DesiredCapabilities opera(int version) { DesiredCapabilities c = DesiredCapabilities.opera(); c.setVersion("" + version); c.setPlatform(Platform.XP); @@ -408,7 +408,7 @@ public abstract class AbstractTB3Test extends TestBenchTestCase { * @return an object describing the capabilities required for running a * test on the given Firefox version */ - protected static DesiredCapabilities firefox(int version) { + public static DesiredCapabilities firefox(int version) { DesiredCapabilities c = DesiredCapabilities.firefox(); c.setVersion("" + version); c.setPlatform(Platform.XP); @@ -423,7 +423,7 @@ public abstract class AbstractTB3Test extends TestBenchTestCase { * @return an object describing the capabilities required for running a * test on the given Internet Explorer version */ - protected static DesiredCapabilities ie(int version) { + public static DesiredCapabilities ie(int version) { DesiredCapabilities c = DesiredCapabilities.internetExplorer(); c.setVersion("" + version); return c; diff --git a/uitest/src/com/vaadin/tests/tb3/ServletIntegrationTests.java b/uitest/src/com/vaadin/tests/tb3/ServletIntegrationTests.java new file mode 100644 index 0000000000..d2aa413749 --- /dev/null +++ b/uitest/src/com/vaadin/tests/tb3/ServletIntegrationTests.java @@ -0,0 +1,35 @@ +/* + * Copyright 2000-2013 Vaadin Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not + * use this file except in compliance with the License. You may obtain a copy of + * the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations under + * the License. + */ + +package com.vaadin.tests.tb3; + +import org.junit.runner.RunWith; +import org.junit.runners.model.InitializationError; + +import com.vaadin.tests.integration.ServletIntegrationTestTB3; +import com.vaadin.tests.tb3.ServletIntegrationTests.ServletIntegrationTestSuite; + +@RunWith(ServletIntegrationTestSuite.class) +public class ServletIntegrationTests { + + public static class ServletIntegrationTestSuite extends TB3TestSuite { + public ServletIntegrationTestSuite(Class<?> klass) + throws InitializationError { + super(klass, ServletIntegrationTestTB3.class, + "com.vaadin.tests.integration", new String[] {}); + } + } +} |