Coverage Report - org.apache.commons.feedparser.test.TestAtom
 
Classes in this File Line Coverage Branch Coverage Complexity
TestAtom
0%
0/13
N/A
1
TestAtom$1
0%
0/13
N/A
1
 
 1  
 /*
 2  
  * Copyright 1999,2004 The Apache Software Foundation.
 3  
  * 
 4  
  * Licensed under the Apache License, Version 2.0 (the "License");
 5  
  * you may not use this file except in compliance with the License.
 6  
  * You may obtain a copy of the License at
 7  
  * 
 8  
  *      http://www.apache.org/licenses/LICENSE-2.0
 9  
  * 
 10  
  * Unless required by applicable law or agreed to in writing, software
 11  
  * distributed under the License is distributed on an "AS IS" BASIS,
 12  
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 13  
  * See the License for the specific language governing permissions and
 14  
  * limitations under the License.
 15  
  */
 16  
 
 17  
 package org.apache.commons.feedparser.test;
 18  
 
 19  
 import junit.framework.TestCase;
 20  
 
 21  
 import org.apache.commons.feedparser.DefaultFeedParserListener;
 22  
 import org.apache.commons.feedparser.FeedParser;
 23  
 import org.apache.commons.feedparser.FeedParserException;
 24  
 import org.apache.commons.feedparser.FeedParserFactory;
 25  
 import org.apache.commons.feedparser.FeedParserListener;
 26  
 import org.apache.commons.feedparser.FeedParserState;
 27  
 import org.apache.commons.feedparser.network.ResourceRequest;
 28  
 import org.apache.commons.feedparser.network.ResourceRequestFactory;
 29  
 
 30  
 /**
 31  
  *
 32  
  * @author <a href="mailto:burton@peerfear.org">Kevin A. Burton</a>
 33  
  * @version $Id: TestAtom.java 373622 2006-01-30 22:53:00Z mvdb $
 34  
  */
 35  
 public class TestAtom extends TestCase {
 36  
 
 37  
     public TestAtom( String name ) throws Exception {
 38  0
         super( name );
 39  0
     }
 40  
 
 41  
     public void doTest( String resource ) throws Exception {
 42  
 
 43  0
         FeedParser parser = FeedParserFactory.newFeedParser();
 44  
 
 45  0
         FeedParserListener listener = new DefaultFeedParserListener() {
 46  
 
 47  
                 public void onItem( FeedParserState state,
 48  
                                     String title,
 49  
                                     String weblog,
 50  
                                     String description,
 51  
                                     String permalink ) throws FeedParserException {
 52  
 
 53  0
                     System.out.println( "title: " + title );
 54  0
                     System.out.println( "description: " + description );
 55  0
                     System.out.println( "permalink: " + permalink );
 56  
                     
 57  0
                 }
 58  
 
 59  0
                 public void onItemEnd() {}
 60  
 
 61  0
                 public void finished() {}
 62  
 
 63  
                 // **** MetaFeedParserListener **********************************************
 64  
                 
 65  
                 public void onSubject( FeedParserState state, String content )
 66  
                     throws FeedParserException {
 67  
 
 68  0
                     System.out.println( "subject: " + content );
 69  
                     
 70  0
                 }
 71  
 
 72  
                 public void onContent( FeedParserState state,
 73  
                                        String type,
 74  
                                        String format,
 75  
                                        String encoding,
 76  
                                        String mode,
 77  
                                        String value ) throws FeedParserException {
 78  
 
 79  0
                     System.out.println( "content (type): " + type );
 80  0
                     System.out.println( "content (mode): " + mode );
 81  0
                     System.out.println( "content (value): " + value );
 82  
                     
 83  0
                 }
 84  
 
 85  
             };
 86  
         
 87  0
         listener.setContext( this );
 88  
         
 89  0
         ResourceRequest request = ResourceRequestFactory.getResourceRequest( resource );
 90  
         
 91  0
         parser.parse( listener, request.getInputStream(), resource );
 92  
 
 93  0
     }
 94  
 
 95  
    public void test1() throws Exception {
 96  
 
 97  
        //String resource = "file:///projects/feedparser/src/java/org/apache/commons/feedparser/test/TestAtom.xml";
 98  
        
 99  
        //doTest( resource );
 100  0
        doTest( "file:tests/feeds/atom-1.xml" );
 101  
     
 102  0
    }
 103  
 
 104  
     public static void main( String[] args ) throws Exception {
 105  
 
 106  0
         TestAtom test = new TestAtom( null );
 107  
         
 108  
         //test.testGetWeblogLinkForResource();
 109  0
         test.test1();
 110  
 
 111  0
     }
 112  
 
 113  
 }
 114