package com.github.davidmoten.rtree;

import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.util.List;

import org.junit.Test;

import com.esotericsoftware.kryo.Kryo;
import com.esotericsoftware.kryo.io.Input;
import com.esotericsoftware.kryo.io.Output;
import com.github.davidmoten.rtree.geometry.Point;

public class SerializationTest {
    
    @Test
    public void testSerializationRoundTrip() throws FileNotFoundException {
        List<Entry<Object, Point>> entries = GreekEarthquakes.entriesList();
        int maxChildren = 8;
        RTree<Object, Point> tree = RTree.maxChildren(maxChildren).<Object, Point> create()
                .add(entries);
        
        File file  = new File("target/greek-serialized.kryo");
        file.delete();
        
        Kryo kryo = new Kryo();
        Output output = new Output(new FileOutputStream(file));
        kryo.writeObject(output, tree);
        output.close();
        
        Input input = new Input(new FileInputStream(file));
//        RTree<Object,Point> tree2 = kryo.readObject(input, RTree.class);
        
        
    }

}

@@ -196,20 +196,100 @@
 g.junit.
-Test
+Ignore;%0Aimport org.junit.Test;%0Aimport org.objenesis.strategy.StdInstantiatorStrategy
 ;%0A%0Aimpor
@@ -494,21 +494,17 @@
 nTest %7B%0A
-    
 %0A
+
     @Tes
@@ -505,16 +505,28 @@
   @Test%0A
+    @Ignore%0A
     publ
@@ -593,16 +593,88 @@
 ption %7B%0A
+        // this test to see if can use kryo to serialize RTree instance%0A
         
@@ -890,32 +890,24 @@
 d(entries);%0A
-        
 %0A        Fil
@@ -913,17 +913,16 @@
 le file 
- 
 = new Fi
@@ -976,33 +976,25 @@
 e.delete();%0A
-        
 %0A
+
         Kryo
@@ -1141,25 +1141,17 @@
 lose();%0A
-        
 %0A
+
         
@@ -1202,18 +1202,85 @@
 file));%0A
-//
+        kryo.setInstantiatorStrategy(new StdInstantiatorStrategy());%0A
         
@@ -1292,16 +1292,17 @@
 %3CObject,
+ 
 Point%3E t
@@ -1349,25 +1349,8 @@
 s);%0A
-        %0A        
 %0A   

update SerializationTest