Package org.eclipse.orion.server.core

Examples of org.eclipse.orion.server.core.ServerStatus


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

    // clone1: push
    ServerStatus pushStatus = push(gitRemoteUri1, 1, 0, Constants.MASTER, Constants.HEAD, false, null, knownHosts2, privateKey, publicKey, passphrase, true);
    assertEquals(true, pushStatus.isOK());

    // clone2: get remote branch location
    JSONObject remoteBranch = getRemoteBranch(gitRemoteUri2, 1, 0, Constants.MASTER);
    String remoteBranchLocation2 = remoteBranch.getString(ProtocolConstants.KEY_LOCATION);
View Full Code Here


    // clone1: push by remote branch
    JSONArray remoteBranchLocations = branch.getJSONArray(GitConstants.KEY_REMOTE);
    assertEquals(1, remoteBranchLocations.length());
    String remoteBranchLocation = remoteBranchLocations.getJSONObject(0).getJSONArray(ProtocolConstants.KEY_CHILDREN).getJSONObject(0).getString(ProtocolConstants.KEY_LOCATION);
    ServerStatus pushStatus = push(remoteBranchLocation, Constants.HEAD, false);
    assertTrue(pushStatus.isOK());

    // clone1: get the remote branch name
    request = getGetRequest(remoteBranchLocation);
    response = webConversation.getResponse(request);
    JSONObject remoteBranch1 = new JSONObject(response.getText());
View Full Code Here

        i = 1;
        remoteBranchName = remoteBranchLocations1.getJSONObject(0).getJSONArray(ProtocolConstants.KEY_CHILDREN).getJSONObject(i).getString(ProtocolConstants.KEY_NAME);
      }
      assertEquals("origin/a", remoteBranchName);
      String remoteBranchLocation1 = remoteBranchLocations1.getJSONObject(0).getJSONArray(ProtocolConstants.KEY_CHILDREN).getJSONObject(i).getString(ProtocolConstants.KEY_LOCATION);
      ServerStatus pushStatus = push(remoteBranchLocation1, Constants.HEAD, false);
      assertEquals(true, pushStatus.isOK());

      // clone 1 - list remote branches - expect 2
      JSONObject remote1 = getRemote(gitRemoteUri1, 1, 0, Constants.DEFAULT_REMOTE_NAME);
      String remoteLocation1 = remote1.getString(ProtocolConstants.KEY_LOCATION);

      request = GitRemoteTest.getGetGitRemoteRequest(remoteLocation1);
      response = webConversation.getResponse(request);
      ServerStatus status = waitForTask(response);
      assertTrue(status.toString(), status.isOK());
      remote1 = status.getJsonData();
      JSONArray refsArray = remote1.getJSONArray(ProtocolConstants.KEY_CHILDREN);
      assertEquals(2, refsArray.length());
      JSONObject ref = refsArray.getJSONObject(0);
      assertEquals(Constants.R_REMOTES + Constants.DEFAULT_REMOTE_NAME + "/" + newBranchName, ref.getString(ProtocolConstants.KEY_FULL_NAME));
      ref = refsArray.getJSONObject(1);
      assertEquals(Constants.R_REMOTES + Constants.DEFAULT_REMOTE_NAME + "/" + Constants.MASTER, ref.getString(ProtocolConstants.KEY_FULL_NAME));

      // clone 2
      JSONObject clone2 = clone(clonePath[1]);
      String cloneLocation2 = clone2.getString(ProtocolConstants.KEY_LOCATION);
      String contentLocation2 = clone2.getString(ProtocolConstants.KEY_CONTENT_LOCATION);

      // clone 2 - get project2 metadata
      request = getGetRequest(contentLocation2);
      response = webConversation.getResponse(request);
      assertEquals(HttpURLConnection.HTTP_OK, response.getResponseCode());
      JSONObject project2 = new JSONObject(response.getText());
      JSONObject gitSection2 = project2.getJSONObject(GitConstants.KEY_GIT);
      String gitRemoteUri2 = gitSection2.getString(GitConstants.KEY_REMOTE);

      // clone 2 - check if the branch "a" is available
      JSONObject remote2 = getRemote(gitRemoteUri2, 1, 0, Constants.DEFAULT_REMOTE_NAME);
      String remoteLocation2 = remote2.getString(ProtocolConstants.KEY_LOCATION);

      request = GitRemoteTest.getGetGitRemoteRequest(remoteLocation2);
      response = webConversation.getResponse(request);
      assertEquals(HttpURLConnection.HTTP_OK, response.getResponseCode());
      remote2 = new JSONObject(response.getText());
      refsArray = remote2.getJSONArray(ProtocolConstants.KEY_CHILDREN);
      assertEquals(2, refsArray.length());
      ref = refsArray.getJSONObject(0);
      assertEquals(Constants.R_REMOTES + Constants.DEFAULT_REMOTE_NAME + "/" + Constants.MASTER, ref.getString(ProtocolConstants.KEY_FULL_NAME));
      ref = refsArray.getJSONObject(1);
      assertEquals(Constants.R_REMOTES + Constants.DEFAULT_REMOTE_NAME + "/" + newBranchName, ref.getString(ProtocolConstants.KEY_FULL_NAME));
      String remoteBranchLocation2 = ref.getString(ProtocolConstants.KEY_LOCATION);

      // clone 2 - checkout branch "a"
      response = checkoutBranch(cloneLocation2, newBranchName);

      // clone 1 - delete remote branch "a"
      push(remoteBranchLocation1, "", false, false);

      // clone 1 - list remote branches - expect 1
      request = GitRemoteTest.getGetGitRemoteRequest(remoteLocation1);
      response = webConversation.getResponse(request);
      assertEquals(HttpURLConnection.HTTP_OK, response.getResponseCode());
      remote1 = new JSONObject(response.getText());
      refsArray = remote1.getJSONArray(ProtocolConstants.KEY_CHILDREN);
      assertEquals(1, refsArray.length());
      ref = refsArray.getJSONObject(0);
      assertEquals(Constants.R_REMOTES + Constants.DEFAULT_REMOTE_NAME + "/" + Constants.MASTER, ref.getString(ProtocolConstants.KEY_FULL_NAME));

      // clone 2 - fetch
      request = GitFetchTest.getPostGitRemoteRequest(remoteBranchLocation2, true, false);
      response = webConversation.getResponse(request);
      status = waitForTask(response);
      assertFalse(status.toString(), status.isOK());

      // clone 2 - fetch task should fail
      JSONObject statusJson = status.toJSON();
      JSONObject result = statusJson.has("Result") ? statusJson.getJSONObject("Result") : statusJson;
      assertEquals("Error", result.getString("Severity"));
    }
  }
View Full Code Here

    String remoteBranchLocation = remoteLocations.getJSONObject(0).getJSONArray(ProtocolConstants.KEY_CHILDREN).getJSONObject(0).getString(ProtocolConstants.KEY_LOCATION);

    // push
    request = getPostGitRemoteRequest(remoteBranchLocation, Constants.HEAD, false, false);
    response = webConversation.getResponse(request);
    ServerStatus status = waitForTask(response);
    assertTrue(status.toString(), status.isOK());
  }
View Full Code Here

    request = GitCommitTest.getPostGitCommitRequest(gitHeadUri1, "clone1 change commit", false);
    response = webConversation.getResponse(request);
    assertEquals(HttpURLConnection.HTTP_OK, response.getResponseCode());

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

    // clone2: change
    JSONObject testTxt2 = getChild(project2, "test.txt");
    modifyFile(testTxt2, "clone2 change");

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

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

    // clone2: push
    pushStatus = push(gitRemoteUri2, 1, 0, Constants.MASTER, Constants.HEAD, false);
    JSONObject jo = pushStatus.getJsonData();
    assertEquals("Error", jo.get("Severity"));

    JSONArray up = (JSONArray) jo.get("Updates");
    assertEquals(1, up.length());
View Full Code Here

    modifyFile(testTxt, "1st change");
    addFile(testTxt);
    commitFile(testTxt, "1st change commit", false);

    // push
    ServerStatus pushStatus = push(gitRemoteUri, 1, 0, Constants.MASTER, Constants.HEAD, false);
    assertEquals(IStatus.OK, pushStatus.getSeverity());

    // 2nd commit
    modifyFile(testTxt, "2nd change");
    addFile(testTxt);
    commitFile(testTxt, "2nd change commit", false);

    FileUtils.delete(new File(gitDir, Constants.DOT_GIT + "/objects/pack/"), FileUtils.RECURSIVE);

    pushStatus = push(gitRemoteUri, 1, 0, Constants.MASTER, Constants.HEAD, false);
    JSONObject jo = pushStatus.getJsonData();

    JSONArray up = (JSONArray) jo.get("Updates");
    assertEquals(1, up.length());

    assertEquals("Error", jo.get("Severity"));
View Full Code Here

      request = GitCommitTest.getPostGitCommitRequest(gitHeadUri1, "clone1 change commit", false);
      response = webConversation.getResponse(request);
      assertEquals(HttpURLConnection.HTTP_OK, response.getResponseCode());

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

      // clone2: change
      JSONObject testTxt2 = getChild(project2, "test.txt");
      modifyFile(testTxt2, "clone2 change");

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

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

      // clone2: push
      pushStatus = push(gitRemoteUri2, 1, 0, Constants.MASTER, Constants.HEAD, false);
      JSONObject jo = pushStatus.getJsonData();

      JSONArray up = (JSONArray) jo.get("Updates");
      assertEquals(1, up.length());

      assertEquals("Error", jo.get("Severity"));
      Status pushResult = Status.valueOf((String) ((JSONObject) up.get(0)).get("Result"));
      assertEquals(Status.REJECTED_NONFASTFORWARD, pushResult);

      // clone2: forced push
      pushStatus = push(gitRemoteUri2, 1, 0, Constants.MASTER, Constants.HEAD, false, true);
      jo = pushStatus.getJsonData();
      up = (JSONArray) jo.get("Updates");
      assertEquals(1, up.length());
      assertEquals("OK", ((JSONObject) up.get(0)).get("Result"));
    }
  }
View Full Code Here

    String gitTagUri2 = gitSection2.getString(GitConstants.KEY_TAG);

    // clone1: tag HEAD with 'tag'
    tag(gitTagUri1, "tag", Constants.HEAD);

    ServerStatus pushStatus = push(gitRemoteUri1, 1, 0, Constants.MASTER, Constants.HEAD, true);
    assertEquals(true, pushStatus.isOK());

    // clone2: list tags
    JSONArray tags = listTags(gitTagUri2);
    assertEquals(0, tags.length());
View Full Code Here

        remoteBranchLocation = remoteBranchLocations.getJSONObject(0).getJSONArray(ProtocolConstants.KEY_CHILDREN).getJSONObject(0).getString(ProtocolConstants.KEY_LOCATION);
      } else if (remoteBranchLocations.getJSONObject(1).getString(ProtocolConstants.KEY_NAME).equals("secondary")) {
        remoteBranchLocation = remoteBranchLocations.getJSONObject(1).getJSONArray(ProtocolConstants.KEY_CHILDREN).getJSONObject(0).getString(ProtocolConstants.KEY_LOCATION);
      }
      assertNotNull(remoteBranchLocation);
      ServerStatus pushStatus = push(remoteBranchLocation, Constants.HEAD, false);
      assertTrue(pushStatus.isOK());

      // see bug 354144
      request = getGetRequest(branch.getString(ProtocolConstants.KEY_LOCATION));
      response = webConversation.getResponse(request);
      assertEquals(HttpURLConnection.HTTP_OK, response.getResponseCode());
View Full Code Here

        try {
          mappedPaths = getMapped(site, contextlessPath, req.getQueryString());
        } catch (URISyntaxException e) {
          String message = "Could not create target URI";
          logger.error(message, e);
          handleException(resp, new ServerStatus(IStatus.ERROR, HttpServletResponse.SC_BAD_REQUEST, message, e));
          return;
        }
        if (mappedPaths != null) {
          serve(req, resp, site, mappedPaths);
        } else {
          handleException(resp, new ServerStatus(IStatus.ERROR, HttpServletResponse.SC_NOT_FOUND, NLS.bind("No mappings matched {0}", path), null));
        }
      } else {
        resp.setHeader("Cache-Control", "no-cache"); //$NON-NLS-1$ //$NON-NLS-2$
        String msg = NLS.bind("Hosted site {0} is stopped", hostedHost);
        handleException(resp, new ServerStatus(IStatus.ERROR, HttpServletResponse.SC_NOT_FOUND, msg, null));
      }
    } else {
      super.doGet(req, resp);
    }
  }
View Full Code Here

TOP

Related Classes of org.eclipse.orion.server.core.ServerStatus

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.