@Test public void testKryoCustomClassSpecification () throws Exception { TypeDescriptor testType = new TypeDescriptor(TestClass.class); KryoSerializerFactory<TestClass> factory = new KryoSerializerFactory<TestClass>(null, Arrays.asList("factory"), testType); factory.readConfiguration(new JSONObject( "{\"factory\": {\n"+ " \"codec\": \"DEFLATE\",\n"+ " \"classes\": [\""+TestClass.class.getName()+"\"]\n"+ "}}")); TileSerializer<TestClass> product = SerializationTypeChecker.checkBinClass(factory.produce(TileSerializer.class), TestClass.class, testType); TileSerializer<TestClass> expected = new KryoSerializer<TestClass>(testType, Codec.DEFLATE, TestClass.class); assertSerializersEqual(expected, product, new TestClassSource()); }
@Test public void testKryoBZip2Specification () throws Exception { TypeDescriptor integerType = new TypeDescriptor(Integer.class); KryoSerializerFactory<Integer> factory = new KryoSerializerFactory<Integer>(null, Arrays.asList("factory"), integerType); factory.readConfiguration(new JSONObject("{\"factory\": { \"codec\": \"BZIP\"}}")); TileSerializer<Integer> product = SerializationTypeChecker.checkBinClass(factory.produce(TileSerializer.class), Integer.class, integerType); TileSerializer<Integer> expected = new KryoSerializer<Integer>(integerType, Codec.BZIP); assertSerializersEqual(expected, product, new IntegerSource()); }
@Test public void testKryoDeflateSpecification () throws Exception { TypeDescriptor integerType = new TypeDescriptor(Integer.class); KryoSerializerFactory<Integer> factory = new KryoSerializerFactory<Integer>(null, Arrays.asList("factory"), integerType); factory.readConfiguration(new JSONObject("{\"factory\": { \"codec\": \"DEFLATE\"}}")); TileSerializer<Integer> product = SerializationTypeChecker.checkBinClass(factory.produce(TileSerializer.class), Integer.class, integerType); TileSerializer<Integer> expected = new KryoSerializer<Integer>(integerType, Codec.DEFLATE); assertSerializersEqual(expected, product, new IntegerSource()); }
@Test public void testKryoDefaultCodecSpecification () throws Exception { TypeDescriptor integerType = new TypeDescriptor(Integer.class); KryoSerializerFactory<Integer> factory = new KryoSerializerFactory<Integer>(null, Arrays.asList("factory"), integerType); factory.readConfiguration(new JSONObject("{}")); TileSerializer<Integer> product = SerializationTypeChecker.checkBinClass(factory.produce(TileSerializer.class), Integer.class, integerType); TileSerializer<Integer> expected = new KryoSerializer<Integer>(integerType, Codec.GZIP); assertSerializersEqual(expected, product, new IntegerSource()); }
@Test public void testKryoGZipSpecification () throws Exception { TypeDescriptor integerType = new TypeDescriptor(Integer.class); KryoSerializerFactory<Integer> factory = new KryoSerializerFactory<Integer>(null, Arrays.asList("factory"), integerType); factory.readConfiguration(new JSONObject("{\"factory\": { \"codec\": \"GZIP\"}}")); TileSerializer<Integer> product = SerializationTypeChecker.checkBinClass(factory.produce(TileSerializer.class), Integer.class, integerType); TileSerializer<Integer> expected = new KryoSerializer<Integer>(integerType, Codec.GZIP); assertSerializersEqual(expected, product, new IntegerSource()); }