1 package org.apache.maven.plugin.changes;
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22 import java.io.IOException;
23 import java.io.StringWriter;
24 import java.io.Writer;
25
26 import java.util.ArrayList;
27 import java.util.List;
28 import java.util.Locale;
29
30 import junit.framework.TestCase;
31
32 import org.apache.maven.plugins.changes.model.Release;
33
34
35
36
37
38 public class FeedGeneratorTest
39 extends TestCase
40 {
41
42
43
44 public void testIsSupportedFeedType()
45 {
46 final FeedGenerator generator = new FeedGenerator( Locale.ENGLISH );
47
48 assertTrue( "rss_0.9 not supported?", generator.isSupportedFeedType( "rss_0.9" ) );
49 assertTrue( "rss_0.91N not supported?", generator.isSupportedFeedType( "rss_0.91N" ) );
50 assertTrue( "rss_0.91U not supported?", generator.isSupportedFeedType( "rss_0.91U" ) );
51 assertTrue( "rss_0.92 not supported?", generator.isSupportedFeedType( "rss_0.92" ) );
52 assertTrue( "rss_0.93 not supported?", generator.isSupportedFeedType( "rss_0.93" ) );
53 assertTrue( "rss_0.94 not supported?", generator.isSupportedFeedType( "rss_0.94" ) );
54 assertTrue( "rss_1.0 not supported?", generator.isSupportedFeedType( "rss_1.0" ) );
55 assertTrue( "rss_2.0 not supported?", generator.isSupportedFeedType( "rss_2.0" ) );
56 assertTrue( "atom_0.3 not supported?", generator.isSupportedFeedType( "atom_0.3" ) );
57 assertTrue( "atom_1.0 not supported?", generator.isSupportedFeedType( "atom_1.0" ) );
58
59 assertFalse( generator.isSupportedFeedType( "" ) );
60 assertFalse( generator.isSupportedFeedType( null ) );
61 assertFalse( generator.isSupportedFeedType( "rss" ) );
62 }
63
64
65
66
67
68
69 public void testExport()
70 throws Exception
71 {
72 final FeedGenerator generator = new FeedGenerator( Locale.ENGLISH );
73 generator.setAuthor( "author" );
74 generator.setTitle( "title" );
75 generator.setLink( "url" );
76 generator.setDateFormat( null );
77
78 Release release = new Release();
79 release.setVersion( "1.0" );
80 List<Release> releases = new ArrayList<Release>( 1 );
81
82 try
83 {
84
85 generator.export( releases, "rss_0.9", new StringWriter( 512 ) );
86 fail( "0 releases not allowed!" );
87 }
88 catch ( IOException ex )
89 {
90 assertNotNull( ex );
91 }
92
93 releases.add( release );
94
95 for ( String type: generator.getSupportedFeedTypes() )
96 {
97 Writer writer = new StringWriter( 512 );
98 generator.export( releases, type, writer );
99 String result = writer.toString();
100 assertNotNull( result );
101 assertTrue( result.length() > 0 );
102 writer.close();
103 }
104 }
105 }