Package de.nava.informa.core

Examples of de.nava.informa.core.ChannelIF


    assertEquals(expDate.getTime(), item.getDate());
  }

  public void testParseGoogleWeblog() throws Exception {
    File inpFile = new File(getDataDir(), "google-weblog.rdf");
    ChannelIF channel_gw = FeedParser.parse(new ChannelBuilder(), inpFile);
    assertEquals("Google Weblog", channel_gw.getTitle());
    assertEquals(15, channel_gw.getItems().size());
    assertEquals(ChannelFormat.RSS_1_0, channel_gw.getFormat());
  }
View Full Code Here


    int chId = -1;
    String chanName = "Unread Tester";
    Transaction tx = null;
    try {
      tx = session.beginTransaction();
      ChannelIF channel = builder.createChannel(chanName);
      channel.setDescription("Test Channel: " + chanName);
      session.save(channel);
      // Add items, with some marked read and some marked unread
      int items;
      for (items = 0; items < 20; items++) {
        boolean unreadflag = ((items > 0 && items < 5))
          || (items > 10 && items < 15);
        String desc = unreadflag ? "UnreadItem" : "ReadItem";
        ItemIF anItem = builder.createItem(channel, "Item: " + items, desc, new URL("http://www.sf.net"));
        anItem.setUnRead(unreadflag);
      }
      session.save(channel);
      chId = (int) channel.getId();
      tx.commit();
    }
    catch (HibernateException he) {
      logger.warn("trying to rollback the transaction");
      if (tx != null) tx.rollback();
      throw he;
    }
    assertTrue("No valid channel created.", chId >= 0);

    // -- try to retrieve channel and check the unread statuses
    try {
      logger.info("Searching for channel " + chId);
      Object result = session.get(Channel.class, new Long(chId));
      assertNotNull(result);
      ChannelIF c = (ChannelIF) result;
      logger.info("retrieved channel --> " + c);

      // now check unread settings
      Iterator itemsIter = c.getItems().iterator();
      while (itemsIter.hasNext()) {
        ItemIF anItem = (ItemIF) itemsIter.next();
        if (anItem.getUnRead())
            assertTrue("Item marked as Unread isn't supposed to be Unread",
                anItem.getDescription().compareTo("UnreadItem") == 0);
View Full Code Here

    assertEquals(ChannelFormat.RSS_1_0, channel_gw.getFormat());
  }

  public void testParseW3CSynd() throws Exception {
    File inpFile = new File(getDataDir(), "w3c-synd.rdf");
    ChannelIF channel_w3c = FeedParser.parse(new ChannelBuilder(), inpFile);
    assertEquals("World Wide Web Consortium", channel_w3c.getTitle());
    assertEquals(7, channel_w3c.getItems().size());
    assertEquals(ChannelFormat.RSS_1_0, channel_w3c.getFormat());
  }
View Full Code Here

    assertEquals(ChannelFormat.RSS_1_0, channel_w3c.getFormat());
  }

  public void testParseContentEncoded() throws Exception {
    File inpFile = new File(getDataDir(), "rss10-content-encoded.rdf");
    ChannelIF channel = FeedParser.parse(new ChannelBuilder(), inpFile);

    ItemIF[] items = (ItemIF[])channel.getItems().toArray(new ItemIF[0]);
    assertEquals(3, items.length);
    assertEquals("1&amp;", items[0].getDescription());
    assertEquals("2", items[1].getDescription());
    assertEquals("3&", items[2].getDescription());
  }
View Full Code Here

    this.method_name = name;
  }

  public void testParseDiveIntoMark() throws Exception {
    File inpFile = new File(getDataDir(), "diveintomark.xml");
    ChannelIF channel_mark = FeedParser.parse(new ChannelBuilder(), inpFile);
    assertEquals("dive into mark", channel_mark.getTitle());
    assertEquals(3, channel_mark.getItems().size());

    // test generator
    assertEquals("Movable Type", channel_mark.getGenerator());

    //test publisher
    assertEquals("Mark Pilgrim", channel_mark.getCreator());

    //test Last pub date
    // should be  <modified>2004-05-13T17:16:00Z</modified>
    Calendar updtDate = new GregorianCalendar(TimeZone.getTimeZone("GMT"));

    updtDate.set(Calendar.YEAR, 2004);
    updtDate.set(Calendar.MONTH, Calendar.MAY);
    updtDate.set(Calendar.DAY_OF_MONTH, 13);
    updtDate.set(Calendar.HOUR_OF_DAY, 17);
    updtDate.set(Calendar.MINUTE, 16);
    updtDate.set(Calendar.SECOND, 00);
    updtDate.set(Calendar.MILLISECOND, 0);
    assertEquals(updtDate.getTime(),  channel_mark.getPubDate());

    //test build date

    // test site url
    assertNotNull(channel_mark.getSite());
    assertEquals("http://diveintomark.org/",channel_mark.getSite().toExternalForm());

    // test link for first item
    java.util.Iterator itemsColl = channel_mark.getItems().iterator();
    Item item = (Item) itemsColl.next();
    assertEquals("http://diveintomark.org/archives/2004/05/12/copy-editor".trim(),item.getLink().toExternalForm());

    assertEquals(ChannelFormat.ATOM_0_3, channel_mark.getFormat());
  }
View Full Code Here

    assertEquals(ChannelFormat.ATOM_0_3, channel_mark.getFormat());
  }

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

    assertEquals(10, channel.getItems().size());
    assertEquals(ChannelFormat.ATOM_0_3, channel.getFormat());

    // check each item that for null values
    java.util.Iterator itemsIterator = channel.getItems().iterator();
    while (itemsIterator.hasNext()) {
      Item item = (Item) itemsIterator.next();
      assertNotNull(item.getDate());
      assertNotNull(item.getDescription());
      assertNotNull(item.getLink());
View Full Code Here

    }
  }

  public void testEntryTitleFormat() throws Exception {
    File inpFile = new File(getDataDir(), "blink.xml");
    ChannelIF channel = FeedParser.parse(new ChannelBuilder(), inpFile);
    java.util.Iterator itemsColl = channel.getItems().iterator();
    // skip first entry
    itemsColl.next();
    while( itemsColl.hasNext() ) {
      Item item = (Item) itemsColl.next();
      //System.out.println("TC title :*"+item.getTitle()+"*"+item.getTitle().length());
 
View Full Code Here

    }
    }

  public void testLanguage() throws Exception {
    File inpFile = new File(getDataDir(), "diveintomark.xml");
    ChannelIF channel = FeedParser.parse(new ChannelBuilder(), inpFile);

    assertEquals("en",channel.getLanguage());

    }
View Full Code Here

    }

  public void testCopyright() throws Exception {
    File inpFile = new File(getDataDir(), "multilink-linkblog.xml");
    ChannelIF channel = FeedParser.parse(new ChannelBuilder(), inpFile);

    //  test copyright text/plain
    assertEquals("Copyright (c) 2004 Mark Pilgrim", channel.getCopyright());

    inpFile = new File(getDataDir(), "diveintomark.xml");
    channel = FeedParser.parse(new ChannelBuilder(), inpFile);
    assertEquals("Copyright \u00a9 2004, Mark Pilgrim", channel.getCopyright());

    }
View Full Code Here

   *
   * @see PersistenceManagerIF#deleteGroup
   */
  public void testDeleteGroupCascade() {
    ChannelGroupIF group = null;
    ChannelIF channel = null;

    try {
      // Create simple group with channel
      group = manager.createGroup(tuids1);
      channel = manager.createChannel(tuids1, url1);
      manager.addChannelToGroup(channel, group);

      final long groupId = group.getId();
      manager.deleteGroup(group);

      assertEquals("Object ID should be turned back to -1.", -1, group.getId());
      final ChannelGroupIF group2 = findGroupById(groupId);
      assertNull("Object should be deleted from storage.", group2);
      assertEquals("Group still has channels assigned.", 0, group.getAll().size());
    } catch (PersistenceManagerException e) {
      e.printStackTrace();
      fail();
    } finally {
      try {
        if (channel != null && channel.getId() != -1) manager.deleteChannel(channel);
      } catch (PersistenceManagerException e) {
        // We can do nothing here
      }
    }
  }
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.