-
Notifications
You must be signed in to change notification settings - Fork 2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add java test cases for WA GB18030 certification. #247
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,102 @@ | ||
/** | ||
* Copyright 2011 Microsoft Corporation | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package com.microsoft.windowsazure.services.queue.client; | ||
|
||
import java.net.URISyntaxException; | ||
import java.util.EnumSet; | ||
|
||
import junit.framework.Assert; | ||
|
||
import org.junit.Test; | ||
|
||
import com.microsoft.windowsazure.services.core.storage.StorageException; | ||
|
||
public class CloudQueueClientGB18030Test extends QueueTestBase { | ||
|
||
public static final String GB18030CharSet = "啊齄丂狛狜隣郎隣兀﨩ˊ▇█〞〡¦℡㈱‐ー﹡﹢﹫、〓ⅰⅹ⒈€㈠㈩ⅠⅫ! ̄ぁんァヶΑ︴АЯаяāɡㄅㄩ─╋︵﹄︻︱︳︴ⅰⅹɑɡ〇〾⿻⺁䜣€㐀㒣㕴㕵㙉㙊䵯䵰䶴䶵"; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Embedding Unicode characters directly in the source code can lead to problems if loaded on a system that doesn't assume UTF-8 by default. For example, if loaded using GB-18030 encoding. Consider leaving the string in a comment, but change the data to be constructed using the Unicode UTF-16 codepoints:
I would also suggest using multiple strings, one for each of the important character sets: String Chinese_2B_1 = new String(new char[] { 0x2488, 0x2460, 0x216B, 0x3128, 0x3129 });
String Chinese_2B_2 = new String(new char[] { 0x554A, 0x963F, 0x9F3E, 0x9F44 });
String Chinese_2B_3 = new String(new char[] { 0x4E02, 0x4E04, 0x72DA, 0x72DB });
String Chinese_2B_4 = new String(new char[] { 0x72DC, 0x72DD, 0xFA28, 0xFA29 });
String Chinese_2B_5 = new String(new char[] { 0x02CA, 0x02CB, 0x02D9, 0x2013, 0xE7F3, 0x3007 });
String Chinese_4B_ExtA = new String(new char[] { 0x3400, 0x3401, 0x4DB4, 0x4DB5 });
String Chinese_ExtB = new String(new char[] { 0xD840, 0xDC00, 0xD840, 0xDC01, 0xD869, 0xDED5, 0xD869, 0xDED6 });
String Minority_Languages_Dehong_Dai = new String(new char[] { 0x1958, 0x1963, 0x196D, 0x1970, 0x0020, 0x1956,
0x196D, 0x1970, 0x0020, 0x1956, 0x196C, 0x1972, 0x1951, 0x1968, 0x1952, 0x1970 });
String Minority_Languages_Mongolian = new String(new char[] { 0x182E, 0x1823, 0x1829, 0x182D, 0x1823, 0x182F,
0x0020, 0x0020, 0x1826, 0x1830, 0x1826, 0x182D, 0x003B, 0x0020, 0x17F8, 0x17F9, 0x0020, 0x188E, 0x188F,
0x1890, 0x1891, 0x1892, 0x1893, 0x1894, 0x1895, 0x1896, 0x1897 });
String Minority_Languages_Mongolian2 = new String(new char[] { 0x1823, 0x183A, 0x1835, 0x1821, 0x1835, 0x183A,
0x1830, 0x0020, 0x182C, 0x1835, 0x1820, 0x182C, 0x1833, 0x1830, 0x1823, 0x182C, 0x1821, 0x1835, 0x182C,
0x0020, 0x182C, 0x1835, 0x183A, 0x1820, 0x182C, 0x1833, 0x1830, 0x0020, 0x183A, 0x182C, 0x1823, 0x0020,
0x1820 });
String Minority_Languages_Tibetan = new String(new char[] { 0x0F56, 0x0F7C, 0x0F51, 0x0F0B, 0x0F61, 0x0F72,
0x0F42, 0x0020, 0x0020, 0x0020, 0x0F00, 0x0F01, 0x0F02, 0x0F03, 0x0F04, 0x0F05, 0x0FA2, 0x0FA3, 0x0FA4,
0x0FA5 });
String Minority_Languages_Tibetan2 = new String(new char[] { 0x0F51, 0x0F56, 0x0FB1, 0x0F44, 0x0F66, 0x0F0B,
0x0F45, 0x0F53, 0x0F0B, 0x0F66, 0x0F92, 0x0FB2, 0x0F7C, 0x0F63, 0x0F0B, 0x0F51, 0x0F40, 0x0F62, 0x0F0D,
0x0020, 0x0F56, 0x0F40, 0x0FB2, 0x0F0B, 0x0F64, 0x0F72, 0x0F66, 0x0F0B, 0x0F62, 0x0F92, 0x0FB1, 0x0F63,
0x0F0D });
String Minority_Languages_Uyghur = new String(new char[] { 0x0626, 0x06C7, 0x064A, 0x063A, 0x06C7, 0x0631,
0x0020, 0x062A, 0x0649, 0x0644, 0x0649, 0x0020, 0x0020, 0x0020, 0x003B, 0x060B, 0x0020, 0x060C, 0x0020,
0x060D, 0x0020, 0x060E, 0x0020, 0x060F, 0x0610, 0x0020, 0x0020, 0x0020, 0xFEF2, 0x0020, 0xFEF3, 0x0020,
0xFEF4, 0x0020, 0xFEF5, 0x0020, 0xFEF6, 0x0020, 0xFEF7, 0x0020, 0xFEF8, 0x0020, 0xFEF9, 0x0020, 0xFEFA,
0x0020, 0xFEFB });
String Minority_Languages_Uyghur2 = new String(new char[] { 0x06CB, 0x06D0, 0x06AD, 0x0643, 0x0642, 0x0642,
0x0020, 0x06BE, 0x0633, 0x0020, 0x0642, 0x0643, 0x0020, 0x0643, 0x062F, 0x0633, 0x062F, 0x0642, 0x0020,
0x062F });
String Minority_Languages_Xishuangbanna_Dai = new String(new char[] { 0x198E, 0x19B7, 0x1991, 0x19BA, 0x1996,
0x19BA, 0x19C8, 0x1989, 0x19B2, 0x19C7, 0x1989, 0x19B8, 0x19C2, 0x1997, 0x19C3, 0x1993, 0x19B1 });
String Minority_Languages_Yi = new String(new char[] { 0xA188, 0xA320, 0xA071, 0xA0B7, 0x003B, 0xA000, 0xA001,
0xA002, 0xA003, 0xA004, 0xA005, 0xA006, 0xA4C1, 0xA4C2, 0xA4C3, 0xA4C4, 0xA4C5, 0xA4C6 });
String Minority_Languages_Yi2 = new String(new char[] { 0xA26C, 0xA112, 0xA435, 0xA113, 0xA428, 0xA435, 0xA113,
0xA428 }); |
||
|
||
@Test | ||
public void GB18030TestForSingleMessage() throws URISyntaxException, StorageException { | ||
|
||
String messageContent = GB18030CharSet; | ||
CloudQueueMessage cqm = new CloudQueueMessage(messageContent); | ||
queue.addMessage(cqm); | ||
|
||
CloudQueueMessage messageFromPeekMessage = queue.peekMessage(); | ||
Assert.assertEquals(messageContent, messageFromPeekMessage.getMessageContentAsString()); | ||
|
||
CloudQueueMessage messageFromRetrieveMessage = queue.retrieveMessage(); | ||
Assert.assertEquals(messageContent, messageFromRetrieveMessage.getMessageContentAsString()); | ||
|
||
String messageContentUpdated = messageContent + " updated"; | ||
messageFromRetrieveMessage.setMessageContent(messageContentUpdated); | ||
queue.updateMessage(messageFromRetrieveMessage, 0); | ||
|
||
messageFromPeekMessage = queue.peekMessage(null, null); | ||
Assert.assertEquals(messageContent, messageFromPeekMessage.getMessageContentAsString()); | ||
|
||
messageContentUpdated = messageContent + " updated again"; | ||
messageFromRetrieveMessage.setMessageContent(messageContentUpdated); | ||
queue.updateMessage(messageFromRetrieveMessage, 0, | ||
EnumSet.of(MessageUpdateFields.VISIBILITY, MessageUpdateFields.CONTENT), null, null); | ||
|
||
messageFromRetrieveMessage = queue.retrieveMessage(5, null, null); | ||
Assert.assertEquals(messageContentUpdated, messageFromRetrieveMessage.getMessageContentAsString()); | ||
|
||
queue.deleteMessage(messageFromRetrieveMessage); | ||
} | ||
|
||
@Test | ||
public void GB18030TestForMultipleMessages() throws URISyntaxException, StorageException { | ||
int messageLength = 2; | ||
String[] messageContents = new String[messageLength]; | ||
for (int i = 0; i < messageLength; i++) { | ||
messageContents[i] = GB18030CharSet + i; | ||
queue.addMessage(new CloudQueueMessage(messageContents[i]), 600, 0, null, null); | ||
} | ||
|
||
Iterable<CloudQueueMessage> messagesFromPeekMessages = queue.peekMessages(messageLength); | ||
int count = 0; | ||
for (CloudQueueMessage message : messagesFromPeekMessages) { | ||
Assert.assertEquals(messageContents[count], message.getMessageContentAsString()); | ||
count++; | ||
} | ||
|
||
Iterable<CloudQueueMessage> messagesFromRetrieveMessages = queue.retrieveMessages(messageLength); | ||
count = 0; | ||
for (CloudQueueMessage message : messagesFromRetrieveMessages) { | ||
Assert.assertEquals(messageContents[count], message.getMessageContentAsString()); | ||
message.setMessageContent(message.getMessageContentAsString() + " updated"); | ||
queue.updateMessage(message, 0, EnumSet.of(MessageUpdateFields.VISIBILITY, MessageUpdateFields.CONTENT), | ||
null, null); | ||
count++; | ||
} | ||
|
||
messagesFromPeekMessages = queue.peekMessages(messageLength, null, null); | ||
count = 0; | ||
for (CloudQueueMessage message : messagesFromPeekMessages) { | ||
Assert.assertEquals(messageContents[count] + " updated", message.getMessageContentAsString()); | ||
count++; | ||
} | ||
|
||
messagesFromRetrieveMessages = queue.retrieveMessages(messageLength, 5, null, null); | ||
count = 0; | ||
for (CloudQueueMessage message : messagesFromRetrieveMessages) { | ||
Assert.assertEquals(messageContents[count] + " updated", message.getMessageContentAsString()); | ||
queue.deleteMessage(message, null, null); | ||
count++; | ||
} | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should be
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ditto