Package de.nava.informa.core

Examples of de.nava.informa.core.ChannelIF


    FeedManager FM = new FeedManager(ChannelUpdatePeriod.UPDATE_HOURLY, 2);
    CacheSettings cs = new CacheSettings();
    cs.setDefaultTtl(3000);

    try {
      ChannelIF channel = FeedParser.parse(new ChannelBuilder(), "http://www.intertwingly.net/blog/index.rss");//inpFile);

      String url = new Feed(channel).getLocation().toString();
      FM.removeFeed(url);
      FM.addFeed(url);
      FeedIF feedRef1 = FM.getFeed(url);
View Full Code Here


    cs.setDefaultTtl(3000);

    /* test RDF behavior, this feed has an updatePeriod element */
    File inpFile = new File(getDataDir(), "slashdot-010604.rdf");
    try {
      ChannelIF channel = FeedParser.parse(new ChannelBuilder(), inpFile);

      //test RSS0.91 behavior
      // default ttl used
      assertEquals(60 * 60 * 1000, cs.getTtl(channel, -1L));

View Full Code Here

    this.builder = new de.nava.informa.impl.basic.ChannelBuilder();
  }

  public void testParseNewsFeedValidChannel() throws Exception {
    logger.info("Reading in feed from " + testURL);
    ChannelIF channel = FeedParser.parse(builder, new URL(testURL));
    assertNotNull("Failed parsing channel " + testURL, channel.getItems());
    assertTrue("Expected at least one item at channel " + testURL,
               channel.getItems().size() > );
  }
View Full Code Here

    int chId = -1;
    // -- first create a channel with two news items
    try {
      tx = session.beginTransaction();
      String chanName = "Foo Test Channel";
      ChannelIF channel = builder.createChannel(chanName, "http://www.nava.de/channelTest");
      channel.setDescription("Test Channel: " + chanName);
      session.saveOrUpdate(channel);
      ItemIF item1 = builder.createItem(channel, "Item 1 for " + chanName,
                                        "First in line", new URL("http://www.sf1.net"));
      session.saveOrUpdate(item1);
      ItemIF item2 = builder.createItem(channel, "Item 2 for " + chanName,
                                        "Second in line", new URL("http://www.sf1.net"));
      session.saveOrUpdate(item2);
      session.saveOrUpdate(channel);
      tx.commit();
      chId = (int) channel.getId();
    }
    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 children
    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);
      assertEquals(1, c.getItems().size()); // The itens links where the same and it's unique
      Iterator it_items = c.getItems().iterator();
      while (it_items.hasNext()) {
        ItemIF item = (ItemIF) it_items.next();
        logger.info("  * " + item);
        assertEquals(c, item.getChannel());
      }
View Full Code Here

    ChannelBuilder builder = new ChannelBuilder(session);
    Transaction tx = null;
    try {
      tx = session.beginTransaction();
      File inpFile = new File(getDataDir(), "xmlhack-0.91.xml");
      ChannelIF channel = FeedParser.parse(builder, inpFile);
      session.save(channel);
      tx.commit();
      assertEquals(6, channel.getItems().size());
    }
    catch (HibernateException he) {
      logger.warn("trying to rollback the transaction");
      if (tx != null) tx.rollback();
      throw he;
View Full Code Here

    ChannelBuilder builder = new ChannelBuilder(session);
    Transaction tx = null;
    try {
      logger.info("start new hibernate transaction");
      tx = session.beginTransaction();
      ChannelIF chA = builder.createChannel("Channel A", "http://test.org/A");
      long chA_id = chA.getId();
      chA.setDescription("test channel for hibernate backend");
      logger.info("created chA: " + chA);
      ItemIF itA = builder.createItem(chA, "Simple item", "oh what a desc",
                                      new URL("http://www.sf.net/"));
      logger.info("created itA: " + itA);
      session.save(chA);
      logger.info("saved chA");
      tx.commit();
      logger.info("transaction commited");
      assertEquals(chA_id, chA.getId());
    }
    catch (HibernateException he) {
      logger.warn("trying to rollback the transaction");
      if (tx != null) tx.rollback();
      throw he;
View Full Code Here

    ChannelBuilder builder = new ChannelBuilder(session);
    Transaction tx = null;
    int chId = -1;
    int chGrpId = -1;
    // our test objects
    ChannelIF channel;
    ChannelGroupIF grp1;
    // -- first create a channel with a category assigned
    try {
      tx = session.beginTransaction();
      String chanName = "Foo Test Channel";
      channel = builder.createChannel(chanName);
      channel.setDescription("Test Channel: " + chanName);
      channel.setLocation(new URL("http://nava.de/test/channelFoo"));
      session.saveOrUpdate(channel);
      grp1 = builder.createChannelGroup("group A");
      grp1.add(channel);
      session.saveOrUpdate(grp1);
      tx.commit();
      chId = (int) channel.getId();
      chGrpId = (int) grp1.getId();
    }
    catch (HibernateException he) {
      logger.warn("trying to rollback the transaction");
      if (tx != null) tx.rollback();
      throw he;
    }
    assertTrue("No valid channel created.", chId >= 0);
    assertTrue("No valid channel group created.", chGrpId >= 0);
    // -- try to retrieve channel and the assigned category
    try {
      logger.info("Searching for channel group " + chGrpId);
      Object result = session.get(ChannelGroup.class, new Long(chGrpId));
      assertNotNull(result);
      ChannelGroupIF cg = (ChannelGroupIF) result;
      logger.info("retrieved channel group --> " + cg);
      assertEquals(1, cg.getAll().size());
      ChannelIF c = (ChannelIF) cg.getAll().iterator().next();
      assertEquals("Foo Test Channel", c.getTitle());
      assertNull(cg.getParent());
    }
    catch (HibernateException he) {
      logger.warn("Error while querying for channel");
      throw he;
View Full Code Here

    String ch_title = "The Great Demo Channel";
    String ch_desc = "Just a very simple short description.";
   
    // create dummy channel
    ChannelIF channel = new Channel(ch_title);
    channel.setDescription(ch_desc);
    channel.setSite(new URL("http://nava.de"));
    ItemIF itemA = new Item("Bugo", "All about it!",
                            new URL("http://nava.de/huhu2002"));
    itemA.setFound(new Date());
    channel.addItem(itemA);
    // TODO: what about markup here ???
    ItemIF itemB = new Item("SoCool",
                            "????**$12 @??? # <strong>should</strong> work",
                            new URL("http://nava.de/very/nested/98"));
    itemB.setFound(new Date());
    channel.addItem(itemB);
    assertEquals(2, channel.getItems().size());
    // export this channel to file (encoding: utf-8)
    String basename = "export-rss091.xml";
    String exp_file = getOutputDir() + FS + basename;
    ChannelExporterIF exporter = new RSS_0_91_Exporter(exp_file);
    exporter.write(channel);

    // clean channel object
    channel = null;
   
    // read in again
    File inpFile = new File(exp_file);
    channel = FeedParser.parse(new ChannelBuilder(), inpFile);

    assertEquals(ch_title, channel.getTitle());
    assertEquals(ch_desc, channel.getDescription());
   
    Collection items = channel.getItems();
    assertEquals(2, items.size());
    Iterator it = items.iterator();
    ItemIF item = (ItemIF) it.next();
    if (item.equals(itemA)) {
      assertEquals(item, itemA);
View Full Code Here

  }

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

    assertEquals(ChannelFormat.ATOM_1_0, channel.getFormat());

    assertEquals("Whatever....", channel.getTitle());
    assertEquals("Jayant Kumar", channel.getCreator());
    assertEquals("Blogger", channel.getGenerator());
    assertNull(channel.getCopyright());

    // test Last pub date
    // should be  2006-08-17T20:50:43.593-07:00
    Calendar updtDate = new GregorianCalendar(TimeZone.getTimeZone("GMT-7:00"));

    updtDate.set(Calendar.YEAR, 2006);
    updtDate.set(Calendar.MONTH, Calendar.AUGUST);
    updtDate.set(Calendar.DAY_OF_MONTH, 17);
    updtDate.set(Calendar.HOUR_OF_DAY, 20);
    updtDate.set(Calendar.MINUTE, 50);
    updtDate.set(Calendar.SECOND, 43);
    updtDate.set(Calendar.MILLISECOND, 593);
    assertEquals(updtDate.getTime(), channel.getPubDate());
  }
View Full Code Here

    assertEquals(updtDate.getTime(), channel.getPubDate());
  }

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

    assertEquals(ChannelFormat.ATOM_1_0, channel.getFormat());
    assertEquals(25, channel.getItems().size());

    // 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());
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.