<NME> AvroBackwardsCompatibilityTest.java
<BEF> package voldemort.serialization.avro.versioned;

import java.io.IOException;
import java.util.HashMap;
import java.util.Map;

import junit.framework.TestCase;

import org.apache.avro.Schema;
import org.apache.avro.generic.GenericData;
import org.apache.avro.generic.GenericData.Record;
import org.apache.avro.util.Utf8;

/**
 * A test that the avro serialization remains compatible with older serialized
 * data
 * 
 * 
 */
public class AvroBackwardsCompatibilityTest extends TestCase {

    private static byte[] writeVersion0(Schema s0) {

        GenericData.Record record = new GenericData.Record(s0);
        record.put("original", new Utf8("Abhinay"));
        AvroVersionedGenericSerializer serializer = new AvroVersionedGenericSerializer(s0.toString());
        return serializer.toBytes(record);

    }

    private static Object readVersion0(Map<Integer, String> versions, byte[] versionZeroBytes) {

        AvroVersionedGenericSerializer serializer = new AvroVersionedGenericSerializer(versions);
        return serializer.toObject(versionZeroBytes);

    }

    public static void testAvroSchemaEvolution() throws IOException {

        String versionZero = "{\"type\": \"record\", \"name\": \"myrec\",\"fields\": [{ \"name\": \"original\", \"type\": \"string\" }]}";
        AvroVersionedGenericSerializer serializer = new AvroVersionedGenericSerializer(versions);
        return serializer.toBytes(record);

    }

    /*
     * This tests if a client tries to deserialize an object created using an
     * old schema is successful or not
     */
    @Test
    public void testAvroSchemaEvolution() throws IOException {

        String versionZero = "{\"type\": \"record\", \"name\": \"myrec\",\"fields\": [{ \"name\": \"original\", \"type\": \"string\" }]}";

        String versionOne = "{\"type\": \"record\", \"name\": \"myrec\",\"fields\": [{ \"name\": \"original\", \"type\": \"string\" } ,"
                            + "{ \"name\": \"new-field\", \"type\": \"string\", \"default\":\"\" }]}";

        Schema s0 = Schema.parse(versionZero);
        Schema s1 = Schema.parse(versionOne);

        Map<Integer, String> versions = new HashMap<Integer, String>();

        versions.put(0, versionZero);
        versions.put(1, versionOne);

        byte[] versionZeroBytes = writeVersion0(s0);

        GenericData.Record record = (Record) readVersion0(versions, versionZeroBytes);

    }

    /*
     * This tests if a client tries to serialize an object created using an old
     * schema is successful or not
     */
    @Test
    public void testAvroSchemaEvolutionWrite() throws IOException {

        String versionZero = "{\"type\": \"record\", \"name\": \"myrec\",\"fields\": [{ \"name\": \"original\", \"type\": \"string\" }]}";

        String versionOne = "{\"type\": \"record\", \"name\": \"myrec\",\"fields\": [{ \"name\": \"original\", \"type\": \"string\" } ,"
                            + "{ \"name\": \"new-field\", \"type\": \"string\", \"default\":\"\" }]}";

        Schema s0 = Schema.parse(versionZero);
        Schema s1 = Schema.parse(versionOne);

        Map<Integer, String> versions = new HashMap<Integer, String>();

        versions.put(0, versionZero);
        versions.put(1, versionOne);

        byte[] versionZeroBytes = writeVersion0with1Present(versions, s0);

    }
}

<MSG> Changed test case to Junit 4

<DFF> @@ -4,12 +4,11 @@ import java.io.IOException;
 import java.util.HashMap;
 import java.util.Map;
 
-import junit.framework.TestCase;
-
 import org.apache.avro.Schema;
 import org.apache.avro.generic.GenericData;
 import org.apache.avro.generic.GenericData.Record;
 import org.apache.avro.util.Utf8;
+import org.junit.Test;
 
 /**
  * A test that the avro serialization remains compatible with older serialized
@@ -17,7 +16,7 @@ import org.apache.avro.util.Utf8;
  * 
  * 
  */
-public class AvroBackwardsCompatibilityTest extends TestCase {
+public class AvroBackwardsCompatibilityTest {
 
     private static byte[] writeVersion0(Schema s0) {
 
@@ -35,6 +34,7 @@ public class AvroBackwardsCompatibilityTest extends TestCase {
 
     }
 
+    @Test
     public static void testAvroSchemaEvolution() throws IOException {
 
         String versionZero = "{\"type\": \"record\", \"name\": \"myrec\",\"fields\": [{ \"name\": \"original\", \"type\": \"string\" }]}";

{'commit': 'diff --git a/test/unit/voldemort/serialization/avro/versioned/AvroBackwardsCompatibilityTest.java b/test/unit/voldemort/serialization/avro/versioned/AvroBackwardsCompatibilityTest.java\nindex 477c26125..8787e1234 100644\n--- a/test/unit/voldemort/serialization/avro/versioned/AvroBackwardsCompatibilityTest.java\n+++ b/test/unit/voldemort/serialization/avro/versioned/AvroBackwardsCompatibilityTest.java\n@@ -4,12 +4,11 @@ import java.io.IOException;\n import java.util.HashMap;\n import java.util.Map;\n \n-import junit.framework.TestCase;\n-\n import org.apache.avro.Schema;\n import org.apache.avro.generic.GenericData;\n import org.apache.avro.generic.GenericData.Record;\n import org.apache.avro.util.Utf8;\n+import org.junit.Test;\n \n /**\n  * A test that the avro serialization remains compatible with older serialized\n@@ -17,7 +16,7 @@ import org.apache.avro.util.Utf8;\n  * \n  * \n  */\n-public class AvroBackwardsCompatibilityTest extends TestCase {\n+public class AvroBackwardsCompatibilityTest {\n \n     private static byte[] writeVersion0(Schema s0) {\n \n@@ -35,6 +34,7 @@ public class AvroBackwardsCompatibilityTest extends TestCase {\n \n     }\n \n+    @Test\n     public static void testAvroSchemaEvolution() throws IOException {\n \n         String versionZero = "{\\"type\\": \\"record\\", \\"name\\": \\"myrec\\",\\"fields\\": [{ \\"name\\": \\"original\\", \\"type\\": \\"string\\" }]}";\n', 'commit_subject': 'Changed test case to Junit 4', 'repo_name': 'voldemort/voldemort', 'committer': {'name': 'Abhinay Nagpal', 'email': '89d88c2507e9f2e126cbf22fda89723276d0b6ee@gmail.com', 'time_sec': '1349994552', 'tz_offset': '-420', 'date': {'seconds': '1349994552'}}, 'commit_tree': '4e2c0c728badbdf32980eb19343ee0d4ff6cb73b', 'commit_message': 'Changed test case to Junit 4\n', 'language_name': 'HTML', 'license': 'apache-2.0', 'hunks': '@@ -4,12 +4,11 @@ import java.io.IOException;\n import java.util.HashMap;\n import java.util.Map;\n \n-import junit.framework.TestCase;\n-\n import org.apache.avro.Schema;\n import org.apache.avro.generic.GenericData;\n import org.apache.avro.generic.GenericData.Record;\n import org.apache.avro.util.Utf8;\n+import org.junit.Test;\n \n /**\n  * A test that the avro serialization remains compatible with older serialized\n@@ -17,7 +16,7 @@ import org.apache.avro.util.Utf8;\n  * \n  * \n  */\n-public class AvroBackwardsCompatibilityTest extends TestCase {\n+public class AvroBackwardsCompatibilityTest {\n \n     private static byte[] writeVersion0(Schema s0) {\n \n@@ -35,6 +34,7 @@ public class AvroBackwardsCompatibilityTest extends TestCase {\n \n     }\n \n+    @Test\n     public static void testAvroSchemaEvolution() throws IOException {\n \n         String versionZero = "{\\"type\\": \\"record\\", \\"name\\": \\"myrec\\",\\"fields\\": [{ \\"name\\": \\"original\\", \\"type\\": \\"string\\" }]}";\n', 'addition_count': 3, 'deletion_count': 3, 'src_file': 'a/test/unit/voldemort/serialization/avro/versioned/AvroBackwardsCompatibilityTest.java', 'tgt_file': 'b/test/unit/voldemort/serialization/avro/versioned/AvroBackwardsCompatibilityTest.java', 'file_extension': '.java', 'before_file': 'package voldemort.serialization.avro.versioned;\n\nimport java.io.IOException;\nimport java.util.HashMap;\nimport java.util.Map;\n\nimport junit.framework.TestCase;\n\nimport org.apache.avro.Schema;\nimport org.apache.avro.generic.GenericData;\nimport org.apache.avro.generic.GenericData.Record;\nimport org.apache.avro.util.Utf8;\n\n/**\n * A test that the avro serialization remains compatible with older serialized\n * data\n * \n * \n */\npublic class AvroBackwardsCompatibilityTest extends TestCase {\n\n    private static byte[] writeVersion0(Schema s0) {\n\n        GenericData.Record record = new GenericData.Record(s0);\n        record.put("original", new Utf8("Abhinay"));\n        AvroVersionedGenericSerializer serializer = new AvroVersionedGenericSerializer(s0.toString());\n        return serializer.toBytes(record);\n\n    }\n\n    private static Object readVersion0(Map<Integer, String> versions, byte[] versionZeroBytes) {\n\n        AvroVersionedGenericSerializer serializer = new AvroVersionedGenericSerializer(versions);\n        return serializer.toObject(versionZeroBytes);\n\n    }\n\n    public static void testAvroSchemaEvolution() throws IOException {\n\n        String versionZero = "{\\"type\\": \\"record\\", \\"name\\": \\"myrec\\",\\"fields\\": [{ \\"name\\": \\"original\\", \\"type\\": \\"string\\" }]}";\n        AvroVersionedGenericSerializer serializer = new AvroVersionedGenericSerializer(versions);\n        return serializer.toBytes(record);\n\n    }\n\n    /*\n     * This tests if a client tries to deserialize an object created using an\n     * old schema is successful or not\n     */\n    @Test\n    public void testAvroSchemaEvolution() throws IOException {\n\n        String versionZero = "{\\"type\\": \\"record\\", \\"name\\": \\"myrec\\",\\"fields\\": [{ \\"name\\": \\"original\\", \\"type\\": \\"string\\" }]}";\n\n        String versionOne = "{\\"type\\": \\"record\\", \\"name\\": \\"myrec\\",\\"fields\\": [{ \\"name\\": \\"original\\", \\"type\\": \\"string\\" } ,"\n                            + "{ \\"name\\": \\"new-field\\", \\"type\\": \\"string\\", \\"default\\":\\"\\" }]}";\n\n        Schema s0 = Schema.parse(versionZero);\n        Schema s1 = Schema.parse(versionOne);\n\n        Map<Integer, String> versions = new HashMap<Integer, String>();\n\n        versions.put(0, versionZero);\n        versions.put(1, versionOne);\n\n        byte[] versionZeroBytes = writeVersion0(s0);\n\n        GenericData.Record record = (Record) readVersion0(versions, versionZeroBytes);\n\n    }\n\n    /*\n     * This tests if a client tries to serialize an object created using an old\n     * schema is successful or not\n     */\n    @Test\n    public void testAvroSchemaEvolutionWrite() throws IOException {\n\n        String versionZero = "{\\"type\\": \\"record\\", \\"name\\": \\"myrec\\",\\"fields\\": [{ \\"name\\": \\"original\\", \\"type\\": \\"string\\" }]}";\n\n        String versionOne = "{\\"type\\": \\"record\\", \\"name\\": \\"myrec\\",\\"fields\\": [{ \\"name\\": \\"original\\", \\"type\\": \\"string\\" } ,"\n                            + "{ \\"name\\": \\"new-field\\", \\"type\\": \\"string\\", \\"default\\":\\"\\" }]}";\n\n        Schema s0 = Schema.parse(versionZero);\n        Schema s1 = Schema.parse(versionOne);\n\n        Map<Integer, String> versions = new HashMap<Integer, String>();\n\n        versions.put(0, versionZero);\n        versions.put(1, versionOne);\n\n        byte[] versionZeroBytes = writeVersion0with1Present(versions, s0);\n\n    }\n}\n', 'message': 'Changed test case to Junit 4\n', 'author_name': 'Abhinay Nagpal', 'lang': 'java'}