Package de.nava.informa.core

Examples of de.nava.informa.core.ChannelIF


  }

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

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

    existsEntry(channel,
                "I'm going to pre-post for tomorrow because I wont'...",
                "I'm going to pre-post for tomorrow because I wont' be able " +
                "to post cuz I will be terribly busy having more fun " +
View Full Code Here


                "2006-08-16T21:08:00.000-04:00");
  }

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

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

    assertEquals(1, channel.getItems().size());

    //first item
    Item item = (Item) channel.getItems().toArray()[0];

    assertEquals(item.getTitle(), "Atom 1.0");
    assertEquals(item.getDate(), ParserUtils.getDate("2005-07-15T12:00:00Z"));
    assertTrue(item.getDescription().contains("<h1>Show Notes</h1>"));
    assertTrue(item.getDescription()
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"));
    channel.setLocation(new URL("http://nava.de/news.rdf"));
    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-rss10.xml";
    String exp_file = getOutputDir() + FS + basename;
    ChannelExporterIF exporter = new RSS_1_0_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 testChannelCategories() throws Exception {
    ChannelBuilder builder = new ChannelBuilder(session);
    Transaction tx = null;
    int chId = -1;
    // our test objects
    ChannelIF channel;
    CategoryIF cat1, cat2;
    // -- first create a channel with a category assigned
    try {
      tx = session.beginTransaction();
      // create channel
      String chanName = "Foo Test Channel";
      channel = builder.createChannel(chanName);
      channel.setDescription("Test Channel: " + chanName);
      session.saveOrUpdate(channel);
      // create cat1
      cat1 = builder.createCategory(null, "Root Cat");
      session.saveOrUpdate(cat1);
      // create cat2
      cat2 = builder.createCategory(cat1, "Agent_A");
      session.saveOrUpdate(cat2);
      channel.addCategory(cat2);
      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 the assigned category
    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.getCategories().size());
      CategoryIF cat = (CategoryIF) c.getCategories().iterator().next();
      assertEquals("Agent_A", cat.getTitle());
      assertNotNull(cat.getParent());
      assertEquals("Root Cat", cat.getParent().getTitle());
    }
    catch (HibernateException he) {
View Full Code Here

    this.method_name = name;
  }

  public void testParseW3CSynd() throws Exception {
    File inpFile = new File(getDataDir(), "juancolecom.rss");
    ChannelIF channel_juan = FeedParser.parse(new ChannelBuilder(), inpFile);
    assertEquals("Juan Cole   *  Informed Comment  *", channel_juan.getTitle());
    assertEquals(25, channel_juan.getItems().size());
    // TODO: For the time being RSS 0.92 is handled by the RSS 0.91 parser
    assertEquals(ChannelFormat.RSS_0_91, channel_juan.getFormat());
  }
View Full Code Here

  public void XXXtestCreate() throws Exception {
    ChannelRegistry reg = new ChannelRegistry(new ChannelBuilder());
    // first channel
    File inpFile = new File(getDataDir(), "xmlhack-0.91.xml");
    ChannelIF chA = reg.addChannel(inpFile.toURL(), 2, true);
    Date dateA = chA.getLastUpdated();
    assertNull("channel shouldn't be parsed now", dateA);
    // second channel
    inpFile = new File(getDataDir(), "pro-linux.rdf");
    ChannelIF chB = reg.addChannel(inpFile.toURL(), 2, true);
    // third channel
    inpFile = new File(getDataDir(), "snipsnap-org.rss");
    ChannelIF chC = reg.addChannel(inpFile.toURL(), 2, true);
    // some basic assertions
    assertEquals("channel exists", 3, reg.getChannels().size());
    assertTrue("channel A", reg.getChannels().contains(chA));
    assertTrue("channel B", reg.getChannels().contains(chB));
    assertTrue("channel C", reg.getChannels().contains(chC));
View Full Code Here

    File inpFile = new File(getDataDir(), "xmlhack-0.91.xml");
    File chFile = new File(getOutputDir(), "xmlhack-0.91.xml");
    synchronized(chFile) {
      FileUtils.copyFile(inpFile, chFile);
    }
    ChannelIF chA = reg.addChannel(chFile.toURL(), 2 /* secs */, true);
    // be sure channel is read in
    try {
      Thread.sleep(2500);
    } catch (InterruptedException e) {
      logger.warn("Interrupted waiting thread");
View Full Code Here

  public TestChannelObserver(String name) {
    super("TestChannelObserver", name);
  }

  public void testObserve() {
    ChannelIF channel = new Channel("Niko's log");
    SimpleChannelObserver observer = new SimpleChannelObserver();
    ((ChannelObservableIF) channel).addObserver(observer);
    assertEquals(0, channel.getItems().size());
    ItemIF item = new Item("Bongo", "Rongoo", null);
    channel.addItem(item);
    assertEquals(1, channel.getItems().size());
    assertTrue(channel.getItems().contains(item));
    assertEquals(item, observer.getMyAddedItem());
   
  }
View Full Code Here

  public TestItemOrder(String testname) {
    super("TestItemOrder", testname);
  }

  private static ChannelIF prepare() throws MalformedURLException {
    ChannelIF chA = builder.createChannel("myChannel");
    builder.createItem(chA, "first item", "descr1", new URL("http://1.net/"));
    builder.createItem(chA, "second item", "22", new URL("http://2.net/"));
    builder.createItem(chA, "third item", "333", new URL("http://3.net/"));
    builder.createItem(chA, "fourth item", "4", new URL("http://4.net/"));
    builder.createItem(chA, "fifth item", "5555", new URL("http://5.net/"));
View Full Code Here

    builder.createItem(chA, "eight item", "8", new URL("http://8.net/"));
    return chA;
  }

  public void testCreatedItemCount() throws MalformedURLException {
    ChannelIF channel = prepare();
    assertEquals(8, channel.getItems().size());
  }
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.