示例#1
0
  public void testNormalOperation() throws IOException {
    TopicIF topic = getTopicById(tm, "tromso");
    OccurrenceIF occ = topic.getOccurrences().iterator().next();
    LocatorIF loc = occ.getLocator();
    Iterator<OccurrenceIF> occIT = topic.getOccurrences().iterator();
    while (loc == null && occIT.hasNext()) {
      occ = occIT.next();
      loc = occ.getLocator();
    }

    // build parms
    ActionParametersIF params = makeParameters(occ, "http://www.sf.net");
    ActionResponseIF response = makeResponse();

    // execute
    action.perform(params, response);

    // test
    LocatorIF locNew = occ.getLocator();
    assertFalse("The locator is not correct", locNew.getAddress().equals(loc.getAddress()));
  }
示例#2
0
  public void testSetBothTopics() throws IOException {

    TopicIF topic = getTopicById(tm, "tromso");
    TopicIF otherTopic = getTopicById(tm, "gamst");
    TopicIF otype = getTopicById(tm, "gamst");
    int numOcc = otherTopic.getOccurrences().size();

    OccurrenceIF occ = topic.getOccurrences().iterator().next();
    LocatorIF loc = occ.getLocator();
    Iterator<OccurrenceIF> occIT = topic.getOccurrences().iterator();
    while (loc == null && occIT.hasNext()) {
      occ = occIT.next();
      loc = occ.getLocator();
    }

    // build parms
    ActionParametersIF params = makeParameters(makeList(occ, topic, otype), "http://www.sf.net");
    ActionResponseIF response = makeResponse();

    // execute
    action.perform(params, response);

    // test
    LocatorIF locNew = occ.getLocator();
    assertFalse(
        "The locator is not correct for topic which owns occurrence",
        locNew.getAddress().equals(loc.getAddress()));

    assertFalse("Occurrence added to other topic", numOcc < otherTopic.getOccurrences().size());
    Iterator<OccurrenceIF> i = otherTopic.getOccurrences().iterator();
    boolean hasit = false;
    while (i.hasNext()) {
      OccurrenceIF foo = i.next();
      if (foo.getLocator().getAddress().equals("http://www.sf.net/")) hasit = true;
    }
    assertFalse("Occurrence is set for the other topic", hasit);
  }