From 8bf4214be1301e34db59ad9d2fd22481c28a09ad Mon Sep 17 00:00:00 2001 From: mindthegab Date: Tue, 23 Dec 2014 12:34:30 -0500 Subject: [PATCH] added amp testing framework to aio. tested remote junit working --- .../META-INF/maven/archetype-metadata.xml | 6 ++ .../archetype-resources/repo-amp/pom.xml | 6 ++ .../context/service-context.xml | 2 + .../org/alfresco/demoamp/DemoComponent.java | 73 +++++++++++++++++-- .../archetype-resources/repo/pom.xml | 7 ++ 5 files changed, 86 insertions(+), 8 deletions(-) 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 4ed715e7..8fa27ab3 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 @@ -25,6 +25,12 @@ **/*.java + + src/test/java + + **/*.java + + src/main/amp diff --git a/archetypes/alfresco-allinone-archetype/src/main/resources/archetype-resources/repo-amp/pom.xml b/archetypes/alfresco-allinone-archetype/src/main/resources/archetype-resources/repo-amp/pom.xml index fa12b026..df793b5e 100644 --- a/archetypes/alfresco-allinone-archetype/src/main/resources/archetype-resources/repo-amp/pom.xml +++ b/archetypes/alfresco-allinone-archetype/src/main/resources/archetype-resources/repo-amp/pom.xml @@ -45,5 +45,11 @@ + + run + + true + + diff --git a/archetypes/alfresco-allinone-archetype/src/main/resources/archetype-resources/repo-amp/src/main/amp/config/alfresco/module/__artifactId__/context/service-context.xml b/archetypes/alfresco-allinone-archetype/src/main/resources/archetype-resources/repo-amp/src/main/amp/config/alfresco/module/__artifactId__/context/service-context.xml index 645860e4..44199812 100644 --- a/archetypes/alfresco-allinone-archetype/src/main/resources/archetype-resources/repo-amp/src/main/amp/config/alfresco/module/__artifactId__/context/service-context.xml +++ b/archetypes/alfresco-allinone-archetype/src/main/resources/archetype-resources/repo-amp/src/main/amp/config/alfresco/module/__artifactId__/context/service-context.xml @@ -29,6 +29,8 @@ + + diff --git a/archetypes/alfresco-allinone-archetype/src/main/resources/archetype-resources/repo-amp/src/main/java/org/alfresco/demoamp/DemoComponent.java b/archetypes/alfresco-allinone-archetype/src/main/resources/archetype-resources/repo-amp/src/main/java/org/alfresco/demoamp/DemoComponent.java index de4c2cbb..45896271 100644 --- a/archetypes/alfresco-allinone-archetype/src/main/resources/archetype-resources/repo-amp/src/main/java/org/alfresco/demoamp/DemoComponent.java +++ b/archetypes/alfresco-allinone-archetype/src/main/resources/archetype-resources/repo-amp/src/main/java/org/alfresco/demoamp/DemoComponent.java @@ -1,26 +1,83 @@ +/* + 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.logging.Logger; - 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; /** * A basic component that will be started for this module. - * This is a sample taken from Maven Alfresco SDK + * Uses the NodeLocatorService to easily find nodes and the + * NodeService to display them * - * @author Derek Hulley + * @author Gabriele Columbro + * @author Maurizio Pillitu */ public class DemoComponent extends AbstractModuleComponent { - Log log = LogFactory.getLog(DemoComponent.class); - + Log log = LogFactory.getLog(DemoComponent.class); + + private NodeService nodeService; + + private NodeLocatorService nodeLocatorService; + + public void setNodeService(NodeService nodeService) { + this.nodeService = nodeService; + } + + public void setNodeLocatorService(NodeLocatorService nodeLocatorService) { + this.nodeLocatorService = nodeLocatorService; + } + + /** + * Bogus component execution + */ @Override protected void executeInternal() throws Throwable { System.out.println("DemoComponent has been executed"); - log.debug("Test debug logging is working"); - log.info("This should not be outputted by default"); + 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. + * This sample method returns the number of child nodes of a certain type + * under a certain node. + * + * @return + */ + public int childNodesCount(NodeRef nodeRef) + { + return nodeService.countChildAssocs(nodeRef, true); + } + + /** + * Returns the NodeRef of "Company Home" + * + * @return + */ + public NodeRef getCompanyHome() + + { + return nodeLocatorService.getNode("companyhome", null, null); } } diff --git a/archetypes/alfresco-allinone-archetype/src/main/resources/archetype-resources/repo/pom.xml b/archetypes/alfresco-allinone-archetype/src/main/resources/archetype-resources/repo/pom.xml index c0f16aff..0b389c4b 100644 --- a/archetypes/alfresco-allinone-archetype/src/main/resources/archetype-resources/repo/pom.xml +++ b/archetypes/alfresco-allinone-archetype/src/main/resources/archetype-resources/repo/pom.xml @@ -145,6 +145,13 @@ + + + org.alfresco.maven + alfresco-rad + ${maven.alfresco.version} + +