-
-
Notifications
You must be signed in to change notification settings - Fork 138
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add a failing test for #39 (not skipped by maven for some reason, nee…
…d to troubleshoot, but not now)
- Loading branch information
1 parent
dda7a6d
commit 08468c2
Showing
3 changed files
with
107 additions
and
33 deletions.
There are no files selected for viewing
70 changes: 70 additions & 0 deletions
70
avro/src/test/java/com/fasterxml/jackson/dataformat/avro/Issue39Test.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
package com.fasterxml.jackson.dataformat.avro; | ||
|
||
import java.io.IOException; | ||
import java.util.LinkedHashMap; | ||
import java.util.Map; | ||
|
||
import com.fasterxml.jackson.core.JsonParser; | ||
import com.fasterxml.jackson.core.JsonToken; | ||
|
||
public class Issue39Test extends AvroTestBase | ||
{ | ||
final static String SCHEMA_MAP_OF_MAPS_JSON = aposToQuotes("{\n" | ||
+" 'namespace': 'com.salesforce.conduit.avro',\n" | ||
+" 'type': 'record',\n" | ||
+" 'name': 'MapContainer',\n" | ||
+" 'fields': [\n" | ||
+" {'name':'props', \n" | ||
+" 'type' : {\n" | ||
+" 'type' : 'map', \n" | ||
+" 'values': ['null','int','long','float','double','string','boolean',{'type':'map','values':['null','int','long','float','double','string','boolean']}]\n" | ||
+" }\n" | ||
+" }\n" | ||
+" ]\n" | ||
+"}"); | ||
static class MapContainer { | ||
public Map<String, Object> props; | ||
|
||
public MapContainer() {} | ||
public MapContainer(Map<String, Object> p) { | ||
props = p; | ||
} | ||
} | ||
|
||
/* | ||
/********************************************************** | ||
/* Test methods | ||
/********************************************************** | ||
*/ | ||
|
||
private final AvroMapper MAPPER = getMapper(); | ||
|
||
public void testMapOfMaps() throws IOException | ||
{ | ||
Map<String,Object> map = new LinkedHashMap<String,Object>(); | ||
map.put("hello", "world"); | ||
map.put("goodbye", "charlie"); | ||
Map<String,String> otherMap = new LinkedHashMap<String,String>(); | ||
otherMap.put("foo", "bar"); | ||
map.put("otherMap", otherMap); | ||
MapContainer event = new MapContainer(map); | ||
|
||
AvroSchema avroSchema = MAPPER.schemaFrom(SCHEMA_MAP_OF_MAPS_JSON); | ||
byte[] serialized = MAPPER.writer(avroSchema).writeValueAsBytes(event); | ||
|
||
/* | ||
MapContainer deserialized = MAPPER.readerFor(MapContainer.class) | ||
.with(avroSchema) | ||
.readValue(serialized); | ||
assertEquals(3, deserialized.props.size()); | ||
*/ | ||
|
||
JsonParser p = MAPPER.getFactory().createParser(serialized); | ||
p.setSchema(avroSchema); | ||
JsonToken t; | ||
while ((t = p.nextToken()) != null) { | ||
System.err.println("GOT: "+t); | ||
} | ||
System.err.println("DONE!"); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters