Skip to content

Commit

Permalink
Refactoring tests for #171, as they are failing, and may not be fixed…
Browse files Browse the repository at this point in the history
… immediately
  • Loading branch information
cowtowncoder committed Feb 26, 2013
1 parent 02c4523 commit 63ff547
Show file tree
Hide file tree
Showing 2 changed files with 53 additions and 28 deletions.
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
package com.fasterxml.jackson.databind.struct;

import java.util.Collections;
import java.util.Map;

import com.fasterxml.jackson.annotation.JsonUnwrapped;
import com.fasterxml.jackson.databind.BaseMapTest;
import com.fasterxml.jackson.databind.ObjectMapper;
Expand Down Expand Up @@ -124,17 +121,6 @@ static class ConfigMisc {
public int value;
}

static class MapUnwrap {

public MapUnwrap() { }
public MapUnwrap(String key, Object value) {
map = Collections.singletonMap(key, value);
}

@JsonUnwrapped(prefix="map.")
public Map<String, Object> map;
}

// // // Reuse mapper to keep tests bit faster

private final ObjectMapper mapper = new ObjectMapper();
Expand Down Expand Up @@ -163,12 +149,6 @@ public void testHierarchicConfigSerialize() throws Exception
assertEquals("{\"general.names.name\":\"Fred\",\"misc.value\":25}", json);
}

public void testMapUnwrapSerialize() throws Exception
{
String json = mapper.writeValueAsString(new MapUnwrap("test", 6));
assertEquals("{\"map.test\": 6}", json);
}

/*
/**********************************************************
/* Tests, deserialization
Expand Down Expand Up @@ -226,12 +206,4 @@ public void testHierarchicConfigRoundTrip() throws Exception
assertEquals("Joe", root.general.names.name);
assertEquals(42, root.misc.value);
}

public void testMapUnwrapDeserialize() throws Exception
{
MapUnwrap root = mapper.readValue("{\"map.test\": 6}", MapUnwrap.class);

assertEquals(1, root.map.size());
assertEquals(6, ((Number)root.map.get("test")).intValue());
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
package com.fasterxml.jackson.failing;

import java.util.Collections;
import java.util.Map;

import com.fasterxml.jackson.annotation.JsonUnwrapped;
import com.fasterxml.jackson.databind.BaseMapTest;
import com.fasterxml.jackson.databind.ObjectMapper;

// Tests for [#171]
public class TestUnwrappedWithPrefix extends BaseMapTest
{
static class MapUnwrap {

public MapUnwrap() { }
public MapUnwrap(String key, Object value) {
map = Collections.singletonMap(key, value);
}

@JsonUnwrapped(prefix="map.")
public Map<String, Object> map;
}

// // // Reuse mapper to keep tests bit faster

private final ObjectMapper mapper = new ObjectMapper();

/*
/**********************************************************
/* Tests, serialization
/**********************************************************
*/

public void testMapUnwrapSerialize() throws Exception
{
String json = mapper.writeValueAsString(new MapUnwrap("test", 6));
assertEquals("{\"map.test\": 6}", json);
}

/*
/**********************************************************
/* Tests, deserialization
/**********************************************************
*/

public void testMapUnwrapDeserialize() throws Exception
{
MapUnwrap root = mapper.readValue("{\"map.test\": 6}", MapUnwrap.class);

assertEquals(1, root.map.size());
assertEquals(6, ((Number)root.map.get("test")).intValue());
}
}

0 comments on commit 63ff547

Please sign in to comment.