Пример #1
0
  @Test
  public void saveAndGetAttachment() throws IOException, GitAPIException {
    register(globalRepoManager.createProjectCentralRepository(PROJECT, USER));
    ILockedRepository repo =
        globalRepoManager.createProjectBranchRepository(PROJECT, BRANCH_1, null);
    register(repo);
    saveRandomPage(BRANCH_1, "foo/bar/baz"); // $NON-NLS-1$
    Page attachment =
        Page.fromData(new byte[] {1, 2, 3}, "application/octet-stream"); // $NON-NLS-1$
    pageStore.saveAttachment(
        PROJECT,
        BRANCH_1,
        "foo/bar/baz",
        "test.dat",
        attachment,
        USER); //$NON-NLS-1$ //$NON-NLS-2$

    Page result =
        pageStore.getAttachment(
            PROJECT, BRANCH_1, "foo/bar/baz", "test.dat"); // $NON-NLS-1$ //$NON-NLS-2$
    assertTrue(ArrayUtils.isEquals(attachment.getData(), result.getData()));
    assertEquals(attachment.getContentType(), result.getContentType());

    assertClean(repo.r());
  }
Пример #2
0
  @Test
  public void saveAndGetPage() throws IOException, GitAPIException {
    register(globalRepoManager.createProjectCentralRepository(PROJECT, USER));
    ILockedRepository repo =
        globalRepoManager.createProjectBranchRepository(PROJECT, BRANCH_1, null);
    register(repo);
    Page page = saveRandomPage(BRANCH_1, "home/foo"); // $NON-NLS-1$
    Page result = pageStore.getPage(PROJECT, BRANCH_1, "home/foo", true); // $NON-NLS-1$
    assertEquals(page.getTitle(), result.getTitle());
    assertEquals(
        ((PageTextData) page.getData()).getText(), ((PageTextData) result.getData()).getText());
    assertEquals(page.getContentType(), result.getContentType());
    assertEquals("home", result.getParentPagePath()); // $NON-NLS-1$
    assertNull(result.getViewRestrictionRole());

    verify(eventBus).post(new PageChangedEvent(PROJECT, BRANCH_1, "home/foo")); // $NON-NLS-1$

    assertClean(repo.r());
  }
Пример #3
0
  @Test
  public void savePageWithViewRestrictionRole() throws IOException, GitAPIException {
    register(globalRepoManager.createProjectCentralRepository(PROJECT, USER));
    ILockedRepository repo =
        globalRepoManager.createProjectBranchRepository(PROJECT, BRANCH_1, null);
    register(repo);
    Page page = Page.fromText("title", "text"); // $NON-NLS-1$ //$NON-NLS-2$
    page.setViewRestrictionRole("viewRole"); // $NON-NLS-1$
    pageStore.savePage(PROJECT, BRANCH_1, "home/foo", page, null, USER); // $NON-NLS-1$
    Page result = pageStore.getPage(PROJECT, BRANCH_1, "home/foo", true); // $NON-NLS-1$
    assertEquals(page.getTitle(), result.getTitle());
    assertEquals(
        ((PageTextData) page.getData()).getText(), ((PageTextData) result.getData()).getText());
    assertEquals(page.getContentType(), result.getContentType());
    assertEquals(page.getViewRestrictionRole(), result.getViewRestrictionRole());
    assertEquals("home", result.getParentPagePath()); // $NON-NLS-1$

    assertClean(repo.r());
  }