Ejemplo n.º 1
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);
  }
Ejemplo n.º 2
0
  public void testNormalOperation3() throws java.io.IOException {
    TopicIF type = getTopicById(tm, "tromso");
    TopicIF otherTopic = getTopicById(tm, "gamst");
    int numOcc = otherTopic.getOccurrences().size();

    // build parms
    List plist = new ArrayList();
    plist.add(Collections.EMPTY_SET);
    plist.add(Collections.singleton(otherTopic));
    plist.add(Collections.singleton(type));
    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.getValue().equals("http://www.sf.net")) && (foo.getType() == type)) hasit = true;
    }
    assertFalse("Occurrence is not set for the topic or type not correct", !(hasit));
  }
Ejemplo n.º 3
0
 protected OccurrenceIF getOccurrenceWithValue(TopicIF topic) {
   Iterator<OccurrenceIF> it = topic.getOccurrences().iterator();
   while (it.hasNext()) {
     OccurrenceIF occ = it.next();
     if (occ.getValue() != null) return occ;
   }
   return null;
 }
Ejemplo n.º 4
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(""));
  }
Ejemplo n.º 5
0
  public void testBadParam3() throws java.io.IOException {
    TopicIF topic = getTopicById(tm, "tromso");
    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, ""), "http://www.sf.net");
    ActionResponseIF response = makeResponse();
    try {
      // execute
      action.perform(params, response);
      // test
      fail("Bad Type param (String)");
    } catch (ActionRuntimeException e) {
    }
  }
Ejemplo n.º 6
0
  public void testNormalOperation() throws java.io.IOException {

    TopicIF topic = getTopicById(tm, "tromso");
    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(occ, "http://www.sf.net");
    ActionResponseIF response = makeResponse();

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

    // test
    String locNew = occ.getValue();
    assertFalse("The value is not correct", locNew.equals(loc));
  }