forked from apache/dubbo
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix apache#1411 Java Locale use '_' split language, country, variant.
- Loading branch information
Showing
3 changed files
with
47 additions
and
39 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
50 changes: 19 additions & 31 deletions
50
hessian-lite/src/test/java/com/alibaba/com/caucho/hessian/io/LocaleSerializerTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,41 +1,29 @@ | ||
package com.alibaba.com.caucho.hessian.io; | ||
|
||
import com.alibaba.com.caucho.hessian.io.base.SerializeTestBase; | ||
import junit.framework.TestCase; | ||
import java.io.IOException; | ||
import java.util.Locale; | ||
|
||
import org.junit.Test; | ||
|
||
import java.util.Locale; | ||
import com.alibaba.com.caucho.hessian.io.base.SerializeTestBase; | ||
|
||
import junit.framework.TestCase; | ||
|
||
public class LocaleSerializerTest extends SerializeTestBase { | ||
|
||
/** {@linkplain LocaleSerializer#writeObject(Object, AbstractHessianOutput)} */ | ||
@Test | ||
public void hessian2() throws Exception { | ||
Locale locale = new Locale("zh"); | ||
Locale result = baseHession2Serialize(locale); | ||
TestCase.assertEquals(locale, result); | ||
locale = new Locale("zh", "CN"); | ||
result = baseHession2Serialize(locale); | ||
TestCase.assertEquals(locale, result); | ||
locale = new Locale("zh", "CN", "GBK"); | ||
result = baseHession2Serialize(locale); | ||
TestCase.assertEquals(locale, result); | ||
locale = new Locale("zh-hant", "CN"); | ||
result = baseHession2Serialize(locale); | ||
TestCase.assertEquals(locale, result); | ||
public void locale() throws IOException { | ||
assertLocale(null); | ||
assertLocale(new Locale("")); | ||
assertLocale(new Locale("zh")); | ||
assertLocale(new Locale("zh", "CN")); | ||
assertLocale(new Locale("zh-hant", "CN")); | ||
assertLocale(new Locale("zh-hant", "CN", "GBK")); | ||
} | ||
|
||
@Test | ||
public void hessian1() throws Exception { | ||
Locale locale = new Locale("zh"); | ||
Locale result = baseHessionSerialize(locale); | ||
TestCase.assertEquals(locale, result); | ||
locale = new Locale("zh", "CN"); | ||
result = baseHessionSerialize(locale); | ||
TestCase.assertEquals(locale, result); | ||
locale = new Locale("zh", "CN", "GBK"); | ||
result = baseHessionSerialize(locale); | ||
TestCase.assertEquals(locale, result); | ||
locale = new Locale("zh-hant", "CN"); | ||
result = baseHessionSerialize(locale); | ||
TestCase.assertEquals(locale, result); | ||
private void assertLocale(Locale locale) throws IOException { | ||
TestCase.assertEquals(locale, baseHession2Serialize(locale)); | ||
TestCase.assertEquals(locale, baseHessionSerialize(locale)); | ||
} | ||
} | ||
} |