コード例 #1
0
  /** Tests the finding of first feed who's XML URL matches the given. */
  public void testFindFirstFeedByXmlURLNoMatch() throws MalformedURLException {
    DirectFeed feed0 = new DirectFeed();
    feed0.setBaseTitle("0");
    feed0.setXmlURL(new URL("file://0"));

    StandardGuide guide1 = new StandardGuide();
    guide1.add(feed0);

    set.add(guide1);

    NetworkFeed feed = set.findDirectFeed(new URL("file://test"));
    assertNull("Feed should not be found.", feed);
  }
コード例 #2
0
  public void testGetFeedsXmlURLs() throws MalformedURLException {
    assertEquals("Please remove all guides from set by this point.", 0, set.getGuidesCount());

    StandardGuide guide1 = new StandardGuide();
    guide1.setTitle("1");
    StandardGuide guide2 = new StandardGuide();
    guide2.setTitle("2");

    DirectFeed feed1 = new DirectFeed();
    feed1.setXmlURL(new URL("file://1"));
    DirectFeed feed2 = new DirectFeed();
    feed2.setXmlURL(new URL("file://2"));
    DirectFeed feed3 = new DirectFeed();
    feed3.setXmlURL(new URL("file://3"));
    DirectFeed feed4 = new DirectFeed();
    feed4.setXmlURL(new URL("file://1"));
    SearchFeed feed5 = new SearchFeed();
    feed5.setBaseTitle("5");

    guide1.add(feed1);
    guide1.add(feed5);
    guide2.add(feed2);
    guide2.add(feed3);
    guide2.add(feed4);

    set.add(guide1);
    set.add(guide2);

    Collection urls = set.getFeedsXmlURLs();
    assertEquals("URL's of network feeds (de-duplicated) should be returned.", 3, urls.size());
    assertTrue(urls.contains(feed1.getXmlURL()));
    assertTrue(urls.contains(feed2.getXmlURL()));
    assertTrue(urls.contains(feed3.getXmlURL()));
  }
コード例 #3
0
  /** Tests the finding of first feed who's XML URL matches the given. */
  public void testFindFirstFeedByXmlURLSingleGuide() throws MalformedURLException {
    DirectFeed feed0 = new DirectFeed();
    feed0.setBaseTitle("0");
    feed0.setXmlURL(new URL("file://0"));
    DirectFeed feed1 = new DirectFeed();
    feed1.setBaseTitle("1");
    feed1.setXmlURL(new URL("file://test"));
    DirectFeed feed2 = new DirectFeed();
    feed2.setBaseTitle("2");
    feed2.setXmlURL(new URL("file://test"));

    StandardGuide guide1 = new StandardGuide();
    guide1.add(feed0);
    guide1.add(feed1);
    guide1.add(feed2);

    set.add(guide1);

    NetworkFeed feed = set.findDirectFeed(new URL("file://test"));
    assertTrue("Wrong feed found: " + feed, feed == feed1);
  }
コード例 #4
0
  /** Tests getting the list of titles for all guides. */
  public void testGetGuidesTitles() {
    Set titles;

    // Empty set of titles -- not guides
    titles = set.getGuidesTitles();
    assertEquals("Should be not titles.", 0, titles.size());

    // There's one guide in the set
    StandardGuide guide = new StandardGuide();
    guide.setTitle("A");
    set.add(guide);

    titles = set.getGuidesTitles();
    assertEquals("Should be not titles.", 1, titles.size());
    assertEquals("Wrong title", "A", titles.toArray()[0]);

    // There's another guide with the same title
    StandardGuide guide2 = new StandardGuide();
    guide2.setTitle("A");
    set.add(guide2);

    titles = set.getGuidesTitles();
    assertEquals("Should be not titles.", 1, titles.size());
    assertTrue("Wrong title", titles.contains("A"));

    // There's third guide with different title
    StandardGuide guide3 = new StandardGuide();
    guide3.setTitle("B");
    set.add(guide3);

    titles = set.getGuidesTitles();
    assertEquals("Should be not titles.", 2, titles.size());
    assertTrue("Wrong title", titles.contains("A"));
    assertTrue("Wrong title", titles.contains("B"));
  }
コード例 #5
0
  /** Tests returning of guides list. */
  public void testGetStandardGuides() {
    IGuide[] guides;

    guides = set.getStandardGuides(null);
    assertEquals("List should be empty -- no guides.", 0, guides.length);

    StandardGuide guide = new StandardGuide();
    guide.setTitle("1");
    set.add(guide);
    guides = set.getStandardGuides(null);
    assertEquals("There should be guide in the list.", 1, guides.length);
    assertTrue("Wrong guide in the list.", guide == guides[0]);

    guides = set.getStandardGuides(guide);
    assertEquals("There should be no guide in the list.", 0, guides.length);

    StandardGuide guide2 = new StandardGuide();
    guide2.setTitle("2");
    set.add(guide2);
    guides = set.getStandardGuides(guide);
    assertEquals("There should be guide in the list.", 1, guides.length);
    assertTrue("Wrong guide in the list.", guide2 == guides[0]);
  }