Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
lovepoem committed Feb 26, 2018
2 parents e2015f5 + 08da452 commit bf556c0
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 29 deletions.
Original file line number Diff line number Diff line change
@@ -1,12 +1,17 @@
package com.alibaba.com.caucho.hessian.io;

import com.alibaba.com.caucho.hessian.io.base.SerializeTestBase;
import com.alibaba.com.caucho.hessian.io.beans.Hessian2StringShortType;
import com.alibaba.com.caucho.hessian.io.beans.PersonType;

import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.junit.Test;

import static junit.framework.TestCase.assertEquals;
Expand All @@ -15,7 +20,7 @@
/**
* @author jason.shang@hotmail.com
*/
public class Hessian2StringShortTest {
public class Hessian2StringShortTest extends SerializeTestBase {

@Test
public void serialize_string_short_map_then_deserialize() throws Exception {
Expand All @@ -26,16 +31,7 @@ public void serialize_string_short_map_then_deserialize() throws Exception {
stringShortMap.put("last", (short)60);
stringShort.stringShortMap = stringShortMap;

ByteArrayOutputStream bout = new ByteArrayOutputStream();
Hessian2Output out = new Hessian2Output(bout);

out.writeObject(stringShort);
out.flush();

ByteArrayInputStream bin = new ByteArrayInputStream(bout.toByteArray());
Hessian2Input input = new Hessian2Input(bin);

Hessian2StringShortType deserialize = (Hessian2StringShortType) input.readObject();
Hessian2StringShortType deserialize = baseHession2Serialize(stringShort);
assertTrue(deserialize.stringShortMap != null);
assertTrue(deserialize.stringShortMap.size() == 2);
assertTrue(deserialize.stringShortMap.get("last") instanceof Short);
Expand All @@ -52,16 +48,7 @@ public void serialize_string_byte_map_then_deserialize() throws Exception {
stringByteMap.put("last", (byte)60);
stringShort.stringByteMap = stringByteMap;

ByteArrayOutputStream bout = new ByteArrayOutputStream();
Hessian2Output out = new Hessian2Output(bout);

out.writeObject(stringShort);
out.flush();

ByteArrayInputStream bin = new ByteArrayInputStream(bout.toByteArray());
Hessian2Input input = new Hessian2Input(bin);

Hessian2StringShortType deserialize = (Hessian2StringShortType) input.readObject();
Hessian2StringShortType deserialize = baseHession2Serialize(stringShort);
assertTrue(deserialize.stringByteMap != null);
assertTrue(deserialize.stringByteMap.size() == 2);
assertTrue(deserialize.stringByteMap.get("last") instanceof Byte);
Expand Down Expand Up @@ -145,8 +132,7 @@ public void serialize_list_then_deserialize() throws Exception {

ByteArrayInputStream bin = new ByteArrayInputStream(bout.toByteArray());
Hessian2Input input = new Hessian2Input(bin);
List deserialize = (List) input.readObject(ArrayList.class, Short.class);
// List deserialize = (List) input.readObject();
List<Short> deserialize = (List) input.readObject(ArrayList.class, Short.class);
assertTrue(deserialize != null);
assertTrue(deserialize.size() == 2);
assertTrue(deserialize.get(1) instanceof Short);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.alibaba.com.caucho.hessian.io;
package com.alibaba.com.caucho.hessian.io.beans;

import java.io.Serializable;
import java.util.Map;
Expand All @@ -11,11 +11,11 @@
*/
public class Hessian2StringShortType implements Serializable {

Map<String, Short> stringShortMap;
public Map<String, Short> stringShortMap;

Map<String, Byte> stringByteMap;
public Map<String, Byte> stringByteMap;

Map<String, PersonType> stringPersonTypeMap;
public Map<String, PersonType> stringPersonTypeMap;

public Hessian2StringShortType(){

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package com.alibaba.com.caucho.hessian.io;
package com.alibaba.com.caucho.hessian.io.beans;

import java.io.Serializable;
import java.util.Arrays;
import java.util.List;

/**
Expand Down

0 comments on commit bf556c0

Please sign in to comment.