Author: norman Date: Thu Jun 9 05:44:03 2011 New Revision: 1133661 URL: http://svn.apache.org/viewvc?rev=1133661&view=rev Log: Check for the correct charset and enable I18NLEVEL=1 if found. See IMAP-312
Modified: james/imap/trunk/api/src/main/java/org/apache/james/imap/api/display/CharsetUtil.java james/imap/trunk/message/src/test/java/org/apache/james/imap/decode/parser/SearchCommandParserCharsetTest.java james/imap/trunk/message/src/test/java/org/apache/james/imap/decode/parser/SearchCommandParserQuotedCharsetTest.java Modified: james/imap/trunk/api/src/main/java/org/apache/james/imap/api/display/CharsetUtil.java URL: http://svn.apache.org/viewvc/james/imap/trunk/api/src/main/java/org/apache/james/imap/api/display/CharsetUtil.java?rev=1133661&r1=1133660&r2=1133661&view=diff ============================================================================== --- james/imap/trunk/api/src/main/java/org/apache/james/imap/api/display/CharsetUtil.java (original) +++ james/imap/trunk/api/src/main/java/org/apache/james/imap/api/display/CharsetUtil.java Thu Jun 9 05:44:03 2011 @@ -43,6 +43,7 @@ public class CharsetUtil { for (final Iterator<Charset> it = Charset.availableCharsets().values().iterator(); it.hasNext();) { final Charset charset = it.next(); final Set<String> aliases = charset.aliases(); + cNames.add(charset.name()); cNames.addAll(aliases); sets.add(charset); Modified: james/imap/trunk/message/src/test/java/org/apache/james/imap/decode/parser/SearchCommandParserCharsetTest.java URL: http://svn.apache.org/viewvc/james/imap/trunk/message/src/test/java/org/apache/james/imap/decode/parser/SearchCommandParserCharsetTest.java?rev=1133661&r1=1133660&r2=1133661&view=diff ============================================================================== --- james/imap/trunk/message/src/test/java/org/apache/james/imap/decode/parser/SearchCommandParserCharsetTest.java (original) +++ james/imap/trunk/message/src/test/java/org/apache/james/imap/decode/parser/SearchCommandParserCharsetTest.java Thu Jun 9 05:44:03 2011 @@ -31,6 +31,7 @@ import java.util.Set; import org.apache.james.imap.api.ImapCommand; import org.apache.james.imap.api.ImapMessage; +import org.apache.james.imap.api.display.CharsetUtil; import org.apache.james.imap.api.display.HumanReadableText; import org.apache.james.imap.api.message.request.SearchKey; import org.apache.james.imap.api.message.response.StatusResponse; @@ -96,19 +97,12 @@ public class SearchCommandParserCharsetT @Test public void testBadCharset() throws Exception { - final Collection<String> charsetNames = new HashSet<String>(); - for (final Iterator<Charset> it = Charset.availableCharsets().values() - .iterator(); it.hasNext();) { - final Charset charset = it.next(); - final Set<String> aliases = charset.aliases(); - charsetNames.addAll(aliases); - } context.checking(new Expectations() {{ oneOf (mockStatusResponseFactory).taggedNo( with(equal(TAG)), with(same(command)), with(equal(HumanReadableText.BAD_CHARSET)), - with(equal(StatusResponse.ResponseCode.badCharset(charsetNames)))); + with(equal(StatusResponse.ResponseCode.badCharset(CharsetUtil.getAvailableCharsetNames())))); oneOf (session).getLog(); returnValue(new MockLogger()); }}); ImapRequestLineReader reader = new ImapRequestStreamLineReader( Modified: james/imap/trunk/message/src/test/java/org/apache/james/imap/decode/parser/SearchCommandParserQuotedCharsetTest.java URL: http://svn.apache.org/viewvc/james/imap/trunk/message/src/test/java/org/apache/james/imap/decode/parser/SearchCommandParserQuotedCharsetTest.java?rev=1133661&r1=1133660&r2=1133661&view=diff ============================================================================== --- james/imap/trunk/message/src/test/java/org/apache/james/imap/decode/parser/SearchCommandParserQuotedCharsetTest.java (original) +++ james/imap/trunk/message/src/test/java/org/apache/james/imap/decode/parser/SearchCommandParserQuotedCharsetTest.java Thu Jun 9 05:44:03 2011 @@ -24,13 +24,10 @@ import static org.junit.Assert.*; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.nio.charset.Charset; -import java.util.Collection; -import java.util.HashSet; -import java.util.Iterator; -import java.util.Set; import org.apache.james.imap.api.ImapCommand; import org.apache.james.imap.api.ImapMessage; +import org.apache.james.imap.api.display.CharsetUtil; import org.apache.james.imap.api.display.HumanReadableText; import org.apache.james.imap.api.message.request.SearchKey; import org.apache.james.imap.api.message.response.StatusResponse; @@ -181,20 +178,13 @@ public class SearchCommandParserQuotedCh } @Test - public void testBadCharset() throws Exception { - final Collection<String> charsetNames = new HashSet<String>(); - for (final Iterator<Charset> it = Charset.availableCharsets().values() - .iterator(); it.hasNext();) { - final Charset charset = it.next(); - final Set<String> aliases = charset.aliases(); - charsetNames.addAll(aliases); - } + public void testBadCharset() throws Exception { mockery.checking(new Expectations() {{ oneOf (mockStatusResponseFactory).taggedNo( with(equal(TAG)), with(same(command)), with(equal(HumanReadableText.BAD_CHARSET)), - with(equal(StatusResponse.ResponseCode.badCharset(charsetNames)))); + with(equal(StatusResponse.ResponseCode.badCharset(CharsetUtil.getAvailableCharsetNames())))); oneOf(session).getLog(); returnValue(new MockLogger()); }}); ImapRequestLineReader reader = new ImapRequestStreamLineReader( --------------------------------------------------------------------- To unsubscribe, e-mail: server-dev-unsubscr...@james.apache.org For additional commands, e-mail: server-dev-h...@james.apache.org