Example usage for org.json JSONObject optJSONObject

List of usage examples for org.json JSONObject optJSONObject

Introduction

In this page you can find the example usage for org.json JSONObject optJSONObject.

Prototype

public JSONObject optJSONObject(String key) 

Source Link

Document

Get an optional JSONObject associated with a key.

Usage

From source file:org.eclipse.orion.server.tests.servlets.git.GitApplyPatchTest.java

@Test
public void testApplyPatch_deleteFile() throws Exception {
    // clone: create
    URI workspaceLocation = createWorkspace(getMethodName());
    String workspaceId = workspaceIdFromLocation(workspaceLocation);
    JSONObject project = createProjectOrLink(workspaceLocation, getMethodName(), null);
    IPath clonePath = getClonePath(workspaceId, project);
    clone(clonePath);/* w  w w .  j a v  a  2  s .  c  om*/

    // get project metadata
    WebRequest request = getGetRequest(project.getString(ProtocolConstants.KEY_CONTENT_LOCATION));
    WebResponse response = webConversation.getResponse(request);
    assertEquals(HttpURLConnection.HTTP_OK, response.getResponseCode());
    project = new JSONObject(response.getText());
    JSONObject gitSection = project.optJSONObject(GitConstants.KEY_GIT);
    assertNotNull(gitSection);

    gitSection = project.getJSONObject(GitConstants.KEY_GIT);
    String gitDiffUri = gitSection.getString(GitConstants.KEY_DIFF);

    StringBuilder sb = new StringBuilder();
    sb.append("diff --git a/test.txt b/test.txt").append("\n");
    sb.append("deleted file mode 100644").append("\n");
    sb.append("index 8013df8..0000000 100644").append("\n");
    sb.append("--- a/test.txt").append("\n");
    sb.append("+++ /dev/null").append("\n");
    sb.append("@@ -1 +0,0 @@").append("\n");
    sb.append("-test").append("\n");

    JSONObject patchResult = patch(gitDiffUri, sb.toString());
    assertEquals("200", patchResult.getString("HttpCode"));

    String gitStatusUri = gitSection.getString(GitConstants.KEY_STATUS);
    assertStatus(new StatusResult().setMissingNames("test.txt"), gitStatusUri);
}

From source file:org.eclipse.orion.server.tests.servlets.git.GitApplyPatchTest.java

@Test
public void testApplyPatch_modifyFile() throws Exception {
    // clone: create
    URI workspaceLocation = createWorkspace(getMethodName());
    String workspaceId = workspaceIdFromLocation(workspaceLocation);
    JSONObject project = createProjectOrLink(workspaceLocation, getMethodName(), null);
    IPath clonePath = getClonePath(workspaceId, project);
    clone(clonePath);//from w w  w . java2 s.  com

    // get project metadata
    WebRequest request = getGetRequest(project.getString(ProtocolConstants.KEY_CONTENT_LOCATION));
    WebResponse response = webConversation.getResponse(request);
    assertEquals(HttpURLConnection.HTTP_OK, response.getResponseCode());
    project = new JSONObject(response.getText());
    JSONObject gitSection = project.optJSONObject(GitConstants.KEY_GIT);
    assertNotNull(gitSection);

    gitSection = project.getJSONObject(GitConstants.KEY_GIT);
    String gitDiffUri = gitSection.getString(GitConstants.KEY_DIFF);

    StringBuilder sb = new StringBuilder();
    sb.append("diff --git a/test.txt b/test.txt").append("\n");
    sb.append("index 30d74d2..8013df8 100644").append("\n");
    sb.append("--- a/test.txt").append("\n");
    sb.append("+++ b/test.txt").append("\n");
    sb.append("@@ -1 +1 @@").append("\n");
    sb.append("-test").append("\n");
    sb.append("\\ No newline at end of file").append("\n");
    sb.append("+patched").append("\n");
    sb.append("\\ No newline at end of file").append("\n");

    JSONObject patchResult = patch(gitDiffUri, sb.toString());
    assertEquals("200", patchResult.getString("HttpCode"));

    JSONObject testTxt = getChild(project, "test.txt");
    assertEquals("patched", getFileContent(testTxt));
    String gitStatusUri = gitSection.getString(GitConstants.KEY_STATUS);
    assertStatus(new StatusResult().setModifiedNames("test.txt").setModifiedContents("patched"), gitStatusUri);
}

From source file:org.eclipse.orion.server.tests.servlets.git.GitApplyPatchTest.java

@Ignore("not reported as a format error")
@Test//from   w w w  .j a  va  2s  .  c  o  m
public void testApplyPatch_modifyFileFormatError() throws Exception {
    // clone: create
    URI workspaceLocation = createWorkspace(getMethodName());
    JSONObject project = createProjectOrLink(workspaceLocation, getMethodName(), null);
    IPath clonePath = new Path("file").append(project.getString(ProtocolConstants.KEY_ID)).makeAbsolute();
    clone(clonePath);

    // get project metadata
    WebRequest request = getGetRequest(project.getString(ProtocolConstants.KEY_CONTENT_LOCATION));
    WebResponse response = webConversation.getResponse(request);
    assertEquals(HttpURLConnection.HTTP_OK, response.getResponseCode());
    project = new JSONObject(response.getText());
    JSONObject gitSection = project.optJSONObject(GitConstants.KEY_GIT);
    assertNotNull(gitSection);

    gitSection = project.getJSONObject(GitConstants.KEY_GIT);
    String gitDiffUri = gitSection.getString(GitConstants.KEY_DIFF);

    StringBuilder sb = new StringBuilder();
    sb.append("diff --git a/test.txt b/test.txt").append("\n");
    sb.append("malformed patch").append("\n");

    JSONObject patchResult = patch(gitDiffUri, sb.toString());
    assertEquals("400", patchResult.getString("HttpCode"));

    // nothing has changed
    JSONObject testTxt = getChild(project, "test.txt");
    assertEquals("test", getFileContent(testTxt));
    String gitStatusUri = gitSection.getString(GitConstants.KEY_STATUS);
    assertStatus(StatusResult.CLEAN, gitStatusUri);
}

From source file:org.eclipse.orion.server.tests.servlets.git.GitApplyPatchTest.java

@Test
public void testApplyPatch_modifyFileApplyError() throws Exception {
    // clone: create
    URI workspaceLocation = createWorkspace(getMethodName());
    String workspaceId = workspaceIdFromLocation(workspaceLocation);
    JSONObject project = createProjectOrLink(workspaceLocation, getMethodName(), null);
    IPath clonePath = getClonePath(workspaceId, project);
    clone(clonePath);//from  ww w  . ja va  2  s .com

    // get project metadata
    WebRequest request = getGetRequest(project.getString(ProtocolConstants.KEY_CONTENT_LOCATION));
    WebResponse response = webConversation.getResponse(request);
    assertEquals(HttpURLConnection.HTTP_OK, response.getResponseCode());
    project = new JSONObject(response.getText());
    JSONObject gitSection = project.optJSONObject(GitConstants.KEY_GIT);
    assertNotNull(gitSection);

    gitSection = project.getJSONObject(GitConstants.KEY_GIT);
    String gitDiffUri = gitSection.getString(GitConstants.KEY_DIFF);

    StringBuilder sb = new StringBuilder();
    sb.append("diff --git a/test.txt b/test.txt").append("\n");
    sb.append("index 30d74d2..8013df8 100644").append("\n");
    sb.append("--- a/test.txt").append("\n");
    sb.append("+++ b/test.txt").append("\n");
    sb.append("@@ -1 +1 @@").append("\n");
    sb.append("-xxx").append("\n");
    sb.append("\\ No newline at end of file").append("\n");
    sb.append("+patched").append("\n");
    sb.append("\\ No newline at end of file").append("\n");

    JSONObject patchResult = patch(gitDiffUri, sb.toString());
    assertEquals("400", patchResult.getString("HttpCode"));

    // nothing has changed
    JSONObject testTxt = getChild(project, "test.txt");
    assertEquals("test", getFileContent(testTxt));
    String gitStatusUri = gitSection.getString(GitConstants.KEY_STATUS);
    assertStatus(StatusResult.CLEAN, gitStatusUri);
}

From source file:org.schedulesdirect.grabber.LogoTask.java

/**
 * Constructor//from   w ww.j av  a2 s.c om
 * @param req A station object containing the details for the logo
 * @param vfs The name of the vfs used for storing the logo image
 * @param cache The internal cache index of the logos
 */
public LogoTask(JSONObject req, FileSystem vfs, JSONObject cache) throws JSONException {
    this.vfs = vfs;
    callsign = req.getString("callsign");
    this.req = req.optJSONObject("logo");
    this.cache = cache;
    if (this.req != null) {
        this.md5 = this.req.optString("md5", null);
        String urlStr = this.req.optString("URL", null);
        try {
            url = urlStr != null && urlStr.length() > 0 ? new URL(urlStr) : null;
            if (url != null)
                ext = urlStr.substring(urlStr.lastIndexOf(".") + 1);
        } catch (MalformedURLException e) {
            LOG.warn("Invalid URL", e);
            url = null;
        }
    }
}

From source file:fr.cobaltians.cobalt.fragments.CobaltWebLayerFragment.java

/********************************************************************************************
 * DISMISS//from ww w  . j a  va2s .co  m
 *******************************************************************************************/

protected void dismissWebLayer(JSONObject jsonObject) {
    if (getActivity() != null) {
        FragmentTransaction fragmentTransaction = getActivity().getSupportFragmentManager().beginTransaction();

        if (jsonObject != null) {
            mData = jsonObject.optJSONObject(Cobalt.kJSData);
            double fadeDuration = jsonObject.optDouble(Cobalt.kJSWebLayerFadeDuration, 0);

            if (fadeDuration > 0) {
                fragmentTransaction.setCustomAnimations(android.R.anim.fade_in, android.R.anim.fade_out,
                        android.R.anim.fade_in, android.R.anim.fade_out);
            } else {
                fragmentTransaction.setTransition(FragmentTransaction.TRANSIT_NONE);
            }
        } else {
            fragmentTransaction.setTransition(FragmentTransaction.TRANSIT_NONE);
        }

        fragmentTransaction.remove(this);
        fragmentTransaction.commit();
    } else if (Cobalt.DEBUG)
        Log.e(Cobalt.TAG, TAG + " - dismissWebLayer: Web layer is not attached to an activity.");
}

From source file:org.eclipse.orion.server.tests.servlets.git.GitFetchTest.java

@Test
public void testFetchRemoteUpToDate() throws Exception {
    // clone a repo
    URI workspaceLocation = createWorkspace(getMethodName());
    String workspaceId = workspaceIdFromLocation(workspaceLocation);
    JSONObject project = createProjectOrLink(workspaceLocation, getMethodName(), null);
    IPath clonePath = getClonePath(workspaceId, project);
    clone(clonePath);//  w  w  w.j  a  v a  2 s  .com

    // get project metadata
    WebRequest request = getGetRequest(project.getString(ProtocolConstants.KEY_CONTENT_LOCATION));
    WebResponse response = webConversation.getResponse(request);
    assertEquals(HttpURLConnection.HTTP_OK, response.getResponseCode());
    project = new JSONObject(response.getText());

    JSONObject gitSection = project.optJSONObject(GitConstants.KEY_GIT);
    assertNotNull(gitSection);
    String gitRemoteUri = gitSection.getString(GitConstants.KEY_REMOTE);

    // list remotes
    JSONObject remote = getRemote(gitRemoteUri, 1, 0, Constants.DEFAULT_REMOTE_NAME);
    String remoteLocation = remote.getString(ProtocolConstants.KEY_LOCATION);

    // get remote details
    JSONObject details = getRemoteBranch(gitRemoteUri, 1, 0, Constants.MASTER);
    String refId = details.getString(ProtocolConstants.KEY_ID);

    // fetch
    fetch(remoteLocation);

    // get remote details again
    String newRefId = getRemoteBranch(gitRemoteUri, 1, 0, Constants.MASTER).getString(ProtocolConstants.KEY_ID);
    // up to date
    assertEquals(refId, newRefId);
}

From source file:org.eclipse.orion.server.tests.servlets.git.GitFetchTest.java

@Test
public void testPushCommitAndFetch() throws Exception {
    URI workspaceLocation = createWorkspace(getMethodName());
    String workspaceId = workspaceIdFromLocation(workspaceLocation);

    // clone1// ww  w  .j a va2  s. c  o m
    JSONObject project1 = createProjectOrLink(workspaceLocation, getMethodName() + "1", null);
    IPath clonePath1 = getClonePath(workspaceId, project1);
    String contentLocation1 = clone(clonePath1).getString(ProtocolConstants.KEY_CONTENT_LOCATION);

    // get project1 metadata
    WebRequest request = getGetRequest(project1.getString(ProtocolConstants.KEY_CONTENT_LOCATION));
    WebResponse response = webConversation.getResponse(request);
    assertEquals(HttpURLConnection.HTTP_OK, response.getResponseCode());
    project1 = new JSONObject(response.getText());
    JSONObject gitSection1 = project1.optJSONObject(GitConstants.KEY_GIT);
    assertNotNull(gitSection1);
    String gitRemoteUri1 = gitSection1.getString(GitConstants.KEY_REMOTE);

    // clone2
    JSONObject project2 = createProjectOrLink(workspaceLocation, getMethodName() + "2", null);
    String projectId2 = project2.getString(ProtocolConstants.KEY_ID);
    IPath clonePath2 = getClonePath(workspaceId, project2);
    clone(clonePath2);

    // get project2 metadata
    request = getGetRequest(project2.getString(ProtocolConstants.KEY_CONTENT_LOCATION));
    response = webConversation.getResponse(request);
    assertEquals(HttpURLConnection.HTTP_OK, response.getResponseCode());
    project2 = new JSONObject(response.getText());
    JSONObject gitSection2 = project2.optJSONObject(GitConstants.KEY_GIT);
    assertNotNull(gitSection2);
    String gitRemoteUri2 = gitSection2.getString(GitConstants.KEY_REMOTE);
    String gitIndexUri2 = gitSection2.getString(GitConstants.KEY_INDEX);
    String gitHeadUri2 = gitSection2.getString(GitConstants.KEY_HEAD);

    // clone2: change
    request = getPutFileRequest(clonePath2 + "/test.txt", "incoming change");
    response = webConversation.getResponse(request);
    assertEquals(HttpURLConnection.HTTP_OK, response.getResponseCode());

    // clone2: add
    request = GitAddTest.getPutGitIndexRequest(gitIndexUri2);
    response = webConversation.getResponse(request);
    assertEquals(HttpURLConnection.HTTP_OK, response.getResponseCode());

    // clone2: commit
    request = GitCommitTest.getPostGitCommitRequest(gitHeadUri2, "incoming change commit", false);
    response = webConversation.getResponse(request);
    assertEquals(HttpURLConnection.HTTP_OK, response.getResponseCode());

    // clone2: push
    ServerStatus pushStatus = push(gitRemoteUri2, 1, 0, Constants.MASTER, Constants.HEAD, false);
    assertEquals(true, pushStatus.isOK());

    JSONObject masterDetails = getRemoteBranch(gitRemoteUri1, 1, 0, Constants.MASTER);
    String refId1 = masterDetails.getString(ProtocolConstants.KEY_ID);
    String remoteBranchLocation = masterDetails.getString(ProtocolConstants.KEY_LOCATION);

    // clone1: fetch
    fetch(remoteBranchLocation);

    masterDetails = getRemoteBranch(gitRemoteUri1, 1, 0, Constants.MASTER);
    String newRefId1 = masterDetails.getString(ProtocolConstants.KEY_ID);
    assertFalse(newRefId1.equals(refId1));

    // clone1: log master..origin/master
    // TODO replace with tests methods from GitLogTest, bug 340051
    Repository db1 = getRepositoryForContentLocation(contentLocation1);
    ObjectId master = db1.resolve(Constants.MASTER);
    ObjectId originMaster = db1
            .resolve(Constants.R_REMOTES + Constants.DEFAULT_REMOTE_NAME + '/' + Constants.MASTER);
    Git git = new Git(db1);
    Iterable<RevCommit> commits = git.log().addRange(master, originMaster).call();
    int c = 0;
    for (RevCommit commit : commits) {
        assertEquals("incoming change commit", commit.getFullMessage());
        c++;
    }
    // a single incoming commit
    assertEquals(1, c);
}

From source file:org.eclipse.orion.server.tests.servlets.git.GitFetchTest.java

@Test
public void testFetchRemote() throws Exception {
    URI workspaceLocation = createWorkspace(getMethodName());
    String workspaceId = workspaceIdFromLocation(workspaceLocation);

    // clone1: create
    JSONObject project1 = createProjectOrLink(workspaceLocation, getMethodName() + "1", null);
    String projectId1 = project1.getString(ProtocolConstants.KEY_ID);
    IPath clonePath1 = getClonePath(workspaceId, project1);
    JSONObject clone1 = clone(clonePath1);
    String cloneContentLocation1 = clone1.getString(ProtocolConstants.KEY_CONTENT_LOCATION);
    String cloneLocation1 = clone1.getString(ProtocolConstants.KEY_LOCATION);
    String branchesLocation1 = clone1.getString(GitConstants.KEY_BRANCH);

    // get project1 metadata
    WebRequest request = getGetRequest(project1.getString(ProtocolConstants.KEY_CONTENT_LOCATION));
    WebResponse response = webConversation.getResponse(request);
    assertEquals(HttpURLConnection.HTTP_OK, response.getResponseCode());
    project1 = new JSONObject(response.getText());
    JSONObject gitSection1 = project1.optJSONObject(GitConstants.KEY_GIT);
    assertNotNull(gitSection1);//from  w  w  w .  ja  va2s.  c o m
    String gitRemoteUri1 = gitSection1.getString(GitConstants.KEY_REMOTE);
    String gitIndexUri1 = gitSection1.getString(GitConstants.KEY_INDEX);
    String gitHeadUri1 = gitSection1.getString(GitConstants.KEY_HEAD);

    // clone1: branch 'a'
    Repository db1 = getRepositoryForContentLocation(cloneContentLocation1);
    Git git1 = new Git(db1);
    branch(branchesLocation1, "a");

    // clone1: push all
    // TODO: replace with REST API when bug 339115 is fixed
    git1.push().setPushAll().call();

    // clone2
    JSONObject project2 = createProjectOrLink(workspaceLocation, getMethodName() + "2", null);
    IPath clonePath2 = getClonePath(workspaceId, project2);
    clone(clonePath2);

    // get project2 metadata
    request = getGetRequest(project2.getString(ProtocolConstants.KEY_CONTENT_LOCATION));
    response = webConversation.getResponse(request);
    assertEquals(HttpURLConnection.HTTP_OK, response.getResponseCode());
    project2 = new JSONObject(response.getText());
    JSONObject gitSection2 = project2.optJSONObject(GitConstants.KEY_GIT);
    assertNotNull(gitSection2);
    String gitRemoteUri2 = gitSection2.getString(GitConstants.KEY_REMOTE);

    // clone1: switch to 'a'
    assertBranchExist(git1, "a");
    checkoutBranch(cloneLocation1, "a");

    // clone1: change
    request = getPutFileRequest(clonePath1 + "/test.txt", "branch 'a' change");
    response = webConversation.getResponse(request);
    assertEquals(HttpURLConnection.HTTP_OK, response.getResponseCode());

    // clone1: add
    request = GitAddTest.getPutGitIndexRequest(gitIndexUri1);
    response = webConversation.getResponse(request);
    assertEquals(HttpURLConnection.HTTP_OK, response.getResponseCode());

    // clone1: commit
    request = GitCommitTest.getPostGitCommitRequest(gitHeadUri1, "incoming branch 'a' commit", false);
    response = webConversation.getResponse(request);
    assertEquals(HttpURLConnection.HTTP_OK, response.getResponseCode());

    // clone1: push
    ServerStatus pushStatus = push(gitRemoteUri1, 2, 0, "a", Constants.HEAD, false);
    assertTrue(pushStatus.isOK());

    // clone1: switch to 'master'
    checkoutBranch(cloneLocation1, Constants.MASTER);

    // clone1: change
    request = getPutFileRequest(clonePath1 + "/test.txt", "branch 'master' change");
    response = webConversation.getResponse(request);
    assertEquals(HttpURLConnection.HTTP_OK, response.getResponseCode());

    // clone1: add
    request = GitAddTest.getPutGitIndexRequest(gitIndexUri1);
    response = webConversation.getResponse(request);
    assertEquals(HttpURLConnection.HTTP_OK, response.getResponseCode());

    // clone1: commit
    request = GitCommitTest.getPostGitCommitRequest(gitHeadUri1, "incoming branch 'master' commit", false);
    response = webConversation.getResponse(request);
    assertEquals(HttpURLConnection.HTTP_OK, response.getResponseCode());

    // clone1: push
    pushStatus = push(gitRemoteUri1, 2, 0, Constants.MASTER, Constants.HEAD, false);
    assertTrue(pushStatus.isOK());

    // clone2: get remote details
    JSONObject masterDetails = getRemoteBranch(gitRemoteUri2, 2, 0, Constants.MASTER);
    String masterOldRefId = masterDetails.getString(ProtocolConstants.KEY_ID);
    JSONObject aDetails = getRemoteBranch(gitRemoteUri2, 2, 1, "a");
    String aOldRefId = aDetails.getString(ProtocolConstants.KEY_ID);

    // clone2: fetch all: 'master' and 'a'
    JSONObject remote = getRemote(gitRemoteUri2, 1, 0, Constants.DEFAULT_REMOTE_NAME);
    String remoteLocation = remote.getString(ProtocolConstants.KEY_LOCATION);
    fetch(remoteLocation);

    // clone2: assert both remote branches have new content
    masterDetails = getRemoteBranch(gitRemoteUri2, 2, 0, Constants.MASTER);
    String newRefId = masterDetails.getString(ProtocolConstants.KEY_ID);
    assertFalse(masterOldRefId.equals(newRefId));

    aDetails = getRemoteBranch(gitRemoteUri2, 2, 1, "a");
    newRefId = aDetails.getString(ProtocolConstants.KEY_ID);
    assertFalse(aOldRefId.equals(newRefId));
}

From source file:org.eclipse.orion.server.tests.servlets.git.GitFetchTest.java

@Test
public void testFetchRemoteBranch() throws Exception {
    URI workspaceLocation = createWorkspace(getMethodName());
    String workspaceId = workspaceIdFromLocation(workspaceLocation);

    // clone1: create
    JSONObject project1 = createProjectOrLink(workspaceLocation, getMethodName() + "1", null);
    IPath clonePath1 = getClonePath(workspaceId, project1);
    JSONObject clone1 = clone(clonePath1);
    String cloneContentLocation1 = clone1.getString(ProtocolConstants.KEY_CONTENT_LOCATION);
    String cloneLocation1 = clone1.getString(ProtocolConstants.KEY_LOCATION);
    String branchesLocation1 = clone1.getString(GitConstants.KEY_BRANCH);

    // get project1 metadata
    WebRequest request = getGetRequest(project1.getString(ProtocolConstants.KEY_CONTENT_LOCATION));
    WebResponse response = webConversation.getResponse(request);
    assertEquals(HttpURLConnection.HTTP_OK, response.getResponseCode());
    project1 = new JSONObject(response.getText());
    JSONObject gitSection1 = project1.optJSONObject(GitConstants.KEY_GIT);
    assertNotNull(gitSection1);//from   w w w. j  a  va  2 s .co m
    String gitRemoteUri1 = gitSection1.getString(GitConstants.KEY_REMOTE);

    // clone1: branch 'a'
    Repository db1 = getRepositoryForContentLocation(cloneContentLocation1);
    Git git1 = new Git(db1);
    branch(branchesLocation1, "a");

    // clone1: push all
    // TODO: replace with REST API when bug 339115 is fixed
    git1.push().setPushAll().call();

    // clone2
    JSONObject project2 = createProjectOrLink(workspaceLocation, getMethodName() + "2", null);
    IPath clonePath2 = getClonePath(workspaceId, project2);
    clone(clonePath2);

    // get project2 metadata
    request = getGetRequest(project2.getString(ProtocolConstants.KEY_CONTENT_LOCATION));
    response = webConversation.getResponse(request);
    assertEquals(HttpURLConnection.HTTP_OK, response.getResponseCode());
    project2 = new JSONObject(response.getText());
    JSONObject gitSection2 = project2.optJSONObject(GitConstants.KEY_GIT);
    assertNotNull(gitSection2);
    String gitRemoteUri2 = gitSection2.getString(GitConstants.KEY_REMOTE);

    // clone1: switch to 'a'
    assertBranchExist(git1, "a");
    checkoutBranch(cloneLocation1, "a");

    // clone1: change, add, commit
    JSONObject testTxt1 = getChild(project1, "test.txt");
    modifyFile(testTxt1, "branch 'a' change");
    addFile(testTxt1);
    commitFile(testTxt1, "incoming branch 'a' commit", false);

    // clone1: push
    ServerStatus pushStatus = push(gitRemoteUri1, 2, 0, "a", Constants.HEAD, false);
    assertTrue(pushStatus.isOK());

    // clone1: switch to 'master'
    checkoutBranch(cloneLocation1, Constants.MASTER);

    // clone1: change
    testTxt1 = getChild(project1, "test.txt");
    modifyFile(testTxt1, "branch 'master' change");
    addFile(testTxt1);
    commitFile(testTxt1, "incoming branch 'master' commit", false);

    // clone1: push
    push(gitRemoteUri1, 2, 0, Constants.MASTER, Constants.HEAD, false);

    // clone2: get remote details
    JSONObject aDetails = getRemoteBranch(gitRemoteUri2, 2, 1, "a");
    String aOldRefId = aDetails.getString(ProtocolConstants.KEY_ID);
    String aBranchLocation = aDetails.getString(ProtocolConstants.KEY_LOCATION);
    JSONObject masterDetails = getRemoteBranch(gitRemoteUri2, 2, 0, Constants.MASTER);
    String masterOldRefId = masterDetails.getString(ProtocolConstants.KEY_ID);

    // clone2: fetch 'a'
    fetch(aBranchLocation);

    // clone2: check for new content on 'a'
    masterDetails = getRemoteBranch(gitRemoteUri2, 2, 1, "a");
    String newRefId = masterDetails.getString(ProtocolConstants.KEY_ID);
    assertFalse(aOldRefId.equals(newRefId));

    // clone2: assert nothing new on 'master'
    masterDetails = getRemoteBranch(gitRemoteUri2, 2, 0, Constants.MASTER);
    newRefId = masterDetails.getString(ProtocolConstants.KEY_ID);
    assertEquals(masterOldRefId, newRefId);
}