From 6a5a8cbe75d26d7324b62b9498fbcc52a25c9a04 Mon Sep 17 00:00:00 2001 From: Andrew Hind Date: Fri, 18 May 2007 11:01:51 +0000 Subject: [PATCH] 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 --- .../repo/search/impl/lucene/ADMLuceneIndexerImpl.java | 5 +++-- .../alfresco/repo/search/impl/lucene/ADMLuceneTest.java | 9 +++++++-- .../repo/search/impl/lucene/AVMLuceneIndexerImpl.java | 5 +++-- 3 files changed, 13 insertions(+), 6 deletions(-) diff --git a/source/java/org/alfresco/repo/search/impl/lucene/ADMLuceneIndexerImpl.java b/source/java/org/alfresco/repo/search/impl/lucene/ADMLuceneIndexerImpl.java index e26cc04814..a3a6d8026f 100644 --- a/source/java/org/alfresco/repo/search/impl/lucene/ADMLuceneIndexerImpl.java +++ b/source/java/org/alfresco/repo/search/impl/lucene/ADMLuceneIndexerImpl.java @@ -41,6 +41,7 @@ import java.util.Locale; import java.util.Map; import java.util.Set; +import org.alfresco.i18n.I18NUtil; import org.alfresco.model.ContentModel; import org.alfresco.repo.content.MimetypeMap; import org.alfresco.repo.content.transform.ContentTransformer; @@ -801,7 +802,7 @@ public class ADMLuceneIndexerImpl extends AbstractLuceneIndexerImpl imp } if (locale == null) { - locale = Locale.getDefault(); + locale = I18NUtil.getLocale(); } doc.add(new Field(attributeName + ".locale", locale.toString().toLowerCase(), Field.Store.NO, Field.Index.UN_TOKENIZED, Field.TermVector.NO)); @@ -977,7 +978,7 @@ public class ADMLuceneIndexerImpl extends AbstractLuceneIndexerImpl imp if (locale == null) { - locale = Locale.getDefault(); + locale = I18NUtil.getLocale(); } if (tokenise) { diff --git a/source/java/org/alfresco/repo/search/impl/lucene/ADMLuceneTest.java b/source/java/org/alfresco/repo/search/impl/lucene/ADMLuceneTest.java index 087a96ec24..8e4180df27 100644 --- a/source/java/org/alfresco/repo/search/impl/lucene/ADMLuceneTest.java +++ b/source/java/org/alfresco/repo/search/impl/lucene/ADMLuceneTest.java @@ -44,6 +44,7 @@ import javax.transaction.UserTransaction; import junit.framework.TestCase; +import org.alfresco.i18n.I18NUtil; import org.alfresco.model.ContentModel; import org.alfresco.repo.dictionary.DictionaryDAO; import org.alfresco.repo.dictionary.DictionaryNamespaceComponent; @@ -208,6 +209,8 @@ public class ADMLuceneTest extends TestCase namespaceDao = (NamespaceDAOImpl) ctx.getBean("namespaceDAO"); + I18NUtil.setLocale(Locale.UK); + this.authenticationComponent = (AuthenticationComponent) ctx.getBean("authenticationComponent"); queryRegisterComponent.loadQueryCollection("testQueryRegister.xml"); @@ -216,6 +219,8 @@ public class ADMLuceneTest extends TestCase testTX = transactionService.getUserTransaction(); testTX.begin(); + + this.authenticationComponent.setSystemUserAsCurrentUser(); // 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 ArrayList contentValues = new ArrayList(); - 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); @@ -376,7 +381,7 @@ public class ADMLuceneTest extends TestCase getOrderProperties()).getChildRef(); Map properties = new HashMap(); - 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"), ContentModel.TYPE_CONTENT, properties).getChildRef(); // nodeService.addAspect(n14, DictionaryBootstrap.ASPECT_QNAME_CONTENT, diff --git a/source/java/org/alfresco/repo/search/impl/lucene/AVMLuceneIndexerImpl.java b/source/java/org/alfresco/repo/search/impl/lucene/AVMLuceneIndexerImpl.java index ff39346545..b989304207 100644 --- a/source/java/org/alfresco/repo/search/impl/lucene/AVMLuceneIndexerImpl.java +++ b/source/java/org/alfresco/repo/search/impl/lucene/AVMLuceneIndexerImpl.java @@ -40,6 +40,7 @@ import java.util.Locale; import java.util.Map; import java.util.Set; +import org.alfresco.i18n.I18NUtil; import org.alfresco.model.ContentModel; import org.alfresco.model.WCMModel; import org.alfresco.repo.avm.AVMDAOs; @@ -639,7 +640,7 @@ public class AVMLuceneIndexerImpl extends AbstractLuceneIndexerImpl impl // No default locale in AVM if (locale == null) { - locale = Locale.getDefault(); + locale = I18NUtil.getLocale(); } doc.add(new Field(attributeName + ".locale", locale.toString().toLowerCase(), Field.Store.NO, Field.Index.UN_TOKENIZED, Field.TermVector.NO)); @@ -806,7 +807,7 @@ public class AVMLuceneIndexerImpl extends AbstractLuceneIndexerImpl impl if (locale == null) { - locale = Locale.getDefault(); + locale = I18NUtil.getLocale(); } if (tokenise) {