mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-08-07 17:49:17 +00:00
Merge the two Model tests suites together
Merging should save a little bit of startup time. Also, add a few more checks inthe the MultilingualContentServiceImpl test, along with more comments explaining what it does. git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@19199 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -16,24 +16,25 @@
|
|||||||
* You should have received a copy of the GNU Lesser General Public License
|
* You should have received a copy of the GNU Lesser General Public License
|
||||||
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
|
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
package org.alfresco.repo.model.ml;
|
package org.alfresco.repo.model;
|
||||||
|
|
||||||
import junit.framework.Test;
|
|
||||||
import junit.framework.TestSuite;
|
|
||||||
|
|
||||||
|
import org.alfresco.repo.model.filefolder.FileFolderDuplicateChildTest;
|
||||||
|
import org.alfresco.repo.model.filefolder.FileFolderServiceImplTest;
|
||||||
import org.alfresco.repo.model.ml.tools.ContentFilterLanguagesMapTest;
|
import org.alfresco.repo.model.ml.tools.ContentFilterLanguagesMapTest;
|
||||||
import org.alfresco.repo.model.ml.tools.EditionServiceImplTest;
|
import org.alfresco.repo.model.ml.tools.EditionServiceImplTest;
|
||||||
import org.alfresco.repo.model.ml.tools.EmptyTranslationAspectTest;
|
import org.alfresco.repo.model.ml.tools.EmptyTranslationAspectTest;
|
||||||
import org.alfresco.repo.model.ml.tools.MLContainerTypeTest;
|
import org.alfresco.repo.model.ml.tools.MLContainerTypeTest;
|
||||||
import org.alfresco.repo.model.ml.tools.MultilingualContentServiceImplTest;
|
import org.alfresco.repo.model.ml.tools.MultilingualContentServiceImplTest;
|
||||||
import org.alfresco.repo.model.ml.tools.MultilingualDocumentAspectTest;
|
import org.alfresco.repo.model.ml.tools.MultilingualDocumentAspectTest;
|
||||||
|
import org.alfresco.util.ApplicationContextHelper;
|
||||||
|
|
||||||
|
import junit.framework.Test;
|
||||||
|
import junit.framework.TestSuite;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Multilingual test suite
|
* Model test suite
|
||||||
*
|
|
||||||
* @author yanipig
|
|
||||||
*/
|
*/
|
||||||
public class MultilingualTestSuite extends TestSuite
|
public class ModelTestSuite extends TestSuite
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Creates the test suite
|
* Creates the test suite
|
||||||
@@ -44,13 +45,23 @@ public class MultilingualTestSuite extends TestSuite
|
|||||||
{
|
{
|
||||||
TestSuite suite = new TestSuite();
|
TestSuite suite = new TestSuite();
|
||||||
|
|
||||||
suite.addTestSuite(EmptyTranslationAspectTest.class);
|
// Ensure that the default context is available
|
||||||
|
ApplicationContextHelper.getApplicationContext();
|
||||||
|
|
||||||
|
// Add the multilingual tests
|
||||||
suite.addTestSuite( ContentFilterLanguagesMapTest.class );
|
suite.addTestSuite( ContentFilterLanguagesMapTest.class );
|
||||||
|
suite.addTestSuite( EmptyTranslationAspectTest.class );
|
||||||
|
suite.addTestSuite( MLContainerTypeTest.class );
|
||||||
suite.addTestSuite( MultilingualContentServiceImplTest.class );
|
suite.addTestSuite( MultilingualContentServiceImplTest.class );
|
||||||
suite.addTestSuite( MultilingualDocumentAspectTest.class );
|
suite.addTestSuite( MultilingualDocumentAspectTest.class );
|
||||||
suite.addTestSuite(MLContainerTypeTest.class);
|
|
||||||
suite.addTestSuite( EditionServiceImplTest.class );
|
suite.addTestSuite( EditionServiceImplTest.class );
|
||||||
|
|
||||||
|
// Add the file folder tests
|
||||||
|
// These need to come afterwards, as they insert extra
|
||||||
|
// interceptors which would otherwise confuse things
|
||||||
|
suite.addTestSuite( FileFolderServiceImplTest.class );
|
||||||
|
suite.addTestSuite( FileFolderDuplicateChildTest.class );
|
||||||
|
|
||||||
return suite;
|
return suite;
|
||||||
}
|
}
|
||||||
}
|
}
|
@@ -1,40 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (C) 2005-2010 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.model.filefolder;
|
|
||||||
|
|
||||||
import junit.framework.Test;
|
|
||||||
import junit.framework.TestSuite;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Suite for FileFolderService tests.
|
|
||||||
*
|
|
||||||
* @author Derek Hulley
|
|
||||||
*/
|
|
||||||
public class FileFolderTestSuite extends TestSuite
|
|
||||||
{
|
|
||||||
public static Test suite()
|
|
||||||
{
|
|
||||||
TestSuite suite = new TestSuite();
|
|
||||||
|
|
||||||
suite.addTestSuite(FileFolderServiceImplTest.class);
|
|
||||||
suite.addTestSuite(FileFolderDuplicateChildTest.class);
|
|
||||||
|
|
||||||
return suite;
|
|
||||||
}
|
|
||||||
}
|
|
@@ -26,6 +26,7 @@ import org.springframework.extensions.surf.util.I18NUtil;
|
|||||||
import org.alfresco.model.ContentModel;
|
import org.alfresco.model.ContentModel;
|
||||||
import org.alfresco.repo.security.authentication.AuthenticationComponent;
|
import org.alfresco.repo.security.authentication.AuthenticationComponent;
|
||||||
import org.alfresco.repo.security.authentication.AuthenticationUtil;
|
import org.alfresco.repo.security.authentication.AuthenticationUtil;
|
||||||
|
import org.alfresco.service.cmr.model.FileExistsException;
|
||||||
import org.alfresco.service.cmr.repository.ContentData;
|
import org.alfresco.service.cmr.repository.ContentData;
|
||||||
import org.alfresco.service.cmr.repository.NodeRef;
|
import org.alfresco.service.cmr.repository.NodeRef;
|
||||||
import org.alfresco.service.cmr.repository.datatype.DefaultTypeConverter;
|
import org.alfresco.service.cmr.repository.datatype.DefaultTypeConverter;
|
||||||
@@ -197,27 +198,79 @@ public class MultilingualContentServiceImplTest extends AbstractMultilingualTest
|
|||||||
multilingualContentService.makeTranslation(chineseContentNodeRef, Locale.CHINESE);
|
multilingualContentService.makeTranslation(chineseContentNodeRef, Locale.CHINESE);
|
||||||
NodeRef koreanContentNodeRef = createContent("Document_ko.txt");
|
NodeRef koreanContentNodeRef = createContent("Document_ko.txt");
|
||||||
multilingualContentService.addTranslation(koreanContentNodeRef, chineseContentNodeRef, Locale.KOREAN);
|
multilingualContentService.addTranslation(koreanContentNodeRef, chineseContentNodeRef, Locale.KOREAN);
|
||||||
|
|
||||||
|
|
||||||
|
// The pivot translation (base language) is Chinese
|
||||||
|
// (It won't matter which language we query to check this)
|
||||||
|
assertEquals(
|
||||||
|
"The wrong language was set as the pivot translation",
|
||||||
|
chineseContentNodeRef,
|
||||||
|
multilingualContentService.getPivotTranslation(chineseContentNodeRef)
|
||||||
|
);
|
||||||
|
assertEquals(
|
||||||
|
"The wrong language was set as the pivot translation",
|
||||||
|
chineseContentNodeRef,
|
||||||
|
multilingualContentService.getPivotTranslation(koreanContentNodeRef)
|
||||||
|
);
|
||||||
|
|
||||||
|
|
||||||
// Create with a null name, and off a non-pivot just to be sure
|
// Create with a null name, and off a non-pivot just to be sure
|
||||||
|
// The locale will be added to the pivot's file name to create a unique one
|
||||||
NodeRef nullNameNodeRef = multilingualContentService.addEmptyTranslation(
|
NodeRef nullNameNodeRef = multilingualContentService.addEmptyTranslation(
|
||||||
koreanContentNodeRef,
|
koreanContentNodeRef,
|
||||||
null,
|
null,
|
||||||
Locale.CANADA);
|
Locale.CANADA);
|
||||||
String nullName = fileFolderService.getFileInfo(nullNameNodeRef).getName();
|
String nullName = fileFolderService.getFileInfo(nullNameNodeRef).getName();
|
||||||
assertEquals("Empty translation name not generated correctly.", "Document_en_CA.txt", nullName);
|
assertEquals("Empty translation name not generated correctly.", "Document_en_CA.txt", nullName);
|
||||||
// Create with the same name
|
|
||||||
|
// This will be referencing the same pivot still
|
||||||
|
assertEquals(
|
||||||
|
"The wrong language was set as the pivot translation",
|
||||||
|
chineseContentNodeRef,
|
||||||
|
multilingualContentService.getPivotTranslation(nullNameNodeRef)
|
||||||
|
);
|
||||||
|
|
||||||
|
|
||||||
|
// Create with the same name as the document we're the translation of
|
||||||
|
// The locale will be added to the supplied file name to create a unique one
|
||||||
NodeRef sameNameNodeRef = multilingualContentService.addEmptyTranslation(
|
NodeRef sameNameNodeRef = multilingualContentService.addEmptyTranslation(
|
||||||
chineseContentNodeRef,
|
chineseContentNodeRef,
|
||||||
"Document.txt",
|
"Document.txt",
|
||||||
Locale.CANADA_FRENCH);
|
Locale.CANADA_FRENCH);
|
||||||
String sameName = fileFolderService.getFileInfo(sameNameNodeRef).getName();
|
String sameName = fileFolderService.getFileInfo(sameNameNodeRef).getName();
|
||||||
assertEquals("Empty translation name not generated correctly.", "Document_fr_CA.txt", sameName);
|
assertEquals("Empty translation name not generated correctly.", "Document_fr_CA.txt", sameName);
|
||||||
|
|
||||||
|
// Still correctly referencing the pivot
|
||||||
|
assertEquals(
|
||||||
|
"The wrong language was set as the pivot translation",
|
||||||
|
chineseContentNodeRef,
|
||||||
|
multilingualContentService.getPivotTranslation(sameNameNodeRef)
|
||||||
|
);
|
||||||
|
|
||||||
|
|
||||||
// Create with a different name
|
// Create with a different name
|
||||||
|
// As there's no clash, the locale won't be added
|
||||||
NodeRef differentNameNodeRef = multilingualContentService.addEmptyTranslation(
|
NodeRef differentNameNodeRef = multilingualContentService.addEmptyTranslation(
|
||||||
chineseContentNodeRef,
|
chineseContentNodeRef,
|
||||||
"Document2.txt",
|
"Document2.txt",
|
||||||
Locale.JAPANESE);
|
Locale.JAPANESE);
|
||||||
String differentName = fileFolderService.getFileInfo(differentNameNodeRef).getName();
|
String differentName = fileFolderService.getFileInfo(differentNameNodeRef).getName();
|
||||||
assertEquals("Empty translation name not generated correctly.", "Document2.txt", differentName);
|
assertEquals("Empty translation name not generated correctly.", "Document2.txt", differentName);
|
||||||
|
|
||||||
|
// If we tried to add a 2nd language with the different name,
|
||||||
|
// it would fail as the name isn't used
|
||||||
|
// (The automatic appending of the locale to avoid duplicates only
|
||||||
|
// works on the Pivot version's name, it isn't allowed for
|
||||||
|
// the names of non-pivot versions)
|
||||||
|
try {
|
||||||
|
multilingualContentService.addEmptyTranslation(
|
||||||
|
chineseContentNodeRef,
|
||||||
|
"Document2.txt",
|
||||||
|
Locale.FRENCH);
|
||||||
|
fail("A duplicate translation filename was created");
|
||||||
|
} catch(FileExistsException e) {
|
||||||
|
// Good, this was spotted
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testGetTranslationContainerPermissions() throws Exception
|
public void testGetTranslationContainerPermissions() throws Exception
|
||||||
|
Reference in New Issue
Block a user