Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Fix previous formatting issues
  • Loading branch information
jmorton committed Feb 14, 2016
1 parent ab36161 commit 6a5ce61
Showing 1 changed file with 33 additions and 4 deletions.
37 changes: 33 additions & 4 deletions test/com/esotericsoftware/kryo/MapSerializerTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,17 @@
* SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */

* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */

package com.esotericsoftware.kryo;

import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Comparator;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.Random;
import java.util.TreeMap;
Expand Down Expand Up @@ -167,7 +171,32 @@ public void testTreeMapWithReferences () {
map.put("4", 44);
roundTrip(29, 43, map);
}


public void testSerializingMapAfterDeserializingMultipleReferencesToSameMap() throws Exception {
Kryo kryo = new Kryo();
Output output = new Output(4096);

kryo.writeClassAndObject(output, new HasMultipleReferenceToSameMap());
kryo.readClassAndObject(new Input(new ByteArrayInputStream(output.getBuffer())));
output.clear();

Map<Integer, List<String>> mapOfLists = new HashMap<Integer, List<String>>();
mapOfLists.put(1, new ArrayList<String>());
kryo.writeClassAndObject(output, mapOfLists);

@SuppressWarnings("unchecked")
Map<Integer, List<String>> deserializedMap =
(Map<Integer, List<String>>) kryo.readClassAndObject(new Input(new ByteArrayInputStream(output.getBuffer())));
assertEquals(1, deserializedMap.size());
}

@SuppressWarnings("unused")
static class HasMultipleReferenceToSameMap {
private Map<Integer, String> mapOne = new HashMap<Integer, String>();
private Map<Integer, String> mapTwo = this.mapOne;
}


static public class HasGenerics {
public HashMap<String, Integer[]> map = new HashMap();
public HashMap<String, ?> map2 = new HashMap();
Expand Down Expand Up @@ -195,4 +224,4 @@ public TreeMapSubclass(Comparator<? super K> comparator) {
super(comparator);
}
}
}
}

0 comments on commit 6a5ce61

Please sign in to comment.