package com.doubley.customandroidtest.customtest;

import android.content.res.AssetManager;
import android.test.InstrumentationTestCase;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;

/**
 * Created by yasudayousuke on 7/2/15.
 */
public class CustomInstrumentationTestCase extends InstrumentationTestCase {
    protected String getStringFromAssetFile(String filename) throws IOException {
        AssetManager assets = getInstrumentation().getContext().getAssets();
        String buffer = "";

        InputStream is = assets.open(filename);
        InputStreamReader isr = new InputStreamReader(is);
        BufferedReader reader = new BufferedReader(isr);
        String str;
        while((str = reader.readLine()) != null)
        {
            buffer += str;
        }
        return buffer;
    }
}

@@ -129,16 +129,75 @@
 estCase;
+%0Aimport org.json.JSONException;%0Aimport org.json.JSONObject;
 %0A%0Aimport
@@ -310,16 +310,43 @@
 mReader;
+%0Aimport java.util.Iterator;
 %0A%0A/**%0A *
@@ -931,16 +931,16 @@
       %7D%0A
-
         
@@ -960,10 +960,430 @@
 ;%0A    %7D%0A
+    protected void checkKeyValidation(JSONObject expectJson, JSONObject actualObject)%7B%0A        Iterator%3CString%3E keys = expectJson.keys();%0A        while(keys.hasNext())%7B%0A            String key = keys.next();%0A            try %7B%0A                actualObject.get(key);%0A            %7D catch (JSONException e) %7B%0A                fail(%22in %22 + actualObject.toString() + %22%22 + key + %22 does not exist%22);%0A            %7D%0A        %7D%0A    %7D%0A
 %7D%0A

add JsonKeyValidater