09-10-2013 09:50 PM
09-12-2013 04:45 AM
09-13-2013 08:15 AM
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.jabil</groupId>
<artifactId>abc</artifactId>
<version>1.0-SNAPSHOT</version>
<name>abc AMP project</name>
<packaging>amp</packaging>
<description>Manages the lifecycle of the abc AMP (Alfresco Module Package)</description>
<build>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.eclipse.m2e</groupId>
<artifactId>lifecycle-mapping</artifactId>
<version>1.0.0</version>
<configuration>
<lifecycleMappingMetadata>
<pluginExecutions>
<pluginExecution>
<pluginExecutionFilter>
<groupId>org.alfresco.maven.plugin</groupId>
<artifactId>alfresco-maven-plugin</artifactId>
<versionRange>[0.0.0,)</versionRange>
<goals>
<goal>set-version</goal>
</goals>
</pluginExecutionFilter>
<action>
<execute>
<runOnIncremental>false</runOnIncremental>
</execute>
</action>
</pluginExecution>
</pluginExecutions>
</lifecycleMappingMetadata>
</configuration>
</plugin>
</plugins>
</pluginManagement>
</build>
<parent>
<groupId>org.alfresco.maven</groupId>
<artifactId>alfresco-sdk-parent</artifactId>
<version>1.0.2</version>
</parent>
<!– | SDK properties have sensible defaults in the SDK parent, | but you
can override the properties below to use another version. | For more available
properties see the alfresco-sdk-parent POM. –>
<properties>
<!– Defines the alfresco edition to compile against. Allowed values are
[org.alfresco|org.alfresco.enterprise] –>
<alfresco.groupId>org.alfresco.enterprise</alfresco.groupId>
<!– Defines the alfresco version to compile against –>
<alfresco.version>4.1.5</alfresco.version>
<app.log.root.level>WARN</app.log.root.level>
<alfresco.data.location>alf_data_dev</alfresco.data.location>
<!– Defines the target WAR artifactId to run this amp, only used with
the -Pamp-to-war switch . | Allowed values: alfresco | share. Defaults to
a repository AMP, but could point to your foundation WAR –>
<alfresco.client.war>alfresco</alfresco.client.war>
<!– Defines the target WAR groupId to run this amp, only used with the
-Pamp-to-war switch . | Could be org.alfresco | org.alfresco.enterprise or
your corporate groupId –>
<alfresco.client.war.groupId>org.alfresco.enterprise</alfresco.client.war.groupId>
<!– Defines the target WAR version to run this amp, only used with the
-Pamp-to-war switch –>
<alfresco.client.war.version>4.1.5</alfresco.client.war.version>
<!– This controls which properties will be picked in src/test/properties
for embedded run –>
<env>local</env>
</properties>
<!– Here we realize the connection with the Alfresco selected platform
(e.g.version and edition) –>
<dependencyManagement>
<dependencies>
<!– This will import the dependencyManagement for all artifacts in the
selected Alfresco version/edition (see http://maven.apache.org/guides/introduction/introduction-to-dependency-mechanism.html#Importing_Depe...)
NOTE: You still need to define dependencies in your POM, but you can omit
version as it's enforced by this dependencyManagement. NOTE: It defaults
to the latest version this SDK pom has been tested with, but alfresco version
can/should be overridden in your project's pom –>
<dependency>
<groupId>${alfresco.groupId}</groupId>
<artifactId>alfresco-platform-distribution</artifactId>
<version>${alfresco.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
<dependency>
<groupId>edu.ucar</groupId>
<artifactId>netcdf</artifactId>
<version>4.2</version>
<exclusions>
<exclusion>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
</exclusion>
</exclusions>
</dependency>
</dependencies>
</dependencyManagement>
<!– Following dependencies are needed for compiling Java code in src/main/java;
<scope>provided</scope> is inherited for each of the following; for more
info, please refer to alfresco-platform-distribution POM –>
<dependencies>
<dependency>
<groupId>${alfresco.groupId}</groupId>
<artifactId>alfresco-repository</artifactId>
</dependency>
<!– Test dependencies –>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.8.1</version>
<scope>test</scope>
</dependency>
</dependencies>
<!– This repository is only needed to retrieve Alfresco parent POM. NOTE:
This can be removed when/if Alfresco will be on Maven Central NOTE: The repository
to be used for Alfresco Enterprise artifacts is https://artifacts.alfresco.com/nexus/content/groups/private/.
Please check with Alfresco Support to get credentials to add to your ~/.m2/settings.xml
if you are a Enterprise customer or Partner –>
<repositories>
<!– <repository> <id>alfresco-public</id> <url>https://artifacts.alfresco.com/nexus/content/groups/public</url>
</repository> <repository> <id>alfresco-public-snapshots</id> <url>https://artifacts.alfresco.com/nexus/content/groups/public-snapshots</url>
<snapshots> <enabled>true</enabled> <updatePolicy>daily</updatePolicy> </snapshots>
</repository> –>
<repository>
<id>alfresco-artifacts-repository</id>
<url>https://artifacts.alfresco.com/nexus/content/groups/private</url>
</repository>
</repositories>
</project>
<beans>
<!– A simple class that is initialized by Spring –>
<bean id="changeme.exampleBean" class="org.alfresco.demoamp.Demo" init-method="init" />
<!– A simple module component that will be executed once –>
<bean id="changeme.exampleComponent" class="org.alfresco.demoamp.DemoComponent" parent="module.baseComponent" >
<property name="moduleId" value="${project.artifactId}" /> <!– See module.properties –>
<property name="name" value="exampleComponent" />
<property name="description" value="A demonstration component" />
<property name="sinceVersion" value="2.0" />
<property name="appliesFromVersion" value="2.0" />
<property name="nodeService" ref="NodeService" />
<property name="nodeLocatorService" ref="nodeLocatorService" />
</bean>
</beans>
09-16-2013 03:45 AM
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(locations = { "/path/to/test-spring-context.xml" })
09-17-2013 04:32 AM
public class DemoComponentTest {
private static final String ADMIN_USER_NAME = "admin";
static Logger log = Logger.getLogger(DemoComponentTest.class);
protected static ApplicationContext applicationContext;
protected static DemoComponent demoComponent;
protected static NodeService nodeService;
@BeforeClass
public static void initAppContext()
{
// TODO: Make testing properly working without need for helpers
// TODO: Provide this in an SDK base class
ApplicationContextHelper.setUseLazyLoading(false);
ApplicationContextHelper.setNoAutoStart(true);
applicationContext = ApplicationContextHelper.getApplicationContext(new String[] { "classpath:alfresco/application-context.xml" });
demoComponent = (DemoComponent) applicationContext.getBean("changeme.exampleComponent");
nodeService = (NodeService) applicationContext.getBean("NodeService");
AuthenticationUtil.setFullyAuthenticatedUser(ADMIN_USER_NAME);
log.debug("Sample test logging: If you see this message, means your unit test logging is properly configured. Change it in test-log4j.properties");
log.debug("Sample test logging: Application Context properly loaded");
}
@Test
public void testWiring() {
assertNotNull(demoComponent);
}
@Test
public void testGetCompanyHome() {
NodeRef companyHome = demoComponent.getCompanyHome();
assertNotNull(companyHome);
String companyHomeName = (String) nodeService.getProperty(companyHome, ContentModel.PROP_NAME);
assertNotNull(companyHomeName);
assertEquals("Company Home", companyHomeName);
}
@Test
public void testChildNodesCount() {
NodeRef companyHome = demoComponent.getCompanyHome();
int childNodeCount = demoComponent.childNodesCount(companyHome);
assertNotNull(childNodeCount);
// There are 5 folders by default under Company Home
assertEquals(6, childNodeCount);
}
}
Tags
Find what you came for
We want to make your experience in Hyland Connect as valuable as possible, so we put together some helpful links.