// modified + checkout = clean
  @Test
  @Ignore("not supported yet")
  public void testCheckoutDotPath() throws Exception {
    // clone a repo
    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 =
        getGetFilesRequest(project.getString(ProtocolConstants.KEY_CONTENT_LOCATION));
    WebResponse response = webConversation.getResponse(request);
    assertEquals(HttpURLConnection.HTTP_OK, response.getResponseCode());
    project = new JSONObject(response.getText());

    JSONObject testTxt = getChild(project, "test.txt");
    modifyFile(testTxt, "change");

    JSONObject folder1 = getChild(project, "folder");
    JSONObject folderTxt = getChild(folder1, "folder.txt");
    modifyFile(folderTxt, "change");

    JSONObject gitSection = project.getJSONObject(GitConstants.KEY_GIT);
    String gitStatusUri = gitSection.getString(GitConstants.KEY_STATUS);
    String gitCloneUri = GitStatusTest.getCloneUri(gitStatusUri);

    request = getCheckoutRequest(gitCloneUri, new String[] {"."});
    response = webConversation.getResponse(request);
    assertEquals(HttpURLConnection.HTTP_OK, response.getResponseCode());

    assertStatus(StatusResult.CLEAN, gitStatusUri);
  }
  /**
   * Uses HttpUnit functionality to retrieve a single sds offering (including curnit and jnlp) from
   * the sds.
   *
   * @param sdsOfferingId The id of the offering you want to retrieve
   * @return The SdsOffering with all parameters set.
   * @throws IOException
   * @throws JDOMException
   * @throws SAXException
   */
  protected SdsOffering getOfferingAlternativeMethod(Serializable sdsOfferingId)
      throws IOException, JDOMException, SAXException {
    WebResponse webResponse = this.makeHttpRestGetRequest("/offering/" + sdsOfferingId);
    assertEquals(HttpStatus.SC_OK, webResponse.getResponseCode());

    Document doc = createDocumentFromResponse(webResponse);
    SdsOffering sdsOffering = (SdsOffering) this.applicationContext.getBean("sdsOffering");
    Element offeringElement = doc.getRootElement();
    sdsOffering.setName(offeringElement.getChild("name").getValue());
    sdsOffering.setSdsObjectId(new Long(offeringElement.getChild("id").getValue()));

    Long sdsCurnitId = new Long(offeringElement.getChild("curnit-id").getValue());
    SdsCurnit sdsCurnit = this.getCurnitInSds(sdsCurnitId);
    sdsOffering.setSdsCurnit(sdsCurnit);

    Long sdsJnlpId = new Long(offeringElement.getChild("jnlp-id").getValue());
    SdsJnlp sdsJnlp = this.getJnlpInSds(sdsJnlpId);
    sdsOffering.setSdsJnlp(sdsJnlp);

    WebResponse curnitMapWebResponse =
        this.makeHttpRestGetRequest("/offering/" + sdsOfferingId + "/curnitmap");
    assertEquals(HttpStatus.SC_OK, curnitMapWebResponse.getResponseCode());

    Document curnitMapDoc = createDocumentFromResponse(curnitMapWebResponse);
    sdsOffering.setSdsCurnitMap(curnitMapDoc.getRootElement().getText());

    return sdsOffering;
  }
  // modified + checkout = clean
  @Test
  public void testCheckoutInFolder() throws Exception {
    // clone a repo
    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 =
        getGetFilesRequest(project.getString(ProtocolConstants.KEY_CONTENT_LOCATION));
    WebResponse response = webConversation.getResponse(request);
    assertEquals(HttpURLConnection.HTTP_OK, response.getResponseCode());
    project = new JSONObject(response.getText());

    JSONObject testTxt = getChild(project, "test.txt");
    modifyFile(testTxt, "change");

    JSONObject folder1 = getChild(project, "folder");
    JSONObject folderTxt = getChild(folder1, "folder.txt");
    modifyFile(folderTxt, "change");

    JSONObject gitSection = folder1.getJSONObject(GitConstants.KEY_GIT);
    String gitStatusUri = gitSection.getString(GitConstants.KEY_STATUS);
    // we should get a proper clone URI here: /git/clone/file/{projectId}/
    String gitCloneUri = GitStatusTest.getCloneUri(gitStatusUri);

    request = getCheckoutRequest(gitCloneUri, new String[] {"folder/folder.txt"});
    response = webConversation.getResponse(request);
    assertEquals(HttpURLConnection.HTTP_OK, response.getResponseCode());

    // 'test.txt' is still modified
    assertStatus(new StatusResult().setModifiedNames("test.txt"), gitStatusUri);
  }
  @Test
  public void testCheckoutBranch() throws Exception {
    // clone a repo
    URI workspaceLocation = createWorkspace(getMethodName());
    JSONObject project = createProjectOrLink(workspaceLocation, getMethodName(), null);
    IPath clonePath =
        new Path("file").append(project.getString(ProtocolConstants.KEY_ID)).makeAbsolute();
    JSONObject clone = clone(clonePath);
    String cloneContentLocation = clone.getString(ProtocolConstants.KEY_CONTENT_LOCATION);
    String cloneLocation = clone.getString(ProtocolConstants.KEY_LOCATION);
    String branchesLocation = clone.getString(GitConstants.KEY_BRANCH);

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

    // create branch 'a'
    branch(branchesLocation, "a");

    // checkout 'a'
    response = checkoutBranch(cloneLocation, "a");
    assertEquals(HttpURLConnection.HTTP_OK, response.getResponseCode());
    Repository db1 = getRepositoryForContentLocation(cloneContentLocation);
    Git git = new Git(db1);
    GitRemoteTest.assertOnBranch(git, "a");
  }
  @Test
  public void testCheckoutPathInUri() throws Exception {
    // clone a repo
    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 =
        getGetFilesRequest(project.getString(ProtocolConstants.KEY_CONTENT_LOCATION));
    WebResponse response = webConversation.getResponse(request);
    assertEquals(HttpURLConnection.HTTP_OK, response.getResponseCode());
    project = new JSONObject(response.getText());

    JSONObject testTxt = getChild(project, "test.txt");
    modifyFile(testTxt, "change");

    JSONObject gitSection = project.getJSONObject(GitConstants.KEY_GIT);
    String gitStatusUri = gitSection.getString(GitConstants.KEY_STATUS);
    String gitCloneUri = GitStatusTest.getCloneUri(gitStatusUri);

    // TODO: don't create URIs out of thin air
    request = getCheckoutRequest(gitCloneUri + "test.txt", new String[] {});
    response = webConversation.getResponse(request);
    assertEquals(HttpURLConnection.HTTP_BAD_REQUEST, response.getResponseCode());
  }
  @Test
  public void testCheckoutAfterResetByPath() throws Exception {
    URI workspaceLocation = createWorkspace(getMethodName());
    JSONObject projectTop = createProjectOrLink(workspaceLocation, getMethodName() + "-top", null);
    IPath clonePathTop =
        new Path("file").append(projectTop.getString(ProtocolConstants.KEY_ID)).makeAbsolute();
    JSONObject projectFolder =
        createProjectOrLink(workspaceLocation, getMethodName() + "-folder", null);
    IPath clonePathFolder =
        new Path("file")
            .append(projectFolder.getString(ProtocolConstants.KEY_ID))
            .append("folder")
            .makeAbsolute();

    IPath[] clonePaths = new IPath[] {clonePathTop, clonePathFolder};

    for (IPath clonePath : clonePaths) {
      // clone a repo
      JSONObject clone = clone(clonePath);
      String cloneContentLocation = clone.getString(ProtocolConstants.KEY_CONTENT_LOCATION);

      // get project/folder metadata
      WebRequest request = getGetFilesRequest(cloneContentLocation);
      WebResponse response = webConversation.getResponse(request);
      assertEquals(HttpURLConnection.HTTP_OK, response.getResponseCode());
      JSONObject folder = new JSONObject(response.getText());

      JSONObject gitSection = folder.getJSONObject(GitConstants.KEY_GIT);
      String gitIndexUri = gitSection.getString(GitConstants.KEY_INDEX);
      String gitStatusUri = gitSection.getString(GitConstants.KEY_STATUS);
      String gitCloneUri = GitStatusTest.getCloneUri(gitStatusUri);

      JSONObject testTxt = getChild(folder, "test.txt");
      modifyFile(testTxt, "change");

      assertStatus(new StatusResult().setModified(1), gitStatusUri);

      addFile(testTxt);

      assertStatus(new StatusResult().setChanged(1), gitStatusUri);

      // unstage
      request =
          GitResetTest.getPostGitIndexRequest(
              gitIndexUri, new String[] {"test.txt"}, null, (String) null);
      response = webConversation.getResponse(request);
      assertEquals(HttpURLConnection.HTTP_OK, response.getResponseCode());

      // check status again
      assertStatus(new StatusResult().setModified(1), gitStatusUri);

      // checkout
      request = getCheckoutRequest(gitCloneUri, new String[] {"test.txt"});
      response = webConversation.getResponse(request);
      assertEquals(HttpURLConnection.HTTP_OK, response.getResponseCode());

      // check status one more time
      assertStatus(StatusResult.CLEAN, gitStatusUri);
    }
  }
  @Test
  public void testUpdateNonExistingConfigEntryUsingPUT() throws Exception {
    URI workspaceLocation = createWorkspace(getMethodName());
    IPath[] clonePaths = createTestProjects(workspaceLocation);

    for (IPath clonePath : clonePaths) {
      // clone a  repo
      String contentLocation = clone(clonePath).getString(ProtocolConstants.KEY_CONTENT_LOCATION);

      // get project metadata
      WebRequest request = getGetRequest(contentLocation);
      WebResponse response = webConversation.getResponse(request);
      assertEquals(HttpURLConnection.HTTP_OK, response.getResponseCode());
      JSONObject project = new JSONObject(response.getText());
      JSONObject gitSection = project.getJSONObject(GitConstants.KEY_GIT);
      String gitConfigUri = gitSection.getString(GitConstants.KEY_CONFIG);

      final String ENTRY_KEY = "a.b.c";
      final String ENTRY_VALUE = "v";

      String invalidEntryLocation =
          gitConfigUri.replace(ConfigOption.RESOURCE, ConfigOption.RESOURCE + "/" + ENTRY_KEY);

      // check if it doesn't exist
      request = getGetGitConfigRequest(invalidEntryLocation);
      response = webConversation.getResponse(request);
      assertEquals(HttpURLConnection.HTTP_NOT_FOUND, response.getResponseCode());

      // try to update non-existing config entry using PUT (not allowed)
      request = getPutGitConfigRequest(invalidEntryLocation, ENTRY_VALUE);
      response = webConversation.getResponse(request);
      assertEquals(HttpURLConnection.HTTP_NOT_FOUND, response.getResponseCode());
    }
  }
  @Test
  public void testCreateInvalidConfigEntry() throws Exception {
    URI workspaceLocation = createWorkspace(getMethodName());
    IPath[] clonePaths = createTestProjects(workspaceLocation);

    for (IPath clonePath : clonePaths) {
      // clone a  repo
      String contentLocation = clone(clonePath).getString(ProtocolConstants.KEY_CONTENT_LOCATION);

      // get project metadata
      WebRequest request = getGetRequest(contentLocation);
      WebResponse response = webConversation.getResponse(request);
      assertEquals(HttpURLConnection.HTTP_OK, response.getResponseCode());
      JSONObject project = new JSONObject(response.getText());
      JSONObject gitSection = project.getJSONObject(GitConstants.KEY_GIT);
      String gitConfigUri = gitSection.getString(GitConstants.KEY_CONFIG);

      final String INVALID_ENTRY_KEY = "a"; // no name specified, dot missing
      final String ENTRY_VALUE = "v";

      // try to set entry with invalid key
      request = getPostGitConfigRequest(gitConfigUri, INVALID_ENTRY_KEY, ENTRY_VALUE);
      response = webConversation.getResponse(request);
      assertEquals(HttpURLConnection.HTTP_BAD_REQUEST, response.getResponseCode());
    }
  }
  @Test
  public void testGetSingleConfigEntry() throws Exception {
    URI workspaceLocation = createWorkspace(getMethodName());
    IPath[] clonePaths = createTestProjects(workspaceLocation);

    for (IPath clonePath : clonePaths) {
      // clone a  repo
      String contentLocation = clone(clonePath).getString(ProtocolConstants.KEY_CONTENT_LOCATION);

      // get project metadata
      WebRequest request = getGetRequest(contentLocation);
      WebResponse response = webConversation.getResponse(request);
      assertEquals(HttpURLConnection.HTTP_OK, response.getResponseCode());
      JSONObject project = new JSONObject(response.getText());
      JSONObject gitSection = project.getJSONObject(GitConstants.KEY_GIT);
      String gitConfigUri = gitSection.getString(GitConstants.KEY_CONFIG);

      // set some dummy value
      final String ENTRY_KEY = "a.b.c";
      final String ENTRY_VALUE = "v";

      request = getPostGitConfigRequest(gitConfigUri, ENTRY_KEY, ENTRY_VALUE);
      response = webConversation.getResponse(request);
      assertEquals(HttpURLConnection.HTTP_CREATED, response.getResponseCode());
      JSONObject configResponse = new JSONObject(response.getText());
      String entryLocation = configResponse.getString(ProtocolConstants.KEY_LOCATION);

      JSONObject configEntry = listConfigEntries(entryLocation);
      assertConfigOption(configEntry, ENTRY_KEY, ENTRY_VALUE);
    }
  }
  /**
   * Uses HttpUnit functionality to retrieve a single sds workgroup from the sds, including the
   * offering and the members
   *
   * @param sdsWorkgroupId The id of the workgroup you want to retrieve
   * @return The SdsWorkgroup with all parameters set.
   * @throws IOException
   * @throws JDOMException
   * @throws SAXException
   */
  @SuppressWarnings("unchecked")
  protected SdsWorkgroup getWorkgroupInSds(Serializable sdsWorkgroupId)
      throws IOException, JDOMException, SAXException {
    String WORKGROUP_PATH = "/workgroup/" + sdsWorkgroupId;
    WebResponse webResponse = this.makeHttpRestGetRequest(WORKGROUP_PATH);
    assertEquals(HttpStatus.SC_OK, webResponse.getResponseCode());

    Document doc = createDocumentFromResponse(webResponse);
    SdsWorkgroup sdsWorkgroup = (SdsWorkgroup) this.applicationContext.getBean("sdsWorkgroup");

    Element workgroupElement = doc.getRootElement();
    sdsWorkgroup.setName(workgroupElement.getChild("name").getValue());
    sdsWorkgroup.setSdsObjectId(new Long(workgroupElement.getChild("id").getValue()));

    Integer sdsOfferingId = new Integer(workgroupElement.getChild("offering-id").getValue());
    SdsOffering sdsOffering = this.getOfferingAlternativeMethod(sdsOfferingId);
    sdsWorkgroup.setSdsOffering(sdsOffering);

    WebResponse membersWebResponse = this.makeHttpRestGetRequest(WORKGROUP_PATH + "/membership");
    assertEquals(HttpStatus.SC_OK, membersWebResponse.getResponseCode());
    Document membersDoc = createDocumentFromResponse(membersWebResponse);

    List<Element> memberElements =
        XPath.newInstance("/workgroup-memberships/workgroup-membership/sail-user-id")
            .selectNodes(membersDoc);

    for (Element memberNode : memberElements) {
      SdsUser sdsUser = this.getUserInSds(new Long(memberNode.getValue()));
      sdsWorkgroup.addMember(sdsUser);
    }

    return sdsWorkgroup;
  }
  @Test
  public void testCloneAndLinkToFolder() throws Exception {
    URI workspaceLocation = createWorkspace(getMethodName());
    JSONObject project = createProjectOrLink(workspaceLocation, getMethodName(), null);
    IPath clonePath =
        new Path("file").append(project.getString(ProtocolConstants.KEY_ID)).makeAbsolute();
    String contentLocation = clone(clonePath).getString(ProtocolConstants.KEY_CONTENT_LOCATION);

    File folder =
        new File(
            getRepositoryForContentLocation(contentLocation).getDirectory().getParentFile(),
            "folder");

    JSONObject newProject =
        createProjectOrLink(
            workspaceLocation, getMethodName() + "-link", folder.toURI().toString());
    String projectContentLocation = newProject.getString(ProtocolConstants.KEY_CONTENT_LOCATION);

    // http://<host>/file/<projectId>/
    WebRequest request = getGetFilesRequest(projectContentLocation);
    WebResponse response = webConversation.getResponse(request);
    assertEquals(HttpURLConnection.HTTP_OK, response.getResponseCode());
    JSONObject link = new JSONObject(response.getText());
    String childrenLocation = link.getString(ProtocolConstants.KEY_CHILDREN_LOCATION);
    assertNotNull(childrenLocation);

    // http://<host>/file/<projectId>/?depth=1
    request = getGetFilesRequest(childrenLocation);
    response = webConversation.getResponse(request);
    assertEquals(HttpURLConnection.HTTP_OK, response.getResponseCode());
    List<JSONObject> children = getDirectoryChildren(new JSONObject(response.getText()));
    String[] expectedChildren = new String[] {"folder.txt"};
    assertEquals("Wrong number of directory children", expectedChildren.length, children.size());
    assertEquals(expectedChildren[0], children.get(0).getString(ProtocolConstants.KEY_NAME));
  }
Beispiel #12
0
  @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));
  }
  @Test
  public void testCloneEmptyPath() throws Exception {
    URI workspaceLocation = createWorkspace(getMethodName());
    IPath clonePath =
        new Path("workspace").append(getWorkspaceId(workspaceLocation)).makeAbsolute();

    AuthorizationService.removeUserRight("test", "/");
    AuthorizationService.removeUserRight("test", "/*");

    // /workspace/{id}
    JSONObject clone = clone(clonePath, null, null);

    String cloneContentLocation = clone.getString(ProtocolConstants.KEY_CONTENT_LOCATION);
    WebRequest request = getGetFilesRequest(cloneContentLocation);
    WebResponse response = webConversation.getResponse(request);
    assertEquals(HttpURLConnection.HTTP_OK, response.getResponseCode());
    JSONObject project = new JSONObject(response.getText());
    assertEquals(gitDir.getName(), project.getString(ProtocolConstants.KEY_NAME));
    assertGitSectionExists(project);

    String childrenLocation = project.getString(ProtocolConstants.KEY_CHILDREN_LOCATION);
    assertNotNull(childrenLocation);

    // http://<host>/file/<projectId>/?depth=1
    request = getGetFilesRequest(childrenLocation);
    response = webConversation.getResponse(request);
    assertEquals(HttpURLConnection.HTTP_OK, response.getResponseCode());
  }
  @Test
  public void testGetNonexistingClone() throws Exception {
    URI workspaceLocation = createWorkspace(getMethodName());
    String workspaceId = getWorkspaceId(workspaceLocation);

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

    String dummyId = "dummyId";

    ensureCloneIdDoesntExist(clonesArray, dummyId);

    String requestURI =
        SERVER_LOCATION + GIT_SERVLET_LOCATION + Clone.RESOURCE + "/workspace/" + dummyId;
    request = getGetRequest(requestURI);
    response = webConversation.getResponse(request);
    assertEquals(HttpURLConnection.HTTP_NOT_FOUND, response.getResponseCode());

    requestURI = SERVER_LOCATION + GIT_SERVLET_LOCATION + Clone.RESOURCE + "/file/" + dummyId;
    request = getGetRequest(requestURI);
    response = webConversation.getResponse(request);
    assertEquals(HttpURLConnection.HTTP_NOT_FOUND, response.getResponseCode());
  }
Beispiel #15
0
  private void assertDiffUris(
      String expectedLocation, String[] expectedContent, JSONObject jsonPart)
      throws JSONException, IOException, SAXException {
    JSONObject gitSection = jsonPart.getJSONObject(GitConstants.KEY_GIT);
    assertNotNull(gitSection);

    String fileOldUri = gitSection.getString(GitConstants.KEY_COMMIT_OLD);
    assertNotNull(fileOldUri);
    WebRequest request = getGetFilesRequest(fileOldUri);
    WebResponse response = webConversation.getResponse(request);
    assertEquals(HttpURLConnection.HTTP_OK, response.getResponseCode());
    assertEquals(expectedContent[0], response.getText());

    String fileNewUri = gitSection.getString(GitConstants.KEY_COMMIT_NEW);
    assertNotNull(fileNewUri);
    request = getGetFilesRequest(fileNewUri);
    response = webConversation.getResponse(request);
    assertEquals(HttpURLConnection.HTTP_OK, response.getResponseCode());
    assertEquals(expectedContent[1], response.getText());

    String fileBaseUri = gitSection.getString(GitConstants.KEY_COMMIT_BASE);
    assertNotNull(fileBaseUri);
    request = getGetFilesRequest(fileBaseUri);
    response = webConversation.getResponse(request);
    assertEquals(HttpURLConnection.HTTP_OK, response.getResponseCode());
    assertEquals(expectedContent[2], response.getText());

    String diffUri = gitSection.getString(GitConstants.KEY_DIFF);
    assertNotNull(diffUri);
    assertEquals(expectedLocation, diffUri);
  }
  @Test
  public void testDeleteInWorkspace() throws Exception {
    URI workspaceLocation = createWorkspace(getMethodName());
    JSONObject project = createProjectOrLink(workspaceLocation, getMethodName(), null);
    IPath clonePath =
        new Path("file").append(project.getString(ProtocolConstants.KEY_ID)).makeAbsolute();
    JSONObject clone = clone(clonePath);
    String cloneLocation = clone.getString(ProtocolConstants.KEY_LOCATION);
    String contentLocation = clone.getString(ProtocolConstants.KEY_CONTENT_LOCATION);

    Repository repository = getRepositoryForContentLocation(contentLocation);
    assertNotNull(repository);

    // delete folder with cloned repository in it
    WebRequest request = getDeleteFilesRequest(contentLocation);
    WebResponse response = webConversation.getResponse(request);
    assertEquals(HttpURLConnection.HTTP_OK, response.getResponseCode());

    // the clone is gone
    request = getGetRequest(cloneLocation);
    response = webConversation.getResponse(request);
    assertEquals(HttpURLConnection.HTTP_NOT_FOUND, response.getResponseCode());

    assertFalse(repository.getDirectory().exists());
  }
Beispiel #17
0
  @Test
  public void testCreateDirectory() throws CoreException, IOException, SAXException, JSONException {
    String directoryPath = "sample/directory/path" + System.currentTimeMillis();
    createDirectory(directoryPath);

    String dirName = "testdir";
    webConversation.setExceptionsThrownOnErrorStatus(false);

    WebRequest request =
        getPostFilesRequest(directoryPath, getNewDirJSON(dirName).toString(), dirName);
    WebResponse response = webConversation.getResponse(request);

    assertEquals(HttpURLConnection.HTTP_CREATED, response.getResponseCode());
    assertTrue(
        "Create directory response was OK, but the directory does not exist",
        checkDirectoryExists(directoryPath + "/" + dirName));
    assertEquals(
        "Response should contain directory metadata in JSON, but was " + response.getText(),
        "application/json",
        response.getContentType());
    JSONObject responseObject = new JSONObject(response.getText());
    assertNotNull("No directory information in response", responseObject);
    checkDirectoryMetadata(responseObject, dirName, null, null, null, null, null);

    // should be able to perform GET on location header to obtain metadata
    String location = response.getHeaderField(ProtocolConstants.HEADER_LOCATION);
    request = getGetFilesRequest(location);
    response = webConversation.getResource(request);
    assertNotNull(location);
    assertEquals(HttpURLConnection.HTTP_OK, response.getResponseCode());
    responseObject = new JSONObject(response.getText());
    assertNotNull("No direcory information in responce", responseObject);
    checkDirectoryMetadata(responseObject, dirName, null, null, null, null, null);
  }
  @Test
  public void testDeleteInFolder() throws Exception {
    URI workspaceLocation = createWorkspace(getMethodName());
    JSONObject project = createProjectOrLink(workspaceLocation, getMethodName(), null);
    IPath clonePath =
        new Path("file")
            .append(project.getString(ProtocolConstants.KEY_ID))
            .append("clone")
            .makeAbsolute();
    JSONObject clone = clone(clonePath);
    String cloneLocation = clone.getString(ProtocolConstants.KEY_LOCATION);
    String contentLocation = clone.getString(ProtocolConstants.KEY_CONTENT_LOCATION);

    // delete clone
    WebRequest request = getDeleteCloneRequest(cloneLocation);
    WebResponse response = webConversation.getResponse(request);
    assertEquals(HttpURLConnection.HTTP_OK, response.getResponseCode());

    // the clone is gone
    request = getGetRequest(cloneLocation);
    response = webConversation.getResponse(request);
    assertEquals(HttpURLConnection.HTTP_NOT_FOUND, response.getResponseCode());

    // so it's the folder
    request = getGetRequest(contentLocation);
    response = webConversation.getResponse(request);
    assertEquals(HttpURLConnection.HTTP_NOT_FOUND, response.getResponseCode());

    // but the project is still there
    request = getGetFilesRequest(project.getString(ProtocolConstants.KEY_ID));
    response = webConversation.getResponse(request);
    assertEquals(HttpURLConnection.HTTP_OK, response.getResponseCode());
  }
Beispiel #19
0
  @Test
  public void testCreateTopLevelFile()
      throws CoreException, IOException, SAXException, JSONException {
    String directoryPath = "sample" + 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());
    assertTrue(
        "Create file response was OK, but the file does not exist",
        checkFileExists(directoryPath + "/" + fileName));
    assertEquals(
        "Response should contain file metadata in JSON, but was " + response.getText(),
        "application/json",
        response.getContentType());
    JSONObject responseObject = new JSONObject(response.getText());
    assertNotNull("No file information in responce", responseObject);
    checkFileMetadata(responseObject, fileName, null, null, null, null, null, null, null);

    // should be able to perform GET on location header to obtain metadata
    String location = response.getHeaderField("Location");
    request = getGetFilesRequest(location + "?parts=meta");
    response = webConversation.getResource(request);
    assertNotNull(location);
    assertEquals(HttpURLConnection.HTTP_OK, response.getResponseCode());
    responseObject = new JSONObject(response.getText());
    assertNotNull("No direcory information in responce", responseObject);
    checkFileMetadata(responseObject, fileName, null, null, null, null, null, null, null);
  }
Beispiel #20
0
  @Test
  public void testDeleteNonEmptyDirectory() throws CoreException, IOException, SAXException {
    String dirPath1 = "sample/directory/path/sample1" + System.currentTimeMillis();
    String dirPath2 = "sample/directory/path/sample2" + System.currentTimeMillis();
    String fileName = "subfile.txt";
    String subDirectory = "subdirectory";

    createDirectory(dirPath1);
    createFile(dirPath1 + "/" + fileName, "Sample file content");
    createDirectory(dirPath2 + "/" + subDirectory);

    WebRequest request = getDeleteFilesRequest(dirPath1);
    WebResponse response = webConversation.getResponse(request);
    assertEquals(
        "Could not delete directory with file",
        HttpURLConnection.HTTP_OK,
        response.getResponseCode());

    assertFalse(
        "Delete directory with file request returned OK, but the file still exists",
        checkDirectoryExists(dirPath1));

    request = getDeleteFilesRequest(dirPath2);
    response = webConversation.getResponse(request);
    assertEquals(
        "Could not delete directory with subdirectory",
        HttpURLConnection.HTTP_OK,
        response.getResponseCode());

    assertFalse(
        "Delete directory with subdirectory request returned OK, but the file still exists",
        checkDirectoryExists(dirPath2));
  }
Beispiel #21
0
  @Test
  public void testDiffModifiedByOrion() throws Exception {
    URI workspaceLocation = createWorkspace(getMethodName());

    String projectName = getMethodName();
    JSONObject project = createProjectOrLink(workspaceLocation, projectName, gitDir.toString());
    String projectId = project.getString(ProtocolConstants.KEY_ID);

    WebRequest request = getPutFileRequest(projectId + "/test.txt", "hello");
    WebResponse response = webConversation.getResponse(request);
    assertEquals(HttpURLConnection.HTTP_OK, response.getResponseCode());

    JSONObject gitSection = project.optJSONObject(GitConstants.KEY_GIT);
    assertNotNull(gitSection);
    String gitDiffUri = gitSection.getString(GitConstants.KEY_DIFF);

    request = getGetGitDiffRequest(gitDiffUri);
    response = webConversation.getResponse(request);
    assertEquals(HttpURLConnection.HTTP_OK, response.getResponseCode());
    StringBuilder sb = new StringBuilder();
    sb.append("diff --git a/test.txt b/test.txt").append("\n");
    sb.append("index 30d74d2..b6fc4c6 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("+hello").append("\n");
    sb.append("\\ No newline at end of file").append("\n");
    String[] parts = parseMultiPartResponse(response);
    assertEquals(sb.toString(), parts[1]);
  }
Beispiel #22
0
  @Test
  public void testDiffFilter() throws Exception {
    URI workspaceLocation = createWorkspace(getMethodName());

    String projectName = getMethodName();
    JSONObject project = createProjectOrLink(workspaceLocation, projectName, gitDir.toString());
    String projectId = project.getString(ProtocolConstants.KEY_ID);

    JSONObject gitSection = project.optJSONObject(GitConstants.KEY_GIT);
    assertNotNull(gitSection);
    String gitDiffUri = gitSection.getString(GitConstants.KEY_DIFF);

    WebRequest request = getPutFileRequest(projectId + "/test.txt", "hi");
    WebResponse response = webConversation.getResponse(request);
    assertEquals(HttpURLConnection.HTTP_OK, response.getResponseCode());

    request = getPutFileRequest(projectId + "/folder/folder.txt", "folder change");
    response = webConversation.getResponse(request);
    assertEquals(HttpURLConnection.HTTP_OK, response.getResponseCode());

    // TODO: don't create URIs out of thin air
    request = getGetGitDiffRequest(gitDiffUri + "folder/");
    response = webConversation.getResponse(request);
    assertEquals(HttpURLConnection.HTTP_OK, response.getResponseCode());
    StringBuilder sb = new StringBuilder();
    sb.append("diff --git a/folder/folder.txt b/folder/folder.txt").append("\n");
    sb.append("index 0119635..95c4c65 100644").append("\n");
    sb.append("--- a/folder/folder.txt").append("\n");
    sb.append("+++ b/folder/folder.txt").append("\n");
    sb.append("@@ -1 +1 @@").append("\n");
    sb.append("-folder").append("\n");
    sb.append("\\ No newline at end of file").append("\n");
    sb.append("+folder change").append("\n");
    sb.append("\\ No newline at end of file").append("\n");
    String[] parts = parseMultiPartResponse(response);
    assertEquals(sb.toString(), parts[1]);

    // TODO: don't create URIs out of thin air
    gitDiffUri += "test.txt";
    request = getGetGitDiffRequest(gitDiffUri);
    response = webConversation.getResponse(request);
    assertEquals(HttpURLConnection.HTTP_OK, response.getResponseCode());
    parts = parseMultiPartResponse(response);

    assertDiffUris(gitDiffUri, new String[] {"test", "hi", "test"}, new JSONObject(parts[0]));

    sb.setLength(0);
    sb.append("diff --git a/test.txt b/test.txt").append("\n");
    sb.append("index 30d74d2..32f95c0 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("+hi").append("\n");
    sb.append("\\ No newline at end of file").append("\n");
    assertEquals(sb.toString(), parts[1]);
  }
  @Test
  public void testMergeIntoLocalFailedDirtyWorkTree() throws Exception {
    // clone a repo
    createWorkspace(SimpleMetaStore.DEFAULT_WORKSPACE_NAME);
    String workspaceId = workspaceIdFromLocation(workspaceLocation);
    JSONObject project =
        createProjectOrLink(workspaceLocation, getMethodName().concat("Project"), null);
    IPath clonePath = getClonePath(workspaceId, project);
    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.getJSONObject(GitConstants.KEY_GIT);
    String gitHeadUri = gitSection.getString(GitConstants.KEY_HEAD);
    String gitRemoteUri = gitSection.getString(GitConstants.KEY_REMOTE);

    // add a parallel commit in secondary clone and push it to the remote
    JSONObject project2 =
        createProjectOrLink(workspaceLocation, getMethodName().concat("Project2"), 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.getJSONObject(GitConstants.KEY_GIT);
    String gitRemoteUri2 = gitSection2.getString(GitConstants.KEY_REMOTE);

    JSONObject testTxt = getChild(project2, "test.txt");
    modifyFile(testTxt, "change in secondary");
    addFile(testTxt);
    commitFile(testTxt, "commit on branch", false);

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

    // modify on master and try to merge
    testTxt = getChild(project, "test.txt");
    modifyFile(testTxt, "dirty");

    JSONObject masterDetails = getRemoteBranch(gitRemoteUri, 1, 0, Constants.MASTER);
    String masterLocation = masterDetails.getString(ProtocolConstants.KEY_LOCATION);
    fetch(masterLocation);
    JSONObject merge = merge(gitHeadUri, Constants.DEFAULT_REMOTE_NAME + "/" + Constants.MASTER);

    MergeStatus mergeResult = MergeStatus.valueOf(merge.getString(GitConstants.KEY_RESULT));
    assertEquals(MergeStatus.FAILED, mergeResult);
    JSONObject failingPaths = merge.getJSONObject(GitConstants.KEY_FAILING_PATHS);
    assertEquals(1, failingPaths.length());
    assertEquals(
        MergeFailureReason.DIRTY_WORKTREE,
        MergeFailureReason.valueOf(failingPaths.getString("test.txt")));
  }
  @Test
  public void testRoom() throws Exception {
    // create room
    WebRequest request =
        new PostMethodWebRequest(
            getCreateUrl(),
            new ByteArrayInputStream(objectMapper.writeValueAsString(baseRoom).getBytes()),
            MediaType.APPLICATION_JSON_VALUE);
    WebResponse response = conversation.getResponse(request);
    assertEquals(HttpURLConnection.HTTP_CREATED, response.getResponseCode());
    assertEquals(MediaType.APPLICATION_JSON_VALUE, response.getContentType());
    Room room = objectMapper.readValue(response.getText(), Room.class);
    assertNotNull(room);
    assertTrue(room.getId() != 0);
    assertTrue(compare(baseRoom, room, "id"));

    // update room
    baseRoom = room;
    baseRoom.setName("New name");
    request =
        new PutMethodWebRequest(
            getUpdateUrl(),
            new ByteArrayInputStream(objectMapper.writeValueAsString(baseRoom).getBytes()),
            MediaType.APPLICATION_JSON_VALUE);
    response = conversation.getResponse(request);
    assertEquals(HttpURLConnection.HTTP_OK, response.getResponseCode());
    assertEquals(MediaType.APPLICATION_JSON_VALUE, response.getContentType());
    room = objectMapper.readValue(response.getText(), Room.class);
    assertNotNull(room);
    assertEquals(room, baseRoom);

    // get room
    request = new GetMethodWebRequest(getViewUrl(baseRoom.getId()));
    response = conversation.getResponse(request);
    assertEquals(HttpURLConnection.HTTP_OK, response.getResponseCode());
    assertEquals(MediaType.APPLICATION_JSON_VALUE, response.getContentType());
    room = objectMapper.readValue(response.getText(), Room.class);
    assertNotNull(room);
    assertEquals(room, baseRoom);

    // remove room
    request =
        new WebRequest(getDeleteUrl(baseRoom.getId())) {

          @Override
          public String getMethod() {
            return RequestMethod.DELETE.toString();
          }
        };
    response = conversation.getResponse(request);
    assertEquals(HttpURLConnection.HTTP_OK, response.getResponseCode());

    // check removed
    URL url = new URL(getViewUrl(baseRoom.getId()));
    HttpURLConnection connection = (HttpURLConnection) url.openConnection();
    connection.connect();
    assertEquals(HttpURLConnection.HTTP_NO_CONTENT, connection.getResponseCode());
  }
  @Test
  public void testAddConfigEntry() throws Exception {
    URI workspaceLocation = createWorkspace(getMethodName());
    IPath[] clonePaths = createTestProjects(workspaceLocation);

    for (IPath clonePath : clonePaths) {
      // clone a  repo
      String contentLocation = clone(clonePath).getString(ProtocolConstants.KEY_CONTENT_LOCATION);

      // get project metadata
      WebRequest request = getGetRequest(contentLocation);
      WebResponse response = webConversation.getResponse(request);
      assertEquals(HttpURLConnection.HTTP_OK, response.getResponseCode());
      JSONObject project = new JSONObject(response.getText());
      JSONObject gitSection = project.getJSONObject(GitConstants.KEY_GIT);
      String gitConfigUri = gitSection.getString(GitConstants.KEY_CONFIG);

      JSONObject configResponse = listConfigEntries(gitConfigUri);
      JSONArray configEntries = configResponse.getJSONArray(ProtocolConstants.KEY_CHILDREN);
      // initial number of config entries
      int initialConfigEntriesCount = configEntries.length();

      // set some dummy value
      final String ENTRY_KEY = "a.b.c";
      final String ENTRY_VALUE = "v";

      request = getPostGitConfigRequest(gitConfigUri, ENTRY_KEY, ENTRY_VALUE);
      response = webConversation.getResponse(request);
      assertEquals(HttpURLConnection.HTTP_CREATED, response.getResponseCode());
      configResponse = new JSONObject(response.getText());
      String entryLocation = configResponse.getString(ProtocolConstants.KEY_LOCATION);
      assertConfigUri(entryLocation);

      // get list of config entries again
      configResponse = listConfigEntries(gitConfigUri);
      configEntries = configResponse.getJSONArray(ProtocolConstants.KEY_CHILDREN);
      assertEquals(initialConfigEntriesCount + 1, configEntries.length());

      entryLocation = null;
      for (int i = 0; i < configEntries.length(); i++) {
        JSONObject configEntry = configEntries.getJSONObject(i);
        if (ENTRY_KEY.equals(configEntry.getString(GitConstants.KEY_CONFIG_ENTRY_KEY))) {
          assertConfigOption(configEntry, ENTRY_KEY, ENTRY_VALUE);
          break;
        }
      }

      // double check
      org.eclipse.jgit.lib.Config config =
          getRepositoryForContentLocation(contentLocation).getConfig();
      assertEquals(ENTRY_VALUE, config.getString("a", "b", "c"));
    }
  }
Beispiel #26
0
  @Test
  public void testDiffCached() throws Exception {
    URI workspaceLocation = createWorkspace(getMethodName());

    String projectName = getMethodName();
    JSONObject project = createProjectOrLink(workspaceLocation, projectName, gitDir.toString());
    String projectId = project.getString(ProtocolConstants.KEY_ID);

    JSONObject gitSection = project.optJSONObject(GitConstants.KEY_GIT);
    assertNotNull(gitSection);

    String gitDiffUri = gitSection.optString(GitConstants.KEY_DIFF, null);
    assertNotNull(gitDiffUri);
    String gitIndexUri = gitSection.optString(GitConstants.KEY_INDEX, null);
    assertNotNull(gitIndexUri);

    WebRequest request = getPutFileRequest(projectId + "/test.txt", "stage me");
    WebResponse response = webConversation.getResponse(request);
    assertEquals(HttpURLConnection.HTTP_OK, response.getResponseCode());

    // TODO: don't create URIs out of thin air
    // "git add test.txt"
    request = GitAddTest.getPutGitIndexRequest(gitIndexUri + "test.txt");
    response = webConversation.getResponse(request);
    assertEquals(HttpURLConnection.HTTP_OK, response.getResponseCode());

    // TODO: don't create URIs out of thin air
    gitDiffUri =
        gitDiffUri.replaceAll(GitConstants.KEY_DIFF_DEFAULT, GitConstants.KEY_DIFF_CACHED)
            + "test.txt";
    request = getGetGitDiffRequest(gitDiffUri);
    response = webConversation.getResponse(request);
    assertEquals(HttpURLConnection.HTTP_OK, response.getResponseCode());
    String[] parts = parseMultiPartResponse(response);

    assertDiffUris(gitDiffUri, new String[] {"test", "stage me", "test"}, new JSONObject(parts[0]));

    StringBuilder sb = new StringBuilder();
    sb.append("diff --git a/test.txt b/test.txt").append("\n");
    sb.append("index 30d74d2..b874aa3 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("+stage me").append("\n");
    sb.append("\\ No newline at end of file").append("\n");
    assertEquals(sb.toString(), parts[1]);
  }
Beispiel #27
0
  @Test
  public void testReadDirectoryChildren()
      throws CoreException, IOException, SAXException, JSONException {
    String dirName = "path" + System.currentTimeMillis();
    String directoryPath = "sample/directory/" + dirName;
    createDirectory(directoryPath);

    String subDirectory = "subdirectory";
    createDirectory(directoryPath + "/" + subDirectory);

    String subFile = "subfile.txt";
    createFile(directoryPath + "/" + subFile, "Sample file");

    WebRequest request = getGetFilesRequest(directoryPath + "?depth=1");
    WebResponse response = webConversation.getResponse(request);
    assertEquals(HttpURLConnection.HTTP_OK, response.getResponseCode());

    List<JSONObject> children = getDirectoryChildren(new JSONObject(response.getText()));

    assertEquals("Wrong number of directory children", 2, children.size());

    for (JSONObject child : children) {
      if (child.getBoolean("Directory")) {
        checkDirectoryMetadata(child, subDirectory, null, null, null, null, null);
      } else {
        checkFileMetadata(child, subFile, null, null, null, null, null, null, null);
      }
    }
  }
  @Test
  public void testCloneEmptyPathBadUrl() throws Exception {
    URI workspaceLocation = createWorkspace(getMethodName());
    IPath workspacePath =
        new Path("workspace").append(getWorkspaceId(workspaceLocation)).makeAbsolute();

    AuthorizationService.removeUserRight("test", "/");
    AuthorizationService.removeUserRight("test", "/*");

    // /workspace/{id} + {methodName}
    WebRequest request =
        new PostGitCloneRequest()
            .setURIish("I'm//bad!")
            .setWorkspacePath(workspacePath)
            .setName(getMethodName())
            .getWebRequest();
    WebResponse response = webConversation.getResponse(request);
    assertEquals(HttpURLConnection.HTTP_BAD_REQUEST, response.getResponseCode());

    // no project should be created
    request = new GetMethodWebRequest(workspaceLocation.toString());
    setAuthentication(request);
    response = webConversation.getResponse(request);
    JSONObject workspace = new JSONObject(response.getText());
    assertEquals(0, workspace.getJSONArray(ProtocolConstants.KEY_CHILDREN).length());
  }
  @Test
  public void testGetCloneAndPull() throws Exception {
    // see bug 339254
    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();
    String contentLocation = clone(clonePath).getString(ProtocolConstants.KEY_CONTENT_LOCATION);

    // get clones for workspace
    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());

    Git git = new Git(getRepositoryForContentLocation(contentLocation));
    // TODO: replace with RESTful API when ready, see bug 339114
    PullResult pullResult = git.pull().call();
    assertEquals(pullResult.getMergeResult().getMergeStatus(), MergeStatus.ALREADY_UP_TO_DATE);
    assertEquals(RepositoryState.SAFE, git.getRepository().getRepositoryState());
  }
  public void testViewIssueNotFound() throws Exception {
    administration.restoreBlankInstance();

    WebResponse resp123 = GET("rest/api/2/issue/1");
    assertEquals(404, resp123.getResponseCode());
    assertNoLongerExistsError(resp123);

    WebResponse resp123Xml =
        GET("rest/api/2/issue/1", singletonMap("Accept", "application/xml;q=0.9,*/*;q=0.8"));
    assertEquals(404, resp123Xml.getResponseCode());
    assertNoLongerExistsError(resp123Xml);

    WebResponse resp415 =
        GET("rest/api/2/issue/1", singletonMap("Accept", "application/xml;q=0.9"));
    assertEquals(406, resp415.getResponseCode());
  }