@@ -0,0 +1,2385 @@
+package com.giannoules.proxstor.testing;%0A%0Aimport com.google.gson.FieldNamingPolicy;%0Aimport com.google.gson.Gson;%0Aimport com.google.gson.GsonBuilder;%0Aimport com.google.gson.JsonArray;%0Aimport com.google.gson.JsonElement;%0Aimport com.google.gson.JsonParser;%0Aimport java.io.BufferedReader;%0Aimport java.io.BufferedWriter;%0Aimport java.io.FileNotFoundException;%0Aimport java.io.FileReader;%0Aimport java.io.FileWriter;%0Aimport java.io.IOException;%0Aimport java.util.ArrayList;%0Aimport java.util.List;%0Aimport java.util.logging.Level;%0Aimport java.util.logging.Logger;%0A%0A/*%0A * encapsulate logic to read/write lists of JSON objects%0A * using Google's GSON library%0A */%0Apublic class ReaderWriter%3CT%3E %7B%0A    %0A    public static %3CT%3E boolean write(String filename, List%3CT%3E objs) %7B%0A        BufferedWriter bw;%0A        Gson gson = new GsonBuilder()%0A                .enableComplexMapKeySerialization()%0A                .serializeNulls()%0A                .setFieldNamingPolicy(FieldNamingPolicy.UPPER_CAMEL_CASE)%0A                .setPrettyPrinting()%0A                .setVersion(1.0)%0A                .create();%0A        String json = gson.toJson(objs);        %0A        try %7B            %0A            FileWriter writer = new FileWriter(filename);            %0A            writer.write(json);%0A            writer.close();%0A            return true;            %0A        %7D catch (IOException ex) %7B%0A            ex.printStackTrace();%0A        %7D%0A        return false;%0A    %7D%0A        %0A    public static %3CT%3E List%3CT%3E read(String filename, Class c) %7B      %0A        List%3CT%3E objs = new ArrayList();%0A        BufferedReader br;%0A        Gson gson = new GsonBuilder()%0A                .enableComplexMapKeySerialization()%0A                .serializeNulls()%0A                .setFieldNamingPolicy(FieldNamingPolicy.UPPER_CAMEL_CASE)%0A                .setPrettyPrinting()%0A                .setVersion(1.0)%0A                .create();%0A        try %7B%0A            br = new BufferedReader(new FileReader(filename));%0A            JsonElement json = new JsonParser().parse(br);%0A            JsonArray array = json.getAsJsonArray();%0A            for (JsonElement json2 : array) %7B                %0A                objs.add((T) gson.fromJson(json2, c));                %0A            %7D%0A        %7D catch (FileNotFoundException ex) %7B%0A            Logger.getLogger(ReaderWriter.class.getName()).log(Level.SEVERE, null, ex);%0A        %7D%0A       return objs;        %0A    %7D%0A      %0A%7D

move ReaderWriter to testing