Merged HEAD (5.1) to 5.1.N (5.1.1)

117315 tpage: ACE-2671 Unit tests for QNameTypeEditor.
   The QNameTypeEditor was migrated from RM to repo in r83388, but
   at the time there were no unit tests. This closes the issue by
   adding unit tests.


git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/BRANCHES/DEV/5.1.N/root@117384 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Tatyana Valkevych
2015-11-12 10:21:30 +00:00
parent 15f7d63375
commit 3ca1dfd1ea
5 changed files with 202 additions and 54 deletions

View File

@@ -76,7 +76,7 @@ public class BeanExtender implements BeanFactoryPostProcessor
// check for extending bean
if (!beanFactory.containsBean(extendingBeanName))
{
throw new NoSuchBeanDefinitionException("Can't find bean '" + extendingBeanName + "' that is going to extend origional bean definition.");
throw new NoSuchBeanDefinitionException("Can't find bean '" + extendingBeanName + "' that is going to extend original bean definition.");
}
// get the bean definitions

View File

@@ -434,4 +434,9 @@ public class Repository01TestSuite extends TestSuite
// This test opens, closes and again opens the alfresco application context.
suite.addTest(new JUnit4TestAdapter(org.alfresco.repo.dictionary.CustomModelRepoRestartTest.class));
}
static void tests69(TestSuite suite)
{
suite.addTest(new JUnit4TestAdapter(org.alfresco.repo.policy.annotation.QNameTypeEditorTest.class));
}
}

View File

@@ -0,0 +1,38 @@
/*
* Copyright (C) 2005-2015 Alfresco Software Limited.
*
* This file is part of Alfresco
*
* Alfresco is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Alfresco is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
*/
package org.alfresco;
import junit.framework.Test;
import junit.framework.TestSuite;
/**
* See {@link Repository01TestSuite}
*
* @author Tom Page
*/
public class Repository69TestSuite extends TestSuite
{
public static Test suite()
{
TestSuite suite = new TestSuite();
Repository01TestSuite.tests69(suite);
return suite;
}
}

View File

@@ -0,0 +1,95 @@
/*
* Copyright (C) 2013-2015 Alfresco Software Limited.
*
* This file is part of Alfresco
*
* Alfresco is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Alfresco is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
*/
package org.alfresco.repo.policy.annotation;
import static org.junit.Assert.assertEquals;
import org.alfresco.service.namespace.QName;
import org.alfresco.test_category.OwnJVMTestsCategory;
import org.alfresco.util.ApplicationContextHelper;
import org.apache.commons.lang3.ArrayUtils;
import org.junit.AfterClass;
import org.junit.Test;
import org.junit.experimental.categories.Category;
import org.springframework.context.ApplicationContext;
/**
* Application context tests for the automatic QName converter.
*
* @author Tom Page
*/
@Category(OwnJVMTestsCategory.class)
public class QNameTypeEditorTest
{
/** The location of the Spring context file used by this test. */
private static final String TEST_CONFIG_LOCATION = "classpath:org/alfresco/repo/policy/annotation/test-qname-type-editor-context.xml";
/** A list containing the standard Spring context files and the context file for this test. */
private static final String[] CONFIG_LOCATIONS = ArrayUtils.add(ApplicationContextHelper.CONFIG_LOCATIONS, TEST_CONFIG_LOCATION);
/** The Spring application context. */
private static ApplicationContext applicationContext = ApplicationContextHelper.getApplicationContext(CONFIG_LOCATIONS);
/** Check that loading a bean with a QName containing a reference to a namespace works. */
@Test
public void testPopulateBeanWithNamespace() throws Exception
{
QNameContainer qNameContainer = (QNameContainer) applicationContext.getBean("qNameContainerWithNamespace");
QName expectedQName = QName.createQName("http://www.alfresco.org/model/content/1.0", "namespacedName");
assertEquals("Loading String as QName failed.", expectedQName, qNameContainer.getQName());
}
/** Check loading a bean with a non-namespaced QName. */
@Test
public void testPopulateBeanWithoutNamespace() throws Exception
{
QNameContainer qNameContainer = (QNameContainer) applicationContext.getBean("qNameContainerNoNamespace");
QName expectedQName = QName.createQName("noNamespaceName");
assertEquals("Loading String as QName failed.", expectedQName, qNameContainer.getQName());
}
/** A POJO used to check the QName property behaviour. */
public static class QNameContainer
{
private QName qName;
/** Store a QName. */
public void setQName(QName qName)
{
this.qName = qName;
}
/** Retrieve the stored QName. */
public QName getQName()
{
return qName;
}
}
/**
* Clear up after all the tests have finished and dereference the application context to allow it to be garbage
* collected.
*/
@AfterClass
public static void tidyAfterTestClass()
{
ApplicationContextHelper.closeApplicationContext();
applicationContext = null;
}
}

View File

@@ -0,0 +1,10 @@
<?xml version='1.0' encoding='UTF-8'?>
<beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
<bean name="qNameContainerWithNamespace" class="org.alfresco.repo.policy.annotation.QNameTypeEditorTest.QNameContainer">
<property name="qName" value="cm:namespacedName" />
</bean>
<bean name="qNameContainerNoNamespace" class="org.alfresco.repo.policy.annotation.QNameTypeEditorTest.QNameContainer">
<property name="qName" value="noNamespaceName" />
</bean>
</beans>