private WebRequest getDeleteCloneRequest(String requestURI) throws CoreException, IOException {
   assertCloneUri(requestURI);
   WebRequest request = new DeleteMethodWebRequest(requestURI);
   request.setHeaderField(ProtocolConstants.HEADER_ORION_VERSION, "1");
   setAuthentication(request);
   return request;
 }
  public void testInvocationContext() throws Exception {
    final String resourceName = "something/interesting";

    ServletRunner sr = new ServletRunner();
    sr.registerServlet(resourceName, StatefulServlet.class.getName());
    ServletUnitClient suc = sr.newClient();

    WebRequest request = new PostMethodWebRequest("http://localhost/" + resourceName);
    request.setParameter("color", "red");

    InvocationContext ic = suc.newInvocation(request);
    StatefulServlet ss = (StatefulServlet) ic.getServlet();
    assertNull("A session already exists", ss.getColor(ic.getRequest()));

    ss.setColor(ic.getRequest(), "blue");
    assertEquals("Color in session", "blue", ss.getColor(ic.getRequest()));

    Enumeration e = ic.getRequest().getSession().getAttributeNames();
    assertNotNull("No attribute list returned", e);
    assertTrue("No attribute names in list", e.hasMoreElements());
    assertEquals("First attribute name", "color", e.nextElement());
    assertTrue("List did not end after one name", !e.hasMoreElements());

    String[] names = ic.getRequest().getSession().getValueNames();
    assertEquals("number of value names", 1, names.length);
    assertEquals("first name", "color", names[0]);
  }
Exemple #3
0
  /**
   * Check sorted column.
   *
   * @param jspName jsp name, with full path
   * @throws Exception any axception thrown during test.
   */
  @Test
  public void doTest() throws Exception {
    WebRequest request = new GetMethodWebRequest(getJspUrl(getJspName()));

    ParamEncoder encoder = new ParamEncoder("table");
    request.setParameter(encoder.encodeParameterName(TableTagParameters.PARAMETER_SORT), "1");
    request.setParameter(
        encoder.encodeParameterName(TableTagParameters.PARAMETER_SORTUSINGNAME), "1");

    WebResponse response = runner.getResponse(request);

    if (log.isDebugEnabled()) {
      log.debug(response.getText());
    }

    WebTable[] tables = response.getTables();
    Assert.assertEquals("Wrong number of tables in result.", 1, tables.length);
    Assert.assertEquals("Wrong number of rows in result.", 3, tables[0].getRowCount());

    if (log.isDebugEnabled()) {
      log.debug(response.getText());
    }

    Assert.assertEquals(
        "Wrong value in first row. Table incorrectly sorted?", "2", tables[0].getCellAsText(1, 1));
    Assert.assertEquals(
        "Column 1 should not be marked as sorted.",
        "sortable",
        tables[0].getTableCell(0, 1).getClassName());
    Assert.assertEquals(
        "Column 2 should be marked as sorted.",
        "sortable sorted order1",
        tables[0].getTableCell(0, 2).getClassName());
  }
 /**
  * Uses httpunit to go over the network to make a GET REST request.
  *
  * @param urlRelativeToBaseUrl
  * @return
  * @throws MalformedURLException
  * @throws IOException
  * @throws SAXException
  */
 protected WebResponse makeHttpRestGetRequest(String urlRelativeToBaseUrl)
     throws MalformedURLException, IOException, SAXException {
   WebRequest webRequest =
       new GetMethodWebRequest(this.httpRestTransport.getBaseUrl() + urlRelativeToBaseUrl);
   webRequest.setHeaderField("Accept", HttpRestTransport.APPLICATION_XML);
   return this.webConversation.getResponse(webRequest);
 }
  @Test
  public void testCopyFileOverwrite() throws Exception {
    String directoryPath = "/testCopyFile/directory/path" + System.currentTimeMillis();
    String sourcePath = directoryPath + "/source.txt";
    String destName = "destination.txt";
    String destPath = directoryPath + "/" + destName;
    createDirectory(directoryPath);
    createFile(sourcePath, "This is the contents");
    createFile(destPath, "Original file");

    // with no-overwrite, copy should fail
    JSONObject requestObject = new JSONObject();
    addSourceLocation(requestObject, sourcePath);
    WebRequest request =
        getPostFilesRequest(directoryPath, requestObject.toString(), "destination.txt");
    request.setHeaderField("X-Create-Options", "copy,no-overwrite");
    WebResponse response = webConversation.getResponse(request);
    assertEquals(HttpURLConnection.HTTP_PRECON_FAILED, response.getResponseCode());

    // now omit no-overwrite and copy should succeed and return 200 instead of 201
    request = getPostFilesRequest(directoryPath, requestObject.toString(), "destination.txt");
    request.setHeaderField("X-Create-Options", "copy");
    response = webConversation.getResponse(request);
    assertEquals(HttpURLConnection.HTTP_OK, response.getResponseCode());
    JSONObject responseObject = new JSONObject(response.getText());
    checkFileMetadata(responseObject, destName, null, null, null, null, null, null, null);
    assertTrue(checkFileExists(sourcePath));
    assertTrue(checkFileExists(destPath));
  }
 static WebRequest getGetGitConfigRequest(String location) {
   String requestURI = toAbsoluteURI(location);
   WebRequest request = new GetMethodWebRequest(requestURI);
   request.setHeaderField(ProtocolConstants.HEADER_ORION_VERSION, "1");
   setAuthentication(request);
   return request;
 }
 // request a table from the servlet
 WebResponse getTable(String table, boolean text) throws Exception {
   initServletRunner();
   WebRequest request = new GetMethodWebRequest("http://null/DaemonStatus");
   request.setParameter("table", table);
   if (text) {
     request.setParameter("output", "text");
   }
   return sClient.getResponse(request);
 }
 static WebRequest getPutGitConfigRequest(String location, String value)
     throws JSONException, UnsupportedEncodingException {
   String requestURI = toAbsoluteURI(location);
   JSONObject body = new JSONObject();
   body.put(GitConstants.KEY_CONFIG_ENTRY_VALUE, value);
   WebRequest request =
       new PutMethodWebRequest(requestURI, IOUtilities.toInputStream(body.toString()), "UTF-8");
   request.setHeaderField(ProtocolConstants.HEADER_ORION_VERSION, "1");
   setAuthentication(request);
   return request;
 }
Exemple #9
0
 /**
  * Creates a request to get the diff result for the given location.
  *
  * @param location Either an absolute URI, or a workspace-relative URI
  */
 static WebRequest getGetGitDiffRequest(String location) {
   String requestURI;
   if (location.startsWith("http://")) requestURI = location;
   else if (location.startsWith("/")) requestURI = SERVER_LOCATION + location;
   else
     requestURI = SERVER_LOCATION + GIT_SERVLET_LOCATION + GitConstants.DIFF_RESOURCE + location;
   WebRequest request = new GetMethodWebRequest(requestURI);
   request.setHeaderField(ProtocolConstants.HEADER_ORION_VERSION, "1");
   setAuthentication(request);
   return request;
 }
Exemple #10
0
  public void testStateCookies() throws Exception {
    final String resourceName = "something/interesting";

    ServletRunner sr = new ServletRunner();
    sr.registerServlet(resourceName, StatefulServlet.class.getName());

    WebRequest request = new PostMethodWebRequest("http://localhost/" + resourceName);
    request.setParameter("color", "red");
    WebResponse response = sr.getResponse(request);
    assertNotNull("No response received", response);
    assertEquals("Returned cookie count", 1, response.getNewCookieNames().length);
  }
 /**
  * Get list of clones for the given workspace or path. When <code>path</code> is not <code>null
  * </code> the result is narrowed to clones under the <code>path</code>.
  *
  * @param workspaceId the workspace ID. Must be null if path is provided.
  * @param path path under the workspace starting with project ID. Must be null if workspaceId is
  *     provided.
  * @return the request
  */
 private WebRequest listGitClonesRequest(String workspaceId, IPath path) {
   assertTrue(workspaceId == null && path != null || workspaceId != null && path == null);
   String requestURI = SERVER_LOCATION + GIT_SERVLET_LOCATION + Clone.RESOURCE + '/';
   if (workspaceId != null) {
     requestURI += "workspace/" + workspaceId;
   } else {
     requestURI += "path" + (path.isAbsolute() ? path : path.makeAbsolute());
   }
   WebRequest request = new GetMethodWebRequest(requestURI);
   request.setHeaderField(ProtocolConstants.HEADER_ORION_VERSION, "1");
   setAuthentication(request);
   return request;
 }
Exemple #12
0
  private static String useGoogleTranslator(String text, TranslationType type) {

    String response = "";
    String urlString =
        "http://translate.google.com/translate_t?text=" + text + "&langpair=" + type.getID();
    // disable scripting to avoid requiring js.jar
    HttpUnitOptions.setScriptingEnabled(false);

    // create the conversation object which will maintain state for us
    WebConversation wc = new WebConversation();

    // Obtain the google translation page
    WebRequest webRequest = new GetMethodWebRequest(urlString);
    // required to prevent a 403 forbidden error from google
    webRequest.setHeaderField("User-agent", "Mozilla/4.0");

    try {
      WebResponse webResponse = wc.getResponse(webRequest);
      // NodeList list = webResponse.getDOM().getDocumentElement().getElementsByTagName("div");
      try {
        NodeList list2 =
            XPathAPI.selectNodeList(webResponse.getDOM(), "//span[@id='result_box']/span/text()");

        for (int i = 0; i < list2.getLength(); ++i) {
          response = response + list2.item(i).getNodeValue() + " ";
        }

      } catch (TransformerException e) {
        Log.warning("Translator error", e);
      }

      //            int length = list.getLength();
      //            for (int i = 0; i < length; i++) {
      //                Element element = (Element)list.item(i);
      //                if ("result_box".equals(element.getAttribute("id"))) {
      //                    Node translation = element.getFirstChild();
      //                    if (translation != null) {
      //                        response = translation.getNodeValue();
      //                    }
      //                }
      //            }
    } catch (MalformedURLException e) {
      Log.error("Could not for url: " + e);
    } catch (IOException e) {
      Log.error("Could not get response: " + e);
    } catch (SAXException e) {
      Log.error("Could not parse response content: " + e);
    }

    return response;
  }
 /**
  * Verifies that submitting the login form without entering a name results in a page containing
  * the text "Login failed"
  */
 public void testQuery() throws Exception {
   WebConversation conversation = new WebConversation();
   // GetMethodWebRequest
   WebRequest request =
       new GetMethodWebRequest(TestConstants.host + "rest/fPMovieTemplate/query.json");
   request.setParameter("JSESSIONID", user.getLoginSessionid());
   WebResponse response = tryGetResponse(conversation, request);
   //	      WebForm loginForm = response.getForms()[0];
   //	      request = loginForm.getRequest();
   //	      response = conversation.getResponse( request );
   HttpUtils.println(conversation, request, response);
   assertTrue("登录-成功", response.getText().indexOf("success") != -1);
   //
   //	      assertTrue( "Login not rejected", response.getText().indexOf( "Login failed" ) != -1 );
 }
  @Test
  public void testCopyFileInvalidSource() throws Exception {
    String directoryPath = "/testCopyFile/directory/path" + System.currentTimeMillis();
    createDirectory(directoryPath);

    JSONObject requestObject = new JSONObject();
    requestObject.put("Location", "/this/does/not/exist/at/all");
    WebRequest request =
        getPostFilesRequest(directoryPath, requestObject.toString(), "destination.txt");
    request.setHeaderField("X-Create-Options", "copy");
    WebResponse response = webConversation.getResponse(request);
    assertEquals(HttpURLConnection.HTTP_NOT_FOUND, response.getResponseCode());
    JSONObject responseObject = new JSONObject(response.getText());
    assertEquals("Error", responseObject.get("Severity"));
  }
Exemple #15
0
  public void testSessionAccess() throws Exception {
    final String resourceName1 = "something/interesting/start";
    final String resourceName2 = "something/continue";

    ServletRunner sr = new ServletRunner();
    sr.registerServlet(resourceName1, StatefulServlet.class.getName());
    sr.registerServlet(resourceName2, StatefulServlet.class.getName());

    WebRequest request = new PostMethodWebRequest("http://localhost/" + resourceName1);
    request.setParameter("color", "yellow");
    sr.getResponse(request);

    assertNotNull("No session was created", sr.getSession(false));
    assertEquals(
        "Color attribute in session", "yellow", sr.getSession(false).getAttribute("color"));
  }
Exemple #16
0
  /**
   * Test for content disposition and filename.
   *
   * @param jspName jsp name, with full path
   * @throws Exception any axception thrown during test.
   */
  @Test
  public void doTest() throws Exception {

    ParamEncoder encoder = new ParamEncoder("table");
    String mediaParameter = encoder.encodeParameterName(TableTagParameters.PARAMETER_EXPORTTYPE);

    WebRequest request = new GetMethodWebRequest(getJspUrl(getJspName()));
    request.setParameter(mediaParameter, Integer.toString(MediaTypeEnum.CSV.getCode()));

    WebResponse response = runner.getResponse(request);

    // we are really testing an xml output?
    Assert.assertEquals(
        "Expected a different content type.", "text/csv", response.getContentType());
    Assert.assertEquals("Wrong content.", "1\n2\n3\n", response.getText());
  }
Exemple #17
0
  private static WebRequest getPostGitDiffRequest(String location, String right)
      throws JSONException, UnsupportedEncodingException {
    String requestURI;
    if (location.startsWith("http://")) requestURI = location;
    else if (location.startsWith("/")) requestURI = SERVER_LOCATION + location;
    else
      requestURI = SERVER_LOCATION + GIT_SERVLET_LOCATION + GitConstants.DIFF_RESOURCE + location;

    JSONObject body = new JSONObject();
    body.put(GitConstants.KEY_COMMIT_NEW, right);
    WebRequest request =
        new PostMethodWebRequest(requestURI, getJsonAsStream(body.toString()), "UTF-8");
    request.setHeaderField(ProtocolConstants.HEADER_ORION_VERSION, "1");
    setAuthentication(request);
    return request;
  }
Exemple #18
0
  public void testInvocationCompletion() throws Exception {
    final String resourceName = "something/interesting";

    ServletRunner sr = new ServletRunner();
    sr.registerServlet(resourceName, StatefulServlet.class.getName());
    ServletUnitClient suc = sr.newClient();

    WebRequest request = new PostMethodWebRequest("http://localhost/" + resourceName);
    request.setParameter("color", "red");

    InvocationContext ic = suc.newInvocation(request);
    StatefulServlet ss = (StatefulServlet) ic.getServlet();
    ss.setColor(ic.getRequest(), "blue");
    ss.writeSelectMessage("blue", ic.getResponse().getWriter());

    WebResponse response = ic.getServletResponse();
    assertEquals("requested resource", "You selected blue", response.getText());
    assertEquals("Returned cookie count", 1, response.getNewCookieNames().length);
  }
 @Test
 public void testCopyFileNoOverwrite() throws Exception {
   String directoryPath = "/testCopyFile/directory/path" + System.currentTimeMillis();
   String sourcePath = directoryPath + "/source.txt";
   String destName = "destination.txt";
   String destPath = directoryPath + "/" + destName;
   createDirectory(directoryPath);
   createFile(sourcePath, "This is the contents");
   JSONObject requestObject = new JSONObject();
   addSourceLocation(requestObject, sourcePath);
   WebRequest request =
       getPostFilesRequest(directoryPath, requestObject.toString(), "destination.txt");
   request.setHeaderField("X-Create-Options", "copy");
   WebResponse response = webConversation.getResponse(request);
   assertEquals(HttpURLConnection.HTTP_CREATED, response.getResponseCode());
   JSONObject responseObject = new JSONObject(response.getText());
   checkFileMetadata(responseObject, destName, null, null, null, null, null, null, null);
   assertTrue(checkFileExists(sourcePath));
   assertTrue(checkFileExists(destPath));
 }
 private WebRequest getCheckoutRequest(String location, String[] paths, boolean removeUntracked)
     throws IOException, JSONException {
   String requestURI;
   if (location.startsWith("http://")) {
     // assume the caller knows what he's doing
     // assertCloneUri(location);
     requestURI = location;
   } else {
     requestURI = SERVER_LOCATION + GIT_SERVLET_LOCATION + Clone.RESOURCE + location;
   }
   JSONObject body = new JSONObject();
   JSONArray jsonPaths = new JSONArray();
   for (String path : paths) jsonPaths.put(path);
   body.put(ProtocolConstants.KEY_PATH, jsonPaths);
   if (removeUntracked) body.put(GitConstants.KEY_REMOVE_UNTRACKED, removeUntracked);
   WebRequest request =
       new PutMethodWebRequest(requestURI, IOUtilities.toInputStream(body.toString()), "UTF-8");
   request.setHeaderField(ProtocolConstants.HEADER_ORION_VERSION, "1");
   setAuthentication(request);
   return request;
 }
  /**
   * @param query to search for.
   * @param attrs attributes to return from search
   * @param ldifFile to compare with
   * @throws Exception On test failure.
   */
  @Parameters({"searchServletQuery", "searchServletAttrs", "searchServletLdif"})
  @Test(groups = {"servlettest"})
  public void searchServlet(final String query, final String attrs, final String ldifFile)
      throws Exception {
    final String ldif = TestUtil.readFileIntoString(ldifFile);
    final LdapEntry entry = TestUtil.convertLdifToEntry(ldif);

    final ServletUnitClient sc = this.ldifServletRunner.newClient();
    final WebRequest request =
        new PostMethodWebRequest("http://servlets.search.ldap.middleware.vt.edu/LdifPeopleSearch");
    request.setParameter("query", query);
    request.setParameter("attrs", attrs.split("\\|"));

    final WebResponse response = sc.getResponse(request);

    AssertJUnit.assertNotNull(response);
    AssertJUnit.assertEquals("text/plain", response.getContentType());

    final LdapEntry result = TestUtil.convertLdifToEntry(response.getText());
    AssertJUnit.assertEquals(entry, result);
  }
Exemple #22
0
  public void testInvocationContextUpdate() throws Exception {
    final String resourceName = "something/interesting";

    ServletRunner sr = new ServletRunner();
    sr.registerServlet(resourceName, StatefulServlet.class.getName());
    ServletUnitClient suc = sr.newClient();

    WebRequest request = new PostMethodWebRequest("http://localhost/" + resourceName);
    request.setParameter("color", "red");

    InvocationContext ic = suc.newInvocation(request);
    StatefulServlet ss = (StatefulServlet) ic.getServlet();
    ss.setColor(ic.getRequest(), "blue");
    suc.getResponse(ic);

    WebResponse response = suc.getResponse("http://localhost/" + resourceName);
    assertNotNull("No response received", response);
    assertEquals("content type", "text/plain", response.getContentType());
    assertEquals("requested resource", "You posted blue", response.getText());
    assertEquals("Returned cookie count", 0, response.getNewCookieNames().length);
  }
  /**
   * @param query to search for.
   * @param attrs attributes to return from search
   * @param ldifFile to compare with
   * @throws Exception On test failure.
   */
  @Parameters({"searchServletQuery", "searchServletAttrs", "searchServletLdif"})
  @Test(groups = {"servlettest"})
  public void dsmlSearchServlet(final String query, final String attrs, final String ldifFile)
      throws Exception {
    final String ldif = TestUtil.readFileIntoString(ldifFile);
    final DsmlResult entry = new DsmlResult(TestUtil.convertLdifToEntry(ldif));

    final ServletUnitClient sc = this.dsmlServletRunner.newClient();
    // test basic dsml query
    WebRequest request =
        new PostMethodWebRequest("http://servlets.search.ldap.middleware.vt.edu/DsmlPeopleSearch");
    request.setParameter("query", query);
    request.setParameter("attrs", attrs.split("\\|"));

    WebResponse response = sc.getResponse(request);

    AssertJUnit.assertNotNull(response);
    AssertJUnit.assertEquals("text/xml", response.getContentType());
    AssertJUnit.assertEquals(entry.toDsmlv1(), response.getText());

    // test plain text
    request =
        new PostMethodWebRequest("http://servlets.search.ldap.middleware.vt.edu/DsmlPeopleSearch");
    request.setParameter("content-type", "text");
    request.setParameter("query", query);
    request.setParameter("attrs", attrs.split("\\|"));
    response = sc.getResponse(request);

    AssertJUnit.assertNotNull(response);
    AssertJUnit.assertEquals("text/plain", response.getContentType());
    AssertJUnit.assertEquals(entry.toDsmlv1(), response.getText());

    // test dsmlv2
    request =
        new PostMethodWebRequest("http://servlets.search.ldap.middleware.vt.edu/DsmlPeopleSearch");
    request.setParameter("dsml-version", "2");
    request.setParameter("query", query);
    request.setParameter("attrs", attrs.split("\\|"));
    response = sc.getResponse(request);

    AssertJUnit.assertNotNull(response);
    AssertJUnit.assertEquals("text/xml", response.getContentType());
    AssertJUnit.assertEquals(entry.toDsmlv2(), response.getText());
  }
Exemple #24
0
  public void testStatePreservation() throws Exception {
    final String resourceName1 = "something/interesting/start";
    final String resourceName2 = "something/continue";

    ServletRunner sr = new ServletRunner();
    sr.registerServlet(resourceName1, StatefulServlet.class.getName());
    sr.registerServlet(resourceName2, StatefulServlet.class.getName());
    WebClient wc = sr.newClient();

    WebRequest request = new PostMethodWebRequest("http://localhost/" + resourceName1);
    request.setParameter("color", "red");
    WebResponse response = wc.getResponse(request);
    assertNotNull("No response received", response);
    assertEquals("content type", "text/plain", response.getContentType());
    assertEquals("requested resource", "You selected red", response.getText());

    request = new GetMethodWebRequest("http://localhost/" + resourceName2);
    response = wc.getResponse(request);
    assertNotNull("No response received", response);
    assertEquals("content type", "text/plain", response.getContentType());
    assertEquals("requested resource", "You posted red", response.getText());
    assertEquals("Returned cookie count", 0, response.getNewCookieNames().length);
  }
  @Test
  public void testCreateFileOverwrite()
      throws CoreException, IOException, SAXException, JSONException {
    String directoryPath = "sample/directory/path" + System.currentTimeMillis();
    createDirectory(directoryPath);
    String fileName = "testfile.txt";

    WebRequest request =
        getPostFilesRequest(directoryPath, getNewFileJSON(fileName).toString(), fileName);
    WebResponse response = webConversation.getResponse(request);
    assertEquals(HttpURLConnection.HTTP_CREATED, response.getResponseCode());

    // creating again at the same location should succeed but return OK rather than CREATED
    request = getPostFilesRequest(directoryPath, getNewFileJSON(fileName).toString(), fileName);
    response = webConversation.getResponse(request);
    assertEquals(HttpURLConnection.HTTP_OK, response.getResponseCode());

    // creating with no-overwrite should fail if it already exists
    request = getPostFilesRequest(directoryPath, getNewFileJSON(fileName).toString(), fileName);
    request.setHeaderField("X-Create-Options", "no-overwrite");
    response = webConversation.getResponse(request);
    assertEquals(HttpURLConnection.HTTP_PRECON_FAILED, response.getResponseCode());
  }
  /**
   * Check that the "no results" property is loaded from the correct locale file.
   *
   * @param jspName jsp name, with full path
   * @throws Exception any axception thrown during test.
   */
  @Test
  public void doTest() throws Exception {

    WebRequest request = new GetMethodWebRequest(getJspUrl(getJspName()));
    request.setHeaderField("Accept-Language", "en-us,en;q=0.5");

    WebResponse response = runner.getResponse(request);

    if (log.isDebugEnabled()) {
      log.debug("RESPONSE: " + response.getText());
    }

    Assert.assertTrue(
        "Expected message\"" + MSG_DEFAULT + "\" has not been found in response with locale en",
        response.getText().indexOf(MSG_DEFAULT) > -1);
    Assert.assertTrue(
        "Unexpected message\"" + MSG_IT + "\" has been found in response with locale en",
        response.getText().indexOf(MSG_IT) == -1);

    // Now, with an Italian locale.
    request = new GetMethodWebRequest(getJspUrl(getJspName()));
    request.setHeaderField("Accept-Language", "it-it,it;q=0.5");

    response = runner.getResponse(request);

    if (log.isDebugEnabled()) {
      log.debug("RESPONSE: " + response.getText());
    }

    Assert.assertTrue(
        "Expected message\"" + MSG_IT + "\" has not been found in response with locale it",
        response.getText().indexOf(MSG_IT) > -1);
    Assert.assertTrue(
        "Unexpected message\"" + MSG_DEFAULT + "\" has been found in response with locale it",
        response.getText().indexOf(MSG_DEFAULT) == -1);
  }
  @Test
  public void testGetOthersClones() throws Exception {
    // my clone
    URI workspaceLocation = createWorkspace(getMethodName());
    String workspaceId = getWorkspaceId(workspaceLocation);
    JSONObject project = createProjectOrLink(workspaceLocation, getMethodName(), null);
    IPath clonePath =
        new Path("file").append(project.getString(ProtocolConstants.KEY_ID)).makeAbsolute();
    clone(clonePath);

    WebRequest request = listGitClonesRequest(workspaceId, null);
    WebResponse response = webConversation.getResponse(request);
    assertEquals(HttpURLConnection.HTTP_OK, response.getResponseCode());
    JSONObject clones = new JSONObject(response.getText());
    JSONArray clonesArray = clones.getJSONArray(ProtocolConstants.KEY_CHILDREN);
    assertEquals(1, clonesArray.length());

    createUser("bob", "bob");
    // URI bobWorkspaceLocation = createWorkspace(getMethodName() + "bob");
    String workspaceName = getClass().getName() + "#" + getMethodName() + "bob";
    request = new PostMethodWebRequest(SERVER_LOCATION + "/workspace");
    request.setHeaderField(ProtocolConstants.HEADER_SLUG, workspaceName);
    request.setHeaderField(ProtocolConstants.HEADER_ORION_VERSION, "1");
    setAuthentication(request, "bob", "bob");
    response = webConversation.getResponse(request);
    assertEquals(HttpURLConnection.HTTP_OK, response.getResponseCode());
    URI bobWorkspaceLocation =
        URI.create(response.getHeaderField(ProtocolConstants.HEADER_LOCATION));

    // String bobWorkspaceId = getWorkspaceId(bobWorkspaceLocation);
    request = new GetMethodWebRequest(bobWorkspaceLocation.toString());
    request.setHeaderField(ProtocolConstants.HEADER_ORION_VERSION, "1");
    setAuthentication(request, "bob", "bob");
    response = webConversation.getResponse(request);

    // JSONObject bobProject = createProjectOrLink(bobWorkspaceLocation, getMethodName() + "bob",
    // null);
    JSONObject body = new JSONObject();
    request =
        new PostMethodWebRequest(
            bobWorkspaceLocation.toString(), IOUtilities.toInputStream(body.toString()), "UTF-8");
    request.setHeaderField(ProtocolConstants.HEADER_SLUG, getMethodName() + "bob");
    request.setHeaderField(ProtocolConstants.HEADER_ORION_VERSION, "1");
    setAuthentication(request, "bob", "bob");
    response = webConversation.getResponse(request);
    assertEquals(HttpURLConnection.HTTP_CREATED, response.getResponseCode());
    JSONObject bobProject = new JSONObject(response.getText());
    assertEquals(getMethodName() + "bob", bobProject.getString(ProtocolConstants.KEY_NAME));
    String bobProjectId = bobProject.optString(ProtocolConstants.KEY_ID, null);
    assertNotNull(bobProjectId);

    IPath bobClonePath = new Path("file").append(bobProjectId).makeAbsolute();

    // bob's clone
    URIish uri = new URIish(gitDir.toURI().toURL());
    request = getPostGitCloneRequest(uri, null, bobClonePath, null, null, null);
    setAuthentication(request, "bob", "bob");
    response = webConversation.getResponse(request);
    response = waitForTaskCompletionObjectResponse(response, "bob", "bob");
    String cloneLocation = response.getHeaderField(ProtocolConstants.HEADER_LOCATION);
    if (cloneLocation == null) {
      JSONObject taskResp = new JSONObject(response.getText());
      assertTrue(taskResp.has(ProtocolConstants.KEY_LOCATION));
      cloneLocation = taskResp.getString(ProtocolConstants.KEY_LOCATION);
    }
    assertNotNull(cloneLocation);

    // validate the clone metadata
    request = getGetRequest(cloneLocation);
    setAuthentication(request, "bob", "bob");
    response = webConversation.getResponse(request);
    assertEquals(HttpURLConnection.HTTP_OK, response.getResponseCode());

    // list my clones again
    request = listGitClonesRequest(workspaceId, null);
    response = webConversation.getResponse(request);
    assertEquals(HttpURLConnection.HTTP_OK, response.getResponseCode());
    clones = new JSONObject(response.getText());
    clonesArray = clones.getJSONArray(ProtocolConstants.KEY_CHILDREN);
    assertEquals(1, clonesArray.length()); // nothing has been added

    // try to get Bob's clone
    request = getGetRequest(cloneLocation);
    response = webConversation.getResponse(request);
    assertEquals(HttpURLConnection.HTTP_NOT_FOUND, response.getResponseCode());
  }