KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > de > nava > informa > utils > TestFormatDetector


1 //
2
// Informa -- RSS Library for Java
3
// Copyright (c) 2002 by Niko Schmuck
4
//
5
// Niko Schmuck
6
// http://sourceforge.net/projects/informa
7
// mailto:niko_schmuck@users.sourceforge.net
8
//
9
// This library is free software.
10
//
11
// You may redistribute it and/or modify it under the terms of the GNU
12
// Lesser General Public License as published by the Free Software Foundation.
13
//
14
// Version 2.1 of the license should be included with this distribution in
15
// the file LICENSE. If the license is not included with this distribution,
16
// you may find a copy at the FSF web site at 'www.gnu.org' or 'www.fsf.org',
17
// or you may write to the Free Software Foundation, 675 Mass Ave, Cambridge,
18
// MA 02139 USA.
19
//
20
// This library is distributed in the hope that it will be useful,
21
// but WITHOUT ANY WARRANTY; without even the implied waranty of
22
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
23
// Lesser General Public License for more details.
24
//
25

26
27 // $Id: TestFormatDetector.java,v 1.15 2003/09/29 19:43:39 niko_schmuck Exp $
28

29 package de.nava.informa.utils;
30
31 import java.io.File JavaDoc;
32
33 import de.nava.informa.core.ChannelFormat;
34 import de.nava.informa.core.UnsupportedFormatException;
35
36 public class TestFormatDetector extends InformaTestCase {
37
38   public TestFormatDetector(String JavaDoc name) {
39     super("TestFormatDetector", name);
40   }
41
42   public void testFormatRSS091xmlhack() throws Exception JavaDoc {
43     File JavaDoc inpFile = new File JavaDoc(getDataDir(), "xmlhack-0.91.xml");
44     ChannelFormat actualFormat = FormatDetector.getFormat(inpFile.toURL());
45     assertEquals(ChannelFormat.RSS_0_91, actualFormat);
46   }
47   
48   public void testFormatRSS091aeden() throws Exception JavaDoc {
49     File JavaDoc inpFile = new File JavaDoc(getDataDir(), "aeden.rss");
50     ChannelFormat actualFormat = FormatDetector.getFormat(inpFile.toURL());
51     assertEquals(ChannelFormat.RSS_0_91, actualFormat);
52   }
53   
54   public void testFormatRSS092gratefuldead() throws Exception JavaDoc {
55     File JavaDoc inpFile = new File JavaDoc(getDataDir(), "gratefulDead-rss-0.92.xml");
56     ChannelFormat actualFormat = FormatDetector.getFormat(inpFile.toURL());
57     assertEquals(ChannelFormat.RSS_0_92, actualFormat);
58   }
59   
60   public void testFormatRSS10xmlhack() throws Exception JavaDoc {
61     File JavaDoc inpFile = new File JavaDoc(getDataDir(), "xmlhack-1.0.xml");
62     ChannelFormat actualFormat = FormatDetector.getFormat(inpFile.toURL());
63     assertEquals(ChannelFormat.RSS_1_0, actualFormat);
64   }
65   
66   public void testFormatRSS10slashdot() throws Exception JavaDoc {
67     File JavaDoc inpFile = new File JavaDoc(getDataDir(), "slashdot.rdf");
68     ChannelFormat actualFormat = FormatDetector.getFormat(inpFile.toURL());
69     assertEquals(ChannelFormat.RSS_1_0, actualFormat);
70   }
71
72   public void testFormatRSS10googleweblog() throws Exception JavaDoc {
73     File JavaDoc inpFile = new File JavaDoc(getDataDir(), "google-weblog.rdf");
74     ChannelFormat actualFormat = FormatDetector.getFormat(inpFile.toURL());
75     assertEquals(ChannelFormat.RSS_1_0, actualFormat);
76   }
77
78   public void testFormatRSS10w3csynd() throws Exception JavaDoc {
79     File JavaDoc inpFile = new File JavaDoc(getDataDir(), "w3c-synd.rdf");
80     ChannelFormat actualFormat = FormatDetector.getFormat(inpFile.toURL());
81     assertEquals(ChannelFormat.RSS_1_0, actualFormat);
82   }
83
84   public void testFormatRSS20A() throws Exception JavaDoc {
85     File JavaDoc inpFile = new File JavaDoc(getDataDir(), "informa-projnews.xml");
86     ChannelFormat actualFormat = FormatDetector.getFormat(inpFile.toURL());
87     assertEquals(ChannelFormat.RSS_2_0, actualFormat);
88   }
89
90   public void testFormatRSS20B() throws Exception JavaDoc {
91     File JavaDoc inpFile = new File JavaDoc(getDataDir(), "snipsnap-org.rss");
92     ChannelFormat actualFormat = FormatDetector.getFormat(inpFile.toURL());
93     assertEquals(ChannelFormat.RSS_2_0, actualFormat);
94   }
95
96   public void testUnsupportedFormat() throws Exception JavaDoc {
97     File JavaDoc inpFile = new File JavaDoc(getDataDir(), "dir-xml-rpc-com.opml");
98     try {
99       ChannelFormat actualFormat = FormatDetector.getFormat(inpFile.toURL());
100       fail("This format is not yet supported ...");
101     } catch (UnsupportedFormatException e) {
102       assertTrue(true);
103     }
104   }
105   
106 }
107
Popular Tags