Package com.salas.bb.utils.parser

Examples of com.salas.bb.utils.parser.Channel


    /**
     * Tests updating the feed data from parsed channel object.
     */
    public void testUpdateFeed()
    {
        Channel channel = new Channel();

        // The parsed channel has information about format and language,
        // the feed we have -- has not. The information should be moved.
        channel.setFormat("A");
        channel.setLanguage("B");

        feed.updateFeed(channel);
        assertEquals("Wrong format.", "A", feed.getFormat());
        assertEquals("Wrong language.", "B", feed.getLanguage());

        // The parsed channel has no information about format and language,
        // the feed we already have -- has. There should be no updates.
        channel.setFormat(null);
        channel.setLanguage(null);

        feed.updateFeed(channel);
        assertEquals("Wrong format.", "A", feed.getFormat());
        assertEquals("Wrong language.", "B", feed.getLanguage());
    }
View Full Code Here


    /**
     * Tests normal update sequence with updates to times and retrieval counts.
     */
    public void testUpdateNotNull()
    {
        Channel channel = new Channel();
        channel.addItem(new Item("1"));

        DummyDataFeed feed = new DummyDataFeed();
        feed.setChannel(channel);

        long base = System.currentTimeMillis();
View Full Code Here

        // Adding two articles one by one (two updates) while having limit of 1
        // The second update should call cleaner and remove the last article
        DummyDataFeed feed = new DummyDataFeed();
        feed.setPurgeLimit(1);
        Channel channel1 = new Channel();
        channel1.addItem(new Item("1"));

        // First update
        feed.setChannel(channel1);
        feed.update();

        // A little pause to create a gap between items
        Thread.sleep(100);

        Channel channel2 = new Channel();
        Item item = new Item("2");
        channel2.addItem(item);

        // Second update
        feed.setChannel(channel2);
        feed.update();
View Full Code Here

        // The second update should call cleaner but the first article should be
        // removed because of a pin.
        DummyDataFeed feed = new DummyDataFeed();
        feed.setPurgeLimit(1);
        DataFeed.setGlobalPurgeUnread(false);
        Channel channel1 = new Channel();
        channel1.addItem(new Item("1"));

        // First update
        feed.setChannel(channel1);
        feed.update();
        feed.getArticleAt(0).setPinned(true);

        Channel channel2 = new Channel();
        Item item = new Item("2");
        channel2.addItem(item);

        // Second update
        feed.setChannel(channel2);
        feed.update();
View Full Code Here

    /**
     * Tests how the last update server time field is populated during updates.
     */
    public void testSavingLastUpdateServerTime()
    {
        Channel chan = new Channel();
        chan.setLastUpdateServerTime(-1);
        chan.addItem(new Item("1"));

        DummyDataFeed feed = new DummyDataFeed();
        feed.setChannel(chan);
        feed.update();

        assertEquals("Wrong last update server time.", -1, feed.getLastUpdateServerTime());

        chan.setLastUpdateServerTime(1);
        chan.addItem(new Item("2"));
        feed.update();

        assertEquals("Wrong last update server time.", 1, feed.getLastUpdateServerTime());
    }
View Full Code Here

    protected Channel fetchFeed()
        throws IOException
    {
        IFeedParser parser = FeedParserConfig.create();

        Channel channel = null;
        try
        {
            FeedParserResult result = parser.parse(getXmlURL(), getTitle(),
                getLastUpdateServerTime());
View Full Code Here

    }

    @Override
    public Channel fetchFeed(QueryFeed queryFeed)
    {
        Channel channel = null;

        String subscriptionId = ResourceUtils.getString("amazon.subscription");
        String partnerId = ResourceUtils.getString("amazon.partner");

        AmazonGateway gateway = new AmazonGateway(subscriptionId, partnerId);
View Full Code Here

     *
     * @return channel.
     */
    private Channel itemsToChannel(AmazonItem[] aAmazonItems, String parameter)
    {
        Channel channel = new Channel();
        channel.setAuthor("Amazon.com");
        channel.setDescription(MessageFormat.format(Strings.message("feed.queryfeed.querying.for.0"), parameter));
        channel.setFormat("XML");
        channel.setLanguage("en_US");
        channel.setUpdatePeriod(Constants.MILLIS_IN_DAY);

        for (AmazonItem amazonItem : aAmazonItems)
        {
            Item item = amazonItemToChannelItem(amazonItem);
            if (item != null) channel.addItem(item);
        }

        return channel;
    }
View Full Code Here

     * Tests how the data from the parsed feeds is moved to the feed properties.
     */
    public void testUpdateFeed()
        throws MalformedURLException
    {
        Channel channel = new Channel();
        channel.setTitle("A");
        channel.setDescription("B");
        channel.setAuthor("C");
        channel.setFormat("D");
        channel.setLanguage("E");
        channel.setSiteURL(new URL("http://site"));

        feed.updateFeed(channel);

        assertEquals("Wrong base title.", "A", feed.getBaseTitle());
        assertEquals("Wrong base description.", "B", feed.getBaseDescription());
        assertEquals("Wrong base author.", "C", feed.getBaseAuthor());
        assertEquals("Wrong format.", "D", feed.getFormat());
        assertEquals("Wrong language.", "E", feed.getLanguage());
        assertEquals("Wrong site URL.", "http://site", feed.getSiteURL().toString());

        // Test not overriding by empty values
        feed.updateFeed(new Channel());

        assertEquals("Wrong base title.", "A", feed.getBaseTitle());
        assertEquals("Wrong base description.", "B", feed.getBaseDescription());
        assertEquals("Wrong base author.", "C", feed.getBaseAuthor());
        assertEquals("Wrong format.", "D", feed.getFormat());
View Full Code Here

     * @return the feed or NULL if there was an error or no updates required.
     */
    protected Channel fetchFeed()
        throws IOException
    {
        Channel result = queryType.fetchFeed(this);

        if (result == null) result = super.fetchFeed();

        return result;
    }
View Full Code Here

TOP

Related Classes of com.salas.bb.utils.parser.Channel

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.