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
2 changed files
with
54 additions
and
44 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
37 changes: 37 additions & 0 deletions
37
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 |
---|---|---|
@@ -0,0 +1,37 @@ | ||
package com.alibaba.com.caucho.hessian.io; | ||
|
||
import static org.junit.Assert.assertEquals; | ||
|
||
import java.io.ByteArrayInputStream; | ||
import java.io.ByteArrayOutputStream; | ||
import java.io.IOException; | ||
import java.util.Locale; | ||
|
||
import org.junit.Test; | ||
|
||
public class LocaleSerializerTest { | ||
|
||
/** {@linkplain LocaleSerializer#writeObject(Object, AbstractHessianOutput)} */ | ||
@Test | ||
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", "xx")); | ||
} | ||
|
||
private void assertLocale(Locale loc) throws IOException { | ||
ByteArrayOutputStream bout = new ByteArrayOutputStream(); | ||
Hessian2Output out = new Hessian2Output(bout); | ||
|
||
out.writeObject(loc); | ||
out.flush(); | ||
|
||
ByteArrayInputStream bin = new ByteArrayInputStream(bout.toByteArray()); | ||
Hessian2Input input = new Hessian2Input(bin); | ||
assertEquals(loc, input.readObject()); | ||
} | ||
|
||
} |