mirror of
https://github.com/Alfresco/alfresco-sdk.git
synced 2025-09-17 14:21:45 +00:00
Merge pull request #215 from michaelsuzukisagi/master
Adding integration test profile
This commit is contained in:
1
.gitignore
vendored
1
.gitignore
vendored
@@ -12,3 +12,4 @@ pom.xml.next
|
|||||||
release.properties
|
release.properties
|
||||||
**.settings
|
**.settings
|
||||||
**bin
|
**bin
|
||||||
|
**.DS_Store
|
||||||
|
@@ -1,8 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<classpath>
|
|
||||||
<classpathentry excluding="**" kind="src" output="target/classes" path="src/main/resources"/>
|
|
||||||
<classpathentry excluding="**" kind="src" output="target/test-classes" path="src/test/resources"/>
|
|
||||||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.4"/>
|
|
||||||
<classpathentry kind="con" path="org.maven.ide.eclipse.MAVEN2_CLASSPATH_CONTAINER"/>
|
|
||||||
<classpathentry kind="output" path="target/classes"/>
|
|
||||||
</classpath>
|
|
@@ -1,29 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<projectDescription>
|
|
||||||
<name>alfresco-amp-archetype</name>
|
|
||||||
<comment></comment>
|
|
||||||
<projects>
|
|
||||||
</projects>
|
|
||||||
<buildSpec>
|
|
||||||
<buildCommand>
|
|
||||||
<name>org.eclipse.jdt.core.javabuilder</name>
|
|
||||||
<arguments>
|
|
||||||
</arguments>
|
|
||||||
</buildCommand>
|
|
||||||
<buildCommand>
|
|
||||||
<name>org.maven.ide.eclipse.maven2Builder</name>
|
|
||||||
<arguments>
|
|
||||||
</arguments>
|
|
||||||
</buildCommand>
|
|
||||||
<buildCommand>
|
|
||||||
<name>org.eclipse.m2e.core.maven2Builder</name>
|
|
||||||
<arguments>
|
|
||||||
</arguments>
|
|
||||||
</buildCommand>
|
|
||||||
</buildSpec>
|
|
||||||
<natures>
|
|
||||||
<nature>org.eclipse.m2e.core.maven2Nature</nature>
|
|
||||||
<nature>org.eclipse.jdt.core.javanature</nature>
|
|
||||||
<nature>org.maven.ide.eclipse.maven2Nature</nature>
|
|
||||||
</natures>
|
|
||||||
</projectDescription>
|
|
@@ -53,6 +53,24 @@
|
|||||||
<include>**/*.xml</include>
|
<include>**/*.xml</include>
|
||||||
</includes>
|
</includes>
|
||||||
</fileSet>
|
</fileSet>
|
||||||
|
<fileSet filtered="false" packaged="false" encoding="UTF-8">
|
||||||
|
<directory>src/integration/java</directory>
|
||||||
|
<includes>
|
||||||
|
<include>**/*.java</include>
|
||||||
|
</includes>
|
||||||
|
</fileSet>
|
||||||
|
<fileSet filtered="false" encoding="UTF-8">
|
||||||
|
<directory>src/integration/resources</directory>
|
||||||
|
<includes>
|
||||||
|
<include>**/*</include>
|
||||||
|
</includes>
|
||||||
|
</fileSet>
|
||||||
|
<fileSet filtered="false" encoding="UTF-8">
|
||||||
|
<directory>src/integration/properties</directory>
|
||||||
|
<includes>
|
||||||
|
<include>**/*</include>
|
||||||
|
</includes>
|
||||||
|
</fileSet>
|
||||||
<fileSet encoding="UTF-8">
|
<fileSet encoding="UTF-8">
|
||||||
<directory></directory>
|
<directory></directory>
|
||||||
<includes>
|
<includes>
|
||||||
|
@@ -73,6 +73,16 @@
|
|||||||
<groupId>${alfresco.groupId}</groupId>
|
<groupId>${alfresco.groupId}</groupId>
|
||||||
<artifactId>alfresco-repository</artifactId>
|
<artifactId>alfresco-repository</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.seleniumhq.selenium</groupId>
|
||||||
|
<artifactId>selenium-java</artifactId>
|
||||||
|
<version>2.39.0</version>
|
||||||
|
<exclusions>
|
||||||
|
<exclusion>
|
||||||
|
<groupId>org.mortbay.jetty</groupId>
|
||||||
|
<artifactId>servlet-api-2.5</artifactId>
|
||||||
|
</exclusion>
|
||||||
|
</exclusions>
|
||||||
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
</project>
|
</project>
|
||||||
|
@@ -0,0 +1,81 @@
|
|||||||
|
/*
|
||||||
|
* 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 <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
package org.alfresco.demoamp;
|
||||||
|
|
||||||
|
import org.alfresco.demoamp.po.DemoPage;
|
||||||
|
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;
|
||||||
|
|
||||||
|
public class DemoTestIT
|
||||||
|
{
|
||||||
|
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/sample/helloworld" + token);
|
||||||
|
}
|
||||||
|
|
||||||
|
@AfterClass
|
||||||
|
public static void teardown()
|
||||||
|
{
|
||||||
|
if(driver != null)
|
||||||
|
{
|
||||||
|
driver.quit();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void titleDisplayed()
|
||||||
|
{
|
||||||
|
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.
|
||||||
|
*/
|
||||||
|
@Test
|
||||||
|
public void messageIsDisplayed()
|
||||||
|
{
|
||||||
|
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());
|
||||||
|
}
|
||||||
|
}
|
@@ -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 <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
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<By> fluentWait = new FluentWait<By>(by);
|
||||||
|
fluentWait.pollingEvery(interval, TimeUnit.MILLISECONDS);
|
||||||
|
fluentWait.withTimeout(limit, TimeUnit.MILLISECONDS);
|
||||||
|
fluentWait.until(new Predicate<By>()
|
||||||
|
{
|
||||||
|
public boolean apply(By by)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
return driver.findElement(by).isDisplayed();
|
||||||
|
}
|
||||||
|
catch (NoSuchElementException ex)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
return driver.findElement(by);
|
||||||
|
}
|
||||||
|
}
|
@@ -1 +1,6 @@
|
|||||||
Message: ${message}
|
<html>
|
||||||
|
<body>
|
||||||
|
<h1 id="demo-title">Welcome to Demoamp</h1>
|
||||||
|
<p id="demo-message">${demoMessage}</p>
|
||||||
|
</body>
|
||||||
|
</html>
|
@@ -1 +0,0 @@
|
|||||||
model["message"] = "Hello World!";
|
|
@@ -22,12 +22,7 @@
|
|||||||
<bean id="changeme.exampleBean" class="org.alfresco.demoamp.Demo" init-method="init" />
|
<bean id="changeme.exampleBean" class="org.alfresco.demoamp.Demo" init-method="init" />
|
||||||
|
|
||||||
<!-- A simple module component that will be executed once -->
|
<!-- A simple module component that will be executed once -->
|
||||||
<bean id="changeme.exampleComponent" class="org.alfresco.demoamp.DemoComponent" parent="module.baseComponent" >
|
<bean id="webscript.webscript.get" class="org.alfresco.demoamp.DemoComponent" parent="webscript">
|
||||||
<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="nodeService" ref="NodeService"/>
|
||||||
<property name="nodeLocatorService" ref="nodeLocatorService" />
|
<property name="nodeLocatorService" ref="nodeLocatorService" />
|
||||||
</bean>
|
</bean>
|
||||||
|
@@ -25,9 +25,11 @@
|
|||||||
package org.alfresco.demoamp;
|
package org.alfresco.demoamp;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This class does nothing except dump some output to <i>system.out</i>.
|
* This is a simple class that generates a message for demo hello world,
|
||||||
|
* and also outputs to <i>system.out</i> a message.
|
||||||
* NB: This code is taken from Alfresco Eclipse SDK Samples
|
* NB: This code is taken from Alfresco Eclipse SDK Samples
|
||||||
* @author Derek Hulley
|
* @author Derek Hulley
|
||||||
|
* @author Michael Suzuki
|
||||||
*/
|
*/
|
||||||
public class Demo
|
public class Demo
|
||||||
{
|
{
|
||||||
@@ -35,4 +37,18 @@ public class Demo
|
|||||||
{
|
{
|
||||||
System.out.println("SDK Demo AMP class has been loaded");
|
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);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@@ -1,27 +1,33 @@
|
|||||||
/*
|
/*
|
||||||
Licensed to the Apache Software Foundation (ASF) under one or more
|
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||||
contributor license agreements. See the NOTICE file distributed with
|
* contributor license agreements. See the NOTICE file distributed with
|
||||||
this work for additional information regarding copyright ownership.
|
* this work for additional information regarding copyright ownership.
|
||||||
The ASF licenses this file to You under the Apache License, Version 2.0
|
* 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 not use this file except in compliance with
|
||||||
the License. You may obtain a copy of the License at
|
* the License. You may obtain a copy of the License at
|
||||||
|
*
|
||||||
http://www.apache.org/licenses/LICENSE-2.0
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
Unless required by applicable law or agreed to in writing, software
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
distributed under the License is distributed on an "AS IS" BASIS,
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
package org.alfresco.demoamp;
|
package org.alfresco.demoamp;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
import org.alfresco.repo.module.AbstractModuleComponent;
|
import org.alfresco.model.ContentModel;
|
||||||
import org.alfresco.repo.nodelocator.NodeLocatorService;
|
import org.alfresco.repo.nodelocator.NodeLocatorService;
|
||||||
import org.alfresco.service.cmr.repository.NodeRef;
|
import org.alfresco.service.cmr.repository.NodeRef;
|
||||||
import org.alfresco.service.cmr.repository.NodeService;
|
import org.alfresco.service.cmr.repository.NodeService;
|
||||||
import org.apache.commons.logging.Log;
|
import org.apache.commons.logging.Log;
|
||||||
import org.apache.commons.logging.LogFactory;
|
import org.apache.commons.logging.LogFactory;
|
||||||
|
import org.springframework.extensions.webscripts.DeclarativeWebScript;
|
||||||
|
import org.springframework.extensions.webscripts.Status;
|
||||||
|
import org.springframework.extensions.webscripts.WebScriptRequest;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A basic component that will be started for this module.
|
* A basic component that will be started for this module.
|
||||||
@@ -30,32 +36,22 @@ import org.apache.commons.logging.LogFactory;
|
|||||||
*
|
*
|
||||||
* @author Gabriele Columbro
|
* @author Gabriele Columbro
|
||||||
* @author Maurizio Pillitu
|
* @author Maurizio Pillitu
|
||||||
|
* @author Michael Suzuki
|
||||||
*/
|
*/
|
||||||
public class DemoComponent extends AbstractModuleComponent
|
public class DemoComponent extends DeclarativeWebScript
|
||||||
{
|
{
|
||||||
Log log = LogFactory.getLog(DemoComponent.class);
|
Log log = LogFactory.getLog(DemoComponent.class);
|
||||||
|
|
||||||
private NodeService nodeService;
|
private NodeService nodeService;
|
||||||
|
|
||||||
private NodeLocatorService nodeLocatorService;
|
private NodeLocatorService nodeLocatorService;
|
||||||
|
|
||||||
public void setNodeService(NodeService nodeService) {
|
public void setNodeService(NodeService nodeService)
|
||||||
|
{
|
||||||
this.nodeService = nodeService;
|
this.nodeService = nodeService;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setNodeLocatorService(NodeLocatorService nodeLocatorService) {
|
public void setNodeLocatorService(NodeLocatorService nodeLocatorService)
|
||||||
this.nodeLocatorService = nodeLocatorService;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Bogus component execution
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
protected void executeInternal() throws Throwable
|
|
||||||
{
|
{
|
||||||
System.out.println("DemoComponent has been executed");
|
this.nodeLocatorService = nodeLocatorService;
|
||||||
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");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -76,8 +72,23 @@ public class DemoComponent extends AbstractModuleComponent
|
|||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public NodeRef getCompanyHome()
|
public NodeRef getCompanyHome()
|
||||||
|
|
||||||
{
|
{
|
||||||
return nodeLocatorService.getNode("companyhome", null, null);
|
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<String, Object> executeImpl(WebScriptRequest req, Status status )
|
||||||
|
{
|
||||||
|
NodeRef companyHome = getCompanyHome();
|
||||||
|
String companyHomeName = (String) nodeService.getProperty(companyHome, ContentModel.PROP_NAME);
|
||||||
|
int directoryCount = childNodesCount(companyHome);
|
||||||
|
String msg = Demo.generateMessage(companyHomeName, directoryCount);
|
||||||
|
Map<String, Object> model = new HashMap<String, Object>();
|
||||||
|
model.put("demoMessage", msg);
|
||||||
|
return model;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@@ -1,4 +1,4 @@
|
|||||||
package org.alfresco.demoamp.test;
|
package org.alfresco.demoamp;
|
||||||
|
|
||||||
|
|
||||||
import static org.junit.Assert.assertEquals;
|
import static org.junit.Assert.assertEquals;
|
||||||
@@ -45,7 +45,8 @@ import com.tradeshift.test.remote.RemoteTestRunner;
|
|||||||
@RunWith(RemoteTestRunner.class)
|
@RunWith(RemoteTestRunner.class)
|
||||||
@Remote(runnerClass=SpringJUnit4ClassRunner.class)
|
@Remote(runnerClass=SpringJUnit4ClassRunner.class)
|
||||||
@ContextConfiguration("classpath:alfresco/application-context.xml")
|
@ContextConfiguration("classpath:alfresco/application-context.xml")
|
||||||
public class DemoComponentTest {
|
public class DemoComponentTest
|
||||||
|
{
|
||||||
|
|
||||||
private static final String ADMIN_USER_NAME = "admin";
|
private static final String ADMIN_USER_NAME = "admin";
|
||||||
|
|
||||||
@@ -59,12 +60,14 @@ public class DemoComponentTest {
|
|||||||
protected NodeService nodeService;
|
protected NodeService nodeService;
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testWiring() {
|
public void testWiring()
|
||||||
|
{
|
||||||
assertNotNull(demoComponent);
|
assertNotNull(demoComponent);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testGetCompanyHome() {
|
public void testGetCompanyHome()
|
||||||
|
{
|
||||||
AuthenticationUtil.setFullyAuthenticatedUser(ADMIN_USER_NAME);
|
AuthenticationUtil.setFullyAuthenticatedUser(ADMIN_USER_NAME);
|
||||||
NodeRef companyHome = demoComponent.getCompanyHome();
|
NodeRef companyHome = demoComponent.getCompanyHome();
|
||||||
assertNotNull(companyHome);
|
assertNotNull(companyHome);
|
||||||
@@ -74,7 +77,8 @@ public class DemoComponentTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testChildNodesCount() {
|
public void testChildNodesCount()
|
||||||
|
{
|
||||||
AuthenticationUtil.setFullyAuthenticatedUser(ADMIN_USER_NAME);
|
AuthenticationUtil.setFullyAuthenticatedUser(ADMIN_USER_NAME);
|
||||||
NodeRef companyHome = demoComponent.getCompanyHome();
|
NodeRef companyHome = demoComponent.getCompanyHome();
|
||||||
int childNodeCount = demoComponent.childNodesCount(companyHome);
|
int childNodeCount = demoComponent.childNodesCount(companyHome);
|
@@ -0,0 +1,58 @@
|
|||||||
|
/*
|
||||||
|
* 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 <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
package org.alfresco.demoamp;
|
||||||
|
|
||||||
|
import org.junit.Assert;
|
||||||
|
import org.junit.Test;
|
||||||
|
import org.junit.runner.RunWith;
|
||||||
|
import org.junit.runners.JUnit4;
|
||||||
|
|
||||||
|
|
||||||
|
/**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
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
@RunWith(JUnit4.class)
|
||||||
|
public class DemoTest
|
||||||
|
{
|
||||||
|
@Test
|
||||||
|
public void init()
|
||||||
|
{
|
||||||
|
Demo demo = new Demo();
|
||||||
|
Assert.assertNotNull(demo);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test(expected = RuntimeException.class)
|
||||||
|
public void initWithNull()
|
||||||
|
{
|
||||||
|
Demo.generateMessage(null, 10);
|
||||||
|
}
|
||||||
|
@Test
|
||||||
|
public void toStringTest()
|
||||||
|
{
|
||||||
|
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());
|
||||||
|
}
|
||||||
|
}
|
@@ -126,6 +126,7 @@
|
|||||||
<h2.version>1.3.174</h2.version>
|
<h2.version>1.3.174</h2.version>
|
||||||
<h2-support.version>1.5</h2-support.version>
|
<h2-support.version>1.5</h2-support.version>
|
||||||
<junit.version>4.11</junit.version>
|
<junit.version>4.11</junit.version>
|
||||||
|
<skip.unit.test>false</skip.unit.test>
|
||||||
</properties>
|
</properties>
|
||||||
|
|
||||||
<!-- This repository is only needed to retrieve Alfresco parent POM.
|
<!-- This repository is only needed to retrieve Alfresco parent POM.
|
||||||
@@ -487,7 +488,6 @@
|
|||||||
</plugin>
|
</plugin>
|
||||||
</plugins>
|
</plugins>
|
||||||
</build>
|
</build>
|
||||||
|
|
||||||
</profile>
|
</profile>
|
||||||
|
|
||||||
<!-- Enables alfresco testing dependencies if a src/test/java folder is found, by adding appropriate dependencies -->
|
<!-- Enables alfresco testing dependencies if a src/test/java folder is found, by adding appropriate dependencies -->
|
||||||
@@ -771,6 +771,127 @@
|
|||||||
</plugins>
|
</plugins>
|
||||||
</build>
|
</build>
|
||||||
</profile>
|
</profile>
|
||||||
|
<profile>
|
||||||
|
<id>integration</id>
|
||||||
|
<activation>
|
||||||
|
<file>
|
||||||
|
<exists>src/integration/java</exists>
|
||||||
|
</file>
|
||||||
|
</activation>
|
||||||
|
<build>
|
||||||
|
<plugins>
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.codehaus.mojo</groupId>
|
||||||
|
<artifactId>build-helper-maven-plugin</artifactId>
|
||||||
|
<version>1.9.1</version>
|
||||||
|
<executions>
|
||||||
|
<execution>
|
||||||
|
<id>add-integration-resource</id>
|
||||||
|
<phase>generate-sources</phase>
|
||||||
|
<goals>
|
||||||
|
<goal>add-test-source</goal>
|
||||||
|
</goals>
|
||||||
|
<configuration>
|
||||||
|
<sources>
|
||||||
|
<source>src/integration/java</source>
|
||||||
|
</sources>
|
||||||
|
</configuration>
|
||||||
|
</execution>
|
||||||
|
</executions>
|
||||||
|
</plugin>
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
|
<artifactId>maven-resources-plugin</artifactId>
|
||||||
|
<version>2.5</version>
|
||||||
|
<executions>
|
||||||
|
<execution>
|
||||||
|
<id>add-integration-resources</id>
|
||||||
|
<phase>generate-resources</phase>
|
||||||
|
<goals>
|
||||||
|
<goal>copy-resources</goal>
|
||||||
|
</goals>
|
||||||
|
<configuration>
|
||||||
|
<outputDirectory>${project.build.directory}/integration-classes</outputDirectory>
|
||||||
|
<resources>
|
||||||
|
<resource>
|
||||||
|
<directory>src/integration/resources</directory>
|
||||||
|
</resource>
|
||||||
|
</resources>
|
||||||
|
</configuration>
|
||||||
|
</execution>
|
||||||
|
</executions>
|
||||||
|
</plugin>
|
||||||
|
</plugins>
|
||||||
|
</build>
|
||||||
|
</profile>
|
||||||
|
<profile>
|
||||||
|
<id>ui-test</id>
|
||||||
|
<properties>
|
||||||
|
<maven.tomcat.fork>true</maven.tomcat.fork>
|
||||||
|
<skipTests>false</skipTests>
|
||||||
|
</properties>
|
||||||
|
<build>
|
||||||
|
<plugins>
|
||||||
|
<!-- compile integration -->
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
|
<artifactId>maven-compiler-plugin</artifactId>
|
||||||
|
<version>2.3.2</version>
|
||||||
|
<executions>
|
||||||
|
<execution>
|
||||||
|
<id>compile-integration-test</id>
|
||||||
|
<!--
|
||||||
|
Do not change the phase as it wont compile unless in the right phase so
|
||||||
|
mvn install -Pui-test wont work.
|
||||||
|
-->
|
||||||
|
<phase>compile</phase>
|
||||||
|
<goals>
|
||||||
|
<goal>testCompile</goal>
|
||||||
|
</goals>
|
||||||
|
<configuration>
|
||||||
|
<compilerArguments>
|
||||||
|
<d>${project.build.directory}/integration-classes</d>
|
||||||
|
</compilerArguments>
|
||||||
|
</configuration>
|
||||||
|
</execution>
|
||||||
|
</executions>
|
||||||
|
</plugin>
|
||||||
|
<!-- Force to skip unit test -->
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
|
<artifactId>maven-surefire-plugin</artifactId>
|
||||||
|
<version>2.17</version>
|
||||||
|
<configuration>
|
||||||
|
<skipTests>${skip.unit.test}</skipTests>
|
||||||
|
</configuration>
|
||||||
|
</plugin>
|
||||||
|
<!-- Run integration test with failsafe, with config to fail build if test failure -->
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
|
<artifactId>maven-failsafe-plugin</artifactId>
|
||||||
|
<version>2.17</version>
|
||||||
|
<configuration>
|
||||||
|
<testSourceDirectory>src/integration/java</testSourceDirectory>
|
||||||
|
<testClassesDirectory>${project.build.directory}/integration-classes</testClassesDirectory>
|
||||||
|
</configuration>
|
||||||
|
<executions>
|
||||||
|
<execution>
|
||||||
|
<id>integration-test</id>
|
||||||
|
<goals>
|
||||||
|
<goal>integration-test</goal>
|
||||||
|
</goals>
|
||||||
|
</execution>
|
||||||
|
<execution>
|
||||||
|
<id>verify</id>
|
||||||
|
<goals>
|
||||||
|
<goal>verify</goal>
|
||||||
|
</goals>
|
||||||
|
</execution>
|
||||||
|
</executions>
|
||||||
|
</plugin>
|
||||||
|
</plugins>
|
||||||
|
</build>
|
||||||
|
</profile>
|
||||||
<!-- Does any SDK dev environment preparation (e.g. spring-loaded download) -->
|
<!-- Does any SDK dev environment preparation (e.g. spring-loaded download) -->
|
||||||
<profile>
|
<profile>
|
||||||
<id>setup</id>
|
<id>setup</id>
|
||||||
|
Reference in New Issue
Block a user