/** Test method update */
 @Test
 public void testUpdate() {
   feed.setTitle("The title changed");
   feedManager.updateFeedMetadata(feed);
   // re-read for assertion
   final Feed readPodcast = feedManager.getFeed(feed);
   assertEquals(feed.getTitle(), readPodcast.getTitle());
 }
 /** Test method read */
 @Test
 public void testReadPodcast() {
   final Feed readPodcast = feedManager.getFeed(feed);
   assertNotNull(readPodcast);
   assertNotNull(readPodcast.getId());
   assertEquals(PODCAST_TITLE, readPodcast.getTitle());
 }
예제 #3
0
파일: Opml.java 프로젝트: jsmadja/fluxx
 private void insertOutline(Feed feed, Element body) {
   Element outline = new Element("outline");
   String title = feed.getTitle();
   outline.setAttribute("text", title);
   outline.setAttribute("title", title);
   outline.setAttribute("type", "rss");
   outline.setAttribute("xmlUrl", feed.getUrl());
   outline.setAttribute("htmlUrl", feed.getUrl());
   body.addContent(outline);
 }
예제 #4
0
 /** Checks if the feed was parsed correctly. */
 private boolean checkFeedData(Feed feed) {
   if (feed.getTitle() == null) {
     Log.e(TAG, "Feed has no title.");
     return false;
   }
   if (!hasValidFeedItems(feed)) {
     Log.e(TAG, "Feed has invalid items");
     return false;
   }
   return true;
 }
예제 #5
0
  protected void showDetail() {
    Intent intent = new Intent(this, DetailActivity.class);

    String title = selectedFeed.getTitle();
    String description = selectedFeed.getDescription();
    String link = selectedFeed.getLink();

    intent.putExtra("title", title);
    intent.putExtra("description", description);
    intent.putExtra("link", link);

    startActivity(intent);
  }
예제 #6
0
  public void testWrite() throws Exception {
    FileWriter fw = null;
    File outFile = null;

    try {
      outFile = File.createTempFile("FeedTest", "tmp");
      filesToDelete.add(outFile);
      fw = new FileWriter(outFile);
      Feed feed = new Feed(tempFile);
      feed.write(fw);
      fw.close();

      // Feed feed2 = new Feed(outFile);
      assertEquals("CruiseControl Build Results", feed.getTitle());
      assertEquals("http://MyMachine.MyDomain.com/cruisecontrol/", feed.getLink());
      assertEquals(
          "Automated build results for CruiseControl project(s) VERSION_10", feed.getDescription());

      // validate the number of items and the contents of the first item.
      assertEquals(11, feed.getItems().size());
      Item item = (Item) feed.getItems().get(0);
      assertEquals("VERSION_10 build.7 Build Successful", item.getTitle());
      assertEquals(
          "http://MyMachine.MyDomain.com/cruisecontrol/buildresults/"
              + "VERSION_10?log=log20050817084109Lbuild.7",
          item.getLink());
      assertEquals(
          "<em>Build Time:</em> Wed Aug 17 08:41:09 MDT 2005<br/>"
              + "<em>Label:</em> build.7<br/><em>Modifications: </em>1<br/>"
              + "\n<ul><li>//depot/MyProduct/VERSION_10/dev/main/src/datacenter/"
              + "ApplicationServer/PlayTime/default.build"
              + "  by jefferson (deploy the mock object dll)</li></ul>",
          item.getDescription());
    } finally {
      IO.close(fw);
    }
  }
예제 #7
0
  public void testConstructors() {
    Feed feed = new Feed(tempFile);

    assertEquals("CruiseControl Build Results", feed.getTitle());
    assertEquals("http://MyMachine.MyDomain.com/cruisecontrol/", feed.getLink());
    assertEquals(
        "Automated build results for CruiseControl project(s) VERSION_10", feed.getDescription());

    // validate the number of items and the contents of the first item.
    assertEquals(11, feed.getItems().size());
    Item item = (Item) feed.getItems().get(0);
    assertEquals("VERSION_10 build.7 Build Successful", item.getTitle());
    assertEquals(
        "http://MyMachine.MyDomain.com/cruisecontrol/buildresults/"
            + "VERSION_10?log=log20050817084109Lbuild.7",
        item.getLink());
    assertEquals(
        "<em>Build Time:</em> Wed Aug 17 08:41:09 MDT 2005<br/>"
            + "<em>Label:</em> build.7<br/><em>Modifications: </em>1<br/>"
            + "\n<ul><li>//depot/MyProduct/VERSION_10/dev/main/src/datacenter/"
            + "ApplicationServer/PlayTime/default.build"
            + "  by jefferson (deploy the mock object dll)</li></ul>",
        item.getDescription());
  }
예제 #8
0
    private Feed parseFeed(DownloadRequest request) {
      Feed savedFeed = null;

      Feed feed = new Feed(request.getSource(), new Date());
      feed.setFile_url(request.getDestination());
      feed.setId(request.getFeedfileId());
      feed.setDownloaded(true);
      feed.setPreferences(
          new FeedPreferences(0, true, request.getUsername(), request.getPassword()));

      DownloadError reason = null;
      String reasonDetailed = null;
      boolean successful = true;
      FeedHandler feedHandler = new FeedHandler();

      try {
        feed = feedHandler.parseFeed(feed).feed;
        if (BuildConfig.DEBUG) Log.d(TAG, feed.getTitle() + " parsed");
        if (checkFeedData(feed) == false) {
          throw new InvalidFeedException();
        }

      } catch (SAXException e) {
        successful = false;
        e.printStackTrace();
        reason = DownloadError.ERROR_PARSER_EXCEPTION;
        reasonDetailed = e.getMessage();
      } catch (IOException e) {
        successful = false;
        e.printStackTrace();
        reason = DownloadError.ERROR_PARSER_EXCEPTION;
        reasonDetailed = e.getMessage();
      } catch (ParserConfigurationException e) {
        successful = false;
        e.printStackTrace();
        reason = DownloadError.ERROR_PARSER_EXCEPTION;
        reasonDetailed = e.getMessage();
      } catch (UnsupportedFeedtypeException e) {
        e.printStackTrace();
        successful = false;
        reason = DownloadError.ERROR_UNSUPPORTED_TYPE;
        reasonDetailed = e.getMessage();
      } catch (InvalidFeedException e) {
        e.printStackTrace();
        successful = false;
        reason = DownloadError.ERROR_PARSER_EXCEPTION;
        reasonDetailed = e.getMessage();
      }

      // cleanup();
      if (savedFeed == null) {
        savedFeed = feed;
      }

      if (successful) {
        return savedFeed;
      } else {
        saveDownloadStatus(
            new DownloadStatus(
                savedFeed,
                savedFeed.getHumanReadableIdentifier(),
                reason,
                successful,
                reasonDetailed));
        return null;
      }
    }