// Path: src/com/pocketreddit/library/datasources/DataSourceException.java
// public class DataSourceException extends Exception {
//     private static final long serialVersionUID = 1L;
// 
//     public DataSourceException(String message) {
//         super(message);
//     }
// 
//     public DataSourceException(String message, Throwable throwable) {
//         super(message, throwable);
//     }
// }
// 
// Path: src/com/pocketreddit/library/datasources/JsonDataSource.java
// public interface JsonDataSource {
// 	public JSONObject getSubreddits(String sessionId) throws DataSourceException;
// 
// 	public JSONObject getLinks(String subreddit) throws DataSourceException;
// 
// 	public JSONObject getComments(String permalink) throws DataSourceException;
// 	
// 	public JSONObject getSubreddit(String subreddit) throws DataSourceException;
// 	
// 	public JSONObject getDefaultSubreddits() throws DataSourceException;
// 	
// 	public JSONObject getLinksForFrontPage() throws DataSourceException;
// }
// 
// Path: src/com/pocketreddit/library/utils/StreamUtils.java
// public class StreamUtils {
//     private static StreamUtils instance;
// 
//     private StreamUtils() {
//     }
// 
//     public static StreamUtils getInstance() {
//         if (instance == null) {
//             instance = new StreamUtils();
//         }
// 
//         return instance;
//     }
// 
//     public String convertStreamToString(InputStream is) throws UtilsException {
//         BufferedReader reader = new BufferedReader(new InputStreamReader(is));
//         String line;
//         StringBuilder sb = new StringBuilder();
// 
//         try {
//             while ((line = reader.readLine()) != null) {
//                 sb.append(line + "\n");
//             }
//         } catch (IOException e) {
//             throw new UtilsException("Couldn't read line from stream.", e);
//         } finally {
//             try {
//                 if (is != null)
//                     is.close();
//             } catch (IOException e) {
//                 // TODO Auto-generated catch block
//                 e.printStackTrace();
//             }
//         }
// 
//         return sb.toString();
//     }
// }
// 
// Path: src/com/pocketreddit/library/utils/UtilsException.java
// public class UtilsException extends Exception {
//     private static final long serialVersionUID = 1L;
// 
//     public UtilsException(String message) {
//         super(message);
//     }
// 
//     public UtilsException(String message, Throwable throwable) {
//         super(message, throwable);
//     }
// }


import java.io.IOException;
import java.io.InputStream;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
import android.content.Context;
import com.pocketreddit.library.datasources.DataSourceException;
import com.pocketreddit.library.datasources.JsonDataSource;
import com.pocketreddit.library.utils.StreamUtils;
import com.pocketreddit.library.utils.UtilsException;
package com.pocketreddit.library.datasources;





public class MockDataSource implements JsonDataSource {
    private Context context;

    public MockDataSource(Context context) {
        this.context = context;
    }

    public JSONObject getSubreddits(String sessionId) throws DataSourceException {
        InputStream is = buildInputStream("/reddits/mine.json");
        try {
            return new JSONObject(StreamUtils.getInstance().convertStreamToString(is));
        } catch (JSONException e) {
            throw new DataSourceException("Could not parse the JSON file.", e);
// Path: src/com/pocketreddit/library/datasources/DataSourceException.java
// public class DataSourceException extends Exception {
//     private static final long serialVersionUID = 1L;
// 
//     public DataSourceException(String message) {
//         super(message);
//     }
// 
//     public DataSourceException(String message, Throwable throwable) {
//         super(message, throwable);
//     }
// }
// 
// Path: src/com/pocketreddit/library/datasources/JsonDataSource.java
// public interface JsonDataSource {
// 	public JSONObject getSubreddits(String sessionId) throws DataSourceException;
// 
// 	public JSONObject getLinks(String subreddit) throws DataSourceException;
// 
// 	public JSONObject getComments(String permalink) throws DataSourceException;
// 	
// 	public JSONObject getSubreddit(String subreddit) throws DataSourceException;
// 	
// 	public JSONObject getDefaultSubreddits() throws DataSourceException;
// 	
// 	public JSONObject getLinksForFrontPage() throws DataSourceException;
// }
// 
// Path: src/com/pocketreddit/library/utils/StreamUtils.java
// public class StreamUtils {
//     private static StreamUtils instance;
// 
//     private StreamUtils() {
//     }
// 
//     public static StreamUtils getInstance() {
//         if (instance == null) {
//             instance = new StreamUtils();
//         }
// 
//         return instance;
//     }
// 
//     public String convertStreamToString(InputStream is) throws UtilsException {
//         BufferedReader reader = new BufferedReader(new InputStreamReader(is));
//         String line;
//         StringBuilder sb = new StringBuilder();
// 
//         try {
//             while ((line = reader.readLine()) != null) {
//                 sb.append(line + "\n");
//             }
//         } catch (IOException e) {
//             throw new UtilsException("Couldn't read line from stream.", e);
//         } finally {
//             try {
//                 if (is != null)
//                     is.close();
//             } catch (IOException e) {
//                 // TODO Auto-generated catch block
//                 e.printStackTrace();
//             }
//         }
// 
//         return sb.toString();
//     }
// }
// 
// Path: src/com/pocketreddit/library/utils/UtilsException.java
// public class UtilsException extends Exception {
//     private static final long serialVersionUID = 1L;
// 
//     public UtilsException(String message) {
//         super(message);
//     }
// 
//     public UtilsException(String message, Throwable throwable) {
//         super(message, throwable);
//     }
// }


// Path: tests/src/com/pocketreddit/library/datasources/MockDataSource.java
import java.io.IOException;
import java.io.InputStream;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
import android.content.Context;
import com.pocketreddit.library.datasources.DataSourceException;
import com.pocketreddit.library.datasources.JsonDataSource;
import com.pocketreddit.library.utils.StreamUtils;
import com.pocketreddit.library.utils.UtilsException;

package com.pocketreddit.library.datasources;





public class MockDataSource implements JsonDataSource {
    private Context context;

    public MockDataSource(Context context) {
        this.context = context;
    }

    public JSONObject getSubreddits(String sessionId) throws DataSourceException {
        InputStream is = buildInputStream("/reddits/mine.json");
        try {
            return new JSONObject(StreamUtils.getInstance().convertStreamToString(is));
        } catch (JSONException e) {
            throw new DataSourceException("Could not parse the JSON file.", e);
        } catch (UtilsException e) {