mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-07-24 17:32:48 +00:00
MNT-21481: IMAP UID search command errors with French Locale- Only folders showing (#1098)
* Bump alfresco-greenmail version and add Integration tests
This commit is contained in:
@@ -34,6 +34,7 @@ import java.io.Serializable;
|
|||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.LinkedList;
|
import java.util.LinkedList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Locale;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Properties;
|
import java.util.Properties;
|
||||||
|
|
||||||
@@ -84,6 +85,7 @@ import org.alfresco.util.testing.category.LuceneTests;
|
|||||||
import org.alfresco.util.testing.category.RedundantTests;
|
import org.alfresco.util.testing.category.RedundantTests;
|
||||||
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.junit.Test;
|
||||||
import org.junit.experimental.categories.Category;
|
import org.junit.experimental.categories.Category;
|
||||||
import org.springframework.context.ApplicationContext;
|
import org.springframework.context.ApplicationContext;
|
||||||
import org.springframework.core.io.ClassPathResource;
|
import org.springframework.core.io.ClassPathResource;
|
||||||
@@ -396,7 +398,72 @@ public class ImapMessageTest extends TestCase
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testSearchTermWithNonEnglishLocale() throws Exception
|
||||||
|
{
|
||||||
|
folder = (IMAPFolder) store.getFolder(TEST_FOLDER);
|
||||||
|
folder.open(Folder.READ_ONLY);
|
||||||
|
|
||||||
|
Locale defaultLocale = Locale.getDefault();
|
||||||
|
try
|
||||||
|
{
|
||||||
|
Locale.setDefault(Locale.FRENCH);
|
||||||
|
String dateStr = "12-Jul-2020";
|
||||||
|
final IMAPFolder.ProtocolCommand uid_search_since = new IMAPFolder.ProtocolCommand()
|
||||||
|
{
|
||||||
|
@Override
|
||||||
|
public Object doCommand(IMAPProtocol protocol)
|
||||||
|
{
|
||||||
|
return protocol.command("UID SEARCH SINCE " + dateStr, null);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
// UID SEARCH SINCE
|
||||||
|
Response[] ret = (Response[]) folder.doCommand(uid_search_since);
|
||||||
|
IMAPResponse response = (IMAPResponse) ret[0];
|
||||||
|
assertEquals("* SEARCH ", response.toString());
|
||||||
|
}
|
||||||
|
catch (MessagingException e)
|
||||||
|
{
|
||||||
|
fail("Date cannot be parsed");
|
||||||
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
Locale.setDefault(defaultLocale);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testSearchTermWithNonEnglishLocaleFalsePositive() throws Exception
|
||||||
|
{
|
||||||
|
Locale defaultLocale = Locale.getDefault();
|
||||||
|
try
|
||||||
|
{
|
||||||
|
folder = (IMAPFolder) store.getFolder(TEST_FOLDER);
|
||||||
|
folder.open(Folder.READ_ONLY);
|
||||||
|
|
||||||
|
Locale.setDefault(Locale.FRENCH);
|
||||||
|
String dateStr = "12-juil.-2020";
|
||||||
|
final IMAPFolder.ProtocolCommand uid_search_since = new IMAPFolder.ProtocolCommand()
|
||||||
|
{
|
||||||
|
@Override
|
||||||
|
public Object doCommand(IMAPProtocol protocol)
|
||||||
|
{
|
||||||
|
return protocol.command("UID SEARCH SINCE " + dateStr, null);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
// UID SEARCH SINCE
|
||||||
|
Response[] ret = (Response[]) folder.doCommand(uid_search_since);
|
||||||
|
assertEquals("java.net.SocketException: Connection reset", ret[0].getException().toString());
|
||||||
|
}
|
||||||
|
catch (MessagingException e)
|
||||||
|
{
|
||||||
|
// expected
|
||||||
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
Locale.setDefault(defaultLocale);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public void testUnmodifiedMessage() throws Exception
|
public void testUnmodifiedMessage() throws Exception
|
||||||
{
|
{
|
||||||
@@ -773,7 +840,7 @@ public class ImapMessageTest extends TestCase
|
|||||||
txn.commit();
|
txn.commit();
|
||||||
|
|
||||||
// Closing client connection
|
// Closing client connection
|
||||||
folder.close(false);
|
folder.forceClose();
|
||||||
store.close();
|
store.close();
|
||||||
logger.debug("tearDown end");
|
logger.debug("tearDown end");
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user