Пример #1
0
  public void testNormalOperation2() throws IOException {

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

    // build params
    List plist = new ArrayList();
    plist.add(Collections.EMPTY_SET);
    plist.add(Collections.singleton(otherTopic));
    plist.add(Collections.singleton(otype));
    ActionParametersIF params = makeParameters(plist, "http://www.sf.net");
    ActionResponseIF response = makeResponse();

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

    // test
    assertFalse("Occurrence not added", 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 not set for the topic", !(hasit));
  }
Пример #2
0
 protected OccurrenceIF getOccurrenceWithLocator(TopicIF topic) {
   Iterator<OccurrenceIF> it = topic.getOccurrences().iterator();
   while (it.hasNext()) {
     OccurrenceIF occ = it.next();
     if (occ.getLocator() != null) return occ;
   }
   return null;
 }
Пример #3
0
  public void testEmptyValue() throws java.io.IOException {
    // get ready
    TopicIF topic = getTopicById(tm, "tromso");
    TopicIF otype = getTopicById(tm, "tromso");
    OccurrenceIF occ = getOccurrenceWithValue(topic);
    int occsbefore = topic.getOccurrences().size();

    // run action
    ActionParametersIF params = makeParameters(makeList(occ, topic, otype), "");
    ActionResponseIF response = makeResponse();
    action.perform(params, response);

    // test post-action state
    int occsnow = topic.getOccurrences().size();
    assertTrue("Number of occurrences has changed!", occsbefore == occsnow);
    assertTrue(
        "Value of occurrence is not empty, but '" + occ.getValue() + "'",
        occ.getValue().equals(""));
  }
Пример #4
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()));
  }
Пример #5
0
  public void testMalformedURL() 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, "snus");
    ActionResponseIF response = makeResponse();
    try {
      // execute
      action.perform(params, response);
      fail("Malformed url for locator");
    } catch (ActionRuntimeException e) {
    }
  }
Пример #6
0
  public void testBadParam3() 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(makeList(occ, topic, ""), "http://www.sf.net");
    ActionResponseIF response = makeResponse();
    try {
      // execute
      action.perform(params, response);
      // test
      fail("Bad Type param (String)");
    } catch (ActionRuntimeException e) {
    }
  }
Пример #7
0
  public void testSetBothTopics() throws java.io.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();
    String loc = occ.getValue();
    Iterator<OccurrenceIF> occIT = topic.getOccurrences().iterator();
    while (loc == null && occIT.hasNext()) {
      occ = occIT.next();
      loc = occ.getValue();
    }

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

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

    // test
    String locNew = occ.getValue();
    assertFalse("The value is not correct for topic which owns occurrence", locNew.equals(loc));

    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.getValue().equals("http://www.sf.net")) hasit = true;
    }
    assertFalse("Occurrence is set for the other topic", hasit);
  }