Exemple #1
0
  @Test(groups = {"wso2.greg"})
  public void CommentDelete() throws Exception {
    String r1Path = "/_c1d1/c1";
    Collection r1 = registry.newCollection();
    registry.put(r1Path, r1);

    String c1Path = registry.addComment(r1Path, new Comment("test comment1"));
    registry.addComment(r1Path, new Comment("test comment2"));

    Comment[] comments1 = registry.getComments(r1Path);

    assertEquals(comments1.length, 2, "There should be two comments.");

    String[] cTexts1 = {comments1[0].getText(), comments1[1].getText()};

    assertTrue(containsString(cTexts1, "test comment1"), "comment is missing");
    assertTrue(containsString(cTexts1, "test comment2"), "comment is missing");

    registry.delete(comments1[0].getPath());

    Comment[] comments2 = registry.getComments(r1Path);

    assertEquals(comments2.length, 1, "There should be one comment.");

    String[] cTexts2 = {comments2[0].getText()};

    assertTrue(containsString(cTexts2, "test comment2"), "comment is missing");
    assertTrue(!containsString(cTexts2, "test comment1"), "deleted comment still exists");
  }
  @Test(groups = {"wso2.greg"})
  public void ContinuousDelete() throws RegistryException, InterruptedException {
    int iterations = 100;

    for (int i = 0; i < iterations; i++) {

      Resource res1 = registry.newResource();
      byte[] r1content = "R2 content".getBytes();
      res1.setContent(r1content);
      String path = "/con-delete/test/" + i + 1;

      registry.put(path, res1);

      Resource resource1 = registry.get(path);

      assertEquals(
          new String((byte[]) resource1.getContent()),
          new String((byte[]) res1.getContent()),
          "File content is not matching");

      registry.delete(path);

      boolean value = false;

      if (registry.resourceExists(path)) {
        value = true;
      }

      assertFalse(value, "Resource found at the path");

      res1.discard();
      resource1.discard();
      Thread.sleep(100);
    }
  }
  @Before
  public void setUp() throws Exception {
    super.setUp();

    boolean exists = false;
    try {
      RemoteRegistry wso2 = RSProviderUtil.getRegistry();
      exists = wso2.resourceExists("/");

      for (String resource : resources) {
        if (wso2.resourceExists(resource)) {
          wso2.delete(resource);
        }
      }
    } catch (Exception ex) {
    }

    assertTrue(exists);
  }
 @AfterClass(alwaysRun = true)
 public void cleanArtifact() throws RegistryException {
   registry.delete("/con-delete");
 }