1 26 27 29 package de.nava.informa.utils; 30 31 import java.io.File ; 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 name) { 39 super("TestFormatDetector", name); 40 } 41 42 public void testFormatRSS091xmlhack() throws Exception { 43 File inpFile = new File (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 { 49 File inpFile = new File (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 { 55 File inpFile = new File (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 { 61 File inpFile = new File (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 { 67 File inpFile = new File (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 { 73 File inpFile = new File (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 { 79 File inpFile = new File (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 { 85 File inpFile = new File (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 { 91 File inpFile = new File (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 { 97 File inpFile = new File (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 |