Skip to content

Commit

Permalink
Add test for #1940
Browse files Browse the repository at this point in the history
  • Loading branch information
cowtowncoder committed Feb 23, 2018
1 parent 9612972 commit c5bfb9a
Showing 1 changed file with 19 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

import org.junit.Assert;

import com.fasterxml.jackson.annotation.JsonTypeInfo;
import com.fasterxml.jackson.core.*;
import com.fasterxml.jackson.databind.*;
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
Expand Down Expand Up @@ -69,7 +70,16 @@ static class Issue467TmpBean {

public Issue467TmpBean(int i) { x = i; }
}


static class Issue709Bean {
public byte[] data;
}

@JsonTypeInfo(use=JsonTypeInfo.Id.CLASS, include=JsonTypeInfo.As.PROPERTY, property="_class")
static class LongContainer1940 {
public Long longObj;
}

/*
/**********************************************************
/* Unit tests
Expand Down Expand Up @@ -172,10 +182,6 @@ public void testBase64Text() throws Exception
}
}

static class Issue709Bean {
public byte[] data;
}

/**
* Simple test to verify that byte[] values can be handled properly when
* converting, as long as there is metadata (from POJO definitions).
Expand Down Expand Up @@ -285,5 +291,12 @@ public void testConversionOfTrees() throws Exception
assertTrue("Expected Object, got "+tree.getNodeType(), tree.isBoolean());
assertEquals(EXP, MAPPER.writeValueAsString(tree));
}
}

// [databind#1940]: losing of precision due to coercion
public void testBufferedLongViaCoercion() throws Exception {
long EXP = 1519348261000L;
JsonNode tree = MAPPER.readTree("{\"longObj\": "+EXP+".0, \"_class\": \""+LongContainer1940.class.getName()+"\"}");
LongContainer1940 obj = MAPPER.treeToValue(tree, LongContainer1940.class);
assertEquals(Long.valueOf(EXP), obj.longObj);
}
}

0 comments on commit c5bfb9a

Please sign in to comment.