// Path: BoincRpc/src/androidTest/java/edu/berkeley/boinc/testutil/TestSupport.java
// public class TestSupport {
// 
//     public static String readResource(int resourceId, int maxSize) {
//         InputStream stream = InstrumentationRegistry.getInstrumentation().getContext().getResources().openRawResource(resourceId);
//         assertNotNull(stream);
//         StringBuilder sb = new StringBuilder();
//         String strLine;
//         try {
//             BufferedReader reader = new BufferedReader(new InputStreamReader(stream));
//             while ((strLine = reader.readLine()) != null) {
//                 sb.append(strLine);
//                 sb.append("\n");
//             }
//         }
//         catch (IOException e) {
//             fail("IOException");
//         }
//         // Truncate that last newline
//         if (sb.length() > 0) {
//             sb.setLength(sb.length() - 1);
//         }
//         if (maxSize > 0) {
//             if (sb.length() > maxSize) {
//                 sb.setLength(maxSize);
//             }
//         }
//         return sb.toString();
//     }
// 
//     public static String readResource(int resourceId) {
//         return readResource(resourceId, 0);
//     }
// }


import android.support.test.runner.AndroidJUnit4;
import android.test.suitebuilder.annotation.SmallTest;
import org.junit.Test;
import org.junit.runner.RunWith;
import edu.berkeley.boinc.testutil.TestSupport;
import static org.hamcrest.CoreMatchers.equalTo;
import static org.hamcrest.CoreMatchers.is;
import static org.junit.Assert.*;
        }
        assertThat(errorMsg, is(equalTo("Invalid data received")));
        assertNull(ccStatus);
    }

    @Test
    public void unauthorized() {
        final String received =
                "<boinc_gui_rpc_reply>\n" +
                "<unauthorized/>\n" +
                "</boinc_gui_rpc_reply>\n";
        CcStatus ccStatus = null;
        String errorMsg = "";
        try {
            ccStatus = CcStatusParser.parse(received);
            fail("Successful parsing unexpected, AuthorizationFailedException should be thrown instead");
        }
        catch (AuthorizationFailedException e) {
            errorMsg = e.getMessage();
        }
        catch (InvalidDataReceivedException e) {
            errorMsg = e.getMessage();
            fail("InvalidDataReceivedException unexpected, AuthorizationFailedException should be thrown instead");
        }
        assertThat(errorMsg, is(equalTo("Authorization Failed")));
        assertNull(ccStatus);
    }

    @Test
    public void invalidData() {
// Path: BoincRpc/src/androidTest/java/edu/berkeley/boinc/testutil/TestSupport.java
// public class TestSupport {
// 
//     public static String readResource(int resourceId, int maxSize) {
//         InputStream stream = InstrumentationRegistry.getInstrumentation().getContext().getResources().openRawResource(resourceId);
//         assertNotNull(stream);
//         StringBuilder sb = new StringBuilder();
//         String strLine;
//         try {
//             BufferedReader reader = new BufferedReader(new InputStreamReader(stream));
//             while ((strLine = reader.readLine()) != null) {
//                 sb.append(strLine);
//                 sb.append("\n");
//             }
//         }
//         catch (IOException e) {
//             fail("IOException");
//         }
//         // Truncate that last newline
//         if (sb.length() > 0) {
//             sb.setLength(sb.length() - 1);
//         }
//         if (maxSize > 0) {
//             if (sb.length() > maxSize) {
//                 sb.setLength(maxSize);
//             }
//         }
//         return sb.toString();
//     }
// 
//     public static String readResource(int resourceId) {
//         return readResource(resourceId, 0);
//     }
// }


// Path: BoincRpc/src/androidTest/java/edu/berkeley/boinc/CcStatusParserTest.java
import android.support.test.runner.AndroidJUnit4;
import android.test.suitebuilder.annotation.SmallTest;
import org.junit.Test;
import org.junit.runner.RunWith;
import edu.berkeley.boinc.testutil.TestSupport;
import static org.hamcrest.CoreMatchers.equalTo;
import static org.hamcrest.CoreMatchers.is;
import static org.junit.Assert.*;

        }
        assertThat(errorMsg, is(equalTo("Invalid data received")));
        assertNull(ccStatus);
    }

    @Test
    public void unauthorized() {
        final String received =
                "<boinc_gui_rpc_reply>\n" +
                "<unauthorized/>\n" +
                "</boinc_gui_rpc_reply>\n";
        CcStatus ccStatus = null;
        String errorMsg = "";
        try {
            ccStatus = CcStatusParser.parse(received);
            fail("Successful parsing unexpected, AuthorizationFailedException should be thrown instead");
        }
        catch (AuthorizationFailedException e) {
            errorMsg = e.getMessage();
        }
        catch (InvalidDataReceivedException e) {
            errorMsg = e.getMessage();
            fail("InvalidDataReceivedException unexpected, AuthorizationFailedException should be thrown instead");
        }
        assertThat(errorMsg, is(equalTo("Authorization Failed")));
        assertNull(ccStatus);
    }

    @Test
    public void invalidData() {
        final String received = TestSupport.readResource(edu.berkeley.boinc.test.R.raw.get_cc_status_reply, 786);