Package org.eclipse.orion.server.core

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


      fetch(remotesArray.getJSONObject(1).getString(ProtocolConstants.KEY_LOCATION));

      // secondary
      request = getGetRequest(remotesArray.getJSONObject(1).getString(ProtocolConstants.KEY_LOCATION));
      response = webConversation.getResponse(request);
      ServerStatus status = waitForTask(response);
      assertTrue(status.toString(), status.isOK());
      JSONObject remote = status.getJsonData();

      // checkout remote branch: secondary/branch
      String remoteBranchName = remote.getJSONArray(ProtocolConstants.KEY_CHILDREN).getJSONObject(0).getString(ProtocolConstants.KEY_NAME);
      if (!remoteBranchName.equals("secondary/branch"))
        remoteBranchName = remote.getJSONArray(ProtocolConstants.KEY_CHILDREN).getJSONObject(1).getString(ProtocolConstants.KEY_NAME);
      assertEquals("secondary/branch", remoteBranchName);
      response = branch(branchesLocation, "branch", remoteBranchName);
      JSONObject branch = new JSONObject(response.getText());
      JSONArray remoteBranchLocations = branch.getJSONArray(GitConstants.KEY_REMOTE);
      assertEquals(1, remoteBranchLocations.length());
      assertEquals("secondary", remoteBranchLocations.getJSONObject(0).getString(ProtocolConstants.KEY_NAME));
      assertEquals("secondary/branch", remoteBranchLocations.getJSONObject(0).getJSONArray(ProtocolConstants.KEY_CHILDREN).getJSONObject(0).getString(ProtocolConstants.KEY_NAME));

      // origin
      request = getGetRequest(remotesArray.getJSONObject(0).getString(ProtocolConstants.KEY_LOCATION));
      response = webConversation.getResponse(request);
      status = waitForTask(response);
      assertTrue(status.toString(), status.isOK());
      remote = status.getJsonData();

      // checkout remote branch: origin/test
      JSONArray remoteChildren = remote.getJSONArray(ProtocolConstants.KEY_CHILDREN);
      assertEquals(2, remoteChildren.length());
      remoteBranchName = remoteChildren.getJSONObject(0).getString(ProtocolConstants.KEY_NAME);
View Full Code Here


    p = p.uptoSegment(2).append("xxx").append(p.removeFirstSegments(3));
    URI nu = new URI(u.getScheme(), u.getUserInfo(), u.getHost(), u.getPort(), p.toString(), u.getQuery(), u.getFragment());

    request = getGetGitRemoteRequest(nu.toString());
    response = webConversation.getResponse(request);
    ServerStatus status = waitForTask(response);
    assertEquals(status.toString(), status.getHttpCode(), HttpURLConnection.HTTP_NOT_FOUND);

    p = new Path(u.getPath());
    p = p.uptoSegment(3).append("xxx").append(p.removeFirstSegments(3));
    nu = new URI(u.getScheme(), u.getUserInfo(), u.getHost(), u.getPort(), p.toString(), u.getQuery(), u.getFragment());
View Full Code Here

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

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

      remoteBranch = getRemoteBranch(gitRemoteUri, 1, 0, Constants.MASTER);
      assertNotNull(remoteBranch);
      remoteBranchLocation = remoteBranch.getString(ProtocolConstants.KEY_LOCATION);
      request = getGetGitRemoteRequest(remoteBranchLocation);
View Full Code Here

    assertEquals(remoteLocation, remoteLocationFromBody);

    // check details
    WebRequest request = getGetRequest(remoteLocation);
    response = webConversation.getResponse(request);
    ServerStatus status = waitForTask(response);
    assertTrue(status.toString(), status.isOK());

    // list remotes
    request = getGetRequest(remotesLocation);
    response = webConversation.getResponse(request);
    status = waitForTask(response);
    assertTrue(status.toString(), status.isOK());
    JSONObject remotes = status.getJsonData();
    JSONArray remotesArray = remotes.getJSONArray(ProtocolConstants.KEY_CHILDREN);
    // expect origin and new remote
    assertEquals(2, remotesArray.length());

    // remove remote
    request = getDeleteGitRemoteRequest(remoteLocation);
    response = webConversation.getResponse(request);
    assertEquals(HttpURLConnection.HTTP_OK, response.getResponseCode());

    // list remotes again, make sure it's gone
    request = getGetRequest(remotesLocation);
    response = webConversation.getResponse(request);
    status = waitForTask(response);
    assertTrue(status.toString(), status.isOK());
    remotes = status.getJsonData();
    remotesArray = remotes.getJSONArray(ProtocolConstants.KEY_CHILDREN);
    // expect origin only
    assertEquals(1, remotesArray.length());
    getRemote(remotesLocation, 1, 0, Constants.DEFAULT_REMOTE_NAME);
  }
View Full Code Here

      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());

      // clone1: fetch
      request = GitFetchTest.getPostGitRemoteRequest(remoteBranchLocation1, true, false);
      response = webConversation.getResponse(request);
      ServerStatus status = waitForTask(response);
      assertTrue(status.toString(), status.isOK());

      // clone1: get remote details again
      JSONObject remoteBranch = getRemoteBranch(gitRemoteUri1, 1, 0, Constants.MASTER);
      String newRefId1 = remoteBranch.getString(ProtocolConstants.KEY_ID);
      // an incoming commit
View Full Code Here

    if (response.getResponseCode() == HttpURLConnection.HTTP_ACCEPTED) {
      String text = response.getText();
      JSONObject taskDescription = new JSONObject(text);
      String location = taskDescription.getString(ProtocolConstants.KEY_LOCATION);
      JSONObject taskResponse = waitForTaskCompletionObject(location, userName, userPassword);
      ServerStatus status = ServerStatus.fromJSON(taskResponse.getString("Result"));
      return status;
    }

    try {
      return ServerStatus.fromJSON(response.getText());
    } catch (Exception e) {
      JSONObject jsonData = null;
      try {
        jsonData = new JSONObject(response.getText());
      } catch (Exception e1) {
        //ignore
      }
      return new ServerStatus(response.getResponseCode() == HttpURLConnection.HTTP_OK ? IStatus.OK : IStatus.ERROR, response.getResponseCode(), response.getText(), jsonData, null);
    }
  }
View Full Code Here

  }

  protected JSONObject clone(URIish uri, IPath workspacePath, IPath filePath, String name, String kh, char[] p) throws JSONException, IOException, SAXException, CoreException {
    // clone
    WebRequest request = getPostGitCloneRequest(uri, workspacePath, filePath, name, kh, p);
    ServerStatus status = waitForTask(webConversation.getResponse(request));

    assertTrue(status.toString(), status.isOK());

    String cloneLocation = status.getJsonData().getString(ProtocolConstants.KEY_LOCATION);
    assertNotNull(cloneLocation);

    // validate the clone metadata
    WebResponse response = webConversation.getResponse(getGetRequest(cloneLocation));
    assertEquals(HttpURLConnection.HTTP_OK, response.getResponseCode());
View Full Code Here

  // init

  protected JSONObject init(IPath workspacePath, IPath filePath, String name) throws JSONException, IOException, SAXException, CoreException {
    // no Git URL for init
    WebRequest request = getPostGitCloneRequest(null, workspacePath, filePath, name, null, null);
    ServerStatus status = waitForTask(webConversation.getResponse(request));

    assertTrue(status.toString(), status.isOK());

    String cloneLocation = status.getJsonData().getString(ProtocolConstants.KEY_LOCATION);
    assertNotNull(cloneLocation);

    // validate the clone metadata
    WebResponse response = webConversation.getResponse(getGetRequest(cloneLocation));
    assertEquals(HttpURLConnection.HTTP_OK, response.getResponseCode());
View Full Code Here

   * @throws JSONException
   */
  protected ServerStatus push(String gitRemoteBranchUri, String srcRef, boolean tags, boolean force) throws IOException, SAXException, JSONException {
    assertRemoteOrRemoteBranchLocation(gitRemoteBranchUri);
    WebRequest request = GitPushTest.getPostGitRemoteRequest(gitRemoteBranchUri, srcRef, tags, force);
    ServerStatus status = waitForTask(webConversation.getResponse(request));
    return status;
  }
View Full Code Here

  protected ServerStatus push(String gitRemoteUri, int size, int i, String name, String srcRef, boolean tags, boolean force, String userName, String kh, byte[] privk, byte[] pubk, byte[] p, boolean shouldBeOK) throws IOException, SAXException, JSONException {
    assertRemoteUri(gitRemoteUri);
    String remoteBranchLocation = getRemoteBranch(gitRemoteUri, size, i, name).getString(ProtocolConstants.KEY_LOCATION);
    WebRequest request = GitPushTest.getPostGitRemoteRequest(remoteBranchLocation, srcRef, tags, force, userName, kh, privk, pubk, p);
    WebResponse response = webConversation.getResponse(request);
    ServerStatus status = waitForTask(response);

    if (shouldBeOK) {
      assertTrue(status.toString(), status.isOK());
    }

    return status;
  }
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.