Explicitly set locale for the index tests.

Correctly find the locale if set on the thread locale via I18utils

git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@5719 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Andrew Hind
2007-05-18 11:01:51 +00:00
parent 5a8f9282b6
commit 6a5a8cbe75
3 changed files with 13 additions and 6 deletions

View File

@@ -41,6 +41,7 @@ import java.util.Locale;
import java.util.Map; import java.util.Map;
import java.util.Set; import java.util.Set;
import org.alfresco.i18n.I18NUtil;
import org.alfresco.model.ContentModel; import org.alfresco.model.ContentModel;
import org.alfresco.repo.content.MimetypeMap; import org.alfresco.repo.content.MimetypeMap;
import org.alfresco.repo.content.transform.ContentTransformer; import org.alfresco.repo.content.transform.ContentTransformer;
@@ -801,7 +802,7 @@ public class ADMLuceneIndexerImpl extends AbstractLuceneIndexerImpl<NodeRef> imp
} }
if (locale == null) if (locale == null)
{ {
locale = Locale.getDefault(); locale = I18NUtil.getLocale();
} }
doc.add(new Field(attributeName + ".locale", locale.toString().toLowerCase(), Field.Store.NO, doc.add(new Field(attributeName + ".locale", locale.toString().toLowerCase(), Field.Store.NO,
Field.Index.UN_TOKENIZED, Field.TermVector.NO)); Field.Index.UN_TOKENIZED, Field.TermVector.NO));
@@ -977,7 +978,7 @@ public class ADMLuceneIndexerImpl extends AbstractLuceneIndexerImpl<NodeRef> imp
if (locale == null) if (locale == null)
{ {
locale = Locale.getDefault(); locale = I18NUtil.getLocale();
} }
if (tokenise) if (tokenise)
{ {

View File

@@ -44,6 +44,7 @@ import javax.transaction.UserTransaction;
import junit.framework.TestCase; import junit.framework.TestCase;
import org.alfresco.i18n.I18NUtil;
import org.alfresco.model.ContentModel; import org.alfresco.model.ContentModel;
import org.alfresco.repo.dictionary.DictionaryDAO; import org.alfresco.repo.dictionary.DictionaryDAO;
import org.alfresco.repo.dictionary.DictionaryNamespaceComponent; import org.alfresco.repo.dictionary.DictionaryNamespaceComponent;
@@ -208,6 +209,8 @@ public class ADMLuceneTest extends TestCase
namespaceDao = (NamespaceDAOImpl) ctx.getBean("namespaceDAO"); namespaceDao = (NamespaceDAOImpl) ctx.getBean("namespaceDAO");
I18NUtil.setLocale(Locale.UK);
this.authenticationComponent = (AuthenticationComponent) ctx.getBean("authenticationComponent"); this.authenticationComponent = (AuthenticationComponent) ctx.getBean("authenticationComponent");
queryRegisterComponent.loadQueryCollection("testQueryRegister.xml"); queryRegisterComponent.loadQueryCollection("testQueryRegister.xml");
@@ -216,6 +219,8 @@ public class ADMLuceneTest extends TestCase
testTX = transactionService.getUserTransaction(); testTX = transactionService.getUserTransaction();
testTX.begin(); testTX.begin();
this.authenticationComponent.setSystemUserAsCurrentUser(); this.authenticationComponent.setSystemUserAsCurrentUser();
// load in the test model // load in the test model
@@ -311,7 +316,7 @@ public class ADMLuceneTest extends TestCase
// - andit has to go in type d:any as d:content is not allowed to be multivalued // - andit has to go in type d:any as d:content is not allowed to be multivalued
ArrayList<Serializable> contentValues = new ArrayList<Serializable>(); ArrayList<Serializable> contentValues = new ArrayList<Serializable>();
contentValues.add(new ContentData(null, "text/plain", 0L, "UTF-16")); contentValues.add(new ContentData(null, "text/plain", 0L, "UTF-16", Locale.CHINESE ));
testProperties.put(QName.createQName(TEST_NAMESPACE, "content-many-ista"), contentValues); testProperties.put(QName.createQName(TEST_NAMESPACE, "content-many-ista"), contentValues);
@@ -376,7 +381,7 @@ public class ADMLuceneTest extends TestCase
getOrderProperties()).getChildRef(); getOrderProperties()).getChildRef();
Map<QName, Serializable> properties = new HashMap<QName, Serializable>(); Map<QName, Serializable> properties = new HashMap<QName, Serializable>();
properties.put(ContentModel.PROP_CONTENT, new ContentData(null, "text/plain", 0L, "UTF-8")); properties.put(ContentModel.PROP_CONTENT, new ContentData(null, "text/plain", 0L, "UTF-8", Locale.CHINESE ));
n14 = nodeService.createNode(n13, ASSOC_TYPE_QNAME, QName.createQName("{namespace}fourteen"), n14 = nodeService.createNode(n13, ASSOC_TYPE_QNAME, QName.createQName("{namespace}fourteen"),
ContentModel.TYPE_CONTENT, properties).getChildRef(); ContentModel.TYPE_CONTENT, properties).getChildRef();
// nodeService.addAspect(n14, DictionaryBootstrap.ASPECT_QNAME_CONTENT, // nodeService.addAspect(n14, DictionaryBootstrap.ASPECT_QNAME_CONTENT,

View File

@@ -40,6 +40,7 @@ import java.util.Locale;
import java.util.Map; import java.util.Map;
import java.util.Set; import java.util.Set;
import org.alfresco.i18n.I18NUtil;
import org.alfresco.model.ContentModel; import org.alfresco.model.ContentModel;
import org.alfresco.model.WCMModel; import org.alfresco.model.WCMModel;
import org.alfresco.repo.avm.AVMDAOs; import org.alfresco.repo.avm.AVMDAOs;
@@ -639,7 +640,7 @@ public class AVMLuceneIndexerImpl extends AbstractLuceneIndexerImpl<String> impl
// No default locale in AVM // No default locale in AVM
if (locale == null) if (locale == null)
{ {
locale = Locale.getDefault(); locale = I18NUtil.getLocale();
} }
doc.add(new Field(attributeName + ".locale", locale.toString().toLowerCase(), Field.Store.NO, doc.add(new Field(attributeName + ".locale", locale.toString().toLowerCase(), Field.Store.NO,
Field.Index.UN_TOKENIZED, Field.TermVector.NO)); Field.Index.UN_TOKENIZED, Field.TermVector.NO));
@@ -806,7 +807,7 @@ public class AVMLuceneIndexerImpl extends AbstractLuceneIndexerImpl<String> impl
if (locale == null) if (locale == null)
{ {
locale = Locale.getDefault(); locale = I18NUtil.getLocale();
} }
if (tokenise) if (tokenise)
{ {