From 4c0e340ab43c871ae4a0691bc90ae036853334d4 Mon Sep 17 00:00:00 2001 From: Martin Bergljung Date: Mon, 27 Apr 2015 14:22:35 +0100 Subject: [PATCH] DEVPLAT-6: Fix regression and functional IT (still needs proper release of share-po) --- .../META-INF/maven/archetype-metadata.xml | 6 +- .../resources/archetype-resources/pom.xml | 13 +- .../archetype-resources/runner/pom.xml | 220 +++++++++++++----- .../runner/tomcat/context-solr.xml | 27 +++ .../archetype-resources/share-amp/pom.xml | 50 +++- .../com/example/pages/simple-page.get.js | 38 +-- .../src/test/java/demoamp/DemoPageTestIT.java | 92 ++++++++ .../src/test/java/demoamp/po/DemoPage.java | 88 +++++++ .../share-amp/src/test/resources/testng.xml | 12 + .../archetype-resources/solr-config/pom.xml | 1 - .../resources/archetype-resources/pom.xml | 4 +- 11 files changed, 462 insertions(+), 89 deletions(-) create mode 100644 archetypes/alfresco-allinone-archetype/src/main/resources/archetype-resources/runner/tomcat/context-solr.xml create mode 100644 archetypes/alfresco-allinone-archetype/src/main/resources/archetype-resources/share-amp/src/test/java/demoamp/DemoPageTestIT.java create mode 100644 archetypes/alfresco-allinone-archetype/src/main/resources/archetype-resources/share-amp/src/test/java/demoamp/po/DemoPage.java create mode 100644 archetypes/alfresco-allinone-archetype/src/main/resources/archetype-resources/share-amp/src/test/resources/testng.xml diff --git a/archetypes/alfresco-allinone-archetype/src/main/resources/META-INF/maven/archetype-metadata.xml b/archetypes/alfresco-allinone-archetype/src/main/resources/META-INF/maven/archetype-metadata.xml index 0d702fec..46834133 100644 --- a/archetypes/alfresco-allinone-archetype/src/main/resources/META-INF/maven/archetype-metadata.xml +++ b/archetypes/alfresco-allinone-archetype/src/main/resources/META-INF/maven/archetype-metadata.xml @@ -56,13 +56,13 @@ - + src/main/java **/*.java - + src/test/java **/*.java @@ -74,7 +74,7 @@ ** - + src/test/resources ** diff --git a/archetypes/alfresco-allinone-archetype/src/main/resources/archetype-resources/pom.xml b/archetypes/alfresco-allinone-archetype/src/main/resources/archetype-resources/pom.xml index cd9e4750..66a0d6e1 100644 --- a/archetypes/alfresco-allinone-archetype/src/main/resources/archetype-resources/pom.xml +++ b/archetypes/alfresco-allinone-archetype/src/main/resources/archetype-resources/pom.xml @@ -23,9 +23,9 @@ --> + + + http://localhost:8080/share + + + 5.1-SNAPSHOT diff --git a/archetypes/alfresco-allinone-archetype/src/main/resources/archetype-resources/runner/pom.xml b/archetypes/alfresco-allinone-archetype/src/main/resources/archetype-resources/runner/pom.xml index 7b17ad14..dd4ce5ae 100644 --- a/archetypes/alfresco-allinone-archetype/src/main/resources/archetype-resources/runner/pom.xml +++ b/archetypes/alfresco-allinone-archetype/src/main/resources/archetype-resources/runner/pom.xml @@ -2,9 +2,9 @@ 4.0.0 ${artifactId} - Alfresco, Share and Solr Tomcat Runner + Alfresco, Share and Solr4 Tomcat Runner pom - Alfresco, Share and Solr Tomcat Runner + Alfresco, Share and Solr4 Tomcat Runner ${groupId} @@ -25,6 +25,7 @@ + org.apache.maven.plugins maven-resources-plugin @@ -72,7 +73,9 @@ ${alfresco.solr.home.dir} - + + true /alfresco ${project.build.directory}/contexts/context-repo.xml @@ -105,7 +109,7 @@ war true /solr4 - ${alfresco.solr.home.dir}/context.xml + ${project.build.directory}/contexts/context-solr.xml @@ -114,18 +118,30 @@ - + - regression + regression-testing + + true - - http://localhost:8080/share + + + false - + + + + org.apache.maven.plugins maven-dependency-plugin @@ -137,77 +153,171 @@ unpack - ${alfresco.groupId}:share-po:${alfresco.version}:jar:tests + ${alfresco.groupId}:share-po:${share.po.version}:jar:tests ${project.build.directory}/testng-resources + org.apache.maven.plugins - maven-surefire-plugin - 2.17 + maven-failsafe-plugin + 2.18.1 + + + + ${project.build.directory}/testng-resources/testng-alfresco-share.xml + + + + + ${project.build.directory}/testng-resources + + + ${share.client.url} + + + + + **/*Test.java + + - run-regression-tests - - test - + regression-tests integration-test - - - ${app.share.url} - - - ${alfresco.groupId}:share-po - - - ${project.build.directory}/testng-resources - - - ${project.build.directory}/testng-resources/testng.xml - - + + integration-test + + + + verify-tests + verify + + verify + + + + ${alfresco.groupId} share-po - ${alfresco.version} + ${share.po.version} test + ${alfresco.groupId} share-po - ${alfresco.version} + ${share.po.version} tests - - - commons-cli - commons-cli - 1.2 test + + + - org.springframework - spring-beans - 3.1.1.RELEASE - test - - - org.springframework - spring-context - 3.1.1.RELEASE - test - - - org.testng - testng - 6.8.8 + org.alfresco.test + alfresco-testng + 1.1 + test + + + org.hamcrest + hamcrest-core + + + + + + + + + functional-testing + + + + true + + + + + org.apache.maven.plugins + maven-failsafe-plugin + 2.18.1 + + + ${project.parent.basedir}/share-amp/target/test-classes/testng.xml + + ${project.parent.basedir}/share-amp/target/test-classes + + + ${share.client.url} + + + + + functional-tests + integration-test + + integration-test + + + + verify-tests + verify + + verify + + + + + + + + + + + ${alfresco.groupId} + share-po + ${share.po.version} + test + + + + + ${alfresco.groupId} + share-po + ${share.po.version} + tests + test + + + + + + org.alfresco.test + alfresco-testng + 1.1 test @@ -219,7 +329,5 @@ - - diff --git a/archetypes/alfresco-allinone-archetype/src/main/resources/archetype-resources/runner/tomcat/context-solr.xml b/archetypes/alfresco-allinone-archetype/src/main/resources/archetype-resources/runner/tomcat/context-solr.xml new file mode 100644 index 00000000..77af260c --- /dev/null +++ b/archetypes/alfresco-allinone-archetype/src/main/resources/archetype-resources/runner/tomcat/context-solr.xml @@ -0,0 +1,27 @@ + + + + + + + + + + + + + + + + + + diff --git a/archetypes/alfresco-allinone-archetype/src/main/resources/archetype-resources/share-amp/pom.xml b/archetypes/alfresco-allinone-archetype/src/main/resources/archetype-resources/share-amp/pom.xml index 6b793919..567931ad 100644 --- a/archetypes/alfresco-allinone-archetype/src/main/resources/archetype-resources/share-amp/pom.xml +++ b/archetypes/alfresco-allinone-archetype/src/main/resources/archetype-resources/share-amp/pom.xml @@ -14,19 +14,19 @@ + Allowed values: alfresco | share. In this case it's configured to use OOTB share --> share - + 8081 - + http://localhost:8080/alfresco @@ -50,6 +50,44 @@ spring-surf-api provided + + + + + + ${alfresco.groupId} + share-po + ${share.po.version} + test + + + + ${alfresco.groupId} + share-po + ${share.po.version} + tests + test + + + + + org.alfresco.test + alfresco-testng + 1.1 + test + + + org.hamcrest + hamcrest-core + + + + diff --git a/archetypes/alfresco-allinone-archetype/src/main/resources/archetype-resources/share-amp/src/main/amp/config/alfresco/site-webscripts/com/example/pages/simple-page.get.js b/archetypes/alfresco-allinone-archetype/src/main/resources/archetype-resources/share-amp/src/main/amp/config/alfresco/site-webscripts/com/example/pages/simple-page.get.js index c7039c4d..849c9e6f 100644 --- a/archetypes/alfresco-allinone-archetype/src/main/resources/archetype-resources/share-amp/src/main/amp/config/alfresco/site-webscripts/com/example/pages/simple-page.get.js +++ b/archetypes/alfresco-allinone-archetype/src/main/resources/archetype-resources/share-amp/src/main/amp/config/alfresco/site-webscripts/com/example/pages/simple-page.get.js @@ -5,23 +5,25 @@ model.jsonModel = { config: { title: "This is a simple page" } - }, - { - id: "MY_HORIZONTAL_WIDGET_LAYOUT", - name: "alfresco/layout/HorizontalWidgets", - config: { - widgetWidth: 50, - widgets: [ - { - name: "alfresco/logo/Logo", - config: { - logoClasses: "alfresco-logo-only" + }, + { + id: "MY_HORIZONTAL_WIDGET_LAYOUT", + name: "alfresco/layout/HorizontalWidgets", + config: { + widgetWidth: 50, + widgets: [ + { + id: "DEMO_SIMPLE_LOGO", + name: "alfresco/logo/Logo", + config: { + logoClasses: "alfresco-logo-only" + } + }, + { + id: "DEMO_SIMPLE_MSG", + name: "example/widgets/TemplateWidget" } - }, - { - name: "example/widgets/TemplateWidget" - } - ] - } - }] + ] + } + }] }; \ No newline at end of file diff --git a/archetypes/alfresco-allinone-archetype/src/main/resources/archetype-resources/share-amp/src/test/java/demoamp/DemoPageTestIT.java b/archetypes/alfresco-allinone-archetype/src/main/resources/archetype-resources/share-amp/src/test/java/demoamp/DemoPageTestIT.java new file mode 100644 index 00000000..7f1b3d71 --- /dev/null +++ b/archetypes/alfresco-allinone-archetype/src/main/resources/archetype-resources/share-amp/src/test/java/demoamp/DemoPageTestIT.java @@ -0,0 +1,92 @@ +#set($symbol_pound='#') +#set($symbol_dollar='$') +#set($symbol_escape='\' ) +/* + * Copyright (C) 2005-2015 Alfresco Software Limited. + * This file is part of Alfresco + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package ${package}.demoamp; + +import ${package}.demoamp.po.DemoPage; +import org.alfresco.po.share.AbstractTest; +import org.alfresco.po.share.LoginPage; +import org.alfresco.po.share.PeopleFinderPage; +import org.testng.Assert; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.BeforeMethod; +import org.testng.annotations.Test; + +/** + * Functional test that demonstrates how to write and + * extend an alfresco share page object. + * This test shows the interaction with page objects + * brought from share-po project along with newly created ones + * that are present in the Demo amp. + * + * @author Michael Suzuki + * @since 2.0.1 + */ +public class DemoPageTestIT extends AbstractTest { + DemoPage page; + + @BeforeClass(groups = {"alfresco-one"}) + public void prepare() throws Exception { + // Navigate to share + drone.navigateTo(shareUrl + "/page/hdp/ws/simple-page"); + // Reuse Alfresco Share login page object from share-po lib. + LoginPage loginPage = new LoginPage(drone); + loginPage.loginAs(username, password); + } + + @BeforeMethod + public void loadPage() { + // Goto demo page + drone.navigateTo(shareUrl + "/page/hdp/ws/simple-page"); + page = new DemoPage(drone); + } + + @Test + public void findLogo() { + Assert.assertTrue(page.isSimpleLogoDisplayed()); + } + + @Test + public void messageIsDisplayed() { + page.render(); + String msg = page.getMessage(); + Assert.assertNotNull(msg); + Assert.assertEquals("Hello from i18n!", msg); + } + + /** + * Example of test reusing methods in abstract share page objects. + */ + @Test + public void titleDisplayed() { + // Invoke render when ready to use page object. + page.render(); + Assert.assertNotNull(page); + Assert.assertTrue(page.getTitle().contains("This is a simple page")); + } + + /** + * Test that show how we are able to reuse share page objects + * objects in particular the navigation object. + */ + @Test + public void navigate() { + Assert.assertNotNull(page.getNav()); + PeopleFinderPage peoppleFinderPage = page.getNav().selectPeople().render(); + Assert.assertNotNull(peoppleFinderPage); + } +} \ No newline at end of file diff --git a/archetypes/alfresco-allinone-archetype/src/main/resources/archetype-resources/share-amp/src/test/java/demoamp/po/DemoPage.java b/archetypes/alfresco-allinone-archetype/src/main/resources/archetype-resources/share-amp/src/test/java/demoamp/po/DemoPage.java new file mode 100644 index 00000000..cd08dc3e --- /dev/null +++ b/archetypes/alfresco-allinone-archetype/src/main/resources/archetype-resources/share-amp/src/test/java/demoamp/po/DemoPage.java @@ -0,0 +1,88 @@ +#set($symbol_pound='#') +#set($symbol_dollar='$') +#set($symbol_escape='\' ) +/* + * Copyright (C) 2005-2015 Alfresco Software Limited. + * This file is part of Alfresco + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package ${package}.demoamp.po; + +import org.alfresco.po.share.SharePage; +import org.alfresco.webdrone.RenderTime; +import org.alfresco.webdrone.WebDrone; +import org.openqa.selenium.By; +import org.openqa.selenium.NoSuchElementException; + +/** + * Demo of simple share page object that encapsulates the demo of simple page. + * + * @author Michael Suzuki + * @since 2.0.1 + */ +public class DemoPage extends SharePage { + private By SIMPLE_DEMO_LOGO = By.id("DEMO_SIMPLE_LOGO"); + private By SIMPLE_DEMO_MESSAGE = By.id("DEMO_SIMPLE_MSG"); + + public DemoPage(WebDrone drone) { + super(drone); + } + + @SuppressWarnings("unchecked") + @Override + public DemoPage render() { + return render(new RenderTime(maxPageLoadingTime)); + } + + @SuppressWarnings("unchecked") + @Override + public DemoPage render(RenderTime timer) { + while (true) { + timer.start(); + try { + if (isSimpleLogoDisplayed() && isMessageDisplayed()) { + break; + } + } catch (NoSuchElementException nse) { + } finally { + timer.end(); + } + } + return this; + } + + @SuppressWarnings("unchecked") + @Override + public DemoPage render(long time) { + return render(new RenderTime(time)); + } + + public boolean isSimpleLogoDisplayed() { + try { + return drone.find(SIMPLE_DEMO_LOGO).isDisplayed(); + } catch (NoSuchElementException se) { + } + return false; + } + + public boolean isMessageDisplayed() { + try { + return drone.find(SIMPLE_DEMO_MESSAGE).isDisplayed(); + } catch (NoSuchElementException se) { + } + return false; + } + + public String getMessage() { + return drone.find(SIMPLE_DEMO_MESSAGE).getText(); + } +} \ No newline at end of file diff --git a/archetypes/alfresco-allinone-archetype/src/main/resources/archetype-resources/share-amp/src/test/resources/testng.xml b/archetypes/alfresco-allinone-archetype/src/main/resources/archetype-resources/share-amp/src/test/resources/testng.xml new file mode 100644 index 00000000..44efc851 --- /dev/null +++ b/archetypes/alfresco-allinone-archetype/src/main/resources/archetype-resources/share-amp/src/test/resources/testng.xml @@ -0,0 +1,12 @@ +#set($symbol_pound='#') +#set($symbol_dollar='$') +#set($symbol_escape='\' ) + + + + + + + + + \ No newline at end of file diff --git a/archetypes/alfresco-allinone-archetype/src/main/resources/archetype-resources/solr-config/pom.xml b/archetypes/alfresco-allinone-archetype/src/main/resources/archetype-resources/solr-config/pom.xml index e7c71c6b..8a2eb457 100644 --- a/archetypes/alfresco-allinone-archetype/src/main/resources/archetype-resources/solr-config/pom.xml +++ b/archetypes/alfresco-allinone-archetype/src/main/resources/archetype-resources/solr-config/pom.xml @@ -86,7 +86,6 @@ false - ${alfresco.solr.home.dir}/context.xml ${alfresco.solr.home.dir}/archive-SpacesStore/conf/solrcore.properties ${alfresco.solr.home.dir}/workspace-SpacesStore/conf/solrcore.properties diff --git a/archetypes/alfresco-amp-archetype/src/main/resources/archetype-resources/pom.xml b/archetypes/alfresco-amp-archetype/src/main/resources/archetype-resources/pom.xml index 3d848e97..d24cf640 100644 --- a/archetypes/alfresco-amp-archetype/src/main/resources/archetype-resources/pom.xml +++ b/archetypes/alfresco-amp-archetype/src/main/resources/archetype-resources/pom.xml @@ -22,8 +22,8 @@ -->