Exemple #1
0
  public void setUp() throws Exception {

    String time = String.valueOf((new Date()).getTime()).substring(8);
    String random = String.valueOf(Math.random()).substring(2);
    unique = (time + random);
    serviceName = "javaTastyTest-" + unique;

    JTastyDAO dao = new JTastyMockDAO();

    TastyBean tb = new TastyBean();
    tb.setDao(dao);
    tc = new TastyClient(tastyServerUrl, serviceName);
    tc.setTastyBean(tb);

    logger.debug(tastyServerUrl + "/service/" + serviceName);
    // create the service:
    tc.post(tastyServerUrl + "/service/" + serviceName);
    // add the user:

    tc.beanstatus();
  }
Exemple #2
0
  public void testTasty() throws Exception {

    try {
      System.out.println(tc.getRawOutput());

    } catch (UnknownHostException e) {
      fail(
          "Either you didn't add tasty to your /etc/hosts file or tasty is down! See docs for info");
    }

    // set up some sets of tags to be reused:
    HashSet ac = new HashSet(Arrays.asList(new String[] {"a", "c"}));
    HashSet cd = new HashSet(Arrays.asList(new String[] {"c", "d"}));
    HashSet abc = new HashSet(Arrays.asList(new String[] {"a", "b", "c"}));
    HashSet bcd = new HashSet(Arrays.asList(new String[] {"b", "c", "d"}));
    HashSet abcd = new HashSet(Arrays.asList(new String[] {"a", "b", "c", "d"}));

    // should come back empty:
    Set allUserTags = tc.getAllTagsForUser("testUser");
    assertEquals(0, allUserTags.size());

    // add some tags (and items):
    tc.addTagsToItem("testUser", "testItem", abc);
    tc.addTagsToItem("testUser", "testItem2", cd);

    // should come back with 4 tags:
    Set tags = tc.getAllTagsForUser("testUser");
    assertEquals(abcd, tags);

    // should return 3 tags:
    tags = tc.getTagsForItem("testUser", "testItem");
    assertEquals(abc, tags);

    // should return 2 tags:
    tags = tc.getTagsForItem("testUser", "testItem2");
    assertEquals(cd, tags);

    // get all items and their tags:
    Map taggedItems = tc.getAllItemsAndTagsForUser("testUser");
    tags = (Set) taggedItems.get("testItem");
    assertEquals(abc, tags);
    tags = (Set) taggedItems.get("testItem2");
    assertEquals(cd, tags);

    // delete all tags:
    tc.deleteTagsFromItem("testUser", "testItem", abc);
    tc.deleteTagsFromItem("testUser", "testItem2", cd);

    // verify that the tag pool is empty:
    tags = tc.getAllTagsForUser("testUser");
    assertEquals(0, tags.size());

    // verify that the items are tagless:
    tags = tc.getTagsForItem("testUser", "testItem");
    assertEquals(0, tags.size());
    tags = tc.getTagsForItem("testUser", "testItem2");
    assertEquals(0, tags.size());

    // try syncing (add-only):
    tc.setTagsForItem("testUser", "testItem", abc);
    // verify:
    tags = tc.getTagsForItem("testUser", "testItem");
    assertEquals(abc, tags);

    // another sync (delete-only):
    tc.setTagsForItem("testUser", "testItem", ac);
    // verify:
    tags = tc.getTagsForItem("testUser", "testItem");
    assertEquals(ac, tags);

    // one more sync (add and delete):
    tc.setTagsForItem("testUser", "testItem", bcd);
    // verify:
    tags = tc.getTagsForItem("testUser", "testItem");
    assertEquals(bcd, tags);
  }
Exemple #3
0
  public void tearDown() throws Exception {

    // delete the service:
    tc.delete(tastyServerUrl + "/service/" + serviceName);
  }