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 Locale deserialize for java {language}_{country}_({va…
…riant}_# | #){script}-{extensions}
- Loading branch information
Showing
2 changed files
with
66 additions
and
1 deletion.
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
33 changes: 33 additions & 0 deletions
33
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,33 @@ | ||
package com.alibaba.com.caucho.hessian.io; | ||
|
||
import static org.junit.Assert.*; | ||
|
||
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(new Locale("zh", "CN")); | ||
assertLocale(new Locale("zh-hant", "CN")); | ||
} | ||
|
||
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()); | ||
} | ||
|
||
} |