mirror of
https://github.com/msgpack/msgpack-c.git
synced 2025-09-24 23:09:34 +02:00
java: changes Template interface: unpack(Unpacker, Object to = null), convert(MessagePackObject from, Object to = null)
This commit is contained in:
parent
e9d44b90bc
commit
76679d33df
@ -20,8 +20,8 @@ package org.msgpack;
|
||||
import java.io.IOException;
|
||||
|
||||
public abstract class AbstractTemplate implements Template {
|
||||
public Object unpack(Unpacker pac) throws IOException, MessageTypeException {
|
||||
return convert(pac.unpackObject());
|
||||
public Object unpack(Unpacker pac, Object to) throws IOException, MessageTypeException {
|
||||
return convert(pac.unpackObject(), to);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -18,6 +18,6 @@
|
||||
package org.msgpack;
|
||||
|
||||
public interface MessageConverter {
|
||||
Object convert(MessagePackObject from) throws MessageTypeException;
|
||||
Object convert(MessagePackObject from, Object to) throws MessageTypeException;
|
||||
}
|
||||
|
||||
|
@ -76,6 +76,16 @@ public class MessagePack {
|
||||
}
|
||||
}
|
||||
|
||||
public static <T> T unpack(byte[] buffer, Template tmpl, T to) throws MessageTypeException {
|
||||
Unpacker pac = new Unpacker();
|
||||
pac.wrap(buffer);
|
||||
try {
|
||||
return pac.unpack(tmpl, to);
|
||||
} catch (IOException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
public static <T> T unpack(byte[] buffer, Class<T> klass) throws MessageTypeException {
|
||||
Unpacker pac = new Unpacker();
|
||||
pac.wrap(buffer);
|
||||
@ -86,6 +96,16 @@ public class MessagePack {
|
||||
}
|
||||
}
|
||||
|
||||
public static <T> T unpack(byte[] buffer, T to) throws MessageTypeException {
|
||||
Unpacker pac = new Unpacker();
|
||||
pac.wrap(buffer);
|
||||
try {
|
||||
return pac.unpack(to);
|
||||
} catch (IOException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
public static MessagePackObject unpack(InputStream in) throws IOException {
|
||||
Unpacker pac = new Unpacker(in);
|
||||
return pac.unpackObject();
|
||||
@ -100,6 +120,15 @@ public class MessagePack {
|
||||
}
|
||||
}
|
||||
|
||||
public static <T> T unpack(InputStream in, Template tmpl, T to) throws IOException, MessageTypeException {
|
||||
Unpacker pac = new Unpacker(in);
|
||||
try {
|
||||
return pac.unpack(tmpl, to);
|
||||
} catch (IOException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
public static <T> T unpack(InputStream in, Class<T> klass) throws IOException, MessageTypeException {
|
||||
Unpacker pac = new Unpacker(in);
|
||||
try {
|
||||
@ -107,7 +136,15 @@ public class MessagePack {
|
||||
} catch (IOException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
public static <T> T unpack(InputStream in, T to) throws IOException, MessageTypeException {
|
||||
Unpacker pac = new Unpacker(in);
|
||||
try {
|
||||
return pac.unpack(to);
|
||||
} catch (IOException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
public static void register(Class<?> target) { // auto-detect
|
||||
|
@ -140,12 +140,24 @@ public abstract class MessagePackObject implements Cloneable, MessagePackable {
|
||||
abstract public Object clone();
|
||||
|
||||
public Object convert(Template tmpl) throws MessageTypeException {
|
||||
return tmpl.convert(this);
|
||||
return convert(tmpl, null);
|
||||
}
|
||||
|
||||
public Object convert(Template tmpl, Object to) throws MessageTypeException {
|
||||
return tmpl.convert(this, to);
|
||||
}
|
||||
|
||||
public <T> T convert(Class<T> klass) throws MessageTypeException {
|
||||
return convert(klass, null);
|
||||
}
|
||||
|
||||
public <T> T convert(T to) throws MessageTypeException {
|
||||
return convert((Class<T>)to.getClass(), to);
|
||||
}
|
||||
|
||||
public <T> T convert(Class<T> klass, Object to) throws MessageTypeException {
|
||||
// FIXME nullable?
|
||||
return (T)convert(new NullableTemplate(new ClassTemplate(klass)));
|
||||
return (T)convert(new NullableTemplate(new ClassTemplate(klass)), to);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -20,6 +20,6 @@ package org.msgpack;
|
||||
import java.io.IOException;
|
||||
|
||||
public interface MessageUnpacker {
|
||||
Object unpack(Unpacker pac) throws IOException, MessageTypeException;
|
||||
Object unpack(Unpacker pac, Object to) throws IOException, MessageTypeException;
|
||||
}
|
||||
|
||||
|
@ -579,12 +579,24 @@ public class Unpacker implements Iterable<MessagePackObject> {
|
||||
//}
|
||||
|
||||
final public Object unpack(Template tmpl) throws IOException, MessageTypeException {
|
||||
return tmpl.unpack(this);
|
||||
return unpack(tmpl, null);
|
||||
}
|
||||
|
||||
final public <T> T unpack(Template tmpl, T to) throws IOException, MessageTypeException {
|
||||
return (T)tmpl.unpack(this, to);
|
||||
}
|
||||
|
||||
final public <T> T unpack(Class<T> klass) throws IOException, MessageTypeException {
|
||||
return unpack(klass, null);
|
||||
}
|
||||
|
||||
final public <T> T unpack(T to) throws IOException, MessageTypeException {
|
||||
return unpack((Class<T>)to.getClass(), to);
|
||||
}
|
||||
|
||||
final public <T> T unpack(Class<T> klass, T to) throws IOException, MessageTypeException {
|
||||
// FIXME nullable?
|
||||
return (T)unpack(new NullableTemplate(new ClassTemplate(klass)));
|
||||
return (T)unpack(new NullableTemplate(new ClassTemplate(klass)), to);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -31,11 +31,11 @@ public class AnyTemplate implements Template {
|
||||
}
|
||||
}
|
||||
|
||||
public Object unpack(Unpacker pac) throws IOException, MessageTypeException {
|
||||
public Object unpack(Unpacker pac, Object to) throws IOException, MessageTypeException {
|
||||
return pac.unpackObject();
|
||||
}
|
||||
|
||||
public Object convert(MessagePackObject from) throws MessageTypeException {
|
||||
public Object convert(MessagePackObject from, Object to) throws MessageTypeException {
|
||||
return from;
|
||||
}
|
||||
|
||||
|
@ -28,11 +28,11 @@ public class BigIntegerTemplate implements Template {
|
||||
pk.packBigInteger((BigInteger)target);
|
||||
}
|
||||
|
||||
public Object unpack(Unpacker pac) throws IOException, MessageTypeException {
|
||||
public Object unpack(Unpacker pac, Object to) throws IOException, MessageTypeException {
|
||||
return pac.unpackBigInteger();
|
||||
}
|
||||
|
||||
public Object convert(MessagePackObject from) throws MessageTypeException {
|
||||
public Object convert(MessagePackObject from, Object to) throws MessageTypeException {
|
||||
return from.asBigInteger();
|
||||
}
|
||||
|
||||
|
@ -27,11 +27,11 @@ public class BooleanTemplate implements Template {
|
||||
pk.packBoolean((Boolean)target);
|
||||
}
|
||||
|
||||
public Object unpack(Unpacker pac) throws IOException, MessageTypeException {
|
||||
public Object unpack(Unpacker pac, Object to) throws IOException, MessageTypeException {
|
||||
return pac.unpackBoolean();
|
||||
}
|
||||
|
||||
public Object convert(MessagePackObject from) throws MessageTypeException {
|
||||
public Object convert(MessagePackObject from, Object to) throws MessageTypeException {
|
||||
return from.asBoolean();
|
||||
}
|
||||
|
||||
|
@ -27,11 +27,11 @@ public class ByteArrayTemplate implements Template {
|
||||
pk.packByteArray((byte[])target);
|
||||
}
|
||||
|
||||
public Object unpack(Unpacker pac) throws IOException, MessageTypeException {
|
||||
public Object unpack(Unpacker pac, Object to) throws IOException, MessageTypeException {
|
||||
return pac.unpackByteArray();
|
||||
}
|
||||
|
||||
public Object convert(MessagePackObject from) throws MessageTypeException {
|
||||
public Object convert(MessagePackObject from, Object to) throws MessageTypeException {
|
||||
return from.asByteArray();
|
||||
}
|
||||
|
||||
|
@ -41,12 +41,12 @@ public class ByteBufferTemplate implements Template {
|
||||
}
|
||||
}
|
||||
|
||||
public Object unpack(Unpacker pac) throws IOException, MessageTypeException {
|
||||
public Object unpack(Unpacker pac, Object to) throws IOException, MessageTypeException {
|
||||
byte[] bytes = pac.unpackByteArray();
|
||||
return ByteBuffer.wrap(bytes);
|
||||
}
|
||||
|
||||
public Object convert(MessagePackObject from) throws MessageTypeException {
|
||||
public Object convert(MessagePackObject from, Object to) throws MessageTypeException {
|
||||
byte[] bytes = from.asByteArray();
|
||||
return ByteBuffer.wrap(bytes);
|
||||
}
|
||||
|
@ -27,11 +27,11 @@ public class ByteTemplate implements Template {
|
||||
pk.packByte((Byte)target);
|
||||
}
|
||||
|
||||
public Object unpack(Unpacker pac) throws IOException, MessageTypeException {
|
||||
public Object unpack(Unpacker pac, Object to) throws IOException, MessageTypeException {
|
||||
return pac.unpackByte();
|
||||
}
|
||||
|
||||
public Object convert(MessagePackObject from) throws MessageTypeException {
|
||||
public Object convert(MessagePackObject from, Object to) throws MessageTypeException {
|
||||
return from.asByte();
|
||||
}
|
||||
|
||||
|
@ -149,16 +149,22 @@ public class ClassTemplate implements Template {
|
||||
throw new MessageTypeException("unknown object "+o+" ("+o.getClass()+")");
|
||||
}
|
||||
|
||||
public Object unpack(Unpacker pac) throws IOException, MessageTypeException {
|
||||
@Override
|
||||
public Object unpack(Unpacker pac, Object to) throws IOException, MessageTypeException {
|
||||
try {
|
||||
MessageUnpacker unpacker = CustomUnpacker.get(klass);
|
||||
if(unpacker != null) {
|
||||
return unpacker.unpack(pac);
|
||||
return unpacker.unpack(pac, to);
|
||||
}
|
||||
|
||||
if(MessageUnpackable.class.isAssignableFrom(klass)) {
|
||||
Object obj = klass.newInstance();
|
||||
((MessageUnpackable)obj).messageUnpack(pac);
|
||||
MessageUnpackable obj;
|
||||
if(to == null) {
|
||||
obj = (MessageUnpackable)klass.newInstance();
|
||||
} else {
|
||||
obj = (MessageUnpackable)to;
|
||||
}
|
||||
obj.messageUnpack(pac);
|
||||
return obj;
|
||||
}
|
||||
|
||||
@ -174,7 +180,7 @@ public class ClassTemplate implements Template {
|
||||
|
||||
if (unpacker != null) {
|
||||
CustomUnpacker.register(klass, unpacker);
|
||||
return unpacker.unpack(pac);
|
||||
return unpacker.unpack(pac, to);
|
||||
}
|
||||
|
||||
// fallback
|
||||
@ -193,7 +199,7 @@ public class ClassTemplate implements Template {
|
||||
|
||||
if (converter != null) {
|
||||
CustomConverter.register(klass, converter);
|
||||
return converter.convert(pac.unpackObject());
|
||||
return converter.convert(pac.unpackObject(), to);
|
||||
}
|
||||
}
|
||||
|
||||
@ -206,16 +212,22 @@ public class ClassTemplate implements Template {
|
||||
}
|
||||
}
|
||||
|
||||
public Object convert(MessagePackObject from) throws MessageTypeException {
|
||||
@Override
|
||||
public Object convert(MessagePackObject from, Object to) throws MessageTypeException {
|
||||
try {
|
||||
MessageConverter converter = CustomConverter.get(klass);
|
||||
if(converter != null) {
|
||||
return converter.convert(from);
|
||||
return converter.convert(from, to);
|
||||
}
|
||||
|
||||
if(MessageConvertable.class.isAssignableFrom(klass)) {
|
||||
Object obj = klass.newInstance();
|
||||
((MessageConvertable)obj).messageConvert(from);
|
||||
MessageConvertable obj;
|
||||
if(to == null) {
|
||||
obj = (MessageConvertable)klass.newInstance();
|
||||
} else {
|
||||
obj = (MessageConvertable)to;
|
||||
}
|
||||
obj.messageConvert(from);
|
||||
return obj;
|
||||
}
|
||||
|
||||
@ -231,7 +243,7 @@ public class ClassTemplate implements Template {
|
||||
|
||||
if (converter != null) {
|
||||
CustomConverter.register(klass, converter);
|
||||
return converter.convert(from);
|
||||
return converter.convert(from, to);
|
||||
}
|
||||
|
||||
throw new MessageTypeException();
|
||||
|
@ -41,20 +41,34 @@ public class CollectionTemplate implements Template {
|
||||
}
|
||||
}
|
||||
|
||||
public Object unpack(Unpacker pac) throws IOException, MessageTypeException {
|
||||
public Object unpack(Unpacker pac, Object to) throws IOException, MessageTypeException {
|
||||
int length = pac.unpackArray();
|
||||
List<Object> list = new LinkedList<Object>();
|
||||
List<Object> list;
|
||||
if(to == null) {
|
||||
list = new LinkedList<Object>();
|
||||
} else {
|
||||
// TODO: optimize if list is instanceof ArrayList
|
||||
list = (List<Object>)to;
|
||||
list.clear();
|
||||
}
|
||||
for(; length > 0; length--) {
|
||||
list.add( elementTemplate.unpack(pac) );
|
||||
list.add( elementTemplate.unpack(pac, null) );
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
public Object convert(MessagePackObject from) throws MessageTypeException {
|
||||
public Object convert(MessagePackObject from, Object to) throws MessageTypeException {
|
||||
MessagePackObject[] array = from.asArray();
|
||||
List<Object> list = new LinkedList<Object>();
|
||||
List<Object> list;
|
||||
if(to == null) {
|
||||
list = new LinkedList<Object>();
|
||||
} else {
|
||||
// TODO: optimize if list is instanceof ArrayList
|
||||
list = (List<Object>)to;
|
||||
list.clear();
|
||||
}
|
||||
for(MessagePackObject element : array) {
|
||||
list.add( elementTemplate.convert(element) );
|
||||
list.add( elementTemplate.convert(element, null) );
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
@ -27,11 +27,11 @@ public class DoubleTemplate implements Template {
|
||||
pk.packDouble(((Double)target));
|
||||
}
|
||||
|
||||
public Object unpack(Unpacker pac) throws IOException, MessageTypeException {
|
||||
public Object unpack(Unpacker pac, Object to) throws IOException, MessageTypeException {
|
||||
return pac.unpackDouble();
|
||||
}
|
||||
|
||||
public Object convert(MessagePackObject from) throws MessageTypeException {
|
||||
public Object convert(MessagePackObject from, Object to) throws MessageTypeException {
|
||||
return from.asDouble();
|
||||
}
|
||||
|
||||
|
@ -27,11 +27,11 @@ public class FloatTemplate implements Template {
|
||||
pk.packFloat((Float)target);
|
||||
}
|
||||
|
||||
public Object unpack(Unpacker pac) throws IOException, MessageTypeException {
|
||||
public Object unpack(Unpacker pac, Object to) throws IOException, MessageTypeException {
|
||||
return pac.unpackFloat();
|
||||
}
|
||||
|
||||
public Object convert(MessagePackObject from) throws MessageTypeException {
|
||||
public Object convert(MessagePackObject from, Object to) throws MessageTypeException {
|
||||
return from.asFloat();
|
||||
}
|
||||
|
||||
|
@ -27,11 +27,11 @@ public class IntegerTemplate implements Template {
|
||||
pk.packInt((Integer)target);
|
||||
}
|
||||
|
||||
public Object unpack(Unpacker pac) throws IOException, MessageTypeException {
|
||||
public Object unpack(Unpacker pac, Object to) throws IOException, MessageTypeException {
|
||||
return pac.unpackInt();
|
||||
}
|
||||
|
||||
public Object convert(MessagePackObject from) throws MessageTypeException {
|
||||
public Object convert(MessagePackObject from, Object to) throws MessageTypeException {
|
||||
return from.asInt();
|
||||
}
|
||||
|
||||
|
@ -45,20 +45,33 @@ public class ListTemplate implements Template {
|
||||
}
|
||||
}
|
||||
|
||||
public Object unpack(Unpacker pac) throws IOException, MessageTypeException {
|
||||
public Object unpack(Unpacker pac, Object to) throws IOException, MessageTypeException {
|
||||
int length = pac.unpackArray();
|
||||
List<Object> list = new ArrayList<Object>(length);
|
||||
List<Object> list;
|
||||
if(to == null) {
|
||||
list = new ArrayList<Object>(length);
|
||||
} else {
|
||||
list = (List<Object>)to;
|
||||
list.clear();
|
||||
}
|
||||
for(; length > 0; length--) {
|
||||
list.add( elementTemplate.unpack(pac) );
|
||||
list.add( elementTemplate.unpack(pac, null) );
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
public Object convert(MessagePackObject from) throws MessageTypeException {
|
||||
public Object convert(MessagePackObject from, Object to) throws MessageTypeException {
|
||||
MessagePackObject[] array = from.asArray();
|
||||
List<Object> list = new ArrayList<Object>(array.length);
|
||||
List<Object> list;
|
||||
if(to == null) {
|
||||
list = new ArrayList<Object>(array.length);
|
||||
} else {
|
||||
// TODO: optimize if list is instanceof ArrayList
|
||||
list = (List<Object>)to;
|
||||
list.clear();
|
||||
}
|
||||
for(MessagePackObject element : array) {
|
||||
list.add( elementTemplate.convert(element) );
|
||||
list.add( elementTemplate.convert(element, null) );
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
@ -27,11 +27,11 @@ public class LongTemplate implements Template {
|
||||
pk.packLong((Long)target);
|
||||
}
|
||||
|
||||
public Object unpack(Unpacker pac) throws IOException, MessageTypeException {
|
||||
public Object unpack(Unpacker pac, Object to) throws IOException, MessageTypeException {
|
||||
return pac.unpackLong();
|
||||
}
|
||||
|
||||
public Object convert(MessagePackObject from) throws MessageTypeException {
|
||||
public Object convert(MessagePackObject from, Object to) throws MessageTypeException {
|
||||
return from.asLong();
|
||||
}
|
||||
|
||||
|
@ -52,24 +52,36 @@ public class MapTemplate implements Template {
|
||||
}
|
||||
}
|
||||
|
||||
public Object unpack(Unpacker pac) throws IOException, MessageTypeException {
|
||||
public Object unpack(Unpacker pac, Object to) throws IOException, MessageTypeException {
|
||||
int length = pac.unpackMap();
|
||||
Map<Object,Object> map = new HashMap<Object,Object>(length);
|
||||
Map<Object,Object> map;
|
||||
if(to == null) {
|
||||
map = new HashMap<Object,Object>(length);
|
||||
} else {
|
||||
map = (Map<Object,Object>)to;
|
||||
map.clear();
|
||||
}
|
||||
for(; length > 0; length--) {
|
||||
Object key = keyTemplate.unpack(pac);
|
||||
Object value = valueTemplate.unpack(pac);
|
||||
Object key = keyTemplate.unpack(pac, null);
|
||||
Object value = valueTemplate.unpack(pac, null);
|
||||
map.put(key, value);
|
||||
}
|
||||
return map;
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public Object convert(MessagePackObject from) throws MessageTypeException {
|
||||
public Object convert(MessagePackObject from, Object to) throws MessageTypeException {
|
||||
Map<MessagePackObject,MessagePackObject> src = from.asMap();
|
||||
Map<Object,Object> map = new HashMap();
|
||||
Map<Object,Object> map;
|
||||
if(to == null) {
|
||||
map = new HashMap<Object,Object>(src.size());
|
||||
} else {
|
||||
map = (Map<Object,Object>)to;
|
||||
map.clear();
|
||||
}
|
||||
for(Map.Entry<MessagePackObject,MessagePackObject> pair : src.entrySet()) {
|
||||
Object key = keyTemplate.convert(pair.getKey());
|
||||
Object value = valueTemplate.convert(pair.getValue());
|
||||
Object key = keyTemplate.convert(pair.getKey(), null);
|
||||
Object value = valueTemplate.convert(pair.getValue(), null);
|
||||
map.put(key, value);
|
||||
}
|
||||
return map;
|
||||
|
@ -39,18 +39,18 @@ public class NullableTemplate implements Template {
|
||||
}
|
||||
}
|
||||
|
||||
public Object unpack(Unpacker pac) throws IOException, MessageTypeException {
|
||||
public Object unpack(Unpacker pac, Object to) throws IOException, MessageTypeException {
|
||||
if(pac.tryUnpackNull()) {
|
||||
return null;
|
||||
}
|
||||
return elementTemplate.unpack(pac);
|
||||
return elementTemplate.unpack(pac, to);
|
||||
}
|
||||
|
||||
public Object convert(MessagePackObject from) throws MessageTypeException {
|
||||
public Object convert(MessagePackObject from, Object to) throws MessageTypeException {
|
||||
if(from.isNil()) {
|
||||
return null;
|
||||
}
|
||||
return elementTemplate.convert(from);
|
||||
return elementTemplate.convert(from, to);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -45,18 +45,18 @@ public class OptionalTemplate implements Template {
|
||||
}
|
||||
}
|
||||
|
||||
public Object unpack(Unpacker pac) throws IOException, MessageTypeException {
|
||||
public Object unpack(Unpacker pac, Object to) throws IOException, MessageTypeException {
|
||||
if(pac.tryUnpackNull()) {
|
||||
return defaultObject;
|
||||
return defaultObject; // FIXME return to?
|
||||
}
|
||||
return elementTemplate.unpack(pac);
|
||||
return elementTemplate.unpack(pac, to);
|
||||
}
|
||||
|
||||
public Object convert(MessagePackObject from) throws MessageTypeException {
|
||||
public Object convert(MessagePackObject from, Object to) throws MessageTypeException {
|
||||
if(from.isNil()) {
|
||||
return defaultObject;
|
||||
return defaultObject; // FIXME return to?
|
||||
}
|
||||
return elementTemplate.convert(from);
|
||||
return elementTemplate.convert(from, to);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -27,11 +27,11 @@ public class ShortTemplate implements Template {
|
||||
pk.packShort((Short)target);
|
||||
}
|
||||
|
||||
public Object unpack(Unpacker pac) throws IOException, MessageTypeException {
|
||||
public Object unpack(Unpacker pac, Object to) throws IOException, MessageTypeException {
|
||||
return pac.unpackShort();
|
||||
}
|
||||
|
||||
public Object convert(MessagePackObject from) throws MessageTypeException {
|
||||
public Object convert(MessagePackObject from, Object to) throws MessageTypeException {
|
||||
return from.asShort();
|
||||
}
|
||||
|
||||
|
@ -27,11 +27,11 @@ public class StringTemplate implements Template {
|
||||
pk.packString((String)target);
|
||||
}
|
||||
|
||||
public Object unpack(Unpacker pac) throws IOException, MessageTypeException {
|
||||
public Object unpack(Unpacker pac, Object to) throws IOException, MessageTypeException {
|
||||
return pac.unpackString();
|
||||
}
|
||||
|
||||
public Object convert(MessagePackObject from) throws MessageTypeException {
|
||||
public Object convert(MessagePackObject from, Object to) throws MessageTypeException {
|
||||
return from.asString();
|
||||
}
|
||||
|
||||
|
@ -76,11 +76,12 @@ public interface Constants {
|
||||
|
||||
String STATEMENT_PACKER_PACKERMETHODBODY_04 = "$1.pack(((java.lang.Enum)_$$_t).ordinal()); ";
|
||||
|
||||
String STATEMENT_TMPL_UNPACKERMETHODBODY_01 = "%s _$$_t = new %s(); ";
|
||||
String STATEMENT_TMPL_UNPACKERMETHODBODY_01 = "%s _$$_t; if($2 == null) { _$$_t = new %s(); } else { _$$_t = (%s)$2; } ";
|
||||
|
||||
String STATEMENT_TMPL_UNPACKERMETHODBODY_02 = "int _$$_len = $1.unpackArray(); ";
|
||||
|
||||
String STATEMENT_TMPL_UNPACKERMETHODBODY_03 = "_$$_t.%s = %s(%s)_$$_templates[%d].unpack($1)%s; ";
|
||||
String STATEMENT_TMPL_UNPACKERMETHODBODY_03_NULL = "_$$_t.%s = %s(%s)_$$_templates[%d].unpack($1, null)%s; ";
|
||||
String STATEMENT_TMPL_UNPACKERMETHODBODY_03 = "_$$_t.%s = %s(%s)_$$_templates[%d].unpack($1, _$$_t.%s)%s; ";
|
||||
|
||||
String STATEMENT_TMPL_UNPACKERMETHODBODY_04 = "return _$$_t; ";
|
||||
|
||||
@ -96,7 +97,8 @@ public interface Constants {
|
||||
|
||||
String STATEMENT_TMPL_CONVERTMETHODBODY_01 = "%s _$$_ary = $1.asArray(); ";
|
||||
|
||||
String STATEMENT_TMPL_CONVERTMETHODBODY_02 = "_$$_t.%s = %s(%s)_$$_templates[%d].convert(_$$_ary[%d])%s; ";
|
||||
String STATEMENT_TMPL_CONVERTMETHODBODY_02_NULL = "_$$_t.%s = %s(%s)_$$_templates[%d].convert(_$$_ary[%d], null)%s; ";
|
||||
String STATEMENT_TMPL_CONVERTMETHODBODY_02 = "_$$_t.%s = %s(%s)_$$_templates[%d].convert(_$$_ary[%d], _$$_t.%s)%s; ";
|
||||
|
||||
String STATEMENT_TMPL_CONVERTMETHODBODY_03 = "int i = _$$_ary[0].asInt(); ";
|
||||
|
||||
|
@ -395,7 +395,7 @@ class DynamicCodeGen extends DynamicCodeGenBase implements Constants {
|
||||
int mod = javassist.Modifier.PUBLIC;
|
||||
CtClass returnType = classToCtClass(Object.class);
|
||||
String mname = METHOD_NAME_UNPACK;
|
||||
CtClass[] paramTypes = new CtClass[] { classToCtClass(Unpacker.class) };
|
||||
CtClass[] paramTypes = new CtClass[] { classToCtClass(Unpacker.class), classToCtClass(Object.class) };
|
||||
CtClass[] exceptTypes = new CtClass[] {
|
||||
classToCtClass(IOException.class),
|
||||
classToCtClass(MessageTypeException.class) };
|
||||
@ -424,7 +424,7 @@ class DynamicCodeGen extends DynamicCodeGenBase implements Constants {
|
||||
sb.append(CHAR_NAME_SPACE);
|
||||
// Foo _$$_t = new Foo();
|
||||
String typeName = classToString(type);
|
||||
Object[] args0 = new Object[] { typeName, typeName };
|
||||
Object[] args0 = new Object[] { typeName, typeName, typeName };
|
||||
sb.append(String.format(STATEMENT_TMPL_UNPACKERMETHODBODY_01, args0));
|
||||
// int _$$_L = $1.unpackArray();
|
||||
Object[] args1 = new Object[0];
|
||||
@ -449,15 +449,25 @@ class DynamicCodeGen extends DynamicCodeGenBase implements Constants {
|
||||
// target.fi = ((Integer)_$$_tmpls[i].unpack(_$$_pk)).intValue();
|
||||
Class<?> returnType = field.getType();
|
||||
boolean isPrim = returnType.isPrimitive();
|
||||
Object[] args = new Object[] {
|
||||
String callExpr;
|
||||
if(isPrim) {
|
||||
Object[] args = new Object[] {
|
||||
field.getName(),
|
||||
isPrim ? "(" : "",
|
||||
isPrim ? getPrimToWrapperType(returnType).getName()
|
||||
: classToString(returnType),
|
||||
i,
|
||||
isPrim ? ")." + getPrimTypeValueMethodName(returnType) + "()"
|
||||
: "" };
|
||||
String callExpr = String.format(STATEMENT_TMPL_UNPACKERMETHODBODY_03, args);
|
||||
"(",
|
||||
getPrimToWrapperType(returnType).getName(),
|
||||
i,
|
||||
")." + getPrimTypeValueMethodName(returnType) + "()" };
|
||||
callExpr = String.format(STATEMENT_TMPL_UNPACKERMETHODBODY_03_NULL, args);
|
||||
} else {
|
||||
Object[] args = new Object[] {
|
||||
field.getName(),
|
||||
"",
|
||||
classToString(returnType),
|
||||
i,
|
||||
field.getName(),
|
||||
"" };
|
||||
callExpr = String.format(STATEMENT_TMPL_UNPACKERMETHODBODY_03, args);
|
||||
}
|
||||
if (tmpl instanceof OptionalTemplate) {
|
||||
Object[] args0 = new Object[] { i, callExpr };
|
||||
// if (_$$_len > i && !unpacker.tryUnpackNull()) { ... }
|
||||
@ -507,7 +517,7 @@ class DynamicCodeGen extends DynamicCodeGenBase implements Constants {
|
||||
int mod = javassist.Modifier.PUBLIC;
|
||||
CtClass returnType = classToCtClass(Object.class);
|
||||
String mname = METHOD_NAME_CONVERT;
|
||||
CtClass[] paramTypes = new CtClass[] { classToCtClass(MessagePackObject.class) };
|
||||
CtClass[] paramTypes = new CtClass[] { classToCtClass(MessagePackObject.class), classToCtClass(Object.class) };
|
||||
CtClass[] exceptTypes = new CtClass[] { classToCtClass(MessageTypeException.class) };
|
||||
CtMethod newCtMethod = CtNewMethod.make(mod, returnType, mname,
|
||||
paramTypes, exceptTypes, sb.toString(), tmplCtClass);
|
||||
@ -534,7 +544,7 @@ class DynamicCodeGen extends DynamicCodeGenBase implements Constants {
|
||||
sb.append(CHAR_NAME_SPACE);
|
||||
// Foo _$$_t = new Foo();
|
||||
String typeName = classToString(type);
|
||||
Object[] args0 = new Object[] { typeName, typeName };
|
||||
Object[] args0 = new Object[] { typeName, typeName, typeName };
|
||||
sb.append(String.format(STATEMENT_TMPL_UNPACKERMETHODBODY_01, args0));
|
||||
// MessagePackObject[] _$$_ary = $1.asArray();
|
||||
Object[] args1 = new Object[] { classToString(MessagePackObject[].class) };
|
||||
@ -560,16 +570,27 @@ class DynamicCodeGen extends DynamicCodeGenBase implements Constants {
|
||||
// target.fi = ((Object)_$$_tmpls[i].convert(_$$_ary[i])).intValue();
|
||||
Class<?> returnType = field.getType();
|
||||
boolean isPrim = returnType.isPrimitive();
|
||||
Object[] args = new Object[] {
|
||||
String callExpr;
|
||||
if(isPrim) {
|
||||
Object[] args = new Object[] {
|
||||
field.getName(),
|
||||
isPrim ? "(" : "",
|
||||
isPrim ? getPrimToWrapperType(returnType).getName()
|
||||
: classToString(returnType),
|
||||
i,
|
||||
i,
|
||||
isPrim ? ")." + getPrimTypeValueMethodName(returnType) + "()"
|
||||
: "" };
|
||||
String callExpr = String.format(STATEMENT_TMPL_CONVERTMETHODBODY_02, args);
|
||||
"(",
|
||||
getPrimToWrapperType(returnType).getName(),
|
||||
i,
|
||||
i,
|
||||
")." + getPrimTypeValueMethodName(returnType) + "()" };
|
||||
callExpr = String.format(STATEMENT_TMPL_CONVERTMETHODBODY_02_NULL, args);
|
||||
} else {
|
||||
Object[] args = new Object[] {
|
||||
field.getName(),
|
||||
"",
|
||||
classToString(returnType),
|
||||
i,
|
||||
i,
|
||||
field.getName(),
|
||||
"" };
|
||||
callExpr = String.format(STATEMENT_TMPL_CONVERTMETHODBODY_02, args);
|
||||
}
|
||||
if (tmpl instanceof OptionalTemplate) {
|
||||
Object[] args0 = new Object[] { i, i, callExpr };
|
||||
// if (_$$_len > i && !_$$_ary[i].isNull()) { ... }
|
||||
|
@ -76,10 +76,15 @@ public class DynamicCodeGenBase implements Constants {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object unpack(Unpacker unpacker) throws IOException,
|
||||
public Object unpack(Unpacker unpacker, Object to) throws IOException,
|
||||
MessageTypeException {
|
||||
try {
|
||||
MessageUnpackable obj = (MessageUnpackable) type.newInstance();
|
||||
MessageUnpackable obj;
|
||||
if(to == null) {
|
||||
obj = (MessageUnpackable) type.newInstance();
|
||||
} else {
|
||||
obj = (MessageUnpackable) to;
|
||||
}
|
||||
obj.messageUnpack(unpacker);
|
||||
return obj;
|
||||
} catch (ClassCastException e) {
|
||||
@ -92,11 +97,15 @@ public class DynamicCodeGenBase implements Constants {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object convert(MessagePackObject from)
|
||||
public Object convert(MessagePackObject from, Object to)
|
||||
throws MessageTypeException {
|
||||
try {
|
||||
MessageConvertable obj = (MessageConvertable) type
|
||||
.newInstance();
|
||||
MessageConvertable obj;
|
||||
if(to == null) {
|
||||
obj = (MessageConvertable) type.newInstance();
|
||||
} else {
|
||||
obj = (MessageConvertable) to;
|
||||
}
|
||||
obj.messageConvert(from);
|
||||
return obj;
|
||||
} catch (ClassCastException e) {
|
||||
|
@ -102,6 +102,14 @@ public class TestMessagePackStaticMethods extends TestCase {
|
||||
assertEquals(eobj, createProvidedClass());
|
||||
assertEquals(fobj, createUserDefinedClass());
|
||||
}
|
||||
|
||||
{
|
||||
ProvidedClass eobj = MessagePack.unpack(e, createProvidedClass());
|
||||
UserDefinedClass fobj = MessagePack.unpack(f, createUserDefinedClass());
|
||||
|
||||
assertEquals(eobj, createProvidedClass());
|
||||
assertEquals(fobj, createUserDefinedClass());
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
@ -164,6 +172,17 @@ public class TestMessagePackStaticMethods extends TestCase {
|
||||
assertEquals(eobj, createProvidedClass());
|
||||
assertEquals(fobj, createUserDefinedClass());
|
||||
}
|
||||
|
||||
{
|
||||
InputStream ein = new ByteArrayInputStream(eout.toByteArray());
|
||||
InputStream fin = new ByteArrayInputStream(fout.toByteArray());
|
||||
|
||||
ProvidedClass eobj = MessagePack.unpack(ein, createProvidedClass());
|
||||
UserDefinedClass fobj = MessagePack.unpack(fin, createUserDefinedClass());
|
||||
|
||||
assertEquals(eobj, createProvidedClass());
|
||||
assertEquals(fobj, createUserDefinedClass());
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -58,14 +58,14 @@ public class TestPackConvert extends TestCase {
|
||||
Byte dst = null;
|
||||
try {
|
||||
tmpl = ByteTemplate.getInstance();
|
||||
dst = (Byte) tmpl.convert(obj);
|
||||
dst = (Byte) tmpl.convert(obj, null);
|
||||
fail();
|
||||
} catch (Exception e) {
|
||||
assertTrue(e instanceof MessageTypeException);
|
||||
}
|
||||
obj = Util.unpackOne(out.toByteArray());
|
||||
tmpl = new NullableTemplate(ByteTemplate.getInstance());
|
||||
dst = (Byte) tmpl.convert(obj);
|
||||
dst = (Byte) tmpl.convert(obj, null);
|
||||
assertEquals(src, dst);
|
||||
}
|
||||
|
||||
@ -101,14 +101,14 @@ public class TestPackConvert extends TestCase {
|
||||
Short dst = null;
|
||||
try {
|
||||
tmpl = ShortTemplate.getInstance();
|
||||
dst = (Short) tmpl.convert(obj);
|
||||
dst = (Short) tmpl.convert(obj, null);
|
||||
fail();
|
||||
} catch (Exception e) {
|
||||
assertTrue(e instanceof MessageTypeException);
|
||||
}
|
||||
obj = Util.unpackOne(out.toByteArray());
|
||||
tmpl = new NullableTemplate(ShortTemplate.getInstance());
|
||||
dst = (Short) tmpl.convert(obj);
|
||||
dst = (Short) tmpl.convert(obj, null);
|
||||
assertEquals(src, dst);
|
||||
}
|
||||
|
||||
@ -144,14 +144,14 @@ public class TestPackConvert extends TestCase {
|
||||
Integer dst = null;
|
||||
try {
|
||||
tmpl = IntegerTemplate.getInstance();
|
||||
dst = (Integer) tmpl.convert(obj);
|
||||
dst = (Integer) tmpl.convert(obj, null);
|
||||
fail();
|
||||
} catch (Exception e) {
|
||||
assertTrue(e instanceof MessageTypeException);
|
||||
}
|
||||
obj = Util.unpackOne(out.toByteArray());
|
||||
tmpl = new NullableTemplate(IntegerTemplate.getInstance());
|
||||
dst = (Integer) tmpl.convert(obj);
|
||||
dst = (Integer) tmpl.convert(obj, null);
|
||||
assertEquals(src, dst);
|
||||
}
|
||||
|
||||
@ -189,14 +189,14 @@ public class TestPackConvert extends TestCase {
|
||||
Long dst = null;
|
||||
try {
|
||||
tmpl = LongTemplate.getInstance();
|
||||
dst = (Long) tmpl.convert(obj);
|
||||
dst = (Long) tmpl.convert(obj, null);
|
||||
fail();
|
||||
} catch (Exception e) {
|
||||
assertTrue(e instanceof MessageTypeException);
|
||||
}
|
||||
obj = Util.unpackOne(out.toByteArray());
|
||||
tmpl = new NullableTemplate(LongTemplate.getInstance());
|
||||
dst = (Long) tmpl.convert(obj);
|
||||
dst = (Long) tmpl.convert(obj, null);
|
||||
assertEquals(src, dst);
|
||||
}
|
||||
|
||||
@ -238,14 +238,14 @@ public class TestPackConvert extends TestCase {
|
||||
BigInteger dst = null;
|
||||
try {
|
||||
tmpl = BigIntegerTemplate.getInstance();
|
||||
dst = (BigInteger) tmpl.convert(obj);
|
||||
dst = (BigInteger) tmpl.convert(obj, null);
|
||||
fail();
|
||||
} catch (Exception e) {
|
||||
assertTrue(e instanceof MessageTypeException);
|
||||
}
|
||||
obj = Util.unpackOne(out.toByteArray());
|
||||
tmpl = new NullableTemplate(BigIntegerTemplate.getInstance());
|
||||
dst = (BigInteger) tmpl.convert(obj);
|
||||
dst = (BigInteger) tmpl.convert(obj, null);
|
||||
assertEquals(src, dst);
|
||||
}
|
||||
|
||||
@ -285,14 +285,14 @@ public class TestPackConvert extends TestCase {
|
||||
Float dst = null;
|
||||
try {
|
||||
tmpl = FloatTemplate.getInstance();
|
||||
dst = (Float) tmpl.convert(obj);
|
||||
dst = (Float) tmpl.convert(obj, null);
|
||||
fail();
|
||||
} catch (Exception e) {
|
||||
assertTrue(e instanceof MessageTypeException);
|
||||
}
|
||||
obj = Util.unpackOne(out.toByteArray());
|
||||
tmpl = new NullableTemplate(FloatTemplate.getInstance());
|
||||
dst = (Float) tmpl.convert(obj);
|
||||
dst = (Float) tmpl.convert(obj, null);
|
||||
assertEquals(src, dst);
|
||||
}
|
||||
|
||||
@ -331,14 +331,14 @@ public class TestPackConvert extends TestCase {
|
||||
Double dst = null;
|
||||
try {
|
||||
tmpl = DoubleTemplate.getInstance();
|
||||
dst = (Double) tmpl.convert(obj);
|
||||
dst = (Double) tmpl.convert(obj, null);
|
||||
fail();
|
||||
} catch (Exception e) {
|
||||
assertTrue(e instanceof MessageTypeException);
|
||||
}
|
||||
obj = Util.unpackOne(out.toByteArray());
|
||||
tmpl = new NullableTemplate(DoubleTemplate.getInstance());
|
||||
dst = (Double) tmpl.convert(obj);
|
||||
dst = (Double) tmpl.convert(obj, null);
|
||||
assertEquals(src, dst);
|
||||
}
|
||||
|
||||
@ -367,14 +367,14 @@ public class TestPackConvert extends TestCase {
|
||||
Boolean dst = null;
|
||||
try {
|
||||
tmpl = BooleanTemplate.getInstance();
|
||||
dst = (Boolean) tmpl.convert(obj);
|
||||
dst = (Boolean) tmpl.convert(obj, null);
|
||||
fail();
|
||||
} catch (Exception e) {
|
||||
assertTrue(e instanceof MessageTypeException);
|
||||
}
|
||||
obj = Util.unpackOne(out.toByteArray());
|
||||
tmpl = new NullableTemplate(BooleanTemplate.getInstance());
|
||||
dst = (Boolean) tmpl.convert(obj);
|
||||
dst = (Boolean) tmpl.convert(obj, null);
|
||||
assertEquals(src, dst);
|
||||
}
|
||||
|
||||
@ -435,14 +435,14 @@ public class TestPackConvert extends TestCase {
|
||||
String dst = null;
|
||||
try {
|
||||
tmpl = StringTemplate.getInstance();
|
||||
dst = (String) tmpl.convert(obj);
|
||||
dst = (String) tmpl.convert(obj, null);
|
||||
fail();
|
||||
} catch (Exception e) {
|
||||
assertTrue(e instanceof MessageTypeException);
|
||||
}
|
||||
obj = Util.unpackOne(out.toByteArray());
|
||||
tmpl = new NullableTemplate(StringTemplate.getInstance());
|
||||
dst = (String) tmpl.convert(obj);
|
||||
dst = (String) tmpl.convert(obj, null);
|
||||
assertEquals(src, dst);
|
||||
}
|
||||
}
|
||||
|
@ -61,14 +61,14 @@ public class TestPackUnpack extends TestCase {
|
||||
try {
|
||||
tmpl = ByteTemplate.getInstance();
|
||||
unpacker.wrap(bytes);
|
||||
dst = (Byte) tmpl.unpack(unpacker);
|
||||
dst = (Byte) tmpl.unpack(unpacker, null);
|
||||
fail();
|
||||
} catch (Exception e) {
|
||||
assertTrue(e instanceof MessageTypeException);
|
||||
}
|
||||
unpacker.wrap(bytes);
|
||||
tmpl = new NullableTemplate(ByteTemplate.getInstance());
|
||||
dst = (Byte) tmpl.unpack(unpacker);
|
||||
dst = (Byte) tmpl.unpack(unpacker, null);
|
||||
assertEquals(src, dst);
|
||||
}
|
||||
|
||||
@ -107,14 +107,14 @@ public class TestPackUnpack extends TestCase {
|
||||
try {
|
||||
tmpl = ShortTemplate.getInstance();
|
||||
unpacker.wrap(bytes);
|
||||
dst = (Short) tmpl.unpack(unpacker);
|
||||
dst = (Short) tmpl.unpack(unpacker, null);
|
||||
fail();
|
||||
} catch (Exception e) {
|
||||
assertTrue(e instanceof MessageTypeException);
|
||||
}
|
||||
unpacker.wrap(bytes);
|
||||
tmpl = new NullableTemplate(ShortTemplate.getInstance());
|
||||
dst = (Short) tmpl.unpack(unpacker);
|
||||
dst = (Short) tmpl.unpack(unpacker, null);
|
||||
assertEquals(src, dst);
|
||||
}
|
||||
|
||||
@ -153,14 +153,14 @@ public class TestPackUnpack extends TestCase {
|
||||
try {
|
||||
tmpl = IntegerTemplate.getInstance();
|
||||
unpacker.wrap(bytes);
|
||||
dst = (Integer) tmpl.unpack(unpacker);
|
||||
dst = (Integer) tmpl.unpack(unpacker, null);
|
||||
fail();
|
||||
} catch (Exception e) {
|
||||
assertTrue(e instanceof MessageTypeException);
|
||||
}
|
||||
unpacker.wrap(bytes);
|
||||
tmpl = new NullableTemplate(IntegerTemplate.getInstance());
|
||||
dst = (Integer) tmpl.unpack(unpacker);
|
||||
dst = (Integer) tmpl.unpack(unpacker, null);
|
||||
assertEquals(src, dst);
|
||||
}
|
||||
|
||||
@ -201,14 +201,14 @@ public class TestPackUnpack extends TestCase {
|
||||
try {
|
||||
tmpl = LongTemplate.getInstance();
|
||||
unpacker.wrap(bytes);
|
||||
dst = (Long) tmpl.unpack(unpacker);
|
||||
dst = (Long) tmpl.unpack(unpacker, null);
|
||||
fail();
|
||||
} catch (Exception e) {
|
||||
assertTrue(e instanceof MessageTypeException);
|
||||
}
|
||||
unpacker.wrap(bytes);
|
||||
tmpl = new NullableTemplate(LongTemplate.getInstance());
|
||||
dst = (Long) tmpl.unpack(unpacker);
|
||||
dst = (Long) tmpl.unpack(unpacker, null);
|
||||
assertEquals(src, dst);
|
||||
}
|
||||
|
||||
@ -253,14 +253,14 @@ public class TestPackUnpack extends TestCase {
|
||||
try {
|
||||
tmpl = BigIntegerTemplate.getInstance();
|
||||
unpacker.wrap(bytes);
|
||||
dst = (BigInteger) tmpl.unpack(unpacker);
|
||||
dst = (BigInteger) tmpl.unpack(unpacker, null);
|
||||
fail();
|
||||
} catch (Exception e) {
|
||||
assertTrue(e instanceof MessageTypeException);
|
||||
}
|
||||
unpacker.wrap(bytes);
|
||||
tmpl = new NullableTemplate(BigIntegerTemplate.getInstance());
|
||||
dst = (BigInteger) tmpl.unpack(unpacker);
|
||||
dst = (BigInteger) tmpl.unpack(unpacker, null);
|
||||
assertEquals(src, dst);
|
||||
}
|
||||
|
||||
@ -303,14 +303,14 @@ public class TestPackUnpack extends TestCase {
|
||||
try {
|
||||
tmpl = FloatTemplate.getInstance();
|
||||
unpacker.wrap(bytes);
|
||||
dst = (Float) tmpl.unpack(unpacker);
|
||||
dst = (Float) tmpl.unpack(unpacker, null);
|
||||
fail();
|
||||
} catch (Exception e) {
|
||||
assertTrue(e instanceof MessageTypeException);
|
||||
}
|
||||
unpacker.wrap(bytes);
|
||||
tmpl = new NullableTemplate(FloatTemplate.getInstance());
|
||||
dst = (Float) tmpl.unpack(unpacker);
|
||||
dst = (Float) tmpl.unpack(unpacker, null);
|
||||
assertEquals(src, dst);
|
||||
}
|
||||
|
||||
@ -352,14 +352,14 @@ public class TestPackUnpack extends TestCase {
|
||||
try {
|
||||
tmpl = DoubleTemplate.getInstance();
|
||||
unpacker.wrap(bytes);
|
||||
dst = (Double) tmpl.unpack(unpacker);
|
||||
dst = (Double) tmpl.unpack(unpacker, null);
|
||||
fail();
|
||||
} catch (Exception e) {
|
||||
assertTrue(e instanceof MessageTypeException);
|
||||
}
|
||||
unpacker.wrap(bytes);
|
||||
tmpl = new NullableTemplate(DoubleTemplate.getInstance());
|
||||
dst = (Double) tmpl.unpack(unpacker);
|
||||
dst = (Double) tmpl.unpack(unpacker, null);
|
||||
assertEquals(src, dst);
|
||||
}
|
||||
|
||||
@ -391,14 +391,14 @@ public class TestPackUnpack extends TestCase {
|
||||
try {
|
||||
tmpl = BooleanTemplate.getInstance();
|
||||
unpacker.wrap(bytes);
|
||||
dst = (Boolean) tmpl.unpack(unpacker);
|
||||
dst = (Boolean) tmpl.unpack(unpacker, null);
|
||||
fail();
|
||||
} catch (Exception e) {
|
||||
assertTrue(e instanceof MessageTypeException);
|
||||
}
|
||||
unpacker.wrap(bytes);
|
||||
tmpl = new NullableTemplate(BooleanTemplate.getInstance());
|
||||
dst = (Boolean) tmpl.unpack(unpacker);
|
||||
dst = (Boolean) tmpl.unpack(unpacker, null);
|
||||
assertEquals(src, dst);
|
||||
}
|
||||
|
||||
@ -462,14 +462,14 @@ public class TestPackUnpack extends TestCase {
|
||||
try {
|
||||
tmpl = StringTemplate.getInstance();
|
||||
unpacker.wrap(bytes);
|
||||
dst = (String) tmpl.unpack(unpacker);
|
||||
dst = (String) tmpl.unpack(unpacker, null);
|
||||
fail();
|
||||
} catch (Exception e) {
|
||||
assertTrue(e instanceof MessageTypeException);
|
||||
}
|
||||
unpacker.wrap(bytes);
|
||||
tmpl = new NullableTemplate(StringTemplate.getInstance());
|
||||
dst = (String) tmpl.unpack(unpacker);
|
||||
dst = (String) tmpl.unpack(unpacker, null);
|
||||
assertEquals(src, dst);
|
||||
}
|
||||
}
|
||||
|
@ -37,7 +37,7 @@ public class TestPackConvert extends TestCase {
|
||||
new Packer(out).pack(src);
|
||||
MessagePackObject obj = Util.unpackOne(out.toByteArray());
|
||||
Template tmpl = IntegerTemplate.getInstance();
|
||||
Integer dst = (Integer) tmpl.convert(obj);
|
||||
Integer dst = (Integer) tmpl.convert(obj, null);
|
||||
assertEquals(src, dst);
|
||||
}
|
||||
|
||||
@ -50,14 +50,14 @@ public class TestPackConvert extends TestCase {
|
||||
Template tmpl = IntegerTemplate.getInstance();
|
||||
Integer dst = null;
|
||||
try {
|
||||
dst = (Integer) tmpl.convert(obj);
|
||||
dst = (Integer) tmpl.convert(obj, null);
|
||||
fail();
|
||||
} catch (Exception e) {
|
||||
assertTrue(e instanceof MessageTypeException);
|
||||
}
|
||||
obj = Util.unpackOne(out.toByteArray());
|
||||
tmpl = new NullableTemplate(IntegerTemplate.getInstance());
|
||||
dst = (Integer) tmpl.convert(obj);
|
||||
dst = (Integer) tmpl.convert(obj, null);
|
||||
assertEquals(src, dst);
|
||||
}
|
||||
|
||||
@ -81,7 +81,7 @@ public class TestPackConvert extends TestCase {
|
||||
new Packer(out).pack(src);
|
||||
MessagePackObject obj = Util.unpackOne(out.toByteArray());
|
||||
Template tmpl = LongTemplate.getInstance();
|
||||
Long dst = (Long) tmpl.convert(obj);
|
||||
Long dst = (Long) tmpl.convert(obj, null);
|
||||
assertEquals(src, dst);
|
||||
}
|
||||
|
||||
@ -94,14 +94,14 @@ public class TestPackConvert extends TestCase {
|
||||
Template tmpl = LongTemplate.getInstance();
|
||||
Long dst = null;
|
||||
try {
|
||||
dst = (Long) tmpl.convert(obj);
|
||||
dst = (Long) tmpl.convert(obj, null);
|
||||
fail();
|
||||
} catch (Exception e) {
|
||||
assertTrue(e instanceof MessageTypeException);
|
||||
}
|
||||
obj = Util.unpackOne(out.toByteArray());
|
||||
tmpl = new NullableTemplate(LongTemplate.getInstance());
|
||||
dst = (Long) tmpl.convert(obj);
|
||||
dst = (Long) tmpl.convert(obj, null);
|
||||
assertEquals(src, dst);
|
||||
}
|
||||
|
||||
@ -128,7 +128,7 @@ public class TestPackConvert extends TestCase {
|
||||
new Packer(out).pack(src);
|
||||
MessagePackObject obj = Util.unpackOne(out.toByteArray());
|
||||
Template tmpl = BigIntegerTemplate.getInstance();
|
||||
BigInteger dst = (BigInteger) tmpl.convert(obj);
|
||||
BigInteger dst = (BigInteger) tmpl.convert(obj, null);
|
||||
assertEquals(src, dst);
|
||||
}
|
||||
|
||||
@ -141,14 +141,14 @@ public class TestPackConvert extends TestCase {
|
||||
Template tmpl = BigIntegerTemplate.getInstance();
|
||||
BigInteger dst = null;
|
||||
try {
|
||||
dst = (BigInteger) tmpl.convert(obj);
|
||||
dst = (BigInteger) tmpl.convert(obj, null);
|
||||
fail();
|
||||
} catch (Exception e) {
|
||||
assertTrue(e instanceof MessageTypeException);
|
||||
}
|
||||
obj = Util.unpackOne(out.toByteArray());
|
||||
tmpl = new NullableTemplate(BigIntegerTemplate.getInstance());
|
||||
dst = (BigInteger) tmpl.convert(obj);
|
||||
dst = (BigInteger) tmpl.convert(obj, null);
|
||||
assertEquals(src, dst);
|
||||
}
|
||||
|
||||
@ -174,7 +174,7 @@ public class TestPackConvert extends TestCase {
|
||||
new Packer(out).pack(src);
|
||||
MessagePackObject obj = Util.unpackOne(out.toByteArray());
|
||||
Template tmpl = FloatTemplate.getInstance();
|
||||
Float dst = (Float) tmpl.convert(obj);
|
||||
Float dst = (Float) tmpl.convert(obj, null);
|
||||
assertEquals(src, dst, 10e-10);
|
||||
}
|
||||
|
||||
@ -187,14 +187,14 @@ public class TestPackConvert extends TestCase {
|
||||
Template tmpl = FloatTemplate.getInstance();
|
||||
Float dst = null;
|
||||
try {
|
||||
dst = (Float) tmpl.convert(obj);
|
||||
dst = (Float) tmpl.convert(obj, null);
|
||||
fail();
|
||||
} catch (Exception e) {
|
||||
assertTrue(e instanceof MessageTypeException);
|
||||
}
|
||||
obj = Util.unpackOne(out.toByteArray());
|
||||
tmpl = new NullableTemplate(FloatTemplate.getInstance());
|
||||
dst = (Float) tmpl.convert(obj);
|
||||
dst = (Float) tmpl.convert(obj, null);
|
||||
assertEquals(src, dst);
|
||||
}
|
||||
|
||||
@ -220,7 +220,7 @@ public class TestPackConvert extends TestCase {
|
||||
new Packer(out).pack(src);
|
||||
MessagePackObject obj = Util.unpackOne(out.toByteArray());
|
||||
Template tmpl = DoubleTemplate.getInstance();
|
||||
Double dst = (Double) tmpl.convert(obj);
|
||||
Double dst = (Double) tmpl.convert(obj, null);
|
||||
assertEquals(src, dst, 10e-10);
|
||||
}
|
||||
|
||||
@ -233,14 +233,14 @@ public class TestPackConvert extends TestCase {
|
||||
Template tmpl = DoubleTemplate.getInstance();
|
||||
Double dst = null;
|
||||
try {
|
||||
dst = (Double) tmpl.convert(obj);
|
||||
dst = (Double) tmpl.convert(obj, null);
|
||||
fail();
|
||||
} catch (Exception e) {
|
||||
assertTrue(e instanceof MessageTypeException);
|
||||
}
|
||||
obj = Util.unpackOne(out.toByteArray());
|
||||
tmpl = new NullableTemplate(DoubleTemplate.getInstance());
|
||||
dst = (Double) tmpl.convert(obj);
|
||||
dst = (Double) tmpl.convert(obj, null);
|
||||
assertEquals(src, dst);
|
||||
}
|
||||
|
||||
@ -255,7 +255,7 @@ public class TestPackConvert extends TestCase {
|
||||
new Packer(out).pack(src);
|
||||
MessagePackObject obj = Util.unpackOne(out.toByteArray());
|
||||
Template tmpl = BooleanTemplate.getInstance();
|
||||
Boolean dst = (Boolean) tmpl.convert(obj);
|
||||
Boolean dst = (Boolean) tmpl.convert(obj, null);
|
||||
assertEquals(src, dst);
|
||||
}
|
||||
|
||||
@ -268,14 +268,14 @@ public class TestPackConvert extends TestCase {
|
||||
Template tmpl = BooleanTemplate.getInstance();
|
||||
Boolean dst = null;
|
||||
try {
|
||||
dst = (Boolean) tmpl.convert(obj);
|
||||
dst = (Boolean) tmpl.convert(obj, null);
|
||||
fail();
|
||||
} catch (Exception e) {
|
||||
assertTrue(e instanceof MessageTypeException);
|
||||
}
|
||||
obj = Util.unpackOne(out.toByteArray());
|
||||
tmpl = new NullableTemplate(BooleanTemplate.getInstance());
|
||||
dst = (Boolean) tmpl.convert(obj);
|
||||
dst = (Boolean) tmpl.convert(obj, null);
|
||||
assertEquals(src, dst);
|
||||
}
|
||||
|
||||
@ -322,7 +322,7 @@ public class TestPackConvert extends TestCase {
|
||||
new Packer(out).pack(src);
|
||||
MessagePackObject obj = Util.unpackOne(out.toByteArray());
|
||||
Template tmpl = StringTemplate.getInstance();
|
||||
String dst = (String) tmpl.convert(obj);
|
||||
String dst = (String) tmpl.convert(obj, null);
|
||||
assertEquals(src, dst);
|
||||
}
|
||||
|
||||
@ -335,14 +335,14 @@ public class TestPackConvert extends TestCase {
|
||||
Template tmpl = StringTemplate.getInstance();
|
||||
String dst = null;
|
||||
try {
|
||||
dst = (String) tmpl.convert(obj);
|
||||
dst = (String) tmpl.convert(obj, null);
|
||||
fail();
|
||||
} catch (Exception e) {
|
||||
assertTrue(e instanceof MessageTypeException);
|
||||
}
|
||||
obj = Util.unpackOne(out.toByteArray());
|
||||
tmpl = new NullableTemplate(StringTemplate.getInstance());
|
||||
dst = (String) tmpl.convert(obj);
|
||||
dst = (String) tmpl.convert(obj, null);
|
||||
assertEquals(src, dst);
|
||||
}
|
||||
|
||||
@ -355,7 +355,7 @@ public class TestPackConvert extends TestCase {
|
||||
new Packer(out).pack(emptyList);
|
||||
MessagePackObject obj = Util.unpackOne(out.toByteArray());
|
||||
Template tmpl = new ListTemplate(IntegerTemplate.getInstance());
|
||||
List<Integer> dst = (List<Integer>) tmpl.convert(obj);
|
||||
List<Integer> dst = (List<Integer>) tmpl.convert(obj, null);
|
||||
assertEquals(emptyList, dst);
|
||||
}
|
||||
|
||||
@ -369,7 +369,7 @@ public class TestPackConvert extends TestCase {
|
||||
new Packer(out).pack(l);
|
||||
MessagePackObject obj = Util.unpackOne(out.toByteArray());
|
||||
Template tmpl = new ListTemplate(IntegerTemplate.getInstance());
|
||||
List<Integer> dst = (List<Integer>) tmpl.convert(obj);
|
||||
List<Integer> dst = (List<Integer>) tmpl.convert(obj, null);
|
||||
assertEquals(l.size(), dst.size());
|
||||
for (int j = 0; j < len; j++) {
|
||||
assertEquals(l.get(j), dst.get(j));
|
||||
@ -386,7 +386,7 @@ public class TestPackConvert extends TestCase {
|
||||
new Packer(out).pack(l);
|
||||
MessagePackObject obj = Util.unpackOne(out.toByteArray());
|
||||
Template tmpl = new ListTemplate(StringTemplate.getInstance());
|
||||
List<String> dst = (List<String>) tmpl.convert(obj);
|
||||
List<String> dst = (List<String>) tmpl.convert(obj, null);
|
||||
assertEquals(l.size(), dst.size());
|
||||
for (int j = 0; j < len; j++) {
|
||||
assertEquals(l.get(j), dst.get(j));
|
||||
@ -404,7 +404,7 @@ public class TestPackConvert extends TestCase {
|
||||
Template tmpl = new ListTemplate(StringTemplate.getInstance());
|
||||
List<String> dst = null;
|
||||
try {
|
||||
dst = (List<String>) tmpl.convert(obj);
|
||||
dst = (List<String>) tmpl.convert(obj, null);
|
||||
fail();
|
||||
} catch (Exception e) {
|
||||
assertTrue(e instanceof MessageTypeException);
|
||||
@ -412,7 +412,7 @@ public class TestPackConvert extends TestCase {
|
||||
obj = Util.unpackOne(out.toByteArray());
|
||||
tmpl = new NullableTemplate(new ListTemplate(StringTemplate
|
||||
.getInstance()));
|
||||
dst = (List<String>) tmpl.convert(obj);
|
||||
dst = (List<String>) tmpl.convert(obj, null);
|
||||
assertEquals(src, dst);
|
||||
}
|
||||
|
||||
@ -427,7 +427,7 @@ public class TestPackConvert extends TestCase {
|
||||
Template tmpl = new MapTemplate(IntegerTemplate.getInstance(),
|
||||
IntegerTemplate.getInstance());
|
||||
Map<Integer, Integer> dst = (Map<Integer, Integer>) tmpl
|
||||
.convert(obj);
|
||||
.convert(obj, null);
|
||||
assertEquals(emptyMap, dst);
|
||||
}
|
||||
|
||||
@ -443,7 +443,7 @@ public class TestPackConvert extends TestCase {
|
||||
Template tmpl = new MapTemplate(IntegerTemplate.getInstance(),
|
||||
IntegerTemplate.getInstance());
|
||||
Map<Integer, Integer> map = (Map<Integer, Integer>) tmpl
|
||||
.convert(obj);
|
||||
.convert(obj, null);
|
||||
assertEquals(m.size(), map.size());
|
||||
for (Map.Entry<Integer, Integer> pair : map.entrySet()) {
|
||||
Integer val = m.get(pair.getKey());
|
||||
@ -462,7 +462,7 @@ public class TestPackConvert extends TestCase {
|
||||
MessagePackObject obj = Util.unpackOne(out.toByteArray());
|
||||
Template tmpl = new MapTemplate(StringTemplate.getInstance(),
|
||||
IntegerTemplate.getInstance());
|
||||
Map<String, Integer> map = (Map<String, Integer>) tmpl.convert(obj);
|
||||
Map<String, Integer> map = (Map<String, Integer>) tmpl.convert(obj, null);
|
||||
assertEquals(m.size(), map.size());
|
||||
for (Map.Entry<String, Integer> pair : map.entrySet()) {
|
||||
Integer val = m.get(pair.getKey());
|
||||
@ -483,7 +483,7 @@ public class TestPackConvert extends TestCase {
|
||||
StringTemplate.getInstance());
|
||||
Map<String, String> dst = null;
|
||||
try {
|
||||
dst = (Map<String, String>) tmpl.convert(obj);
|
||||
dst = (Map<String, String>) tmpl.convert(obj, null);
|
||||
fail();
|
||||
} catch (Exception e) {
|
||||
assertTrue(e instanceof MessageTypeException);
|
||||
@ -491,7 +491,7 @@ public class TestPackConvert extends TestCase {
|
||||
obj = Util.unpackOne(out.toByteArray());
|
||||
tmpl = new NullableTemplate(new MapTemplate(StringTemplate
|
||||
.getInstance(), StringTemplate.getInstance()));
|
||||
dst = (Map<String, String>) tmpl.convert(obj);
|
||||
dst = (Map<String, String>) tmpl.convert(obj, null);
|
||||
assertEquals(src, dst);
|
||||
}
|
||||
}
|
||||
|
@ -36,7 +36,7 @@ public class TestPackUnpack extends TestCase {
|
||||
new Packer(out).pack(src);
|
||||
ByteArrayInputStream in = new ByteArrayInputStream(out.toByteArray());
|
||||
Template tmpl = IntegerTemplate.getInstance();
|
||||
Integer dst = (Integer) tmpl.unpack(new Unpacker(in));
|
||||
Integer dst = (Integer) tmpl.unpack(new Unpacker(in), null);
|
||||
assertEquals(src, dst);
|
||||
}
|
||||
|
||||
@ -52,14 +52,14 @@ public class TestPackUnpack extends TestCase {
|
||||
try {
|
||||
tmpl = IntegerTemplate.getInstance();
|
||||
unpacker.wrap(bytes);
|
||||
dst = (Integer) tmpl.unpack(unpacker);
|
||||
dst = (Integer) tmpl.unpack(unpacker, null);
|
||||
fail();
|
||||
} catch (Exception e) {
|
||||
assertTrue(e instanceof MessageTypeException);
|
||||
}
|
||||
unpacker.wrap(bytes);
|
||||
tmpl = new NullableTemplate(IntegerTemplate.getInstance());
|
||||
dst = (Integer) tmpl.unpack(unpacker);
|
||||
dst = (Integer) tmpl.unpack(unpacker, null);
|
||||
assertEquals(src, dst);
|
||||
}
|
||||
|
||||
@ -83,7 +83,7 @@ public class TestPackUnpack extends TestCase {
|
||||
new Packer(out).pack(src);
|
||||
ByteArrayInputStream in = new ByteArrayInputStream(out.toByteArray());
|
||||
Template tmpl = LongTemplate.getInstance();
|
||||
Long dst = (Long) tmpl.unpack(new Unpacker(in));
|
||||
Long dst = (Long) tmpl.unpack(new Unpacker(in), null);
|
||||
assertEquals(src, dst);
|
||||
}
|
||||
|
||||
@ -99,14 +99,14 @@ public class TestPackUnpack extends TestCase {
|
||||
try {
|
||||
tmpl = LongTemplate.getInstance();
|
||||
unpacker.wrap(bytes);
|
||||
dst = (Long) tmpl.unpack(unpacker);
|
||||
dst = (Long) tmpl.unpack(unpacker, null);
|
||||
fail();
|
||||
} catch (Exception e) {
|
||||
assertTrue(e instanceof MessageTypeException);
|
||||
}
|
||||
unpacker.wrap(bytes);
|
||||
tmpl = new NullableTemplate(LongTemplate.getInstance());
|
||||
dst = (Long) tmpl.unpack(unpacker);
|
||||
dst = (Long) tmpl.unpack(unpacker, null);
|
||||
assertEquals(src, dst);
|
||||
}
|
||||
|
||||
@ -133,7 +133,7 @@ public class TestPackUnpack extends TestCase {
|
||||
new Packer(out).pack((Object) src);
|
||||
ByteArrayInputStream in = new ByteArrayInputStream(out.toByteArray());
|
||||
Template tmpl = BigIntegerTemplate.getInstance();
|
||||
BigInteger dst = (BigInteger) tmpl.unpack(new Unpacker(in));
|
||||
BigInteger dst = (BigInteger) tmpl.unpack(new Unpacker(in), null);
|
||||
assertEquals(src, dst);
|
||||
}
|
||||
|
||||
@ -149,14 +149,14 @@ public class TestPackUnpack extends TestCase {
|
||||
try {
|
||||
tmpl = BigIntegerTemplate.getInstance();
|
||||
unpacker.wrap(bytes);
|
||||
dst = (BigInteger) tmpl.unpack(unpacker);
|
||||
dst = (BigInteger) tmpl.unpack(unpacker, null);
|
||||
fail();
|
||||
} catch (Exception e) {
|
||||
assertTrue(e instanceof MessageTypeException);
|
||||
}
|
||||
unpacker.wrap(bytes);
|
||||
tmpl = new NullableTemplate(BigIntegerTemplate.getInstance());
|
||||
dst = (BigInteger) tmpl.unpack(unpacker);
|
||||
dst = (BigInteger) tmpl.unpack(unpacker, null);
|
||||
assertEquals(src, dst);
|
||||
}
|
||||
|
||||
@ -182,7 +182,7 @@ public class TestPackUnpack extends TestCase {
|
||||
new Packer(out).pack(src);
|
||||
ByteArrayInputStream in = new ByteArrayInputStream(out.toByteArray());
|
||||
Template tmpl = FloatTemplate.getInstance();
|
||||
Float dst = (Float) tmpl.unpack(new Unpacker(in));
|
||||
Float dst = (Float) tmpl.unpack(new Unpacker(in), null);
|
||||
assertEquals(src, dst, 10e-10);
|
||||
}
|
||||
|
||||
@ -208,7 +208,7 @@ public class TestPackUnpack extends TestCase {
|
||||
new Packer(out).pack(src);
|
||||
ByteArrayInputStream in = new ByteArrayInputStream(out.toByteArray());
|
||||
Template tmpl = DoubleTemplate.getInstance();
|
||||
Double dst = (Double) tmpl.unpack(new Unpacker(in));
|
||||
Double dst = (Double) tmpl.unpack(new Unpacker(in), null);
|
||||
assertEquals(src, dst, 10e-10);
|
||||
}
|
||||
|
||||
@ -224,14 +224,14 @@ public class TestPackUnpack extends TestCase {
|
||||
try {
|
||||
tmpl = DoubleTemplate.getInstance();
|
||||
unpacker.wrap(bytes);
|
||||
dst = (Double) tmpl.unpack(unpacker);
|
||||
dst = (Double) tmpl.unpack(unpacker, null);
|
||||
fail();
|
||||
} catch (Exception e) {
|
||||
assertTrue(e instanceof MessageTypeException);
|
||||
}
|
||||
unpacker.wrap(bytes);
|
||||
tmpl = new NullableTemplate(DoubleTemplate.getInstance());
|
||||
dst = (Double) tmpl.unpack(unpacker);
|
||||
dst = (Double) tmpl.unpack(unpacker, null);
|
||||
assertEquals(src, dst);
|
||||
}
|
||||
|
||||
@ -246,7 +246,7 @@ public class TestPackUnpack extends TestCase {
|
||||
new Packer(out).pack(src);
|
||||
ByteArrayInputStream in = new ByteArrayInputStream(out.toByteArray());
|
||||
Template tmpl = BooleanTemplate.getInstance();
|
||||
Boolean dst = (Boolean) tmpl.unpack(new Unpacker(in));
|
||||
Boolean dst = (Boolean) tmpl.unpack(new Unpacker(in), null);
|
||||
assertEquals(src, dst);
|
||||
}
|
||||
|
||||
@ -262,14 +262,14 @@ public class TestPackUnpack extends TestCase {
|
||||
try {
|
||||
tmpl = BooleanTemplate.getInstance();
|
||||
unpacker.wrap(bytes);
|
||||
dst = (Boolean) tmpl.unpack(unpacker);
|
||||
dst = (Boolean) tmpl.unpack(unpacker, null);
|
||||
fail();
|
||||
} catch (Exception e) {
|
||||
assertTrue(e instanceof MessageTypeException);
|
||||
}
|
||||
unpacker.wrap(bytes);
|
||||
tmpl = new NullableTemplate(BooleanTemplate.getInstance());
|
||||
dst = (Boolean) tmpl.unpack(unpacker);
|
||||
dst = (Boolean) tmpl.unpack(unpacker, null);
|
||||
assertEquals(src, dst);
|
||||
}
|
||||
|
||||
@ -316,7 +316,7 @@ public class TestPackUnpack extends TestCase {
|
||||
new Packer(out).pack(src);
|
||||
ByteArrayInputStream in = new ByteArrayInputStream(out.toByteArray());
|
||||
Template tmpl = StringTemplate.getInstance();
|
||||
String dst = (String) tmpl.unpack(new Unpacker(in));
|
||||
String dst = (String) tmpl.unpack(new Unpacker(in), null);
|
||||
assertEquals(src, dst);
|
||||
}
|
||||
|
||||
@ -332,14 +332,14 @@ public class TestPackUnpack extends TestCase {
|
||||
try {
|
||||
tmpl = StringTemplate.getInstance();
|
||||
unpacker.wrap(bytes);
|
||||
dst = (String) tmpl.unpack(unpacker);
|
||||
dst = (String) tmpl.unpack(unpacker, null);
|
||||
fail();
|
||||
} catch (Exception e) {
|
||||
assertTrue(e instanceof MessageTypeException);
|
||||
}
|
||||
unpacker.wrap(bytes);
|
||||
tmpl = new NullableTemplate(StringTemplate.getInstance());
|
||||
dst = (String) tmpl.unpack(unpacker);
|
||||
dst = (String) tmpl.unpack(unpacker, null);
|
||||
assertEquals(src, dst);
|
||||
}
|
||||
|
||||
@ -353,7 +353,7 @@ public class TestPackUnpack extends TestCase {
|
||||
ByteArrayInputStream in = new ByteArrayInputStream(out
|
||||
.toByteArray());
|
||||
Template tmpl = new ListTemplate(IntegerTemplate.getInstance());
|
||||
List<Integer> dst = (List<Integer>) tmpl.unpack(new Unpacker(in));
|
||||
List<Integer> dst = (List<Integer>) tmpl.unpack(new Unpacker(in), null);
|
||||
assertEquals(emptyList, dst);
|
||||
}
|
||||
|
||||
@ -368,7 +368,7 @@ public class TestPackUnpack extends TestCase {
|
||||
ByteArrayInputStream in = new ByteArrayInputStream(out
|
||||
.toByteArray());
|
||||
Template tmpl = new ListTemplate(IntegerTemplate.getInstance());
|
||||
List<Integer> dst = (List<Integer>) tmpl.unpack(new Unpacker(in));
|
||||
List<Integer> dst = (List<Integer>) tmpl.unpack(new Unpacker(in), null);
|
||||
assertEquals(len, dst.size());
|
||||
for (int j = 0; j < len; j++) {
|
||||
assertEquals(l.get(j), dst.get(j));
|
||||
@ -385,7 +385,7 @@ public class TestPackUnpack extends TestCase {
|
||||
ByteArrayInputStream in = new ByteArrayInputStream(out
|
||||
.toByteArray());
|
||||
Template tmpl = new ListTemplate(StringTemplate.getInstance());
|
||||
List<String> dst = (List<String>) tmpl.unpack(new Unpacker(in));
|
||||
List<String> dst = (List<String>) tmpl.unpack(new Unpacker(in), null);
|
||||
assertEquals(len, dst.size());
|
||||
for (int j = 0; j < len; j++) {
|
||||
assertEquals(l.get(j), dst.get(j));
|
||||
@ -406,7 +406,7 @@ public class TestPackUnpack extends TestCase {
|
||||
try {
|
||||
tmpl = new ListTemplate(StringTemplate.getInstance());
|
||||
unpacker.wrap(bytes);
|
||||
dst = (List<String>) tmpl.unpack(unpacker);
|
||||
dst = (List<String>) tmpl.unpack(unpacker, null);
|
||||
fail();
|
||||
} catch (Exception e) {
|
||||
assertTrue(e instanceof MessageTypeException);
|
||||
@ -414,7 +414,7 @@ public class TestPackUnpack extends TestCase {
|
||||
unpacker.wrap(bytes);
|
||||
tmpl = new NullableTemplate(new ListTemplate(StringTemplate
|
||||
.getInstance()));
|
||||
dst = (List<String>) tmpl.unpack(unpacker);
|
||||
dst = (List<String>) tmpl.unpack(unpacker, null);
|
||||
assertEquals(src, dst);
|
||||
}
|
||||
|
||||
@ -430,7 +430,7 @@ public class TestPackUnpack extends TestCase {
|
||||
Template tmpl = new MapTemplate(IntegerTemplate.getInstance(),
|
||||
IntegerTemplate.getInstance());
|
||||
Map<Integer, Integer> dst = (Map<Integer, Integer>) tmpl
|
||||
.unpack(new Unpacker(in));
|
||||
.unpack(new Unpacker(in), null);
|
||||
assertEquals(emptyMap, dst);
|
||||
}
|
||||
|
||||
@ -447,7 +447,7 @@ public class TestPackUnpack extends TestCase {
|
||||
Template tmpl = new MapTemplate(IntegerTemplate.getInstance(),
|
||||
IntegerTemplate.getInstance());
|
||||
Map<Integer, Integer> map = (Map<Integer, Integer>) tmpl
|
||||
.unpack(new Unpacker(in));
|
||||
.unpack(new Unpacker(in), null);
|
||||
assertEquals(len, map.size());
|
||||
for (Map.Entry<Integer, Integer> pair : map.entrySet()) {
|
||||
Integer val = m.get(pair.getKey());
|
||||
@ -469,7 +469,7 @@ public class TestPackUnpack extends TestCase {
|
||||
Template tmpl = new MapTemplate(StringTemplate.getInstance(),
|
||||
IntegerTemplate.getInstance());
|
||||
Map<String, Integer> map = (Map<String, Integer>) tmpl
|
||||
.unpack(new Unpacker(in));
|
||||
.unpack(new Unpacker(in), null);
|
||||
assertEquals(m.size(), map.size());
|
||||
for (Map.Entry<String, Integer> pair : map.entrySet()) {
|
||||
Integer val = m.get(pair.getKey());
|
||||
@ -493,7 +493,7 @@ public class TestPackUnpack extends TestCase {
|
||||
tmpl = new MapTemplate(StringTemplate.getInstance(), StringTemplate
|
||||
.getInstance());
|
||||
unpacker.wrap(bytes);
|
||||
dst = (Map<String, String>) tmpl.unpack(unpacker);
|
||||
dst = (Map<String, String>) tmpl.unpack(unpacker, null);
|
||||
fail();
|
||||
} catch (Exception e) {
|
||||
assertTrue(e instanceof MessageTypeException);
|
||||
@ -501,7 +501,7 @@ public class TestPackUnpack extends TestCase {
|
||||
unpacker.wrap(bytes);
|
||||
tmpl = new NullableTemplate(new MapTemplate(StringTemplate
|
||||
.getInstance(), StringTemplate.getInstance()));
|
||||
dst = (Map<String, String>) tmpl.unpack(unpacker);
|
||||
dst = (Map<String, String>) tmpl.unpack(unpacker, null);
|
||||
assertEquals(src, dst);
|
||||
}
|
||||
}
|
||||
|
@ -55,7 +55,7 @@ public class TestPackConvert extends TestCase {
|
||||
assertTrue(it.hasNext());
|
||||
MessagePackObject mpo = it.next();
|
||||
PrimitiveTypeFieldsClass dst = (PrimitiveTypeFieldsClass) tmpl
|
||||
.convert(mpo);
|
||||
.convert(mpo, null);
|
||||
assertEquals(src.f0, dst.f0);
|
||||
assertEquals(src.f1, dst.f1);
|
||||
assertEquals(src.f2, dst.f2);
|
||||
@ -81,7 +81,7 @@ public class TestPackConvert extends TestCase {
|
||||
assertTrue(it.hasNext());
|
||||
MessagePackObject mpo = it.next();
|
||||
PrimitiveTypeFieldsClass dst = (PrimitiveTypeFieldsClass) tmpl
|
||||
.convert(mpo);
|
||||
.convert(mpo, null);
|
||||
assertEquals(src, dst);
|
||||
assertFalse(it.hasNext());
|
||||
}
|
||||
@ -121,7 +121,7 @@ public class TestPackConvert extends TestCase {
|
||||
assertTrue(it.hasNext());
|
||||
MessagePackObject mpo = it.next();
|
||||
OptionalPrimitiveTypeFieldsClass dst = (OptionalPrimitiveTypeFieldsClass) tmpl
|
||||
.convert(mpo);
|
||||
.convert(mpo, null);
|
||||
assertEquals(src.f0, dst.f0);
|
||||
assertEquals(src.f1, dst.f1);
|
||||
assertEquals(src.f2, dst.f2);
|
||||
@ -147,7 +147,7 @@ public class TestPackConvert extends TestCase {
|
||||
assertTrue(it.hasNext());
|
||||
MessagePackObject mpo = it.next();
|
||||
OptionalPrimitiveTypeFieldsClass dst = (OptionalPrimitiveTypeFieldsClass) tmpl
|
||||
.convert(mpo);
|
||||
.convert(mpo, null);
|
||||
assertEquals(src.f0, dst.f0);
|
||||
assertEquals(src.f1, dst.f1);
|
||||
assertEquals(src.f2, dst.f2);
|
||||
@ -173,7 +173,7 @@ public class TestPackConvert extends TestCase {
|
||||
assertTrue(it.hasNext());
|
||||
MessagePackObject mpo = it.next();
|
||||
OptionalPrimitiveTypeFieldsClass dst = (OptionalPrimitiveTypeFieldsClass) tmpl
|
||||
.convert(mpo);
|
||||
.convert(mpo, null);
|
||||
assertEquals(src, dst);
|
||||
assertFalse(it.hasNext());
|
||||
}
|
||||
@ -224,7 +224,7 @@ public class TestPackConvert extends TestCase {
|
||||
assertTrue(it.hasNext());
|
||||
MessagePackObject mpo = it.next();
|
||||
GeneralReferenceTypeFieldsClass dst = (GeneralReferenceTypeFieldsClass) tmpl
|
||||
.convert(mpo);
|
||||
.convert(mpo, null);
|
||||
assertEquals(src.f0, dst.f0);
|
||||
assertEquals(src.f1, dst.f1);
|
||||
assertEquals(src.f2, dst.f2);
|
||||
@ -255,7 +255,7 @@ public class TestPackConvert extends TestCase {
|
||||
assertTrue(it.hasNext());
|
||||
MessagePackObject mpo = it.next();
|
||||
GeneralReferenceTypeFieldsClass dst = (GeneralReferenceTypeFieldsClass) tmpl
|
||||
.convert(mpo);
|
||||
.convert(mpo, null);
|
||||
assertEquals(src, dst);
|
||||
assertFalse(it.hasNext());
|
||||
}
|
||||
@ -304,7 +304,7 @@ public class TestPackConvert extends TestCase {
|
||||
assertTrue(it.hasNext());
|
||||
MessagePackObject mpo = it.next();
|
||||
OptionalGeneralReferenceTypeFieldsClass dst = (OptionalGeneralReferenceTypeFieldsClass) tmpl
|
||||
.convert(mpo);
|
||||
.convert(mpo, null);
|
||||
assertEquals(src.f0, dst.f0);
|
||||
assertEquals(src.f1, dst.f1);
|
||||
assertEquals(src.f2, dst.f2);
|
||||
@ -347,7 +347,7 @@ public class TestPackConvert extends TestCase {
|
||||
assertTrue(it.hasNext());
|
||||
MessagePackObject mpo = it.next();
|
||||
OptionalGeneralReferenceTypeFieldsClass dst = (OptionalGeneralReferenceTypeFieldsClass) tmpl
|
||||
.convert(mpo);
|
||||
.convert(mpo, null);
|
||||
assertEquals(src.f0, dst.f0);
|
||||
assertEquals(src.f1, dst.f1);
|
||||
assertEquals(src.f2, dst.f2);
|
||||
@ -378,7 +378,7 @@ public class TestPackConvert extends TestCase {
|
||||
assertTrue(it.hasNext());
|
||||
MessagePackObject mpo = it.next();
|
||||
OptionalGeneralReferenceTypeFieldsClass dst = (OptionalGeneralReferenceTypeFieldsClass) tmpl
|
||||
.convert(mpo);
|
||||
.convert(mpo, null);
|
||||
assertEquals(src, dst);
|
||||
assertFalse(it.hasNext());
|
||||
}
|
||||
@ -443,7 +443,7 @@ public class TestPackConvert extends TestCase {
|
||||
Iterator<MessagePackObject> it = pac.iterator();
|
||||
assertTrue(it.hasNext());
|
||||
MessagePackObject mpo = it.next();
|
||||
SampleListTypes dst = (SampleListTypes) tmpl.convert(mpo);
|
||||
SampleListTypes dst = (SampleListTypes) tmpl.convert(mpo, null);
|
||||
assertEquals(src.f0.size(), dst.f0.size());
|
||||
assertEquals(src.f1.size(), dst.f1.size());
|
||||
for (int i = 0; i < src.f1.size(); ++i) {
|
||||
@ -493,7 +493,7 @@ public class TestPackConvert extends TestCase {
|
||||
Iterator<MessagePackObject> it = pac.iterator();
|
||||
assertTrue(it.hasNext());
|
||||
MessagePackObject mpo = it.next();
|
||||
SampleListTypes dst = (SampleListTypes) tmpl.convert(mpo);
|
||||
SampleListTypes dst = (SampleListTypes) tmpl.convert(mpo, null);
|
||||
assertEquals(src, dst);
|
||||
assertFalse(it.hasNext());
|
||||
}
|
||||
@ -553,7 +553,7 @@ public class TestPackConvert extends TestCase {
|
||||
assertTrue(it.hasNext());
|
||||
MessagePackObject mpo = it.next();
|
||||
SampleOptionalListTypes dst = (SampleOptionalListTypes) tmpl
|
||||
.convert(mpo);
|
||||
.convert(mpo, null);
|
||||
assertEquals(src.f0.size(), dst.f0.size());
|
||||
assertEquals(src.f1.size(), dst.f1.size());
|
||||
for (int i = 0; i < src.f1.size(); ++i) {
|
||||
@ -609,7 +609,7 @@ public class TestPackConvert extends TestCase {
|
||||
assertTrue(it.hasNext());
|
||||
MessagePackObject mpo = it.next();
|
||||
SampleOptionalListTypes dst = (SampleOptionalListTypes) tmpl
|
||||
.convert(mpo);
|
||||
.convert(mpo, null);
|
||||
assertEquals(src.f0.size(), dst.f0.size());
|
||||
assertEquals(src.f1, dst.f1);
|
||||
assertEquals(src.f2.size(), dst.f2.size());
|
||||
@ -634,7 +634,7 @@ public class TestPackConvert extends TestCase {
|
||||
assertTrue(it.hasNext());
|
||||
MessagePackObject mpo = it.next();
|
||||
SampleOptionalListTypes dst = (SampleOptionalListTypes) tmpl
|
||||
.convert(mpo);
|
||||
.convert(mpo, null);
|
||||
assertEquals(src, dst);
|
||||
assertFalse(it.hasNext());
|
||||
}
|
||||
@ -689,7 +689,7 @@ public class TestPackConvert extends TestCase {
|
||||
Iterator<MessagePackObject> it = pac.iterator();
|
||||
assertTrue(it.hasNext());
|
||||
MessagePackObject mpo = it.next();
|
||||
SampleMapTypes dst = (SampleMapTypes) tmpl.convert(mpo);
|
||||
SampleMapTypes dst = (SampleMapTypes) tmpl.convert(mpo, null);
|
||||
assertEquals(src.f0.size(), dst.f0.size());
|
||||
assertEquals(src.f1.size(), dst.f1.size());
|
||||
Iterator<Integer> srcf1 = src.f1.keySet().iterator();
|
||||
@ -726,7 +726,7 @@ public class TestPackConvert extends TestCase {
|
||||
Iterator<MessagePackObject> it = pac.iterator();
|
||||
assertTrue(it.hasNext());
|
||||
MessagePackObject mpo = it.next();
|
||||
SampleMapTypes dst = (SampleMapTypes) tmpl.convert(mpo);
|
||||
SampleMapTypes dst = (SampleMapTypes) tmpl.convert(mpo, null);
|
||||
assertEquals(src, dst);
|
||||
assertFalse(it.hasNext());
|
||||
}
|
||||
@ -762,7 +762,7 @@ public class TestPackConvert extends TestCase {
|
||||
Iterator<MessagePackObject> it = pac.iterator();
|
||||
assertTrue(it.hasNext());
|
||||
MessagePackObject mpo = it.next();
|
||||
SampleOptionalMapTypes dst = (SampleOptionalMapTypes) tmpl.convert(mpo);
|
||||
SampleOptionalMapTypes dst = (SampleOptionalMapTypes) tmpl.convert(mpo, null);
|
||||
assertEquals(src.f0.size(), dst.f0.size());
|
||||
assertEquals(src.f1.size(), dst.f1.size());
|
||||
Iterator<Integer> srcf1 = src.f1.keySet().iterator();
|
||||
@ -801,7 +801,7 @@ public class TestPackConvert extends TestCase {
|
||||
Iterator<MessagePackObject> it = pac.iterator();
|
||||
assertTrue(it.hasNext());
|
||||
MessagePackObject mpo = it.next();
|
||||
SampleOptionalMapTypes dst = (SampleOptionalMapTypes) tmpl.convert(mpo);
|
||||
SampleOptionalMapTypes dst = (SampleOptionalMapTypes) tmpl.convert(mpo, null);
|
||||
assertEquals(src.f0.size(), dst.f0.size());
|
||||
assertEquals(src.f1, dst.f1);
|
||||
assertEquals(src.f2.size(), dst.f2.size());
|
||||
@ -822,7 +822,7 @@ public class TestPackConvert extends TestCase {
|
||||
Iterator<MessagePackObject> it = pac.iterator();
|
||||
assertTrue(it.hasNext());
|
||||
MessagePackObject mpo = it.next();
|
||||
SampleOptionalMapTypes dst = (SampleOptionalMapTypes) tmpl.convert(mpo);
|
||||
SampleOptionalMapTypes dst = (SampleOptionalMapTypes) tmpl.convert(mpo, null);
|
||||
assertEquals(src, dst);
|
||||
assertFalse(it.hasNext());
|
||||
}
|
||||
@ -1072,7 +1072,7 @@ public class TestPackConvert extends TestCase {
|
||||
Iterator<MessagePackObject> it = pac.iterator();
|
||||
assertTrue(it.hasNext());
|
||||
MessagePackObject mpo = it.next();
|
||||
SampleEnumFieldClass dst = (SampleEnumFieldClass) tmpl.convert(mpo);
|
||||
SampleEnumFieldClass dst = (SampleEnumFieldClass) tmpl.convert(mpo, null);
|
||||
assertTrue(src.f0 == dst.f0);
|
||||
assertTrue(src.f1 == dst.f1);
|
||||
assertFalse(it.hasNext());
|
||||
@ -1092,7 +1092,7 @@ public class TestPackConvert extends TestCase {
|
||||
Iterator<MessagePackObject> it = pac.iterator();
|
||||
assertTrue(it.hasNext());
|
||||
MessagePackObject mpo = it.next();
|
||||
SampleEnumFieldClass dst = (SampleEnumFieldClass) tmpl.convert(mpo);
|
||||
SampleEnumFieldClass dst = (SampleEnumFieldClass) tmpl.convert(mpo, null);
|
||||
assertEquals(src, dst);
|
||||
assertFalse(it.hasNext());
|
||||
}
|
||||
@ -1127,7 +1127,7 @@ public class TestPackConvert extends TestCase {
|
||||
assertTrue(it.hasNext());
|
||||
MessagePackObject mpo = it.next();
|
||||
SampleOptionalEnumFieldClass dst = (SampleOptionalEnumFieldClass) tmpl
|
||||
.convert(mpo);
|
||||
.convert(mpo, null);
|
||||
assertTrue(src.f0 == dst.f0);
|
||||
assertTrue(src.f1 == dst.f1);
|
||||
assertFalse(it.hasNext());
|
||||
@ -1149,7 +1149,7 @@ public class TestPackConvert extends TestCase {
|
||||
assertTrue(it.hasNext());
|
||||
MessagePackObject mpo = it.next();
|
||||
SampleOptionalEnumFieldClass dst = (SampleOptionalEnumFieldClass) tmpl
|
||||
.convert(mpo);
|
||||
.convert(mpo, null);
|
||||
assertEquals(src.f0, dst.f0);
|
||||
assertEquals(src.f1, dst.f1);
|
||||
assertFalse(it.hasNext());
|
||||
@ -1170,7 +1170,7 @@ public class TestPackConvert extends TestCase {
|
||||
assertTrue(it.hasNext());
|
||||
MessagePackObject mpo = it.next();
|
||||
SampleOptionalEnumFieldClass dst = (SampleOptionalEnumFieldClass) tmpl
|
||||
.convert(mpo);
|
||||
.convert(mpo, null);
|
||||
assertEquals(src, dst);
|
||||
assertFalse(it.hasNext());
|
||||
}
|
||||
@ -1206,7 +1206,7 @@ public class TestPackConvert extends TestCase {
|
||||
Iterator<MessagePackObject> it = pac.iterator();
|
||||
assertTrue(it.hasNext());
|
||||
MessagePackObject mpo = it.next();
|
||||
FieldModifiersClass dst = (FieldModifiersClass) tmpl.convert(mpo);
|
||||
FieldModifiersClass dst = (FieldModifiersClass) tmpl.convert(mpo, null);
|
||||
assertTrue(src.f0 == dst.f0);
|
||||
assertTrue(src.f1 == dst.f1);
|
||||
assertTrue(src.f2 != dst.f2);
|
||||
@ -1245,7 +1245,7 @@ public class TestPackConvert extends TestCase {
|
||||
assertTrue(it.hasNext());
|
||||
MessagePackObject mpo = it.next();
|
||||
OptionalFieldModifiersClass dst = (OptionalFieldModifiersClass) tmpl
|
||||
.convert(mpo);
|
||||
.convert(mpo, null);
|
||||
assertTrue(src.f0 == dst.f0);
|
||||
assertTrue(src.f1 == dst.f1);
|
||||
assertTrue(src.f2 != dst.f2);
|
||||
@ -1429,7 +1429,7 @@ public class TestPackConvert extends TestCase {
|
||||
assertTrue(it.hasNext());
|
||||
MessagePackObject mpo = it.next();
|
||||
Template tmpl = DynamicTemplate.create(BaseClass2.class);
|
||||
BaseClass2 dst = (BaseClass2) tmpl.convert(mpo);
|
||||
BaseClass2 dst = (BaseClass2) tmpl.convert(mpo, null);
|
||||
assertTrue(src.f0 == dst.f0);
|
||||
assertTrue(src.f1.f2 == dst.f1.f2);
|
||||
assertFalse(it.hasNext());
|
||||
@ -1449,7 +1449,7 @@ public class TestPackConvert extends TestCase {
|
||||
MessagePackObject mpo = it.next();
|
||||
Template tmpl = new NullableTemplate(DynamicTemplate
|
||||
.create(BaseClass2.class));
|
||||
BaseClass2 dst = (BaseClass2) tmpl.convert(mpo);
|
||||
BaseClass2 dst = (BaseClass2) tmpl.convert(mpo, null);
|
||||
assertEquals(src, dst);
|
||||
assertFalse(it.hasNext());
|
||||
}
|
||||
@ -1486,7 +1486,7 @@ public class TestPackConvert extends TestCase {
|
||||
assertTrue(it.hasNext());
|
||||
MessagePackObject mpo = it.next();
|
||||
Template tmpl = DynamicTemplate.create(OptionalBaseClass2.class);
|
||||
OptionalBaseClass2 dst = (OptionalBaseClass2) tmpl.convert(mpo);
|
||||
OptionalBaseClass2 dst = (OptionalBaseClass2) tmpl.convert(mpo, null);
|
||||
assertTrue(src.f0 == dst.f0);
|
||||
assertTrue(src.f1.f2 == dst.f1.f2);
|
||||
assertFalse(it.hasNext());
|
||||
@ -1504,7 +1504,7 @@ public class TestPackConvert extends TestCase {
|
||||
assertTrue(it.hasNext());
|
||||
MessagePackObject mpo = it.next();
|
||||
Template tmpl = DynamicTemplate.create(OptionalBaseClass2.class);
|
||||
OptionalBaseClass2 dst = (OptionalBaseClass2) tmpl.convert(mpo);
|
||||
OptionalBaseClass2 dst = (OptionalBaseClass2) tmpl.convert(mpo, null);
|
||||
assertTrue(src.f0 == dst.f0);
|
||||
assertEquals(src.f1, dst.f1);
|
||||
assertFalse(it.hasNext());
|
||||
@ -1524,7 +1524,7 @@ public class TestPackConvert extends TestCase {
|
||||
MessagePackObject mpo = it.next();
|
||||
Template tmpl = new NullableTemplate(DynamicTemplate
|
||||
.create(OptionalBaseClass2.class));
|
||||
OptionalBaseClass2 dst = (OptionalBaseClass2) tmpl.convert(mpo);
|
||||
OptionalBaseClass2 dst = (OptionalBaseClass2) tmpl.convert(mpo, null);
|
||||
assertEquals(src, dst);
|
||||
assertFalse(it.hasNext());
|
||||
}
|
||||
@ -1567,7 +1567,7 @@ public class TestPackConvert extends TestCase {
|
||||
Iterator<MessagePackObject> it = pac.iterator();
|
||||
assertTrue(it.hasNext());
|
||||
MessagePackObject mpo = it.next();
|
||||
SampleSubClass dst = (SampleSubClass) tmpl.convert(mpo);
|
||||
SampleSubClass dst = (SampleSubClass) tmpl.convert(mpo, null);
|
||||
assertTrue(src.f0 == dst.f0);
|
||||
assertTrue(src.f1 == dst.f1);
|
||||
assertTrue(src.f2 != dst.f2);
|
||||
@ -1594,7 +1594,7 @@ public class TestPackConvert extends TestCase {
|
||||
Iterator<MessagePackObject> it = pac.iterator();
|
||||
assertTrue(it.hasNext());
|
||||
MessagePackObject mpo = it.next();
|
||||
SampleSubClass dst = (SampleSubClass) tmpl.convert(mpo);
|
||||
SampleSubClass dst = (SampleSubClass) tmpl.convert(mpo, null);
|
||||
assertEquals(src, dst);
|
||||
assertFalse(it.hasNext());
|
||||
}
|
||||
@ -1642,7 +1642,7 @@ public class TestPackConvert extends TestCase {
|
||||
Iterator<MessagePackObject> it = pac.iterator();
|
||||
assertTrue(it.hasNext());
|
||||
MessagePackObject mpo = it.next();
|
||||
SampleOptionalSubClass dst = (SampleOptionalSubClass) tmpl.convert(mpo);
|
||||
SampleOptionalSubClass dst = (SampleOptionalSubClass) tmpl.convert(mpo, null);
|
||||
assertTrue(src.f0 == dst.f0);
|
||||
assertTrue(src.f1 == dst.f1);
|
||||
assertTrue(src.f2 != dst.f2);
|
||||
@ -1669,7 +1669,7 @@ public class TestPackConvert extends TestCase {
|
||||
Iterator<MessagePackObject> it = pac.iterator();
|
||||
assertTrue(it.hasNext());
|
||||
MessagePackObject mpo = it.next();
|
||||
SampleOptionalSubClass dst = (SampleOptionalSubClass) tmpl.convert(mpo);
|
||||
SampleOptionalSubClass dst = (SampleOptionalSubClass) tmpl.convert(mpo, null);
|
||||
assertEquals(src, dst);
|
||||
assertFalse(it.hasNext());
|
||||
}
|
||||
@ -1722,7 +1722,7 @@ public class TestPackConvert extends TestCase {
|
||||
assertTrue(it.hasNext());
|
||||
MessagePackObject mpo = it.next();
|
||||
BaseMessagePackableConvertableClass dst = (BaseMessagePackableConvertableClass) tmpl
|
||||
.convert(mpo);
|
||||
.convert(mpo, null);
|
||||
assertEquals(src.f0.f0, dst.f0.f0);
|
||||
assertEquals(src.f0.f1, dst.f0.f1);
|
||||
assertEquals(src.f1, dst.f1);
|
||||
@ -1747,7 +1747,7 @@ public class TestPackConvert extends TestCase {
|
||||
assertTrue(it.hasNext());
|
||||
MessagePackObject mpo = it.next();
|
||||
BaseMessagePackableConvertableClass dst = (BaseMessagePackableConvertableClass) tmpl
|
||||
.convert(mpo);
|
||||
.convert(mpo, null);
|
||||
assertEquals(src, dst);
|
||||
assertFalse(it.hasNext());
|
||||
}
|
||||
@ -1811,7 +1811,7 @@ public class TestPackConvert extends TestCase {
|
||||
assertTrue(it.hasNext());
|
||||
MessagePackObject mpo = it.next();
|
||||
OptionalBaseMessagePackableConvertableClass dst = (OptionalBaseMessagePackableConvertableClass) tmpl
|
||||
.convert(mpo);
|
||||
.convert(mpo, null);
|
||||
assertEquals(src.f0.f0, dst.f0.f0);
|
||||
assertEquals(src.f0.f1, dst.f0.f1);
|
||||
assertEquals(src.f1, dst.f1);
|
||||
@ -1839,7 +1839,7 @@ public class TestPackConvert extends TestCase {
|
||||
assertTrue(it.hasNext());
|
||||
MessagePackObject mpo = it.next();
|
||||
OptionalBaseMessagePackableConvertableClass dst = (OptionalBaseMessagePackableConvertableClass) tmpl
|
||||
.convert(mpo);
|
||||
.convert(mpo, null);
|
||||
assertEquals(src.f0, dst.f0);
|
||||
assertEquals(src.f1, dst.f1);
|
||||
assertEquals(src.f2, dst.f2);
|
||||
@ -1861,7 +1861,7 @@ public class TestPackConvert extends TestCase {
|
||||
assertTrue(it.hasNext());
|
||||
MessagePackObject mpo = it.next();
|
||||
OptionalBaseMessagePackableConvertableClass dst = (OptionalBaseMessagePackableConvertableClass) tmpl
|
||||
.convert(mpo);
|
||||
.convert(mpo, null);
|
||||
assertEquals(src, dst);
|
||||
assertFalse(it.hasNext());
|
||||
}
|
||||
|
@ -65,7 +65,7 @@ public class TestPackConvertWithFieldOption extends TestCase {
|
||||
Iterator<MessagePackObject> it = pac.iterator();
|
||||
assertTrue(it.hasNext());
|
||||
MessagePackObject mpo = it.next();
|
||||
PrimitiveTypeFieldsClass dst = (PrimitiveTypeFieldsClass) tmpl.convert(mpo);
|
||||
PrimitiveTypeFieldsClass dst = (PrimitiveTypeFieldsClass) tmpl.convert(mpo, null);
|
||||
assertEquals(src.f0, dst.f0);
|
||||
assertEquals(src.f1, dst.f1);
|
||||
assertEquals(src.f2, dst.f2);
|
||||
@ -98,7 +98,7 @@ public class TestPackConvertWithFieldOption extends TestCase {
|
||||
Iterator<MessagePackObject> it = pac.iterator();
|
||||
assertTrue(it.hasNext());
|
||||
MessagePackObject mpo = it.next();
|
||||
PrimitiveTypeFieldsClass dst = (PrimitiveTypeFieldsClass) tmpl.convert(mpo);
|
||||
PrimitiveTypeFieldsClass dst = (PrimitiveTypeFieldsClass) tmpl.convert(mpo, null);
|
||||
assertEquals(src.f0, dst.f0);
|
||||
assertEquals(src.f1, dst.f1);
|
||||
assertEquals(src.f2, dst.f2);
|
||||
@ -131,7 +131,7 @@ public class TestPackConvertWithFieldOption extends TestCase {
|
||||
Iterator<MessagePackObject> it = pac.iterator();
|
||||
assertTrue(it.hasNext());
|
||||
MessagePackObject mpo = it.next();
|
||||
PrimitiveTypeFieldsClass dst = (PrimitiveTypeFieldsClass) tmpl.convert(mpo);
|
||||
PrimitiveTypeFieldsClass dst = (PrimitiveTypeFieldsClass) tmpl.convert(mpo, null);
|
||||
assertEquals(src, dst);
|
||||
assertFalse(it.hasNext());
|
||||
}
|
||||
@ -184,7 +184,7 @@ public class TestPackConvertWithFieldOption extends TestCase {
|
||||
Iterator<MessagePackObject> it = pac.iterator();
|
||||
assertTrue(it.hasNext());
|
||||
MessagePackObject mpo = it.next();
|
||||
GeneralReferenceTypeFieldsClass dst = (GeneralReferenceTypeFieldsClass) tmpl.convert(mpo);
|
||||
GeneralReferenceTypeFieldsClass dst = (GeneralReferenceTypeFieldsClass) tmpl.convert(mpo, null);
|
||||
assertEquals(src.f0, dst.f0);
|
||||
assertEquals(src.f1, dst.f1);
|
||||
assertEquals(src.f2, dst.f2);
|
||||
@ -234,7 +234,7 @@ public class TestPackConvertWithFieldOption extends TestCase {
|
||||
Iterator<MessagePackObject> it = pac.iterator();
|
||||
assertTrue(it.hasNext());
|
||||
MessagePackObject mpo = it.next();
|
||||
GeneralReferenceTypeFieldsClass dst = (GeneralReferenceTypeFieldsClass) tmpl.convert(mpo);
|
||||
GeneralReferenceTypeFieldsClass dst = (GeneralReferenceTypeFieldsClass) tmpl.convert(mpo, null);
|
||||
assertEquals(src.f0, dst.f0);
|
||||
assertEquals(src.f1, dst.f1);
|
||||
assertEquals(src.f2, dst.f2);
|
||||
@ -275,7 +275,7 @@ public class TestPackConvertWithFieldOption extends TestCase {
|
||||
Iterator<MessagePackObject> it = pac.iterator();
|
||||
assertTrue(it.hasNext());
|
||||
MessagePackObject mpo = it.next();
|
||||
GeneralReferenceTypeFieldsClass dst = (GeneralReferenceTypeFieldsClass) tmpl.convert(mpo);
|
||||
GeneralReferenceTypeFieldsClass dst = (GeneralReferenceTypeFieldsClass) tmpl.convert(mpo, null);
|
||||
assertEquals(src, dst);
|
||||
assertFalse(it.hasNext());
|
||||
}
|
||||
@ -332,7 +332,7 @@ public class TestPackConvertWithFieldOption extends TestCase {
|
||||
Iterator<MessagePackObject> it = pac.iterator();
|
||||
assertTrue(it.hasNext());
|
||||
MessagePackObject mpo = it.next();
|
||||
SampleListTypes dst = (SampleListTypes) tmpl.convert(mpo);
|
||||
SampleListTypes dst = (SampleListTypes) tmpl.convert(mpo, null);
|
||||
assertEquals(src.f0.size(), dst.f0.size());
|
||||
assertEquals(src.f1.size(), dst.f1.size());
|
||||
for (int i = 0; i < src.f1.size(); ++i) {
|
||||
@ -387,7 +387,7 @@ public class TestPackConvertWithFieldOption extends TestCase {
|
||||
Iterator<MessagePackObject> it = pac.iterator();
|
||||
assertTrue(it.hasNext());
|
||||
MessagePackObject mpo = it.next();
|
||||
SampleListTypes dst = (SampleListTypes) tmpl.convert(mpo);
|
||||
SampleListTypes dst = (SampleListTypes) tmpl.convert(mpo, null);
|
||||
assertEquals(src.f0.size(), dst.f0.size());
|
||||
assertEquals(src.f1, dst.f1);
|
||||
assertEquals(src.f2.size(), dst.f2.size());
|
||||
@ -417,7 +417,7 @@ public class TestPackConvertWithFieldOption extends TestCase {
|
||||
Iterator<MessagePackObject> it = pac.iterator();
|
||||
assertTrue(it.hasNext());
|
||||
MessagePackObject mpo = it.next();
|
||||
SampleListTypes dst = (SampleListTypes) tmpl.convert(mpo);
|
||||
SampleListTypes dst = (SampleListTypes) tmpl.convert(mpo, null);
|
||||
assertEquals(src, dst);
|
||||
assertFalse(it.hasNext());
|
||||
}
|
||||
@ -469,7 +469,7 @@ public class TestPackConvertWithFieldOption extends TestCase {
|
||||
Iterator<MessagePackObject> it = pac.iterator();
|
||||
assertTrue(it.hasNext());
|
||||
MessagePackObject mpo = it.next();
|
||||
SampleMapTypes dst = (SampleMapTypes) tmpl.convert(mpo);
|
||||
SampleMapTypes dst = (SampleMapTypes) tmpl.convert(mpo, null);
|
||||
assertEquals(src.f0.size(), dst.f0.size());
|
||||
assertEquals(src.f1.size(), dst.f1.size());
|
||||
Iterator<Integer> srcf1 = src.f1.keySet().iterator();
|
||||
@ -513,7 +513,7 @@ public class TestPackConvertWithFieldOption extends TestCase {
|
||||
Iterator<MessagePackObject> it = pac.iterator();
|
||||
assertTrue(it.hasNext());
|
||||
MessagePackObject mpo = it.next();
|
||||
SampleMapTypes dst = (SampleMapTypes) tmpl.convert(mpo);
|
||||
SampleMapTypes dst = (SampleMapTypes) tmpl.convert(mpo, null);
|
||||
assertEquals(src.f0.size(), dst.f0.size());
|
||||
assertEquals(src.f1, dst.f1);
|
||||
assertEquals(src.f2.size(), dst.f2.size());
|
||||
@ -538,7 +538,7 @@ public class TestPackConvertWithFieldOption extends TestCase {
|
||||
Iterator<MessagePackObject> it = pac.iterator();
|
||||
assertTrue(it.hasNext());
|
||||
MessagePackObject mpo = it.next();
|
||||
SampleMapTypes dst = (SampleMapTypes) tmpl.convert(mpo);
|
||||
SampleMapTypes dst = (SampleMapTypes) tmpl.convert(mpo, null);
|
||||
assertEquals(src, dst);
|
||||
assertFalse(it.hasNext());
|
||||
}
|
||||
|
@ -47,7 +47,7 @@ public class TestPackUnpack extends TestCase {
|
||||
ByteArrayInputStream in = new ByteArrayInputStream(out.toByteArray());
|
||||
Template tmpl = DynamicTemplate.create(PrimitiveTypeFieldsClass.class);
|
||||
PrimitiveTypeFieldsClass dst = (PrimitiveTypeFieldsClass) tmpl
|
||||
.unpack(new Unpacker(in));
|
||||
.unpack(new Unpacker(in), null);
|
||||
assertEquals(src.f0, dst.f0);
|
||||
assertEquals(src.f1, dst.f1);
|
||||
assertEquals(src.f2, dst.f2);
|
||||
@ -67,7 +67,7 @@ public class TestPackUnpack extends TestCase {
|
||||
ByteArrayInputStream in = new ByteArrayInputStream(out.toByteArray());
|
||||
Template tmpl = DynamicTemplate.create(PrimitiveTypeFieldsClass.class);
|
||||
PrimitiveTypeFieldsClass dst = (PrimitiveTypeFieldsClass) tmpl
|
||||
.unpack(new Unpacker(in));
|
||||
.unpack(new Unpacker(in), null);
|
||||
assertEquals(src.f0, dst.f0);
|
||||
assertEquals(src.f1, dst.f1);
|
||||
assertEquals(src.f2, dst.f2);
|
||||
@ -88,7 +88,7 @@ public class TestPackUnpack extends TestCase {
|
||||
Template tmpl = new NullableTemplate(DynamicTemplate
|
||||
.create(PrimitiveTypeFieldsClass.class));
|
||||
PrimitiveTypeFieldsClass dst = (PrimitiveTypeFieldsClass) tmpl
|
||||
.unpack(new Unpacker(in));
|
||||
.unpack(new Unpacker(in), null);
|
||||
assertEquals(src, dst);
|
||||
}
|
||||
|
||||
@ -123,7 +123,7 @@ public class TestPackUnpack extends TestCase {
|
||||
Template tmpl = DynamicTemplate
|
||||
.create(OptionalPrimitiveTypeFieldsClass.class);
|
||||
OptionalPrimitiveTypeFieldsClass dst = (OptionalPrimitiveTypeFieldsClass) tmpl
|
||||
.unpack(new Unpacker(in));
|
||||
.unpack(new Unpacker(in), null);
|
||||
assertEquals(src.f0, dst.f0);
|
||||
assertEquals(src.f1, dst.f1);
|
||||
assertEquals(src.f2, dst.f2);
|
||||
@ -144,7 +144,7 @@ public class TestPackUnpack extends TestCase {
|
||||
Template tmpl = DynamicTemplate
|
||||
.create(OptionalPrimitiveTypeFieldsClass.class);
|
||||
OptionalPrimitiveTypeFieldsClass dst = (OptionalPrimitiveTypeFieldsClass) tmpl
|
||||
.unpack(new Unpacker(in));
|
||||
.unpack(new Unpacker(in), null);
|
||||
assertEquals(src.f0, dst.f0);
|
||||
assertEquals(src.f1, dst.f1);
|
||||
assertEquals(src.f2, dst.f2);
|
||||
@ -165,7 +165,7 @@ public class TestPackUnpack extends TestCase {
|
||||
Template tmpl = new NullableTemplate(DynamicTemplate
|
||||
.create(OptionalPrimitiveTypeFieldsClass.class));
|
||||
OptionalPrimitiveTypeFieldsClass dst = (OptionalPrimitiveTypeFieldsClass) tmpl
|
||||
.unpack(new Unpacker(in));
|
||||
.unpack(new Unpacker(in), null);
|
||||
assertEquals(src, dst);
|
||||
}
|
||||
|
||||
@ -211,7 +211,7 @@ public class TestPackUnpack extends TestCase {
|
||||
Template tmpl = DynamicTemplate
|
||||
.create(GeneralReferenceTypeFieldsClass.class);
|
||||
GeneralReferenceTypeFieldsClass dst = (GeneralReferenceTypeFieldsClass) tmpl
|
||||
.unpack(new Unpacker(in));
|
||||
.unpack(new Unpacker(in), null);
|
||||
assertEquals(src.f0, dst.f0);
|
||||
assertEquals(src.f1, dst.f1);
|
||||
assertEquals(src.f2, dst.f2);
|
||||
@ -237,7 +237,7 @@ public class TestPackUnpack extends TestCase {
|
||||
Template tmpl = new NullableTemplate(DynamicTemplate
|
||||
.create(GeneralReferenceTypeFieldsClass.class));
|
||||
GeneralReferenceTypeFieldsClass dst = (GeneralReferenceTypeFieldsClass) tmpl
|
||||
.unpack(new Unpacker(in));
|
||||
.unpack(new Unpacker(in), null);
|
||||
assertEquals(src, dst);
|
||||
}
|
||||
|
||||
@ -281,7 +281,7 @@ public class TestPackUnpack extends TestCase {
|
||||
Template tmpl = DynamicTemplate
|
||||
.create(GeneralOptionalReferenceTypeFieldsClass.class);
|
||||
GeneralOptionalReferenceTypeFieldsClass dst = (GeneralOptionalReferenceTypeFieldsClass) tmpl
|
||||
.unpack(new Unpacker(in));
|
||||
.unpack(new Unpacker(in), null);
|
||||
assertEquals(src.f0, dst.f0);
|
||||
assertEquals(src.f1, dst.f1);
|
||||
assertEquals(src.f2, dst.f2);
|
||||
@ -319,7 +319,7 @@ public class TestPackUnpack extends TestCase {
|
||||
Template tmpl = DynamicTemplate
|
||||
.create(GeneralOptionalReferenceTypeFieldsClass.class);
|
||||
GeneralOptionalReferenceTypeFieldsClass dst = (GeneralOptionalReferenceTypeFieldsClass) tmpl
|
||||
.unpack(new Unpacker(in));
|
||||
.unpack(new Unpacker(in), null);
|
||||
assertEquals(src.f0, dst.f0);
|
||||
assertEquals(src.f1, dst.f1);
|
||||
assertEquals(src.f2, dst.f2);
|
||||
@ -345,7 +345,7 @@ public class TestPackUnpack extends TestCase {
|
||||
Template tmpl = new NullableTemplate(DynamicTemplate
|
||||
.create(GeneralOptionalReferenceTypeFieldsClass.class));
|
||||
GeneralOptionalReferenceTypeFieldsClass dst = (GeneralOptionalReferenceTypeFieldsClass) tmpl
|
||||
.unpack(new Unpacker(in));
|
||||
.unpack(new Unpacker(in), null);
|
||||
assertEquals(src, dst);
|
||||
}
|
||||
|
||||
@ -405,7 +405,7 @@ public class TestPackUnpack extends TestCase {
|
||||
packer.pack(new Packer(out), src);
|
||||
ByteArrayInputStream in = new ByteArrayInputStream(out.toByteArray());
|
||||
Template tmpl = DynamicTemplate.create(SampleListTypes.class);
|
||||
SampleListTypes dst = (SampleListTypes) tmpl.unpack(new Unpacker(in));
|
||||
SampleListTypes dst = (SampleListTypes) tmpl.unpack(new Unpacker(in), null);
|
||||
assertEquals(src.f0.size(), dst.f0.size());
|
||||
assertEquals(src.f1.size(), dst.f1.size());
|
||||
for (int i = 0; i < src.f1.size(); ++i) {
|
||||
@ -450,7 +450,7 @@ public class TestPackUnpack extends TestCase {
|
||||
ByteArrayInputStream in = new ByteArrayInputStream(out.toByteArray());
|
||||
Template tmpl = new NullableTemplate(DynamicTemplate
|
||||
.create(SampleListTypes.class));
|
||||
SampleListTypes dst = (SampleListTypes) tmpl.unpack(new Unpacker(in));
|
||||
SampleListTypes dst = (SampleListTypes) tmpl.unpack(new Unpacker(in), null);
|
||||
assertEquals(src, dst);
|
||||
}
|
||||
|
||||
@ -505,7 +505,7 @@ public class TestPackUnpack extends TestCase {
|
||||
ByteArrayInputStream in = new ByteArrayInputStream(out.toByteArray());
|
||||
Template tmpl = DynamicTemplate.create(SampleOptionalListTypes.class);
|
||||
SampleOptionalListTypes dst = (SampleOptionalListTypes) tmpl
|
||||
.unpack(new Unpacker(in));
|
||||
.unpack(new Unpacker(in), null);
|
||||
assertEquals(src.f0.size(), dst.f0.size());
|
||||
assertEquals(src.f1.size(), dst.f1.size());
|
||||
for (int i = 0; i < src.f1.size(); ++i) {
|
||||
@ -556,7 +556,7 @@ public class TestPackUnpack extends TestCase {
|
||||
ByteArrayInputStream in = new ByteArrayInputStream(out.toByteArray());
|
||||
Template tmpl = DynamicTemplate.create(SampleOptionalListTypes.class);
|
||||
SampleOptionalListTypes dst = (SampleOptionalListTypes) tmpl
|
||||
.unpack(new Unpacker(in));
|
||||
.unpack(new Unpacker(in), null);
|
||||
assertEquals(src.f0.size(), dst.f0.size());
|
||||
assertEquals(src.f1, dst.f1);
|
||||
assertEquals(src.f2.size(), dst.f2.size());
|
||||
@ -575,7 +575,7 @@ public class TestPackUnpack extends TestCase {
|
||||
ByteArrayInputStream in = new ByteArrayInputStream(out.toByteArray());
|
||||
Template tmpl = new NullableTemplate(DynamicTemplate
|
||||
.create(SampleOptionalListTypes.class));
|
||||
SampleListTypes dst = (SampleListTypes) tmpl.unpack(new Unpacker(in));
|
||||
SampleListTypes dst = (SampleListTypes) tmpl.unpack(new Unpacker(in), null);
|
||||
assertEquals(src, dst);
|
||||
}
|
||||
|
||||
@ -625,7 +625,7 @@ public class TestPackUnpack extends TestCase {
|
||||
packer.pack(new Packer(out), src);
|
||||
ByteArrayInputStream in = new ByteArrayInputStream(out.toByteArray());
|
||||
Template tmpl = DynamicTemplate.create(SampleMapTypes.class);
|
||||
SampleMapTypes dst = (SampleMapTypes) tmpl.unpack(new Unpacker(in));
|
||||
SampleMapTypes dst = (SampleMapTypes) tmpl.unpack(new Unpacker(in), null);
|
||||
assertEquals(src.f0.size(), dst.f0.size());
|
||||
assertEquals(src.f1.size(), dst.f1.size());
|
||||
Iterator<Integer> srcf1 = src.f1.keySet().iterator();
|
||||
@ -657,7 +657,7 @@ public class TestPackUnpack extends TestCase {
|
||||
ByteArrayInputStream in = new ByteArrayInputStream(out.toByteArray());
|
||||
Template tmpl = new NullableTemplate(DynamicTemplate
|
||||
.create(SampleMapTypes.class));
|
||||
SampleMapTypes dst = (SampleMapTypes) tmpl.unpack(new Unpacker(in));
|
||||
SampleMapTypes dst = (SampleMapTypes) tmpl.unpack(new Unpacker(in), null);
|
||||
assertEquals(src, dst);
|
||||
}
|
||||
|
||||
@ -689,7 +689,7 @@ public class TestPackUnpack extends TestCase {
|
||||
ByteArrayInputStream in = new ByteArrayInputStream(out.toByteArray());
|
||||
Template tmpl = DynamicTemplate.create(SampleOptionalMapTypes.class);
|
||||
SampleOptionalMapTypes dst = (SampleOptionalMapTypes) tmpl
|
||||
.unpack(new Unpacker(in));
|
||||
.unpack(new Unpacker(in), null);
|
||||
assertEquals(src.f0.size(), dst.f0.size());
|
||||
assertEquals(src.f1.size(), dst.f1.size());
|
||||
Iterator<Integer> srcf1 = src.f1.keySet().iterator();
|
||||
@ -724,7 +724,7 @@ public class TestPackUnpack extends TestCase {
|
||||
ByteArrayInputStream in = new ByteArrayInputStream(out.toByteArray());
|
||||
Template tmpl = DynamicTemplate.create(SampleOptionalMapTypes.class);
|
||||
SampleOptionalMapTypes dst = (SampleOptionalMapTypes) tmpl
|
||||
.unpack(new Unpacker(in));
|
||||
.unpack(new Unpacker(in), null);
|
||||
assertEquals(src.f0.size(), dst.f0.size());
|
||||
assertEquals(src.f1, dst.f1);
|
||||
assertEquals(src.f2.size(), dst.f2.size());
|
||||
@ -741,7 +741,7 @@ public class TestPackUnpack extends TestCase {
|
||||
Template tmpl = new NullableTemplate(DynamicTemplate
|
||||
.create(SampleOptionalMapTypes.class));
|
||||
SampleOptionalMapTypes dst = (SampleOptionalMapTypes) tmpl
|
||||
.unpack(new Unpacker(in));
|
||||
.unpack(new Unpacker(in), null);
|
||||
assertEquals(src, dst);
|
||||
}
|
||||
|
||||
@ -980,7 +980,7 @@ public class TestPackUnpack extends TestCase {
|
||||
ByteArrayInputStream in = new ByteArrayInputStream(out.toByteArray());
|
||||
Template tmpl = DynamicTemplate.create(SampleEnumFieldClass.class);
|
||||
SampleEnumFieldClass dst = (SampleEnumFieldClass) tmpl
|
||||
.unpack(new Unpacker(in));
|
||||
.unpack(new Unpacker(in), null);
|
||||
assertTrue(src.f0 == dst.f0);
|
||||
assertTrue(src.f1 == dst.f1);
|
||||
}
|
||||
@ -996,7 +996,7 @@ public class TestPackUnpack extends TestCase {
|
||||
Template tmpl = new NullableTemplate(DynamicTemplate
|
||||
.create(SampleEnumFieldClass.class));
|
||||
SampleEnumFieldClass dst = (SampleEnumFieldClass) tmpl
|
||||
.unpack(new Unpacker(in));
|
||||
.unpack(new Unpacker(in), null);
|
||||
assertEquals(src, dst);
|
||||
}
|
||||
|
||||
@ -1027,7 +1027,7 @@ public class TestPackUnpack extends TestCase {
|
||||
Template tmpl = DynamicTemplate
|
||||
.create(SampleOptionalEnumFieldClass.class);
|
||||
SampleOptionalEnumFieldClass dst = (SampleOptionalEnumFieldClass) tmpl
|
||||
.unpack(new Unpacker(in));
|
||||
.unpack(new Unpacker(in), null);
|
||||
assertTrue(src.f0 == dst.f0);
|
||||
assertTrue(src.f1 == dst.f1);
|
||||
}
|
||||
@ -1044,7 +1044,7 @@ public class TestPackUnpack extends TestCase {
|
||||
Template tmpl = DynamicTemplate
|
||||
.create(SampleOptionalEnumFieldClass.class);
|
||||
SampleOptionalEnumFieldClass dst = (SampleOptionalEnumFieldClass) tmpl
|
||||
.unpack(new Unpacker(in));
|
||||
.unpack(new Unpacker(in), null);
|
||||
assertTrue(src.f0 == dst.f0);
|
||||
assertEquals(src.f1, dst.f1);
|
||||
}
|
||||
@ -1060,7 +1060,7 @@ public class TestPackUnpack extends TestCase {
|
||||
Template tmpl = new NullableTemplate(DynamicTemplate
|
||||
.create(SampleEnumFieldClass.class));
|
||||
SampleEnumFieldClass dst = (SampleEnumFieldClass) tmpl
|
||||
.unpack(new Unpacker(in));
|
||||
.unpack(new Unpacker(in), null);
|
||||
assertEquals(src, dst);
|
||||
}
|
||||
|
||||
@ -1093,7 +1093,7 @@ public class TestPackUnpack extends TestCase {
|
||||
ByteArrayInputStream in = new ByteArrayInputStream(out.toByteArray());
|
||||
Template tmpl = DynamicTemplate.create(FieldModifiersClass.class);
|
||||
FieldModifiersClass dst = (FieldModifiersClass) tmpl
|
||||
.unpack(new Unpacker(in));
|
||||
.unpack(new Unpacker(in), null);
|
||||
assertTrue(src.f0 == dst.f0);
|
||||
assertTrue(src.f1 == dst.f1);
|
||||
assertTrue(src.f2 != dst.f2);
|
||||
@ -1127,7 +1127,7 @@ public class TestPackUnpack extends TestCase {
|
||||
Template tmpl = DynamicTemplate
|
||||
.create(OptionalFieldModifiersClass.class);
|
||||
OptionalFieldModifiersClass dst = (OptionalFieldModifiersClass) tmpl
|
||||
.unpack(new Unpacker(in));
|
||||
.unpack(new Unpacker(in), null);
|
||||
assertTrue(src.f0 == dst.f0);
|
||||
assertTrue(src.f1 == dst.f1);
|
||||
assertTrue(src.f2 != dst.f2);
|
||||
@ -1162,7 +1162,7 @@ public class TestPackUnpack extends TestCase {
|
||||
ByteArrayOutputStream out = new ByteArrayOutputStream();
|
||||
tmpl.pack(new Packer(out), src);
|
||||
ByteArrayInputStream in = new ByteArrayInputStream(out.toByteArray());
|
||||
BaseClass dst = (BaseClass) tmpl.unpack(new Unpacker(in));
|
||||
BaseClass dst = (BaseClass) tmpl.unpack(new Unpacker(in), null);
|
||||
assertTrue(src.f0 == dst.f0);
|
||||
assertTrue(src.f1.f2 == dst.f1.f2);
|
||||
}
|
||||
@ -1176,7 +1176,7 @@ public class TestPackUnpack extends TestCase {
|
||||
ByteArrayOutputStream out = new ByteArrayOutputStream();
|
||||
tmpl.pack(new Packer(out), src);
|
||||
ByteArrayInputStream in = new ByteArrayInputStream(out.toByteArray());
|
||||
BaseClass dst = (BaseClass) tmpl.unpack(new Unpacker(in));
|
||||
BaseClass dst = (BaseClass) tmpl.unpack(new Unpacker(in), null);
|
||||
assertEquals(src, dst);
|
||||
}
|
||||
|
||||
@ -1208,7 +1208,7 @@ public class TestPackUnpack extends TestCase {
|
||||
ByteArrayOutputStream out = new ByteArrayOutputStream();
|
||||
tmpl.pack(new Packer(out), src);
|
||||
ByteArrayInputStream in = new ByteArrayInputStream(out.toByteArray());
|
||||
OptionalBaseClass dst = (OptionalBaseClass) tmpl.unpack(new Unpacker(in));
|
||||
OptionalBaseClass dst = (OptionalBaseClass) tmpl.unpack(new Unpacker(in), null);
|
||||
assertTrue(src.f0 == dst.f0);
|
||||
assertTrue(src.f1.f2 == dst.f1.f2);
|
||||
}
|
||||
@ -1224,7 +1224,7 @@ public class TestPackUnpack extends TestCase {
|
||||
ByteArrayOutputStream out = new ByteArrayOutputStream();
|
||||
tmpl.pack(new Packer(out), src);
|
||||
ByteArrayInputStream in = new ByteArrayInputStream(out.toByteArray());
|
||||
OptionalBaseClass dst = (OptionalBaseClass) tmpl.unpack(new Unpacker(in));
|
||||
OptionalBaseClass dst = (OptionalBaseClass) tmpl.unpack(new Unpacker(in), null);
|
||||
assertTrue(src.f0 == dst.f0);
|
||||
assertTrue(src.f1 == dst.f1);
|
||||
}
|
||||
@ -1240,7 +1240,7 @@ public class TestPackUnpack extends TestCase {
|
||||
tmpl.pack(new Packer(out), src);
|
||||
ByteArrayInputStream in = new ByteArrayInputStream(out.toByteArray());
|
||||
OptionalBaseClass dst = (OptionalBaseClass) tmpl
|
||||
.unpack(new Unpacker(in));
|
||||
.unpack(new Unpacker(in), null);
|
||||
assertEquals(src, dst);
|
||||
}
|
||||
|
||||
@ -1274,7 +1274,7 @@ public class TestPackUnpack extends TestCase {
|
||||
packer.pack(new Packer(out), src);
|
||||
ByteArrayInputStream in = new ByteArrayInputStream(out.toByteArray());
|
||||
Template tmpl = DynamicTemplate.create(BaseClass2.class);
|
||||
BaseClass2 dst = (BaseClass2) tmpl.unpack(new Unpacker(in));
|
||||
BaseClass2 dst = (BaseClass2) tmpl.unpack(new Unpacker(in), null);
|
||||
assertTrue(src.f0 == dst.f0);
|
||||
assertTrue(src.f1.f2 == dst.f1.f2);
|
||||
}
|
||||
@ -1289,7 +1289,7 @@ public class TestPackUnpack extends TestCase {
|
||||
ByteArrayInputStream in = new ByteArrayInputStream(out.toByteArray());
|
||||
Template tmpl = new NullableTemplate(DynamicTemplate
|
||||
.create(BaseClass2.class));
|
||||
BaseClass2 dst = (BaseClass2) tmpl.unpack(new Unpacker(in));
|
||||
BaseClass2 dst = (BaseClass2) tmpl.unpack(new Unpacker(in), null);
|
||||
assertEquals(src, dst);
|
||||
}
|
||||
|
||||
@ -1321,8 +1321,7 @@ public class TestPackUnpack extends TestCase {
|
||||
packer.pack(new Packer(out), src);
|
||||
ByteArrayInputStream in = new ByteArrayInputStream(out.toByteArray());
|
||||
Template tmpl = DynamicTemplate.create(OptionalBaseClass2.class);
|
||||
OptionalBaseClass2 dst = (OptionalBaseClass2) tmpl.unpack(new Unpacker(
|
||||
in));
|
||||
OptionalBaseClass2 dst = (OptionalBaseClass2) tmpl.unpack(new Unpacker(in), null);
|
||||
assertTrue(src.f0 == dst.f0);
|
||||
assertTrue(src.f1.f2 == dst.f1.f2);
|
||||
}
|
||||
@ -1336,8 +1335,7 @@ public class TestPackUnpack extends TestCase {
|
||||
packer.pack(new Packer(out), src);
|
||||
ByteArrayInputStream in = new ByteArrayInputStream(out.toByteArray());
|
||||
Template tmpl = DynamicTemplate.create(OptionalBaseClass2.class);
|
||||
OptionalBaseClass2 dst = (OptionalBaseClass2) tmpl.unpack(new Unpacker(
|
||||
in));
|
||||
OptionalBaseClass2 dst = (OptionalBaseClass2) tmpl.unpack(new Unpacker(in), null);
|
||||
assertTrue(src.f0 == dst.f0);
|
||||
assertEquals(src.f1, dst.f1);
|
||||
}
|
||||
@ -1352,8 +1350,7 @@ public class TestPackUnpack extends TestCase {
|
||||
ByteArrayInputStream in = new ByteArrayInputStream(out.toByteArray());
|
||||
Template tmpl = new NullableTemplate(DynamicTemplate
|
||||
.create(OptionalBaseClass2.class));
|
||||
OptionalBaseClass2 dst = (OptionalBaseClass2) tmpl.unpack(new Unpacker(
|
||||
in));
|
||||
OptionalBaseClass2 dst = (OptionalBaseClass2) tmpl.unpack(new Unpacker(in), null);
|
||||
assertEquals(src, dst);
|
||||
}
|
||||
|
||||
@ -1391,7 +1388,7 @@ public class TestPackUnpack extends TestCase {
|
||||
packer.pack(new Packer(out), src);
|
||||
ByteArrayInputStream in = new ByteArrayInputStream(out.toByteArray());
|
||||
Template tmpl = DynamicTemplate.create(SampleSubClass.class);
|
||||
SampleSubClass dst = (SampleSubClass) tmpl.unpack(new Unpacker(in));
|
||||
SampleSubClass dst = (SampleSubClass) tmpl.unpack(new Unpacker(in), null);
|
||||
assertTrue(src.f0 == dst.f0);
|
||||
assertTrue(src.f1 == dst.f1);
|
||||
assertTrue(src.f2 != dst.f2);
|
||||
@ -1413,7 +1410,7 @@ public class TestPackUnpack extends TestCase {
|
||||
ByteArrayInputStream in = new ByteArrayInputStream(out.toByteArray());
|
||||
Template tmpl = new NullableTemplate(DynamicTemplate
|
||||
.create(SampleSubClass.class));
|
||||
SampleSubClass dst = (SampleSubClass) tmpl.unpack(new Unpacker(in));
|
||||
SampleSubClass dst = (SampleSubClass) tmpl.unpack(new Unpacker(in), null);
|
||||
assertEquals(src, dst);
|
||||
}
|
||||
|
||||
@ -1457,7 +1454,7 @@ public class TestPackUnpack extends TestCase {
|
||||
ByteArrayInputStream in = new ByteArrayInputStream(out.toByteArray());
|
||||
Template tmpl = DynamicTemplate.create(SampleOptionalSubClass.class);
|
||||
SampleOptionalSubClass dst = (SampleOptionalSubClass) tmpl
|
||||
.unpack(new Unpacker(in));
|
||||
.unpack(new Unpacker(in), null);
|
||||
assertTrue(src.f0 == dst.f0);
|
||||
assertTrue(src.f1 == dst.f1);
|
||||
assertTrue(src.f2 != dst.f2);
|
||||
@ -1480,7 +1477,7 @@ public class TestPackUnpack extends TestCase {
|
||||
Template tmpl = new NullableTemplate(DynamicTemplate
|
||||
.create(SampleOptionalSubClass.class));
|
||||
SampleOptionalSubClass dst = (SampleOptionalSubClass) tmpl
|
||||
.unpack(new Unpacker(in));
|
||||
.unpack(new Unpacker(in), null);
|
||||
assertEquals(src, dst);
|
||||
}
|
||||
|
||||
@ -1528,7 +1525,7 @@ public class TestPackUnpack extends TestCase {
|
||||
Template tmpl = DynamicTemplate
|
||||
.create(BaseMessagePackableUnpackableClass.class);
|
||||
BaseMessagePackableUnpackableClass dst = (BaseMessagePackableUnpackableClass) tmpl
|
||||
.unpack(new Unpacker(in));
|
||||
.unpack(new Unpacker(in), null);
|
||||
assertEquals(src.f0.f0, dst.f0.f0);
|
||||
assertEquals(src.f0.f1, dst.f0.f1);
|
||||
assertEquals(src.f1, dst.f1);
|
||||
@ -1548,7 +1545,7 @@ public class TestPackUnpack extends TestCase {
|
||||
Template tmpl = new NullableTemplate(DynamicTemplate
|
||||
.create(BaseMessagePackableUnpackableClass.class));
|
||||
BaseMessagePackableUnpackableClass dst = (BaseMessagePackableUnpackableClass) tmpl
|
||||
.unpack(new Unpacker(in));
|
||||
.unpack(new Unpacker(in), null);
|
||||
assertEquals(src, dst);
|
||||
}
|
||||
|
||||
@ -1607,7 +1604,7 @@ public class TestPackUnpack extends TestCase {
|
||||
Template tmpl = DynamicTemplate
|
||||
.create(OptionalBaseMessagePackableUnpackableClass.class);
|
||||
OptionalBaseMessagePackableUnpackableClass dst = (OptionalBaseMessagePackableUnpackableClass) tmpl
|
||||
.unpack(new Unpacker(in));
|
||||
.unpack(new Unpacker(in), null);
|
||||
assertEquals(src.f0.f0, dst.f0.f0);
|
||||
assertEquals(src.f0.f1, dst.f0.f1);
|
||||
assertEquals(src.f1, dst.f1);
|
||||
@ -1630,7 +1627,7 @@ public class TestPackUnpack extends TestCase {
|
||||
Template tmpl = DynamicTemplate
|
||||
.create(OptionalBaseMessagePackableUnpackableClass.class);
|
||||
OptionalBaseMessagePackableUnpackableClass dst = (OptionalBaseMessagePackableUnpackableClass) tmpl
|
||||
.unpack(new Unpacker(in));
|
||||
.unpack(new Unpacker(in), null);
|
||||
assertEquals(src.f0, dst.f0);
|
||||
assertEquals(src.f1, dst.f1);
|
||||
assertEquals(src.f2, dst.f2);
|
||||
@ -1647,7 +1644,7 @@ public class TestPackUnpack extends TestCase {
|
||||
Template tmpl = new NullableTemplate(DynamicTemplate
|
||||
.create(OptionalBaseMessagePackableUnpackableClass.class));
|
||||
OptionalBaseMessagePackableUnpackableClass dst = (OptionalBaseMessagePackableUnpackableClass) tmpl
|
||||
.unpack(new Unpacker(in));
|
||||
.unpack(new Unpacker(in), null);
|
||||
assertEquals(src, dst);
|
||||
}
|
||||
|
||||
|
@ -62,7 +62,7 @@ public class TestPackUnpackWithFieldOption extends TestCase {
|
||||
Template tmpl = DynamicTemplate.create(PrimitiveTypeFieldsClass.class,
|
||||
opts);
|
||||
PrimitiveTypeFieldsClass dst = (PrimitiveTypeFieldsClass) tmpl
|
||||
.unpack(new Unpacker(in));
|
||||
.unpack(new Unpacker(in), null);
|
||||
assertEquals(src.f0, dst.f0);
|
||||
assertEquals(src.f1, dst.f1);
|
||||
assertEquals(src.f2, dst.f2);
|
||||
@ -92,7 +92,7 @@ public class TestPackUnpackWithFieldOption extends TestCase {
|
||||
Template tmpl = DynamicTemplate.create(PrimitiveTypeFieldsClass.class,
|
||||
opts);
|
||||
PrimitiveTypeFieldsClass dst = (PrimitiveTypeFieldsClass) tmpl
|
||||
.unpack(new Unpacker(in));
|
||||
.unpack(new Unpacker(in), null);
|
||||
assertEquals(src.f0, dst.f0);
|
||||
assertEquals(src.f1, dst.f1);
|
||||
assertEquals(src.f2, dst.f2);
|
||||
@ -122,7 +122,7 @@ public class TestPackUnpackWithFieldOption extends TestCase {
|
||||
Template tmpl = new NullableTemplate(DynamicTemplate.create(
|
||||
PrimitiveTypeFieldsClass.class, opts));
|
||||
PrimitiveTypeFieldsClass dst = (PrimitiveTypeFieldsClass) tmpl
|
||||
.unpack(new Unpacker(in));
|
||||
.unpack(new Unpacker(in), null);
|
||||
assertEquals(src, dst);
|
||||
}
|
||||
|
||||
@ -172,7 +172,7 @@ public class TestPackUnpackWithFieldOption extends TestCase {
|
||||
Template tmpl = DynamicTemplate
|
||||
.create(GeneralReferenceTypeFieldsClass.class, opts);
|
||||
GeneralReferenceTypeFieldsClass dst = (GeneralReferenceTypeFieldsClass) tmpl
|
||||
.unpack(new Unpacker(in));
|
||||
.unpack(new Unpacker(in), null);
|
||||
assertEquals(src.f0, dst.f0);
|
||||
assertEquals(src.f1, dst.f1);
|
||||
assertEquals(src.f2, dst.f2);
|
||||
@ -219,7 +219,7 @@ public class TestPackUnpackWithFieldOption extends TestCase {
|
||||
Template tmpl = DynamicTemplate
|
||||
.create(GeneralReferenceTypeFieldsClass.class, opts);
|
||||
GeneralReferenceTypeFieldsClass dst = (GeneralReferenceTypeFieldsClass) tmpl
|
||||
.unpack(new Unpacker(in));
|
||||
.unpack(new Unpacker(in), null);
|
||||
assertEquals(src.f0, dst.f0);
|
||||
assertEquals(src.f1, dst.f1);
|
||||
assertEquals(src.f2, dst.f2);
|
||||
@ -256,7 +256,7 @@ public class TestPackUnpackWithFieldOption extends TestCase {
|
||||
Template tmpl = new NullableTemplate(DynamicTemplate
|
||||
.create(GeneralReferenceTypeFieldsClass.class, opts));
|
||||
GeneralReferenceTypeFieldsClass dst = (GeneralReferenceTypeFieldsClass) tmpl
|
||||
.unpack(new Unpacker(in));
|
||||
.unpack(new Unpacker(in), null);
|
||||
assertEquals(src, dst);
|
||||
}
|
||||
|
||||
@ -309,7 +309,7 @@ public class TestPackUnpackWithFieldOption extends TestCase {
|
||||
ByteArrayInputStream in = new ByteArrayInputStream(out.toByteArray());
|
||||
Template tmpl = DynamicTemplate.create(SampleListTypes.class, opts);
|
||||
SampleListTypes dst = (SampleListTypes) tmpl
|
||||
.unpack(new Unpacker(in));
|
||||
.unpack(new Unpacker(in), null);
|
||||
assertEquals(src.f0.size(), dst.f0.size());
|
||||
assertEquals(src.f1.size(), dst.f1.size());
|
||||
for (int i = 0; i < src.f1.size(); ++i) {
|
||||
@ -360,7 +360,7 @@ public class TestPackUnpackWithFieldOption extends TestCase {
|
||||
ByteArrayInputStream in = new ByteArrayInputStream(out.toByteArray());
|
||||
Template tmpl = DynamicTemplate.create(SampleListTypes.class, opts);
|
||||
SampleListTypes dst = (SampleListTypes) tmpl
|
||||
.unpack(new Unpacker(in));
|
||||
.unpack(new Unpacker(in), null);
|
||||
assertEquals(src.f0.size(), dst.f0.size());
|
||||
assertEquals(src.f1, dst.f1);
|
||||
assertEquals(src.f2.size(), dst.f2.size());
|
||||
@ -385,7 +385,7 @@ public class TestPackUnpackWithFieldOption extends TestCase {
|
||||
ByteArrayInputStream in = new ByteArrayInputStream(out.toByteArray());
|
||||
Template tmpl = new NullableTemplate(DynamicTemplate
|
||||
.create(SampleListTypes.class));
|
||||
SampleListTypes dst = (SampleListTypes) tmpl.unpack(new Unpacker(in));
|
||||
SampleListTypes dst = (SampleListTypes) tmpl.unpack(new Unpacker(in), null);
|
||||
assertEquals(src, dst);
|
||||
}
|
||||
|
||||
@ -433,7 +433,7 @@ public class TestPackUnpackWithFieldOption extends TestCase {
|
||||
ByteArrayInputStream in = new ByteArrayInputStream(out.toByteArray());
|
||||
Template tmpl = DynamicTemplate.create(SampleMapTypes.class, opts);
|
||||
SampleMapTypes dst = (SampleMapTypes) tmpl
|
||||
.unpack(new Unpacker(in));
|
||||
.unpack(new Unpacker(in), null);
|
||||
assertEquals(src.f0.size(), dst.f0.size());
|
||||
assertEquals(src.f1.size(), dst.f1.size());
|
||||
Iterator<Integer> srcf1 = src.f1.keySet().iterator();
|
||||
@ -473,7 +473,7 @@ public class TestPackUnpackWithFieldOption extends TestCase {
|
||||
ByteArrayInputStream in = new ByteArrayInputStream(out.toByteArray());
|
||||
Template tmpl = DynamicTemplate.create(SampleMapTypes.class, opts);
|
||||
SampleMapTypes dst = (SampleMapTypes) tmpl
|
||||
.unpack(new Unpacker(in));
|
||||
.unpack(new Unpacker(in), null);
|
||||
assertEquals(src.f0.size(), dst.f0.size());
|
||||
assertEquals(src.f1, dst.f1);
|
||||
assertEquals(src.f2.size(), dst.f2.size());
|
||||
@ -495,7 +495,7 @@ public class TestPackUnpackWithFieldOption extends TestCase {
|
||||
Template tmpl = new NullableTemplate(DynamicTemplate
|
||||
.create(SampleMapTypes.class, opts));
|
||||
SampleMapTypes dst = (SampleMapTypes) tmpl
|
||||
.unpack(new Unpacker(in));
|
||||
.unpack(new Unpacker(in), null);
|
||||
assertEquals(src, dst);
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user