Ejemplo n.º 1
0
 public void testUploadFileAlreadyExists() throws Exception {
   String fileName = "existedFile.txt";
   VirtualFile folder = mountPoint.getVirtualFileById(uploadTestFolderId);
   folder.createFile(fileName, new ByteArrayInputStream(DEFAULT_CONTENT.getBytes()));
   ContainerResponse response = doUploadFile(fileName, DEFAULT_CONTENT, "", "", false);
   assertEquals(200, response.getStatus());
   String entity = (String) response.getEntity();
   assertTrue(entity.contains("Item with the same name exists"));
   log.info(entity);
 }
Ejemplo n.º 2
0
  @Override
  protected void setUp() throws Exception {
    super.setUp();
    String name = getClass().getName();
    VirtualFile deleteTestFolder = mountPoint.getRoot().createFolder(name);

    VirtualFile folder = deleteTestFolder.createFolder("DeleteTest_FOLDER");
    // add child in folder
    VirtualFile childFile =
        folder.createFile("file", new ByteArrayInputStream(DEFAULT_CONTENT.getBytes()));
    folderId = folder.getId();
    folderChildId = childFile.getId();
    folderPath = folder.getPath();
    folderChildPath = childFile.getPath();

    file =
        deleteTestFolder.createFile(
            "DeleteTest_FILE", new ByteArrayInputStream(DEFAULT_CONTENT.getBytes()));
    fileId = file.getId();
    filePath = file.getPath();
  }
Ejemplo n.º 3
0
  public void testUploadFileAlreadyExistsOverwrite() throws Exception {
    String fileName = "existedFileOverwrite.txt";
    VirtualFile folder = mountPoint.getVirtualFileById(uploadTestFolderId);
    folder.createFile(fileName, new ByteArrayInputStream(DEFAULT_CONTENT.getBytes()));

    String fileContent = "test upload and overwrite existed file";
    ContainerResponse response = doUploadFile(fileName, fileContent, "", "", true);
    assertEquals(200, response.getStatus());
    String expectedPath = uploadTestFolderPath + '/' + fileName;
    VirtualFile file = mountPoint.getVirtualFile(expectedPath);
    assertNotNull("File was not created in expected location. ", file);
    checkFileContext(fileContent, MediaType.TEXT_PLAIN, file);
  }