@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()); }
@Test public void relocatePage() throws IOException, GitAPIException { register(globalRepoManager.createProjectCentralRepository(PROJECT, USER)); ILockedRepository repo = globalRepoManager.createProjectBranchRepository(PROJECT, BRANCH_1, null); register(repo); saveRandomPage(BRANCH_1, "home"); // $NON-NLS-1$ saveRandomPage(BRANCH_1, "home/foo"); // $NON-NLS-1$ Page page = saveRandomPage(BRANCH_1, "home/foo/bar"); // $NON-NLS-1$ saveRandomPage(BRANCH_1, "home/foo/bar/quuux"); // $NON-NLS-1$ saveRandomPage(BRANCH_1, "home/foo/quux"); // $NON-NLS-1$ saveRandomPage(BRANCH_1, "home/baz"); // $NON-NLS-1$ saveRandomPage(BRANCH_1, "home/baz/bar"); // $NON-NLS-1$ saveRandomPage(BRANCH_1, "home/baz/qux"); // $NON-NLS-1$ Page attachment = saveRandomAttachment(BRANCH_1, "home/foo/bar", "test.txt"); // $NON-NLS-1$ //$NON-NLS-2$ saveRandomAttachment(BRANCH_1, "home/baz/bar", "test.txt"); // $NON-NLS-1$ //$NON-NLS-2$ pageStore.relocatePage( PROJECT, BRANCH_1, "home/foo/bar", "home/baz", USER); // $NON-NLS-1$ //$NON-NLS-2$ assertEquals( Sets.newHashSet("home/foo/quux"), // $NON-NLS-1$ Sets.newHashSet( pageStore.listChildPagePaths(PROJECT, BRANCH_1, "home/foo"))); // $NON-NLS-1$ assertEquals( Sets.newHashSet("home/baz/bar", "home/baz/qux"), // $NON-NLS-1$ //$NON-NLS-2$ Sets.newHashSet( pageStore.listChildPagePaths(PROJECT, BRANCH_1, "home/baz"))); // $NON-NLS-1$ assertEquals( Sets.newHashSet("home/baz/bar/quuux"), // $NON-NLS-1$ Sets.newHashSet( pageStore.listChildPagePaths(PROJECT, BRANCH_1, "home/baz/bar"))); // $NON-NLS-1$ assertEquals( page.getData(), pageStore.getPage(PROJECT, BRANCH_1, "home/baz/bar", true).getData()); // $NON-NLS-1$ assertEquals( attachment.getData(), pageStore .getAttachment(PROJECT, BRANCH_1, "home/baz/bar", "test.txt") .getData()); //$NON-NLS-1$ //$NON-NLS-2$ assertClean(repo.r()); }