From fc55716499b1aa8f8c52d1cda1bdc9b2fcc62476 Mon Sep 17 00:00:00 2001 From: Michael Suzuki Date: Wed, 3 Sep 2014 10:10:31 +0100 Subject: [PATCH 01/22] tidy up formatting --- archetypes/alfresco-amp-archetype/.project | 47 ++++++++----------- .../main/java/org/alfresco/demoamp/Demo.java | 8 ++-- .../org/alfresco/demoamp/DemoComponent.java | 7 +-- 3 files changed, 28 insertions(+), 34 deletions(-) diff --git a/archetypes/alfresco-amp-archetype/.project b/archetypes/alfresco-amp-archetype/.project index 365fc830..69ab5d79 100644 --- a/archetypes/alfresco-amp-archetype/.project +++ b/archetypes/alfresco-amp-archetype/.project @@ -1,29 +1,22 @@ - alfresco-amp-archetype - - - - - - org.eclipse.jdt.core.javabuilder - - - - - org.maven.ide.eclipse.maven2Builder - - - - - org.eclipse.m2e.core.maven2Builder - - - - - - org.eclipse.m2e.core.maven2Nature - org.eclipse.jdt.core.javanature - org.maven.ide.eclipse.maven2Nature - - + alfresco-amp-archetype + Sample project with full support for lifecycle and rapid development of Repository AMPs (Alfresco Module Packages). NO_M2ECLIPSE_SUPPORT: Project files created with the maven-eclipse-plugin are not supported in M2Eclipse. + + + + org.eclipse.jdt.core.javabuilder + + + org.maven.ide.eclipse.maven2Builder + + + org.eclipse.m2e.core.maven2Builder + + + + org.eclipse.m2e.core.maven2Nature + org.eclipse.jdt.core.javanature + org.maven.ide.eclipse.maven2Nature + + \ No newline at end of file diff --git a/archetypes/alfresco-amp-archetype/src/main/resources/archetype-resources/src/main/java/org/alfresco/demoamp/Demo.java b/archetypes/alfresco-amp-archetype/src/main/resources/archetype-resources/src/main/java/org/alfresco/demoamp/Demo.java index 402f7195..d37df61e 100644 --- a/archetypes/alfresco-amp-archetype/src/main/resources/archetype-resources/src/main/java/org/alfresco/demoamp/Demo.java +++ b/archetypes/alfresco-amp-archetype/src/main/resources/archetype-resources/src/main/java/org/alfresco/demoamp/Demo.java @@ -31,8 +31,8 @@ package org.alfresco.demoamp; */ public class Demo { - public void init() - { - System.out.println("SDK Demo AMP class has been loaded"); - } + public void init() + { + System.out.println("SDK Demo AMP class has been loaded"); + } } diff --git a/archetypes/alfresco-amp-archetype/src/main/resources/archetype-resources/src/main/java/org/alfresco/demoamp/DemoComponent.java b/archetypes/alfresco-amp-archetype/src/main/resources/archetype-resources/src/main/java/org/alfresco/demoamp/DemoComponent.java index 45896271..01027280 100644 --- a/archetypes/alfresco-amp-archetype/src/main/resources/archetype-resources/src/main/java/org/alfresco/demoamp/DemoComponent.java +++ b/archetypes/alfresco-amp-archetype/src/main/resources/archetype-resources/src/main/java/org/alfresco/demoamp/DemoComponent.java @@ -39,11 +39,13 @@ public class DemoComponent extends AbstractModuleComponent private NodeLocatorService nodeLocatorService; - public void setNodeService(NodeService nodeService) { + public void setNodeService(NodeService nodeService) + { this.nodeService = nodeService; } - public void setNodeLocatorService(NodeLocatorService nodeLocatorService) { + public void setNodeLocatorService(NodeLocatorService nodeLocatorService) + { this.nodeLocatorService = nodeLocatorService; } @@ -76,7 +78,6 @@ public class DemoComponent extends AbstractModuleComponent * @return */ public NodeRef getCompanyHome() - { return nodeLocatorService.getNode("companyhome", null, null); } From 5421b845c8b409723bd4bf005f37f15f8222b1c2 Mon Sep 17 00:00:00 2001 From: Michael Suzuki Date: Wed, 3 Sep 2014 11:15:47 +0100 Subject: [PATCH 02/22] seperated tests into unit and integration --- .../webscripts/webscript.get.html.ftl | 7 ++- .../org/alfresco/demoamp/DemoComponent.java | 29 ++++++++++ .../alfresco/demoamp/HelloWorldMessage.java | 58 +++++++++++++++++++ .../DemoComponentTest.java | 0 .../demoamp/unit/HelloWorldMessageTest.java | 50 ++++++++++++++++ 5 files changed, 143 insertions(+), 1 deletion(-) create mode 100644 archetypes/alfresco-amp-archetype/src/main/resources/archetype-resources/src/main/java/org/alfresco/demoamp/HelloWorldMessage.java rename archetypes/alfresco-amp-archetype/src/main/resources/archetype-resources/src/test/java/org/alfresco/demoamp/{test => integration}/DemoComponentTest.java (100%) create mode 100644 archetypes/alfresco-amp-archetype/src/main/resources/archetype-resources/src/test/java/org/alfresco/demoamp/unit/HelloWorldMessageTest.java diff --git a/archetypes/alfresco-amp-archetype/src/main/resources/archetype-resources/src/main/amp/config/alfresco/extension/templates/webscripts/webscript.get.html.ftl b/archetypes/alfresco-amp-archetype/src/main/resources/archetype-resources/src/main/amp/config/alfresco/extension/templates/webscripts/webscript.get.html.ftl index f4672ea6..ca0cf4e9 100644 --- a/archetypes/alfresco-amp-archetype/src/main/resources/archetype-resources/src/main/amp/config/alfresco/extension/templates/webscripts/webscript.get.html.ftl +++ b/archetypes/alfresco-amp-archetype/src/main/resources/archetype-resources/src/main/amp/config/alfresco/extension/templates/webscripts/webscript.get.html.ftl @@ -1 +1,6 @@ -Message: ${message} \ No newline at end of file + + +

Welcome to Demoamp

+

${demoMessage}

+ + \ No newline at end of file diff --git a/archetypes/alfresco-amp-archetype/src/main/resources/archetype-resources/src/main/java/org/alfresco/demoamp/DemoComponent.java b/archetypes/alfresco-amp-archetype/src/main/resources/archetype-resources/src/main/java/org/alfresco/demoamp/DemoComponent.java index 01027280..df873808 100644 --- a/archetypes/alfresco-amp-archetype/src/main/resources/archetype-resources/src/main/java/org/alfresco/demoamp/DemoComponent.java +++ b/archetypes/alfresco-amp-archetype/src/main/resources/archetype-resources/src/main/java/org/alfresco/demoamp/DemoComponent.java @@ -15,7 +15,18 @@ limitations under the License. */ package org.alfresco.demoamp; +import java.util.HashMap; +import java.util.Map; +import org.alfresco.model.ContentModel; +import org.alfresco.repo.nodelocator.NodeLocatorService; +import org.alfresco.service.cmr.repository.NodeRef; +import org.alfresco.service.cmr.repository.NodeService; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.springframework.extensions.webscripts.DeclarativeWebScript; +import org.springframework.extensions.webscripts.Status; +import org.springframework.extensions.webscripts.WebScriptRequest; import org.alfresco.repo.module.AbstractModuleComponent; import org.alfresco.repo.nodelocator.NodeLocatorService; import org.alfresco.service.cmr.repository.NodeRef; @@ -23,6 +34,7 @@ import org.alfresco.service.cmr.repository.NodeService; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; + /** * A basic component that will be started for this module. * Uses the NodeLocatorService to easily find nodes and the @@ -30,6 +42,7 @@ import org.apache.commons.logging.LogFactory; * * @author Gabriele Columbro * @author Maurizio Pillitu + * @author Michael Suzuki */ public class DemoComponent extends AbstractModuleComponent { @@ -81,4 +94,20 @@ public class DemoComponent extends AbstractModuleComponent { return nodeLocatorService.getNode("companyhome", null, null); } + /** + * Binding data to webscript demoamp. + * @param req webscript request + * @param status + * @return {@link java.util.Map} data binding + */ + protected Map executeImpl(WebScriptRequest req, Status status ) + { + NodeRef companyHome = getCompanyHome(); + String companyHomeName = (String) nodeService.getProperty(companyHome, ContentModel.PROP_NAME); + int directoryCount = childNodesCount(companyHome); + HelloWorldMessage msg = new HelloWorldMessage(companyHomeName, directoryCount); + Map model = new HashMap(); + model.put("demoMessage", msg); + return model; + } } diff --git a/archetypes/alfresco-amp-archetype/src/main/resources/archetype-resources/src/main/java/org/alfresco/demoamp/HelloWorldMessage.java b/archetypes/alfresco-amp-archetype/src/main/resources/archetype-resources/src/main/java/org/alfresco/demoamp/HelloWorldMessage.java new file mode 100644 index 00000000..ed4faec8 --- /dev/null +++ b/archetypes/alfresco-amp-archetype/src/main/resources/archetype-resources/src/main/java/org/alfresco/demoamp/HelloWorldMessage.java @@ -0,0 +1,58 @@ +/* + * Copyright (C) 2005-2007 Alfresco Software Limited. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * As a special exception to the terms and conditions of version 2.0 of + * the GPL, you may redistribute this Program in connection with Free/Libre + * and Open Source Software ("FLOSS") applications as described in Alfresco's + * FLOSS exception. You should have recieved a copy of the text describing + * the FLOSS exception, and it is also available here: + * http://www.alfresco.com/legal/licensing" + */ +package org.alfresco.demoamp; + +import com.sun.star.uno.RuntimeException; + +/** + * Simple pojo that holds directory name and + * the number of folders in the directory. + * + * This is used to create the message for the demoamp. + * + * @author Michael Suzuki + * + */ +public class HelloWorldMessage +{ + private final String directoryName; + private final int folders; + + public HelloWorldMessage(final String directoryName, final int folders) + { + if(directoryName == null || directoryName.isEmpty()) + { + throw new RuntimeException("Directory name is required"); + } + this.directoryName = directoryName; + this.folders = folders; + } + + public String toString() + { + return String.format("%s has %d folders", directoryName, folders); + } + +} diff --git a/archetypes/alfresco-amp-archetype/src/main/resources/archetype-resources/src/test/java/org/alfresco/demoamp/test/DemoComponentTest.java b/archetypes/alfresco-amp-archetype/src/main/resources/archetype-resources/src/test/java/org/alfresco/demoamp/integration/DemoComponentTest.java similarity index 100% rename from archetypes/alfresco-amp-archetype/src/main/resources/archetype-resources/src/test/java/org/alfresco/demoamp/test/DemoComponentTest.java rename to archetypes/alfresco-amp-archetype/src/main/resources/archetype-resources/src/test/java/org/alfresco/demoamp/integration/DemoComponentTest.java diff --git a/archetypes/alfresco-amp-archetype/src/main/resources/archetype-resources/src/test/java/org/alfresco/demoamp/unit/HelloWorldMessageTest.java b/archetypes/alfresco-amp-archetype/src/main/resources/archetype-resources/src/test/java/org/alfresco/demoamp/unit/HelloWorldMessageTest.java new file mode 100644 index 00000000..e67ef812 --- /dev/null +++ b/archetypes/alfresco-amp-archetype/src/main/resources/archetype-resources/src/test/java/org/alfresco/demoamp/unit/HelloWorldMessageTest.java @@ -0,0 +1,50 @@ +/* + * Copyright (C) 2005-2012 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 org.alfresco.demo.test.unit; + +import org.alfresco.demoamp.HelloWorldMessage; +import org.junit.Assert; +import org.junit.Test; + + +/**s + * Hello world demo unit test, show the basics of junit and unit testing. + * Create the message to display on hello world webscript. + * @author Michael Suzuki + * + */ +public class HelloWorldMessageTest +{ + @Test + public void init() + { + HelloWorldMessage msg = new HelloWorldMessage("bla", 0); + Assert.assertNotNull(msg); + } + + @Test(expected = RuntimeException.class) + public void initWithNull() + { + new HelloWorldMessage(null, 0); + } + @Test + public void toStringTest() + { + HelloWorldMessage msg = new HelloWorldMessage("Home", 10); + Assert.assertNotNull(msg); + Assert.assertEquals("Home has 10 folders",msg.toString()); + } + +} From a409cf08bdcb92993debe329fcdf9cc48ea759b2 Mon Sep 17 00:00:00 2001 From: Michael Suzuki Date: Thu, 4 Sep 2014 13:45:02 +0100 Subject: [PATCH 03/22] added new integration test directory, manages all integration test content --- .gitignore | 1 + archetypes/alfresco-amp-archetype/.classpath | 8 --- archetypes/alfresco-amp-archetype/.project | 22 ------ .../META-INF/maven/archetype-metadata.xml | 20 +++++- .../resources/archetype-resources/pom.xml | 16 ++++- .../java/org/alfresco/demoamp/Demo.java | 72 +++++++++++++++++++ .../alfresco/demoamp/po/HelloWorldPage.java | 56 +++++++++++++++ .../src/integration/resources/testng.xml | 9 +++ .../templates/webscripts/webscript.get.js | 1 - .../org/alfresco/demoamp/DemoComponent.java | 38 +++++----- .../{integration => }/DemoComponentTest.java | 2 +- .../{unit => }/HelloWorldMessageTest.java | 2 +- poms/alfresco-sdk-parent/pom.xml | 70 +++++++++--------- 13 files changed, 226 insertions(+), 91 deletions(-) delete mode 100644 archetypes/alfresco-amp-archetype/.classpath delete mode 100644 archetypes/alfresco-amp-archetype/.project create mode 100644 archetypes/alfresco-amp-archetype/src/main/resources/archetype-resources/src/integration/java/org/alfresco/demoamp/Demo.java create mode 100644 archetypes/alfresco-amp-archetype/src/main/resources/archetype-resources/src/integration/java/org/alfresco/demoamp/po/HelloWorldPage.java create mode 100644 archetypes/alfresco-amp-archetype/src/main/resources/archetype-resources/src/integration/resources/testng.xml delete mode 100644 archetypes/alfresco-amp-archetype/src/main/resources/archetype-resources/src/main/amp/config/alfresco/extension/templates/webscripts/webscript.get.js rename archetypes/alfresco-amp-archetype/src/main/resources/archetype-resources/src/test/java/org/alfresco/demoamp/{integration => }/DemoComponentTest.java (98%) rename archetypes/alfresco-amp-archetype/src/main/resources/archetype-resources/src/test/java/org/alfresco/demoamp/{unit => }/HelloWorldMessageTest.java (97%) diff --git a/.gitignore b/.gitignore index cf317585..3c5c31a2 100644 --- a/.gitignore +++ b/.gitignore @@ -12,3 +12,4 @@ pom.xml.next release.properties **.settings **bin +**.DS_Store diff --git a/archetypes/alfresco-amp-archetype/.classpath b/archetypes/alfresco-amp-archetype/.classpath deleted file mode 100644 index b4ac4c6f..00000000 --- a/archetypes/alfresco-amp-archetype/.classpath +++ /dev/null @@ -1,8 +0,0 @@ - - - - - - - - diff --git a/archetypes/alfresco-amp-archetype/.project b/archetypes/alfresco-amp-archetype/.project deleted file mode 100644 index 69ab5d79..00000000 --- a/archetypes/alfresco-amp-archetype/.project +++ /dev/null @@ -1,22 +0,0 @@ - - - alfresco-amp-archetype - Sample project with full support for lifecycle and rapid development of Repository AMPs (Alfresco Module Packages). NO_M2ECLIPSE_SUPPORT: Project files created with the maven-eclipse-plugin are not supported in M2Eclipse. - - - - org.eclipse.jdt.core.javabuilder - - - org.maven.ide.eclipse.maven2Builder - - - org.eclipse.m2e.core.maven2Builder - - - - org.eclipse.m2e.core.maven2Nature - org.eclipse.jdt.core.javanature - org.maven.ide.eclipse.maven2Nature - - \ No newline at end of file diff --git a/archetypes/alfresco-amp-archetype/src/main/resources/META-INF/maven/archetype-metadata.xml b/archetypes/alfresco-amp-archetype/src/main/resources/META-INF/maven/archetype-metadata.xml index f38333c1..a37e7905 100644 --- a/archetypes/alfresco-amp-archetype/src/main/resources/META-INF/maven/archetype-metadata.xml +++ b/archetypes/alfresco-amp-archetype/src/main/resources/META-INF/maven/archetype-metadata.xml @@ -62,5 +62,23 @@ **/*.xml - + + src/integration/java + + **/*.java + + + + src/integration/resources + + **/* + + + + src/integration/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 34b6c54c..bef81a56 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 @@ -68,6 +68,20 @@ ${alfresco.groupId} alfresco-repository + + ${alfresco.groupId} + share-po + ${alfresco.version} + + + org.springframework + spring-context + + + org.springframework + spring-beans + + + - diff --git a/archetypes/alfresco-amp-archetype/src/main/resources/archetype-resources/src/integration/java/org/alfresco/demoamp/Demo.java b/archetypes/alfresco-amp-archetype/src/main/resources/archetype-resources/src/integration/java/org/alfresco/demoamp/Demo.java new file mode 100644 index 00000000..eb695647 --- /dev/null +++ b/archetypes/alfresco-amp-archetype/src/main/resources/archetype-resources/src/integration/java/org/alfresco/demoamp/Demo.java @@ -0,0 +1,72 @@ +/* + * Copyright (C) 2005-2012 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 org.alfresco.demoamp; + +import org.alfresco.demoamp.po.HelloWorldPage; +import org.junit.AfterClass; +import org.junit.Assert; +import org.junit.BeforeClass; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; +import org.openqa.selenium.By; +import org.openqa.selenium.WebDriver; +import org.openqa.selenium.WebElement; +import org.openqa.selenium.firefox.FirefoxDriver; + +@RunWith(JUnit4.class) +public class Demo +{ + private static WebDriver driver; + + @BeforeClass + public static void setup() + { + //Create WebDriver + driver = new FirefoxDriver(); + //Login and obtain ticket + driver.get("http://localhost:8080/alfresco/service/api/login?u=admin&pw=admin"); + WebElement ticket = driver.findElement(By.tagName("ticket")); + String token =String.format("?alf_ticket=%s",ticket.getText()); + //Navigate to sample page with token + driver.get("http://localhost:8080/alfresco/service/summit/hello" + token); + } + + @AfterClass + public static void teardown() + { + driver.quit(); + } + @Test + public void titleDisplayed() + { + HelloWorldPage page = new HelloWorldPage(driver); + Assert.assertNotNull(page); + Assert.assertTrue(page.isTitleVisible()); + Assert.assertEquals("Welcome to Summit 2014", page.getTitle()); + } + /** + * Message should include the directory name + * and number of folders currently in that directory. + */ + @Test + public void messageIsDisplayed() + { + HelloWorldPage page = new HelloWorldPage(driver); + Assert.assertNotNull(page); + Assert.assertTrue(page.isMessageVisible()); + Assert.assertEquals("Company Home has 7 folders", page.getMessage()); + } +} diff --git a/archetypes/alfresco-amp-archetype/src/main/resources/archetype-resources/src/integration/java/org/alfresco/demoamp/po/HelloWorldPage.java b/archetypes/alfresco-amp-archetype/src/main/resources/archetype-resources/src/integration/java/org/alfresco/demoamp/po/HelloWorldPage.java new file mode 100644 index 00000000..0f78e3db --- /dev/null +++ b/archetypes/alfresco-amp-archetype/src/main/resources/archetype-resources/src/integration/java/org/alfresco/demoamp/po/HelloWorldPage.java @@ -0,0 +1,56 @@ +/* + * Copyright (C) 2005-2012 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 org.alfresco.demoamp.po; + +import org.openqa.selenium.By; +import org.openqa.selenium.WebDriver; +/** + * Hello World Page object used in Summit Demo. + * @author Michael Suzuki + * + */ +public class HelloWorldPage +{ + private static final By TITLE_LOCATOR = By.id("demo-title"); + private static final By MESSAGE_LOCATOR = By.id("demo-message"); + + private WebDriver driver; + /** + * Constructor + * @param driver + */ + public HelloWorldPage(WebDriver driver) + { + this.driver = driver; + } + + public boolean isTitleVisible() + { + return driver.findElement(TITLE_LOCATOR).isDisplayed(); + } + + public String getTitle() + { + return driver.findElement(TITLE_LOCATOR).getText(); + } + public boolean isMessageVisible() + { + return driver.findElement(MESSAGE_LOCATOR).isDisplayed(); + } + public String getMessage() + { + return driver.findElement(MESSAGE_LOCATOR).getText(); + } +} diff --git a/archetypes/alfresco-amp-archetype/src/main/resources/archetype-resources/src/integration/resources/testng.xml b/archetypes/alfresco-amp-archetype/src/main/resources/archetype-resources/src/integration/resources/testng.xml new file mode 100644 index 00000000..001a88eb --- /dev/null +++ b/archetypes/alfresco-amp-archetype/src/main/resources/archetype-resources/src/integration/resources/testng.xml @@ -0,0 +1,9 @@ + + + + + + + + + diff --git a/archetypes/alfresco-amp-archetype/src/main/resources/archetype-resources/src/main/amp/config/alfresco/extension/templates/webscripts/webscript.get.js b/archetypes/alfresco-amp-archetype/src/main/resources/archetype-resources/src/main/amp/config/alfresco/extension/templates/webscripts/webscript.get.js deleted file mode 100644 index 1c5dc480..00000000 --- a/archetypes/alfresco-amp-archetype/src/main/resources/archetype-resources/src/main/amp/config/alfresco/extension/templates/webscripts/webscript.get.js +++ /dev/null @@ -1 +0,0 @@ -model["message"] = "Hello World!"; \ No newline at end of file diff --git a/archetypes/alfresco-amp-archetype/src/main/resources/archetype-resources/src/main/java/org/alfresco/demoamp/DemoComponent.java b/archetypes/alfresco-amp-archetype/src/main/resources/archetype-resources/src/main/java/org/alfresco/demoamp/DemoComponent.java index df873808..f418e8df 100644 --- a/archetypes/alfresco-amp-archetype/src/main/resources/archetype-resources/src/main/java/org/alfresco/demoamp/DemoComponent.java +++ b/archetypes/alfresco-amp-archetype/src/main/resources/archetype-resources/src/main/java/org/alfresco/demoamp/DemoComponent.java @@ -1,38 +1,32 @@ /* - Licensed to the Apache Software Foundation (ASF) under one or more - contributor license agreements. See the NOTICE file distributed with - this work for additional information regarding copyright ownership. - The ASF licenses this file to You 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. + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You 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 org.alfresco.demoamp; import java.util.HashMap; import java.util.Map; import org.alfresco.model.ContentModel; -import org.alfresco.repo.nodelocator.NodeLocatorService; -import org.alfresco.service.cmr.repository.NodeRef; -import org.alfresco.service.cmr.repository.NodeService; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.springframework.extensions.webscripts.DeclarativeWebScript; -import org.springframework.extensions.webscripts.Status; -import org.springframework.extensions.webscripts.WebScriptRequest; import org.alfresco.repo.module.AbstractModuleComponent; import org.alfresco.repo.nodelocator.NodeLocatorService; import org.alfresco.service.cmr.repository.NodeRef; import org.alfresco.service.cmr.repository.NodeService; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; +import org.springframework.extensions.webscripts.Status; +import org.springframework.extensions.webscripts.WebScriptRequest; /** diff --git a/archetypes/alfresco-amp-archetype/src/main/resources/archetype-resources/src/test/java/org/alfresco/demoamp/integration/DemoComponentTest.java b/archetypes/alfresco-amp-archetype/src/main/resources/archetype-resources/src/test/java/org/alfresco/demoamp/DemoComponentTest.java similarity index 98% rename from archetypes/alfresco-amp-archetype/src/main/resources/archetype-resources/src/test/java/org/alfresco/demoamp/integration/DemoComponentTest.java rename to archetypes/alfresco-amp-archetype/src/main/resources/archetype-resources/src/test/java/org/alfresco/demoamp/DemoComponentTest.java index cbbfae4c..f61ec3eb 100644 --- a/archetypes/alfresco-amp-archetype/src/main/resources/archetype-resources/src/test/java/org/alfresco/demoamp/integration/DemoComponentTest.java +++ b/archetypes/alfresco-amp-archetype/src/main/resources/archetype-resources/src/test/java/org/alfresco/demoamp/DemoComponentTest.java @@ -1,4 +1,4 @@ -package org.alfresco.demoamp.test; +package org.alfresco.demoamp; import static org.junit.Assert.assertEquals; diff --git a/archetypes/alfresco-amp-archetype/src/main/resources/archetype-resources/src/test/java/org/alfresco/demoamp/unit/HelloWorldMessageTest.java b/archetypes/alfresco-amp-archetype/src/main/resources/archetype-resources/src/test/java/org/alfresco/demoamp/HelloWorldMessageTest.java similarity index 97% rename from archetypes/alfresco-amp-archetype/src/main/resources/archetype-resources/src/test/java/org/alfresco/demoamp/unit/HelloWorldMessageTest.java rename to archetypes/alfresco-amp-archetype/src/main/resources/archetype-resources/src/test/java/org/alfresco/demoamp/HelloWorldMessageTest.java index e67ef812..79894c24 100644 --- a/archetypes/alfresco-amp-archetype/src/main/resources/archetype-resources/src/test/java/org/alfresco/demoamp/unit/HelloWorldMessageTest.java +++ b/archetypes/alfresco-amp-archetype/src/main/resources/archetype-resources/src/test/java/org/alfresco/demoamp/HelloWorldMessageTest.java @@ -12,7 +12,7 @@ * You should have received a copy of the GNU Lesser General Public License * along with Alfresco. If not, see . */ -package org.alfresco.demo.test.unit; +package org.alfresco.demoamp; import org.alfresco.demoamp.HelloWorldMessage; import org.junit.Assert; diff --git a/poms/alfresco-sdk-parent/pom.xml b/poms/alfresco-sdk-parent/pom.xml index 289bd218..ffda6d5e 100644 --- a/poms/alfresco-sdk-parent/pom.xml +++ b/poms/alfresco-sdk-parent/pom.xml @@ -504,40 +504,40 @@ - junit - junit - test - - - - org.alfresco.maven - alfresco-rad - ${maven.alfresco.version} - test - - - - org.springframework - spring-context - 3.0.6.RELEASE - provided - - - - com.h2database - h2 - ${h2.version} - test - - - tk.skuro.alfresco - h2-support - ${h2-support.version} - test - + junit + junit + test + + + + org.alfresco.maven + alfresco-rad + ${maven.alfresco.version} + test + + + + org.springframework + spring-context + 3.0.6.RELEASE + provided + + + + com.h2database + h2 + ${h2.version} + test + + + tk.skuro.alfresco + h2-support + ${h2-support.version} + test + @@ -760,5 +760,7 @@ + + From faf0d89df9a27a48f8b460e37e7d7dfd830f1a5e Mon Sep 17 00:00:00 2001 From: Michael Suzuki Date: Thu, 4 Sep 2014 14:57:41 +0100 Subject: [PATCH 04/22] added integration as source folder for m2 eclipse setup --- poms/alfresco-sdk-parent/pom.xml | 24 ++++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-) diff --git a/poms/alfresco-sdk-parent/pom.xml b/poms/alfresco-sdk-parent/pom.xml index ffda6d5e..dc7f4bfc 100644 --- a/poms/alfresco-sdk-parent/pom.xml +++ b/poms/alfresco-sdk-parent/pom.xml @@ -336,11 +336,24 @@ src/main/resources ${app.filtering.enabled} - - ${app.amp.folder} - ${app.amp.output.folder} - ${app.filtering.enabled} - + + src/integration/java + ${app.filtering.enabled} + + + src/integration/resources + ${app.filtering.enabled} + + + src/integration/properties + ${app.filtering.enabled} + + + + ${app.amp.folder} + ${app.amp.output.folder} + ${app.filtering.enabled} + @@ -475,7 +488,6 @@ - From 114d66fca1c01803a364de8d9091de7c3ce03b0c Mon Sep 17 00:00:00 2001 From: Michael Suzuki Date: Thu, 4 Sep 2014 15:35:36 +0100 Subject: [PATCH 05/22] adding integration profile --- poms/alfresco-sdk-parent/pom.xml | 132 +++++++++++++++++++++++++++---- 1 file changed, 118 insertions(+), 14 deletions(-) diff --git a/poms/alfresco-sdk-parent/pom.xml b/poms/alfresco-sdk-parent/pom.xml index dc7f4bfc..9213154b 100644 --- a/poms/alfresco-sdk-parent/pom.xml +++ b/poms/alfresco-sdk-parent/pom.xml @@ -336,19 +336,6 @@ src/main/resources ${app.filtering.enabled} - - src/integration/java - ${app.filtering.enabled} - - - src/integration/resources - ${app.filtering.enabled} - - - src/integration/properties - ${app.filtering.enabled} - - ${app.amp.folder} ${app.amp.output.folder} @@ -771,8 +758,125 @@ + + + enable-integration-testing + + true + + + + src/integration/java + + + + + + + org.apache.maven.plugins + maven-surefire-plugin + + + true + + + + org.codehaus.mojo + build-helper-maven-plugin + 1.5 + + + add-test-source + + process-resources + + + add-test-source + + + + src/integration/java + src/integration/properties + src/integration/resources + + + + + + + org.apache.maven.plugins + maven-failsafe-plugin + 2.17 + + + integration-test + + integration-test + + + + verify + + verify + + + + + + src/integration/resources/testng.xml + + + + + + + + org.testng + testng + 6.3.1 + test + + + ${alfresco.groupId} + share-po + ${alfresco.version} + test + + + + org.alfresco.maven + alfresco-rad + ${maven.alfresco.version} + test + + + + org.springframework + spring-context + 3.0.6.RELEASE + provided + + + + com.h2database + h2 + ${h2.version} + test + + + tk.skuro.alfresco + h2-support + ${h2-support.version} + test + + - From eb583a15fd6f9e6cff5718431d6b7cc77d8a38f7 Mon Sep 17 00:00:00 2001 From: Michael Suzuki Date: Fri, 5 Sep 2014 11:47:22 +0100 Subject: [PATCH 06/22] updated profile to not affect mvn test --- .../java/org/alfresco/demoamp/Demo.java | 11 +- poms/alfresco-sdk-parent/pom.xml | 197 +++++++++--------- 2 files changed, 100 insertions(+), 108 deletions(-) diff --git a/archetypes/alfresco-amp-archetype/src/main/resources/archetype-resources/src/integration/java/org/alfresco/demoamp/Demo.java b/archetypes/alfresco-amp-archetype/src/main/resources/archetype-resources/src/integration/java/org/alfresco/demoamp/Demo.java index eb695647..a7bb9419 100644 --- a/archetypes/alfresco-amp-archetype/src/main/resources/archetype-resources/src/integration/java/org/alfresco/demoamp/Demo.java +++ b/archetypes/alfresco-amp-archetype/src/main/resources/archetype-resources/src/integration/java/org/alfresco/demoamp/Demo.java @@ -15,18 +15,15 @@ package org.alfresco.demoamp; import org.alfresco.demoamp.po.HelloWorldPage; -import org.junit.AfterClass; -import org.junit.Assert; -import org.junit.BeforeClass; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.JUnit4; import org.openqa.selenium.By; import org.openqa.selenium.WebDriver; import org.openqa.selenium.WebElement; import org.openqa.selenium.firefox.FirefoxDriver; +import org.testng.Assert; +import org.testng.annotations.AfterClass; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; -@RunWith(JUnit4.class) public class Demo { private static WebDriver driver; diff --git a/poms/alfresco-sdk-parent/pom.xml b/poms/alfresco-sdk-parent/pom.xml index 9213154b..5ea092f8 100644 --- a/poms/alfresco-sdk-parent/pom.xml +++ b/poms/alfresco-sdk-parent/pom.xml @@ -760,123 +760,118 @@ - enable-integration-testing + ui-test true - - - src/integration/java - - - - - org.apache.maven.plugins - maven-surefire-plugin - - - true - - org.codehaus.mojo build-helper-maven-plugin - 1.5 + 1.7 - - add-test-source - - process-resources - - - add-test-source - - - - src/integration/java - src/integration/properties - src/integration/resources - - - - + + add-integration-source + pre-integration-test + + add-test-source + + + + src/integration/java + + + + - org.apache.maven.plugins - maven-failsafe-plugin - 2.17 - - - integration-test - - integration-test - - - - verify - - verify - - - - - - src/integration/resources/testng.xml - - - - + org.apache.maven.plugins + maven-resources-plugin + 2.5 + + + add-integration-resources + pre-integration-test + + copy-resources + + + ${project.build.directory}/integration-classes + + + src/integration/resources + + + + + + + + + org.apache.maven.plugins + maven-compiler-plugin + 2.3.2 + + + compile-integration-test + pre-integration-test + + testCompile + + + + ${project.build.directory}/integration-classes + + + + + + + org.apache.maven.plugins + maven-surefire-plugin + 2.9 + + + org.apache.maven.plugins + maven-failsafe-plugin + 2.9 + + src/integration/java + ${project.build.directory}/integration-classes + **/*.java + + + + integration-test + + integration-test + + + + verify + + verify + + + + + - - org.testng - testng - 6.3.1 - test - - - ${alfresco.groupId} - share-po - ${alfresco.version} + + org.testng + testng + 6.8.8 test - - - - org.alfresco.maven - alfresco-rad - ${maven.alfresco.version} - test - - - - org.springframework - spring-context - 3.0.6.RELEASE - provided - - - - com.h2database - h2 - ${h2.version} - test - - - tk.skuro.alfresco - h2-support - ${h2-support.version} - test + + + org.hamcrest + hamcrest-core + + - From 6076eecf4cb1e8a655a9966a9a468c20926c1209 Mon Sep 17 00:00:00 2001 From: Michael Suzuki Date: Fri, 5 Sep 2014 11:52:51 +0100 Subject: [PATCH 07/22] added junit runner to junit test class --- .../test/java/org/alfresco/demoamp/HelloWorldMessageTest.java | 3 +++ 1 file changed, 3 insertions(+) diff --git a/archetypes/alfresco-amp-archetype/src/main/resources/archetype-resources/src/test/java/org/alfresco/demoamp/HelloWorldMessageTest.java b/archetypes/alfresco-amp-archetype/src/main/resources/archetype-resources/src/test/java/org/alfresco/demoamp/HelloWorldMessageTest.java index 79894c24..19280edd 100644 --- a/archetypes/alfresco-amp-archetype/src/main/resources/archetype-resources/src/test/java/org/alfresco/demoamp/HelloWorldMessageTest.java +++ b/archetypes/alfresco-amp-archetype/src/main/resources/archetype-resources/src/test/java/org/alfresco/demoamp/HelloWorldMessageTest.java @@ -17,6 +17,8 @@ package org.alfresco.demoamp; import org.alfresco.demoamp.HelloWorldMessage; import org.junit.Assert; import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /**s @@ -25,6 +27,7 @@ import org.junit.Test; * @author Michael Suzuki * */ +@RunWith(JUnit4.class) public class HelloWorldMessageTest { @Test From dab870c8f5c46c73da842c32e758cdc197c6918b Mon Sep 17 00:00:00 2001 From: Michael Suzuki Date: Fri, 5 Sep 2014 14:06:34 +0100 Subject: [PATCH 08/22] fix to run testng in functional and integration tests --- poms/alfresco-sdk-parent/pom.xml | 222 ++++++++++++++++--------------- 1 file changed, 112 insertions(+), 110 deletions(-) diff --git a/poms/alfresco-sdk-parent/pom.xml b/poms/alfresco-sdk-parent/pom.xml index 5ea092f8..41eb26d8 100644 --- a/poms/alfresco-sdk-parent/pom.xml +++ b/poms/alfresco-sdk-parent/pom.xml @@ -760,118 +760,120 @@ - ui-test - - true - - - - - org.codehaus.mojo - build-helper-maven-plugin - 1.7 - - - add-integration-source - pre-integration-test - - add-test-source - - - - src/integration/java - - - - - - - org.apache.maven.plugins - maven-resources-plugin - 2.5 - - - add-integration-resources - pre-integration-test - - copy-resources - - - ${project.build.directory}/integration-classes - - - src/integration/resources - - - - - - - - - org.apache.maven.plugins - maven-compiler-plugin - 2.3.2 - - - compile-integration-test - pre-integration-test - - testCompile - - - - ${project.build.directory}/integration-classes - - - - - - - org.apache.maven.plugins - maven-surefire-plugin - 2.9 - - - org.apache.maven.plugins - maven-failsafe-plugin - 2.9 - - src/integration/java - ${project.build.directory}/integration-classes - **/*.java - - - - integration-test - - integration-test - - - - verify - - verify - - - - - + ui-test + + true + + + + + org.codehaus.mojo + build-helper-maven-plugin + 1.7 + + + add-integration-source + pre-integration-test + + add-test-source + + + + src/integration/java + + + + + + + org.apache.maven.plugins + maven-resources-plugin + 2.5 + + + add-integration-resources + pre-integration-test + + copy-resources + + + ${project.build.directory}/integration-classes + + + src/integration/resources + + + + + + + + + org.apache.maven.plugins + maven-compiler-plugin + 2.3.2 + + + compile-integration-test + pre-integration-test + + testCompile + + + + ${project.build.directory}/integration-classes + + + + + + + org.apache.maven.plugins + maven-surefire-plugin + 2.9 + + + org.apache.maven.plugins + maven-failsafe-plugin + 2.10 + + src/integration/java + ${project.build.directory}/integration-classes + + src/integration/resources/testng.xml + + + + + integration-test + + integration-test + + + + verify + + verify + + + + + - - org.testng - testng - 6.8.8 - test - - - org.hamcrest - hamcrest-core - - - + + org.testng + testng + 6.8.8 + test + + + org.hamcrest + hamcrest-core + + + - + From 51ab29e79ba43c0f557880f2176977371b35f082 Mon Sep 17 00:00:00 2001 From: Michael Suzuki Date: Fri, 5 Sep 2014 14:23:38 +0100 Subject: [PATCH 09/22] formatting amend --- poms/alfresco-sdk-parent/pom.xml | 134 +++++++++++++++---------------- 1 file changed, 67 insertions(+), 67 deletions(-) diff --git a/poms/alfresco-sdk-parent/pom.xml b/poms/alfresco-sdk-parent/pom.xml index 41eb26d8..bcaeff51 100644 --- a/poms/alfresco-sdk-parent/pom.xml +++ b/poms/alfresco-sdk-parent/pom.xml @@ -808,72 +808,72 @@ - - org.apache.maven.plugins - maven-compiler-plugin - 2.3.2 - - - compile-integration-test - pre-integration-test - - testCompile - - - - ${project.build.directory}/integration-classes - - - - - - - org.apache.maven.plugins - maven-surefire-plugin - 2.9 - - - org.apache.maven.plugins - maven-failsafe-plugin - 2.10 - - src/integration/java - ${project.build.directory}/integration-classes - - src/integration/resources/testng.xml - - - - - integration-test - - integration-test - - - - verify - - verify - - - - - - - - - org.testng - testng - 6.8.8 - test - - - org.hamcrest - hamcrest-core - - - - - + + org.apache.maven.plugins + maven-compiler-plugin + 2.3.2 + + + compile-integration-test + pre-integration-test + + testCompile + + + + ${project.build.directory}/integration-classes + + + + + + + org.apache.maven.plugins + maven-surefire-plugin + 2.9 + + + org.apache.maven.plugins + maven-failsafe-plugin + 2.10 + + src/integration/java + ${project.build.directory}/integration-classes + + src/integration/resources/testng.xml + + + + + integration-test + + integration-test + + + + verify + + verify + + + + + + + + + org.testng + testng + 6.8.8 + test + + + org.hamcrest + hamcrest-core + + + + + From 6d5ab89f4ae81a3cafb1cc2c16b9d317816cb42f Mon Sep 17 00:00:00 2001 From: Michael Suzuki Date: Fri, 5 Sep 2014 14:37:04 +0100 Subject: [PATCH 10/22] remove dependency from project, included in profile --- .../main/resources/archetype-resources/pom.xml | 15 --------------- 1 file changed, 15 deletions(-) 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 bef81a56..c6956387 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 @@ -68,20 +68,5 @@ ${alfresco.groupId} alfresco-repository - - ${alfresco.groupId} - share-po - ${alfresco.version} - - - org.springframework - spring-context - - - org.springframework - spring-beans - - - From be3b8618ae3265839958e09dd4ac0db7738bde31 Mon Sep 17 00:00:00 2001 From: Michael Suzuki Date: Fri, 5 Sep 2014 15:07:50 +0100 Subject: [PATCH 11/22] import all sub dependency via share po project --- poms/alfresco-sdk-parent/pom.xml | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/poms/alfresco-sdk-parent/pom.xml b/poms/alfresco-sdk-parent/pom.xml index bcaeff51..a88b8637 100644 --- a/poms/alfresco-sdk-parent/pom.xml +++ b/poms/alfresco-sdk-parent/pom.xml @@ -862,16 +862,19 @@ - org.testng - testng - 6.8.8 - test - - - org.hamcrest - hamcrest-core - - + ${alfresco.groupId} + share-po + ${alfresco.version} + + + org.springframework + spring-context + + + org.springframework + spring-beans + + From fe2fdd3c0621143361972afbe304e6bba9957e32 Mon Sep 17 00:00:00 2001 From: Michael Suzuki Date: Fri, 5 Sep 2014 16:37:39 +0100 Subject: [PATCH 12/22] updated to latest plugin version and fix to allow ui-test run after amp-to-war --- poms/alfresco-sdk-parent/pom.xml | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/poms/alfresco-sdk-parent/pom.xml b/poms/alfresco-sdk-parent/pom.xml index a88b8637..1f3f4b11 100644 --- a/poms/alfresco-sdk-parent/pom.xml +++ b/poms/alfresco-sdk-parent/pom.xml @@ -682,11 +682,11 @@ slf4j-log4j12 1.5.11 - - org.alfresco.maven - alfresco-rad - ${maven.alfresco.version} - + + org.alfresco.maven + alfresco-rad + ${maven.alfresco.version} + @@ -763,6 +763,7 @@ ui-test true + false @@ -830,12 +831,12 @@ org.apache.maven.plugins maven-surefire-plugin - 2.9 + 2.17 org.apache.maven.plugins maven-failsafe-plugin - 2.10 + 2.17 src/integration/java ${project.build.directory}/integration-classes From f3df237cf0789b22cface1ad8ac45e2ac195cc61 Mon Sep 17 00:00:00 2001 From: Michael Suzuki Date: Fri, 5 Sep 2014 17:15:58 +0100 Subject: [PATCH 13/22] fix demo to work --- .../java/org/alfresco/demoamp/Demo.java | 2 +- .../__artifactId__/context/service-context.xml | 9 ++------- .../org/alfresco/demoamp/DemoComponent.java | 17 ++--------------- 3 files changed, 5 insertions(+), 23 deletions(-) diff --git a/archetypes/alfresco-amp-archetype/src/main/resources/archetype-resources/src/integration/java/org/alfresco/demoamp/Demo.java b/archetypes/alfresco-amp-archetype/src/main/resources/archetype-resources/src/integration/java/org/alfresco/demoamp/Demo.java index a7bb9419..44d904dd 100644 --- a/archetypes/alfresco-amp-archetype/src/main/resources/archetype-resources/src/integration/java/org/alfresco/demoamp/Demo.java +++ b/archetypes/alfresco-amp-archetype/src/main/resources/archetype-resources/src/integration/java/org/alfresco/demoamp/Demo.java @@ -38,7 +38,7 @@ public class Demo WebElement ticket = driver.findElement(By.tagName("ticket")); String token =String.format("?alf_ticket=%s",ticket.getText()); //Navigate to sample page with token - driver.get("http://localhost:8080/alfresco/service/summit/hello" + token); + driver.get("http://localhost:8080/alfresco/service/sample/helloworld" + token); } @AfterClass diff --git a/archetypes/alfresco-amp-archetype/src/main/resources/archetype-resources/src/main/amp/config/alfresco/module/__artifactId__/context/service-context.xml b/archetypes/alfresco-amp-archetype/src/main/resources/archetype-resources/src/main/amp/config/alfresco/module/__artifactId__/context/service-context.xml index 10441e94..a51a1014 100644 --- a/archetypes/alfresco-amp-archetype/src/main/resources/archetype-resources/src/main/amp/config/alfresco/module/__artifactId__/context/service-context.xml +++ b/archetypes/alfresco-amp-archetype/src/main/resources/archetype-resources/src/main/amp/config/alfresco/module/__artifactId__/context/service-context.xml @@ -22,13 +22,8 @@ - - - - - - - + + diff --git a/archetypes/alfresco-amp-archetype/src/main/resources/archetype-resources/src/main/java/org/alfresco/demoamp/DemoComponent.java b/archetypes/alfresco-amp-archetype/src/main/resources/archetype-resources/src/main/java/org/alfresco/demoamp/DemoComponent.java index f418e8df..a779454b 100644 --- a/archetypes/alfresco-amp-archetype/src/main/resources/archetype-resources/src/main/java/org/alfresco/demoamp/DemoComponent.java +++ b/archetypes/alfresco-amp-archetype/src/main/resources/archetype-resources/src/main/java/org/alfresco/demoamp/DemoComponent.java @@ -19,12 +19,12 @@ import java.util.HashMap; import java.util.Map; import org.alfresco.model.ContentModel; -import org.alfresco.repo.module.AbstractModuleComponent; import org.alfresco.repo.nodelocator.NodeLocatorService; import org.alfresco.service.cmr.repository.NodeRef; import org.alfresco.service.cmr.repository.NodeService; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; +import org.springframework.extensions.webscripts.DeclarativeWebScript; import org.springframework.extensions.webscripts.Status; import org.springframework.extensions.webscripts.WebScriptRequest; @@ -38,12 +38,10 @@ import org.springframework.extensions.webscripts.WebScriptRequest; * @author Maurizio Pillitu * @author Michael Suzuki */ -public class DemoComponent extends AbstractModuleComponent +public class DemoComponent extends DeclarativeWebScript { Log log = LogFactory.getLog(DemoComponent.class); - private NodeService nodeService; - private NodeLocatorService nodeLocatorService; public void setNodeService(NodeService nodeService) @@ -55,17 +53,6 @@ public class DemoComponent extends AbstractModuleComponent { this.nodeLocatorService = nodeLocatorService; } - - /** - * Bogus component execution - */ - @Override - protected void executeInternal() throws Throwable - { - System.out.println("DemoComponent has been executed"); - log.debug("Test debug logging. Congratulation your AMP is working"); - log.info("This is only for information purposed. Better remove me from the log in Production"); - } /** * This is a demo service interaction with Alfresco Foundation API. From 84e8fd5ae7c2aaa4d109db774aee538b9536b8ba Mon Sep 17 00:00:00 2001 From: Michael Suzuki Date: Fri, 5 Sep 2014 17:20:30 +0100 Subject: [PATCH 14/22] fix test --- .../src/integration/java/org/alfresco/demoamp/Demo.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/archetypes/alfresco-amp-archetype/src/main/resources/archetype-resources/src/integration/java/org/alfresco/demoamp/Demo.java b/archetypes/alfresco-amp-archetype/src/main/resources/archetype-resources/src/integration/java/org/alfresco/demoamp/Demo.java index 44d904dd..6fe7aae2 100644 --- a/archetypes/alfresco-amp-archetype/src/main/resources/archetype-resources/src/integration/java/org/alfresco/demoamp/Demo.java +++ b/archetypes/alfresco-amp-archetype/src/main/resources/archetype-resources/src/integration/java/org/alfresco/demoamp/Demo.java @@ -52,7 +52,7 @@ public class Demo HelloWorldPage page = new HelloWorldPage(driver); Assert.assertNotNull(page); Assert.assertTrue(page.isTitleVisible()); - Assert.assertEquals("Welcome to Summit 2014", page.getTitle()); + Assert.assertEquals("Welcome to Demoamp", page.getTitle()); } /** * Message should include the directory name From ab258df2b45963be0076123518474e8192a1a45d Mon Sep 17 00:00:00 2001 From: Michael Suzuki Date: Mon, 8 Sep 2014 13:05:04 +0100 Subject: [PATCH 15/22] add new profile to setup integration --- .../resources/archetype-resources/pom.xml | 5 +++ .../demoamp/{Demo.java => DemoTestIT.java} | 12 ++--- poms/alfresco-sdk-parent/pom.xml | 44 +++++++++++++++++++ 3 files changed, 55 insertions(+), 6 deletions(-) rename archetypes/alfresco-amp-archetype/src/main/resources/archetype-resources/src/integration/java/org/alfresco/demoamp/{Demo.java => DemoTestIT.java} (92%) 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 c6956387..945ef84c 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 @@ -68,5 +68,10 @@ ${alfresco.groupId} alfresco-repository + + org.seleniumhq.selenium + selenium-java + 2.39.0 + diff --git a/archetypes/alfresco-amp-archetype/src/main/resources/archetype-resources/src/integration/java/org/alfresco/demoamp/Demo.java b/archetypes/alfresco-amp-archetype/src/main/resources/archetype-resources/src/integration/java/org/alfresco/demoamp/DemoTestIT.java similarity index 92% rename from archetypes/alfresco-amp-archetype/src/main/resources/archetype-resources/src/integration/java/org/alfresco/demoamp/Demo.java rename to archetypes/alfresco-amp-archetype/src/main/resources/archetype-resources/src/integration/java/org/alfresco/demoamp/DemoTestIT.java index 6fe7aae2..270677cb 100644 --- a/archetypes/alfresco-amp-archetype/src/main/resources/archetype-resources/src/integration/java/org/alfresco/demoamp/Demo.java +++ b/archetypes/alfresco-amp-archetype/src/main/resources/archetype-resources/src/integration/java/org/alfresco/demoamp/DemoTestIT.java @@ -15,20 +15,20 @@ package org.alfresco.demoamp; import org.alfresco.demoamp.po.HelloWorldPage; +import org.junit.AfterClass; +import org.junit.Assert; +import org.junit.BeforeClass; +import org.junit.Test; import org.openqa.selenium.By; import org.openqa.selenium.WebDriver; import org.openqa.selenium.WebElement; import org.openqa.selenium.firefox.FirefoxDriver; -import org.testng.Assert; -import org.testng.annotations.AfterClass; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.Test; -public class Demo +public class DemoTestIT { private static WebDriver driver; - @BeforeClass + @BeforeClass public static void setup() { //Create WebDriver diff --git a/poms/alfresco-sdk-parent/pom.xml b/poms/alfresco-sdk-parent/pom.xml index 1f3f4b11..139261f3 100644 --- a/poms/alfresco-sdk-parent/pom.xml +++ b/poms/alfresco-sdk-parent/pom.xml @@ -759,6 +759,50 @@ + + integration + + + src/integration/java + + + + + + org.codehaus.mojo + build-helper-maven-plugin + 1.9.1 + + + add-test-source + generate-sources + + add-test-source + + + + src/integration/java + + + + + + + org.apache.maven.plugins + maven-surefire-plugin + 2.17 + + + **/*Test.java + + + %regex[.Test*[a-z|A-Z].class] + + + + + + ui-test From 5c4174e0d8709f5fa2f4fa8d2f85b3306f7217dd Mon Sep 17 00:00:00 2001 From: Michael Suzuki Date: Mon, 8 Sep 2014 14:41:21 +0100 Subject: [PATCH 16/22] fix amp archetype to run, resolve dependency conflict --- .../resources/archetype-resources/pom.xml | 5 - poms/alfresco-sdk-parent/pom.xml | 126 ++++-------------- 2 files changed, 26 insertions(+), 105 deletions(-) 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 945ef84c..c6956387 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 @@ -68,10 +68,5 @@ ${alfresco.groupId} alfresco-repository - - org.seleniumhq.selenium - selenium-java - 2.39.0 - diff --git a/poms/alfresco-sdk-parent/pom.xml b/poms/alfresco-sdk-parent/pom.xml index 139261f3..b11a20d7 100644 --- a/poms/alfresco-sdk-parent/pom.xml +++ b/poms/alfresco-sdk-parent/pom.xml @@ -761,6 +761,9 @@ integration + + true + src/integration/java @@ -774,7 +777,19 @@ 1.9.1 - add-test-source + add-integration-source + generate-sources + + add-test-source + + + + src/integration/java + + + + + add-integration-resource generate-sources add-test-source @@ -811,117 +826,28 @@ - - org.codehaus.mojo - build-helper-maven-plugin - 1.7 - - - add-integration-source - pre-integration-test - - add-test-source - - - - src/integration/java - - - - - - - org.apache.maven.plugins - maven-resources-plugin - 2.5 - - - add-integration-resources - pre-integration-test - - copy-resources - - - ${project.build.directory}/integration-classes - - - src/integration/resources - - - - - - - - - org.apache.maven.plugins - maven-compiler-plugin - 2.3.2 - - - compile-integration-test - pre-integration-test - - testCompile - - - - ${project.build.directory}/integration-classes - - - - - org.apache.maven.plugins maven-surefire-plugin 2.17 - - - org.apache.maven.plugins - maven-failsafe-plugin - 2.17 - src/integration/java - ${project.build.directory}/integration-classes - - src/integration/resources/testng.xml - + + %regex[.Test*[a-z|A-Z].class] + + + **/*Test.java + - - - integration-test - - integration-test - - - - verify - - verify - - - - ${alfresco.groupId} - share-po - ${alfresco.version} - - - org.springframework - spring-context - - - org.springframework - spring-beans - - + org.seleniumhq.selenium + selenium-java + 2.39.0 - + From d23ce407cd3f60c86e8b0882c3630fcc108c4721 Mon Sep 17 00:00:00 2001 From: Michael Suzuki Date: Tue, 9 Sep 2014 08:54:06 +0100 Subject: [PATCH 17/22] fix to compile integration folder --- poms/alfresco-sdk-parent/pom.xml | 44 +++++++++++++++++++++++++++----- 1 file changed, 37 insertions(+), 7 deletions(-) diff --git a/poms/alfresco-sdk-parent/pom.xml b/poms/alfresco-sdk-parent/pom.xml index b11a20d7..099ab3e1 100644 --- a/poms/alfresco-sdk-parent/pom.xml +++ b/poms/alfresco-sdk-parent/pom.xml @@ -777,7 +777,7 @@ 1.9.1 - add-integration-source + add-integration-resource generate-sources add-test-source @@ -788,16 +788,26 @@ + + + + org.apache.maven.plugins + maven-resources-plugin + 2.5 + - add-integration-resource - generate-sources + add-integration-resources + generate-resources - add-test-source + copy-resources - - src/integration/java - + ${project.build.directory}/integration-classes + + + src/integration/resources + + @@ -826,6 +836,26 @@ + + + org.apache.maven.plugins + maven-compiler-plugin + 2.3.2 + + + compile-integration-test + compile + + testCompile + + + + ${project.build.directory}/integration-classes + + + + + org.apache.maven.plugins maven-surefire-plugin From 247b23a81868e0202e98b7a9750925c5e7e6389d Mon Sep 17 00:00:00 2001 From: Michael Suzuki Date: Tue, 9 Sep 2014 11:06:51 +0100 Subject: [PATCH 18/22] fix to run unit test and integration test --- poms/alfresco-sdk-parent/pom.xml | 43 ++++++++++++++++++++++---------- 1 file changed, 30 insertions(+), 13 deletions(-) diff --git a/poms/alfresco-sdk-parent/pom.xml b/poms/alfresco-sdk-parent/pom.xml index 099ab3e1..39e83315 100644 --- a/poms/alfresco-sdk-parent/pom.xml +++ b/poms/alfresco-sdk-parent/pom.xml @@ -844,6 +844,10 @@ compile-integration-test + compile testCompile @@ -856,28 +860,41 @@ + org.apache.maven.plugins maven-surefire-plugin 2.17 - - %regex[.Test*[a-z|A-Z].class] - - - **/*Test.java - + true + + + org.apache.maven.plugins + maven-failsafe-plugin + 2.17 + + src/integration/java + ${project.build.directory}/integration-classes + + + + integration-test + + integration-test + + + + verify + + verify + + + + - - - org.seleniumhq.selenium - selenium-java - 2.39.0 - - From 6f3363074edea383ea999437bfba38c692da899c Mon Sep 17 00:00:00 2001 From: Michael Suzuki Date: Tue, 9 Sep 2014 11:26:18 +0100 Subject: [PATCH 19/22] remove testing from integration profile --- poms/alfresco-sdk-parent/pom.xml | 20 ++------------------ 1 file changed, 2 insertions(+), 18 deletions(-) diff --git a/poms/alfresco-sdk-parent/pom.xml b/poms/alfresco-sdk-parent/pom.xml index 39e83315..c944ebcf 100644 --- a/poms/alfresco-sdk-parent/pom.xml +++ b/poms/alfresco-sdk-parent/pom.xml @@ -761,17 +761,14 @@ integration - - true - src/integration/java - - + + org.codehaus.mojo build-helper-maven-plugin 1.9.1 @@ -812,19 +809,6 @@ - - org.apache.maven.plugins - maven-surefire-plugin - 2.17 - - - **/*Test.java - - - %regex[.Test*[a-z|A-Z].class] - - - From 19701b28c69c81c5c9619fe4c96133bfdc25913e Mon Sep 17 00:00:00 2001 From: Michael Suzuki Date: Tue, 9 Sep 2014 12:28:49 +0100 Subject: [PATCH 20/22] added param to allow skiping of unit test --- poms/alfresco-sdk-parent/pom.xml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/poms/alfresco-sdk-parent/pom.xml b/poms/alfresco-sdk-parent/pom.xml index c944ebcf..e181685e 100644 --- a/poms/alfresco-sdk-parent/pom.xml +++ b/poms/alfresco-sdk-parent/pom.xml @@ -120,6 +120,7 @@ 1.3.174 1.5 4.11 + false From cb8315e26813f75bb2bde83f2b98f576c0585937 Mon Sep 17 00:00:00 2001 From: Michael Suzuki Date: Tue, 9 Sep 2014 12:58:21 +0100 Subject: [PATCH 21/22] remove testng from sample --- .../src/integration/resources/testng.xml | 9 --------- 1 file changed, 9 deletions(-) delete mode 100644 archetypes/alfresco-amp-archetype/src/main/resources/archetype-resources/src/integration/resources/testng.xml diff --git a/archetypes/alfresco-amp-archetype/src/main/resources/archetype-resources/src/integration/resources/testng.xml b/archetypes/alfresco-amp-archetype/src/main/resources/archetype-resources/src/integration/resources/testng.xml deleted file mode 100644 index 001a88eb..00000000 --- a/archetypes/alfresco-amp-archetype/src/main/resources/archetype-resources/src/integration/resources/testng.xml +++ /dev/null @@ -1,9 +0,0 @@ - - - - - - - - - From 4c6610a004d68bc49c5a2d701926731b4ede2c24 Mon Sep 17 00:00:00 2001 From: Michael Suzuki Date: Tue, 9 Sep 2014 15:47:42 +0100 Subject: [PATCH 22/22] tidy amp demo,and added mechanism to slow test down to allow every one to see the demo page with selenium --- .../resources/archetype-resources/pom.xml | 11 ++ .../java/org/alfresco/demoamp/DemoTestIT.java | 20 +++- .../org/alfresco/demoamp/po/DemoPage.java | 106 ++++++++++++++++++ .../alfresco/demoamp/po/HelloWorldPage.java | 56 --------- .../main/java/org/alfresco/demoamp/Demo.java | 18 ++- .../org/alfresco/demoamp/DemoComponent.java | 2 +- .../alfresco/demoamp/HelloWorldMessage.java | 58 ---------- .../alfresco/demoamp/DemoComponentTest.java | 16 ++- ...lloWorldMessageTest.java => DemoTest.java} | 19 ++-- 9 files changed, 173 insertions(+), 133 deletions(-) create mode 100644 archetypes/alfresco-amp-archetype/src/main/resources/archetype-resources/src/integration/java/org/alfresco/demoamp/po/DemoPage.java delete mode 100644 archetypes/alfresco-amp-archetype/src/main/resources/archetype-resources/src/integration/java/org/alfresco/demoamp/po/HelloWorldPage.java delete mode 100644 archetypes/alfresco-amp-archetype/src/main/resources/archetype-resources/src/main/java/org/alfresco/demoamp/HelloWorldMessage.java rename archetypes/alfresco-amp-archetype/src/main/resources/archetype-resources/src/test/java/org/alfresco/demoamp/{HelloWorldMessageTest.java => DemoTest.java} (79%) 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 c6956387..f2e5ea5e 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 @@ -68,5 +68,16 @@ ${alfresco.groupId} alfresco-repository + + org.seleniumhq.selenium + selenium-java + 2.39.0 + + + org.mortbay.jetty + servlet-api-2.5 + + + diff --git a/archetypes/alfresco-amp-archetype/src/main/resources/archetype-resources/src/integration/java/org/alfresco/demoamp/DemoTestIT.java b/archetypes/alfresco-amp-archetype/src/main/resources/archetype-resources/src/integration/java/org/alfresco/demoamp/DemoTestIT.java index 270677cb..72925b20 100644 --- a/archetypes/alfresco-amp-archetype/src/main/resources/archetype-resources/src/integration/java/org/alfresco/demoamp/DemoTestIT.java +++ b/archetypes/alfresco-amp-archetype/src/main/resources/archetype-resources/src/integration/java/org/alfresco/demoamp/DemoTestIT.java @@ -14,7 +14,7 @@ */ package org.alfresco.demoamp; -import org.alfresco.demoamp.po.HelloWorldPage; +import org.alfresco.demoamp.po.DemoPage; import org.junit.AfterClass; import org.junit.Assert; import org.junit.BeforeClass; @@ -44,16 +44,21 @@ public class DemoTestIT @AfterClass public static void teardown() { - driver.quit(); + if(driver != null) + { + driver.quit(); + } } + @Test public void titleDisplayed() { - HelloWorldPage page = new HelloWorldPage(driver); + DemoPage page = new DemoPage(driver); Assert.assertNotNull(page); Assert.assertTrue(page.isTitleVisible()); Assert.assertEquals("Welcome to Demoamp", page.getTitle()); } + /** * Message should include the directory name * and number of folders currently in that directory. @@ -61,9 +66,16 @@ public class DemoTestIT @Test public void messageIsDisplayed() { - HelloWorldPage page = new HelloWorldPage(driver); + DemoPage page = new DemoPage(driver); Assert.assertNotNull(page); Assert.assertTrue(page.isMessageVisible()); Assert.assertEquals("Company Home has 7 folders", page.getMessage()); } + + @Test + public void findLogo() + { + DemoPage page = new DemoPage(driver); + Assert.assertFalse(page.hasLogo()); + } } diff --git a/archetypes/alfresco-amp-archetype/src/main/resources/archetype-resources/src/integration/java/org/alfresco/demoamp/po/DemoPage.java b/archetypes/alfresco-amp-archetype/src/main/resources/archetype-resources/src/integration/java/org/alfresco/demoamp/po/DemoPage.java new file mode 100644 index 00000000..fcf59a91 --- /dev/null +++ b/archetypes/alfresco-amp-archetype/src/main/resources/archetype-resources/src/integration/java/org/alfresco/demoamp/po/DemoPage.java @@ -0,0 +1,106 @@ +/* + * Copyright (C) 2005-2012 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 org.alfresco.demoamp.po; + +import java.util.concurrent.TimeUnit; + +import org.openqa.selenium.By; +import org.openqa.selenium.NoSuchElementException; +import org.openqa.selenium.TimeoutException; +import org.openqa.selenium.WebDriver; +import org.openqa.selenium.WebElement; +import org.openqa.selenium.support.ui.FluentWait; + +import com.google.common.base.Predicate; +/** + * Demo page object that encapsulates the demo webscript hello world page. + * @author Michael Suzuki + * + */ +public class DemoPage +{ + private static final By TITLE_LOCATOR = By.id("demo-title"); + private static final By MESSAGE_LOCATOR = By.id("demo-message"); + + private WebDriver driver; + /** + * Constructor + * @param driver + */ + public DemoPage(WebDriver driver) + { + this.driver = driver; + } + + public boolean isTitleVisible() + { + return driver.findElement(TITLE_LOCATOR).isDisplayed(); + } + + public String getTitle() + { + return driver.findElement(TITLE_LOCATOR).getText(); + } + public boolean isMessageVisible() + { + return driver.findElement(MESSAGE_LOCATOR).isDisplayed(); + } + public String getMessage() + { + return driver.findElement(MESSAGE_LOCATOR).getText(); + } + /** + * Sample find with wait element to keep searching for a set time. + * @return true if the logo is exists + */ + public boolean hasLogo() + { + try + { + return findAndWait(By.id("logo"), 6000, 1000).isDisplayed(); + + } + catch(TimeoutException te){ } + return false; + } + /** + * Mechanism to keep looking for an element on the page. + * @param by selector + * @param limit max time to wait in ms + * @param interval time to wait between calls in ms + * @return + */ + public WebElement findAndWait(final By by, final long limit, final long interval) + { + FluentWait fluentWait = new FluentWait(by); + fluentWait.pollingEvery(interval, TimeUnit.MILLISECONDS); + fluentWait.withTimeout(limit, TimeUnit.MILLISECONDS); + fluentWait.until(new Predicate() + { + public boolean apply(By by) + { + try + { + return driver.findElement(by).isDisplayed(); + } + catch (NoSuchElementException ex) + { + return false; + } + } + }); + return driver.findElement(by); + } +} diff --git a/archetypes/alfresco-amp-archetype/src/main/resources/archetype-resources/src/integration/java/org/alfresco/demoamp/po/HelloWorldPage.java b/archetypes/alfresco-amp-archetype/src/main/resources/archetype-resources/src/integration/java/org/alfresco/demoamp/po/HelloWorldPage.java deleted file mode 100644 index 0f78e3db..00000000 --- a/archetypes/alfresco-amp-archetype/src/main/resources/archetype-resources/src/integration/java/org/alfresco/demoamp/po/HelloWorldPage.java +++ /dev/null @@ -1,56 +0,0 @@ -/* - * Copyright (C) 2005-2012 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 org.alfresco.demoamp.po; - -import org.openqa.selenium.By; -import org.openqa.selenium.WebDriver; -/** - * Hello World Page object used in Summit Demo. - * @author Michael Suzuki - * - */ -public class HelloWorldPage -{ - private static final By TITLE_LOCATOR = By.id("demo-title"); - private static final By MESSAGE_LOCATOR = By.id("demo-message"); - - private WebDriver driver; - /** - * Constructor - * @param driver - */ - public HelloWorldPage(WebDriver driver) - { - this.driver = driver; - } - - public boolean isTitleVisible() - { - return driver.findElement(TITLE_LOCATOR).isDisplayed(); - } - - public String getTitle() - { - return driver.findElement(TITLE_LOCATOR).getText(); - } - public boolean isMessageVisible() - { - return driver.findElement(MESSAGE_LOCATOR).isDisplayed(); - } - public String getMessage() - { - return driver.findElement(MESSAGE_LOCATOR).getText(); - } -} diff --git a/archetypes/alfresco-amp-archetype/src/main/resources/archetype-resources/src/main/java/org/alfresco/demoamp/Demo.java b/archetypes/alfresco-amp-archetype/src/main/resources/archetype-resources/src/main/java/org/alfresco/demoamp/Demo.java index d37df61e..765e07f4 100644 --- a/archetypes/alfresco-amp-archetype/src/main/resources/archetype-resources/src/main/java/org/alfresco/demoamp/Demo.java +++ b/archetypes/alfresco-amp-archetype/src/main/resources/archetype-resources/src/main/java/org/alfresco/demoamp/Demo.java @@ -25,9 +25,11 @@ package org.alfresco.demoamp; /** - * This class does nothing except dump some output to system.out. + * This is a simple class that generates a message for demo hello world, + * and also outputs to system.out a message. * NB: This code is taken from Alfresco Eclipse SDK Samples * @author Derek Hulley + * @author Michael Suzuki */ public class Demo { @@ -35,4 +37,18 @@ public class Demo { System.out.println("SDK Demo AMP class has been loaded"); } + /** + * Generates a message. + * @param directoryName String directory identifier + * @param folders int count of folders for that directory + * @return String message + */ + public static String generateMessage(final String directoryName, final int folders) + { + if(directoryName == null || directoryName.isEmpty()) + { + throw new RuntimeException("Directory name is required"); + } + return String.format("%s has %d folders", directoryName, folders); + } } diff --git a/archetypes/alfresco-amp-archetype/src/main/resources/archetype-resources/src/main/java/org/alfresco/demoamp/DemoComponent.java b/archetypes/alfresco-amp-archetype/src/main/resources/archetype-resources/src/main/java/org/alfresco/demoamp/DemoComponent.java index a779454b..06be0cf1 100644 --- a/archetypes/alfresco-amp-archetype/src/main/resources/archetype-resources/src/main/java/org/alfresco/demoamp/DemoComponent.java +++ b/archetypes/alfresco-amp-archetype/src/main/resources/archetype-resources/src/main/java/org/alfresco/demoamp/DemoComponent.java @@ -86,7 +86,7 @@ public class DemoComponent extends DeclarativeWebScript NodeRef companyHome = getCompanyHome(); String companyHomeName = (String) nodeService.getProperty(companyHome, ContentModel.PROP_NAME); int directoryCount = childNodesCount(companyHome); - HelloWorldMessage msg = new HelloWorldMessage(companyHomeName, directoryCount); + String msg = Demo.generateMessage(companyHomeName, directoryCount); Map model = new HashMap(); model.put("demoMessage", msg); return model; diff --git a/archetypes/alfresco-amp-archetype/src/main/resources/archetype-resources/src/main/java/org/alfresco/demoamp/HelloWorldMessage.java b/archetypes/alfresco-amp-archetype/src/main/resources/archetype-resources/src/main/java/org/alfresco/demoamp/HelloWorldMessage.java deleted file mode 100644 index ed4faec8..00000000 --- a/archetypes/alfresco-amp-archetype/src/main/resources/archetype-resources/src/main/java/org/alfresco/demoamp/HelloWorldMessage.java +++ /dev/null @@ -1,58 +0,0 @@ -/* - * Copyright (C) 2005-2007 Alfresco Software Limited. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program 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 General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * As a special exception to the terms and conditions of version 2.0 of - * the GPL, you may redistribute this Program in connection with Free/Libre - * and Open Source Software ("FLOSS") applications as described in Alfresco's - * FLOSS exception. You should have recieved a copy of the text describing - * the FLOSS exception, and it is also available here: - * http://www.alfresco.com/legal/licensing" - */ -package org.alfresco.demoamp; - -import com.sun.star.uno.RuntimeException; - -/** - * Simple pojo that holds directory name and - * the number of folders in the directory. - * - * This is used to create the message for the demoamp. - * - * @author Michael Suzuki - * - */ -public class HelloWorldMessage -{ - private final String directoryName; - private final int folders; - - public HelloWorldMessage(final String directoryName, final int folders) - { - if(directoryName == null || directoryName.isEmpty()) - { - throw new RuntimeException("Directory name is required"); - } - this.directoryName = directoryName; - this.folders = folders; - } - - public String toString() - { - return String.format("%s has %d folders", directoryName, folders); - } - -} diff --git a/archetypes/alfresco-amp-archetype/src/main/resources/archetype-resources/src/test/java/org/alfresco/demoamp/DemoComponentTest.java b/archetypes/alfresco-amp-archetype/src/main/resources/archetype-resources/src/test/java/org/alfresco/demoamp/DemoComponentTest.java index f61ec3eb..4f512105 100644 --- a/archetypes/alfresco-amp-archetype/src/main/resources/archetype-resources/src/test/java/org/alfresco/demoamp/DemoComponentTest.java +++ b/archetypes/alfresco-amp-archetype/src/main/resources/archetype-resources/src/test/java/org/alfresco/demoamp/DemoComponentTest.java @@ -45,7 +45,8 @@ import com.tradeshift.test.remote.RemoteTestRunner; @RunWith(RemoteTestRunner.class) @Remote(runnerClass=SpringJUnit4ClassRunner.class) @ContextConfiguration("classpath:alfresco/application-context.xml") -public class DemoComponentTest { +public class DemoComponentTest +{ private static final String ADMIN_USER_NAME = "admin"; @@ -59,13 +60,15 @@ public class DemoComponentTest { protected NodeService nodeService; @Test - public void testWiring() { + public void testWiring() + { assertNotNull(demoComponent); } @Test - public void testGetCompanyHome() { - AuthenticationUtil.setFullyAuthenticatedUser(ADMIN_USER_NAME); + public void testGetCompanyHome() + { + AuthenticationUtil.setFullyAuthenticatedUser(ADMIN_USER_NAME); NodeRef companyHome = demoComponent.getCompanyHome(); assertNotNull(companyHome); String companyHomeName = (String) nodeService.getProperty(companyHome, ContentModel.PROP_NAME); @@ -74,8 +77,9 @@ public class DemoComponentTest { } @Test - public void testChildNodesCount() { - AuthenticationUtil.setFullyAuthenticatedUser(ADMIN_USER_NAME); + public void testChildNodesCount() + { + AuthenticationUtil.setFullyAuthenticatedUser(ADMIN_USER_NAME); NodeRef companyHome = demoComponent.getCompanyHome(); int childNodeCount = demoComponent.childNodesCount(companyHome); assertNotNull(childNodeCount); diff --git a/archetypes/alfresco-amp-archetype/src/main/resources/archetype-resources/src/test/java/org/alfresco/demoamp/HelloWorldMessageTest.java b/archetypes/alfresco-amp-archetype/src/main/resources/archetype-resources/src/test/java/org/alfresco/demoamp/DemoTest.java similarity index 79% rename from archetypes/alfresco-amp-archetype/src/main/resources/archetype-resources/src/test/java/org/alfresco/demoamp/HelloWorldMessageTest.java rename to archetypes/alfresco-amp-archetype/src/main/resources/archetype-resources/src/test/java/org/alfresco/demoamp/DemoTest.java index 19280edd..5e2b1c3a 100644 --- a/archetypes/alfresco-amp-archetype/src/main/resources/archetype-resources/src/test/java/org/alfresco/demoamp/HelloWorldMessageTest.java +++ b/archetypes/alfresco-amp-archetype/src/main/resources/archetype-resources/src/test/java/org/alfresco/demoamp/DemoTest.java @@ -14,7 +14,6 @@ */ package org.alfresco.demoamp; -import org.alfresco.demoamp.HelloWorldMessage; import org.junit.Assert; import org.junit.Test; import org.junit.runner.RunWith; @@ -28,26 +27,32 @@ import org.junit.runners.JUnit4; * */ @RunWith(JUnit4.class) -public class HelloWorldMessageTest +public class DemoTest { @Test public void init() { - HelloWorldMessage msg = new HelloWorldMessage("bla", 0); - Assert.assertNotNull(msg); + Demo demo = new Demo(); + Assert.assertNotNull(demo); } @Test(expected = RuntimeException.class) public void initWithNull() { - new HelloWorldMessage(null, 0); + Demo.generateMessage(null, 10); } @Test public void toStringTest() { - HelloWorldMessage msg = new HelloWorldMessage("Home", 10); + String msg = Demo.generateMessage("Home", 10); Assert.assertNotNull(msg); Assert.assertEquals("Home has 10 folders",msg.toString()); } - + @Test + public void negativeValue() + { + String msg = Demo.generateMessage("Home", -10); + Assert.assertNotNull(msg); + Assert.assertEquals("Home has -10 folders",msg.toString()); + } }