Coverage Report - org.apache.commons.feedparser.test.TestFeedFilter
 
Classes in this File Line Coverage Branch Coverage Complexity
TestFeedFilter
0%
0/37
0%
0/2
1.25
 
 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 java.io.FileOutputStream;
 20  
 import java.io.PrintStream;
 21  
 import java.net.URL;
 22  
 
 23  
 import junit.framework.TestCase;
 24  
 
 25  
 import org.apache.commons.feedparser.FeedParser;
 26  
 import org.apache.commons.feedparser.FeedParserFactory;
 27  
 import org.apache.commons.feedparser.impl.DebugFeedParserListener;
 28  
 
 29  
 /**
 30  
  *
 31  
  * @author <a href="mailto:burton@peerfear.org">Kevin A. Burton</a>
 32  
  * @version $Id: TestFeedFilter.java 373622 2006-01-30 22:53:00Z mvdb $
 33  
  */
 34  
 public class TestFeedFilter extends TestCase {
 35  
     protected String feedparserHome;
 36  
     
 37  0
     public static int current = 0;
 38  
 
 39  
     public TestFeedFilter( String name ) throws Exception {
 40  0
         super( name );
 41  
         
 42  0
         feedparserHome = System.getProperty("feedparser.home", ".");
 43  
         // these come in as forward slashes, even on Windows, because of Ant,
 44  
         // so it is safe to check them as / rather than File.separator
 45  
         // Brad Neuberg
 46  0
         if (feedparserHome.endsWith("/") == false)
 47  0
             feedparserHome = feedparserHome + "/";
 48  0
     }
 49  
 
 50  
     private void doTest( String resource ) throws Exception {
 51  
 
 52  0
         System.out.println( "resource: (" + current + ") " + resource );
 53  
 
 54  0
         URL url = new URL( resource );
 55  
 
 56  0
         FileOutputStream fos = new FileOutputStream( "/tmp/test-feed-filter-" + current + ".html" );
 57  
 
 58  0
         PrintStream out = new PrintStream( fos, true, "UTF-8" );
 59  
 
 60  0
         out.println( "<META HTTP-EQUIV=\"Content-Type\" CONTENT=\"text/html; charset=UTF-8\"> " );
 61  0
         out.println( "<pre>" );
 62  
 
 63  0
         DebugFeedParserListener listener = new DebugFeedParserListener( out );
 64  
 
 65  0
         FeedParser parser=FeedParserFactory.newFeedParser();
 66  0
         parser.parse( listener, url.openStream(), resource );
 67  
 
 68  0
         out.println( "</pre>" );
 69  
 
 70  0
         ++current;
 71  
 
 72  0
     }
 73  
 
 74  
     public void test1() throws Exception {
 75  0
         String path = "file:" + feedparserHome;
 76  
 
 77  0
         doTest( path + "tests/feeds/rss-1.0-EUC-JP.rdf" );
 78  
 
 79  0
         doTest( path + "tests/filter/nbsp-1.xml" );
 80  
 
 81  0
         doTest( path + "tests/filter/entity-atom-1.xml" );
 82  
 
 83  0
         doTest( path + "tests/filter/prolog-atom-1.xml" );
 84  0
         doTest( path + "tests/filter/prolog-atom-2.xml" );
 85  0
         doTest( path + "tests/filter/prolog-opml-1.xml" );
 86  
 
 87  0
         doTest( path + "tests/filter/lisa.opml" );
 88  
 
 89  0
         doTest( path + "tests/feeds/utf16.rss1" );
 90  0
         doTest( path + "tests/feeds/utf16.rss2" );
 91  0
         doTest( path + "tests/feeds/i18n.atom" );
 92  0
         doTest( path + "tests/feeds/utf16.atom" );
 93  
 
 94  0
         doTest( path + "tests/feeds/atom-1.xml" );
 95  0
         doTest( path + "tests/feeds/rss-1.0-EUC-JP.rdf" );
 96  0
         doTest( path + "tests/feeds/rss-1.0-international-1.rdf" );
 97  
 
 98  0
     }
 99  
 
 100  
     public static void main( String[] args ) throws Exception {
 101  
 
 102  0
         TestFeedFilter test = new TestFeedFilter( null );
 103  
 
 104  
         //test.testGetWeblogLinkForResource();
 105  0
         test.test1();
 106  
 
 107  0
     }
 108  
 
 109  
 }
 110