mirror of https://github.com/apache/jclouds.git
correct order of List<Byte> gson registration and filled missing test
This commit is contained in:
parent
d0240f38f9
commit
6cef2c7984
|
@ -106,14 +106,14 @@ public class GsonModule extends AbstractModule {
|
||||||
// simple (type adapters)
|
// simple (type adapters)
|
||||||
builder.registerTypeAdapter(Properties.class, propertiesAdapter.nullSafe());
|
builder.registerTypeAdapter(Properties.class, propertiesAdapter.nullSafe());
|
||||||
builder.registerTypeAdapter(Date.class, adapter.nullSafe());
|
builder.registerTypeAdapter(Date.class, adapter.nullSafe());
|
||||||
builder.registerTypeAdapter(new TypeToken<List<Byte>>() {
|
|
||||||
}.getType(), byteListAdapter.nullSafe());
|
|
||||||
builder.registerTypeAdapter(byte[].class, byteArrayAdapter.nullSafe());
|
builder.registerTypeAdapter(byte[].class, byteArrayAdapter.nullSafe());
|
||||||
builder.registerTypeAdapter(JsonBall.class, jsonAdapter.nullSafe());
|
builder.registerTypeAdapter(JsonBall.class, jsonAdapter.nullSafe());
|
||||||
builder.registerTypeAdapterFactory(optional);
|
builder.registerTypeAdapterFactory(optional);
|
||||||
builder.registerTypeAdapterFactory(iterable);
|
builder.registerTypeAdapterFactory(iterable);
|
||||||
builder.registerTypeAdapterFactory(collection);
|
builder.registerTypeAdapterFactory(collection);
|
||||||
builder.registerTypeAdapterFactory(list);
|
builder.registerTypeAdapterFactory(list);
|
||||||
|
builder.registerTypeAdapter(new TypeToken<List<Byte>>() {
|
||||||
|
}.getType(), byteListAdapter.nullSafe());
|
||||||
builder.registerTypeAdapterFactory(immutableList);
|
builder.registerTypeAdapterFactory(immutableList);
|
||||||
builder.registerTypeAdapterFactory(set);
|
builder.registerTypeAdapterFactory(set);
|
||||||
builder.registerTypeAdapterFactory(immutableSet);
|
builder.registerTypeAdapterFactory(immutableSet);
|
||||||
|
|
|
@ -18,8 +18,11 @@
|
||||||
*/
|
*/
|
||||||
package org.jclouds.json;
|
package org.jclouds.json;
|
||||||
|
|
||||||
|
import static com.google.common.io.BaseEncoding.base16;
|
||||||
|
import static com.google.common.primitives.Bytes.asList;
|
||||||
import static org.testng.Assert.assertEquals;
|
import static org.testng.Assert.assertEquals;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Properties;
|
import java.util.Properties;
|
||||||
|
|
||||||
|
@ -113,6 +116,17 @@ public class JsonTest {
|
||||||
private Test enumValue;
|
private Test enumValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static class ByteList {
|
||||||
|
List<Byte> checksum;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void testByteList() {
|
||||||
|
ByteList bl = new ByteList();
|
||||||
|
bl.checksum = asList(base16().lowerCase().decode("1dda05ed139664f1f89b9dec482b77c0"));
|
||||||
|
assertEquals(json.toJson(bl), "{\"checksum\":\"1dda05ed139664f1f89b9dec482b77c0\"}");
|
||||||
|
assertEquals(json.fromJson(json.toJson(bl), ByteList.class).checksum, bl.checksum);
|
||||||
|
}
|
||||||
|
|
||||||
public void testPropertiesSerializesDefaults() {
|
public void testPropertiesSerializesDefaults() {
|
||||||
Properties props = new Properties();
|
Properties props = new Properties();
|
||||||
props.put("string", "string");
|
props.put("string", "string");
|
||||||
|
|
Loading…
Reference in New Issue