Ejemplo n.º 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());
  }
Ejemplo n.º 2
0
 /**
  * Returns true if the two passed methods are equal. Methods are in this case regarded as equal if
  * they take the same parameter types, return the same return type and share the same name.
  *
  * @param m1
  * @param m2
  * @return true if method m1 and method m2 are considered equal for our case
  */
 public static boolean methodsAreEqual(Method m1, Method m2) {
   if (!m1.getName().equals(m2.getName())) return false;
   if (!m1.getReturnType().equals(m2.getReturnType())) return false;
   if (!ArrayUtils.isEquals(m1.getParameterTypes(), m2.getParameterTypes())) return false;
   return true;
 }