Пример #1
0
  public void ResourceCopyTest() throws RegistryException {

    Resource r1 = registry.newResource();
    r1.setProperty("test", "copy");
    r1.setContent("c");
    registry.put("/test1/copy/c1/copy1", r1);

    Collection c1 = registry.newCollection();
    registry.put("/test1/move", c1);

    registry.copy("/test1/copy/c1/copy1", "/test1/copy/c2/copy2");

    Resource newR1 = registry.get("/test1/copy/c2/copy2");
    assertEquals(
        "Copied resource should have a property named 'test' with value 'copy'.",
        newR1.getProperty("test"),
        "copy");

    Resource oldR1 = registry.get("/test1/copy/c1/copy1");
    assertEquals(
        "Original resource should have a property named 'test' with value 'copy'.",
        oldR1.getProperty("test"),
        "copy");

    String newContent = new String((byte[]) newR1.getContent());
    String oldContent = new String((byte[]) oldR1.getContent());
    assertEquals("Contents are not equal in copied resources", newContent, oldContent);
  }
Пример #2
0
  public void CollectionCopyTest() throws RegistryException {

    Resource r1 = registry.newResource();
    r1.setProperty("test", "copy");
    r1.setContent("c");
    registry.put("/test1/copy/copy3/c3/resource1", r1);

    Collection c1 = registry.newCollection();
    registry.put("/test1/move", c1);

    registry.copy("/test1/copy/copy3", "/test1/newc/copy3");

    Resource newR1 = registry.get("/test1/newc/copy3/c3/resource1");
    assertEquals(
        "Copied resource should have a property named 'test' with value 'copy'.",
        newR1.getProperty("test"),
        "copy");

    Resource oldR1 = registry.get("/test1/copy/copy3/c3/resource1");
    assertEquals(
        "Original resource should have a property named 'test' with value 'copy'.",
        oldR1.getProperty("test"),
        "copy");
  }