Package de.nava.informa.core

Examples of de.nava.informa.core.ChannelIF


    FeedParser.parse(new ChannelBuilder(), inpFile);
  }

  public void testSummaryOnly() throws Exception {
    File inpFile = new File(getDataDir(), "atom-summary-only.xml");
    ChannelIF channel = FeedParser.parse(new ChannelBuilder(), inpFile);

    ItemIF[] items = (ItemIF[]) channel.getItems().toArray(new ItemIF[0]);
    assertEquals(3, items.length);

    assertEquals("Google <b>Blog</b>", items[1].getDescription());
  }
View Full Code Here


   *
   * @see PersistenceManagerIF#createChannel
   */
  public void testCreateChannel() {
    // Create channel and check
    ChannelIF channel = null;

    try {
      channel = manager.createChannel(tuids1, url1);
      assertNotNull("Channel object should be returned.", channel);
      assertTrue("ID should be initialized.", -1 != channel.getId());
      assertEquals("Title should be set.", tuids1, channel.getTitle());
    } catch (PersistenceManagerException e) {
      e.printStackTrace();
      fail();
    } finally {
      // Delete channel
      try {
        if (channel != null && channel.getId() != -1) manager.deleteChannel(channel);
      } catch (PersistenceManagerException e) {
        // We can do nothing here
      }
    }
  }
View Full Code Here

  /**
   * Tests parsing of titles and descriptions with CDATA objects inside.
   */
  public void testCDATAInTitlesAndDescriptions() throws IOException, ParseException {
    File inpFile = new File(getDataDir(), "atomic-cdata.xml");
    ChannelIF feed = FeedParser.parse(new ChannelBuilder(), inpFile);

    Collection items = feed.getItems();
    assertEquals(1, items.size());

    Item item = (Item) items.iterator().next();
    assertEquals("Tilden <b>Hike</b>", item.getTitle());
    assertEquals("A hike in Tilden Park...", item.getDescription());
View Full Code Here

   * @see PersistenceManagerIF#deleteChannel
   */
  public void testDeleteChannelSimple() {
    try {
      // Create channel
      final ChannelIF channel = manager.createChannel(tuids1, url1);

      // Delete channel
      manager.deleteChannel(channel);
      assertTrue("ID should be reset to uninitialized state (-1).", -1 == channel.getId());
    } catch (PersistenceManagerException e) {
      e.printStackTrace();
      fail();
    }
  }
View Full Code Here

   *
   * @see PersistenceManagerIF#deleteChannel
   */
  public void testDeleteChannelCascade() {
    ChannelGroupIF group = null;
    ChannelIF channel = null;
    ItemIF item1 = null;
    ItemIF item2 = null;

    try {
      // Create group and channel with two items
      group = manager.createGroup(tuids1);
      channel = manager.createChannel(tuids1, url1);
      item1 = manager.createItem(channel, tuids1);
      item2 = manager.createItem(channel, tuids2);

      // Put channel in group
      manager.addChannelToGroup(channel, group);

      // Delete channel
      manager.deleteChannel(channel);

      // Check that it was removed from parent group and all of its items gone too
      assertEquals("Group still has channels.", 0, group.getAll().size());
      assertEquals("Channel still has items.", 0, channel.getItems().size());
      assertEquals("Item still has initialized ID.", -1, item1.getId());
      assertEquals("Item still has initialized ID.", -1, item2.getId());
    } catch (PersistenceManagerException e) {
      e.printStackTrace();
      fail();
    } finally {
      // Delete channel, group and items
      try {
        if (item1 != null && item1.getId() != -1) manager.deleteItem(item1);
        if (item2 != null && item2.getId() != -1) manager.deleteItem(item2);
        if (channel != null && channel.getId() != -1) manager.deleteChannel(channel);
        if (group != null && group.getId() != -1) manager.deleteGroup(group);
      } catch (PersistenceManagerException e) {
        // We can do nothing here
      }
    }
View Full Code Here

   * Tests how channels are added to groups.
   *
   * @see PersistenceManagerIF#addChannelToGroup
   */
  public void testAddChannelToGroup() {
    ChannelIF channel = null;
    ChannelGroupIF group = null;

    try {
      // Create channel & group
      channel = manager.createChannel(tuids1, url1);
      group = manager.createGroup(tuids2);

      // Add channel to group
      manager.addChannelToGroup(channel, group);
      final Collection channels = group.getAll();
      assertEquals("Channel isn't added to group.", 1, channels.size());
      assertEquals("Wrong channel was added to group.", channel, channels.iterator().next());

      // Add duplicate channel to group
      manager.addChannelToGroup(channel, group);
      final Collection channels2 = group.getAll();
      assertEquals("Duplicate channel shouldn't be added to group.", 1, channels2.size());
    } catch (PersistenceManagerException e) {
      e.printStackTrace();
      fail();
    } finally {
      // Delete channel and group
      try {
        if (channel != null && channel.getId() != -1) manager.deleteChannel(channel);
        if (group != null && group.getId() != -1) manager.deleteGroup(group);
      } catch (PersistenceManagerException e) {
        // We can do nothing here.
      }
    }
View Full Code Here

   * Tests how channels are removed from group. Performs non-existing channel removing check.
   *
   * @see PersistenceManagerIF#removeChannelFromGroup
   */
  public void testRemoveChannelFromGroup() {
    ChannelIF channel = null;
    ChannelGroupIF group = null;

    try {
      // Create channel & group
      channel = manager.createChannel(tuids1, url1);
View Full Code Here

   * @see PersistenceManagerIF#mergeGroups
   */
  public void testMergeChannels() {
    ChannelGroupIF group1 = null;
    ChannelGroupIF group2 = null;
    ChannelIF channel1 = null;
    ChannelIF channel2 = null;
    ChannelIF channel3 = null;

    try {
      // Create 2 grops and 3 channels: 1 in first group and 2 in the second
      group1 = manager.createGroup(tuids1);
      group2 = manager.createGroup(tuids2);
View Full Code Here

   * Checks simple item creation.
   *
   * @see PersistenceManagerIF#createItem
   */
  public void testCreateItem() {
    ChannelIF channel = null;
    ItemIF item = null;

    try {
      // Create channel and item
      channel = manager.createChannel(tuids1, url1);
      item = manager.createItem(channel, tuids2);

      // Check item
      assertNotNull(item);
      assertEquals("Title isn't properly initialized.", tuids2, item.getTitle());

      // Check channel
      final Collection items = channel.getItems();
      assertNotNull(items);
      assertEquals("Item was not correclty added to the channel.", 1, items.size());
      assertEquals("Incorrect item was added to the channel.", item, items.iterator().next());
    } catch (PersistenceManagerException e) {
      e.printStackTrace();
View Full Code Here

   * Checks creation of item using information from another item.
   *
   * @see PersistenceManagerIF#createItem
   */
  public void testCreateItemFromItem() {
    ChannelIF channel1 = null;
    ChannelIF channel2 = null;
    ItemIF item1 = null;
    ItemIF item2 = null;

    try {
      // Create two channels and item
View Full Code Here

TOP

Related Classes of de.nava.informa.core.ChannelIF

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.