Search in sources :

Example 11 with Release

use of org.apache.maven.plugins.changes.model.Release in project maven-plugins by apache.

the class FeedGeneratorTest method testExport.

/**
     * Test of export method, of class FeedGenerator.
     *
     * @throws Exception if any.
     */
public void testExport() throws Exception {
    final FeedGenerator generator = new FeedGenerator(Locale.ENGLISH);
    generator.setAuthor("author");
    generator.setTitle("title");
    generator.setLink("url");
    generator.setDateFormat(null);
    Release release = new Release();
    release.setVersion("1.0");
    List<Release> releases = new ArrayList<Release>(1);
    try {
        // test with no release: should fail
        generator.export(releases, "rss_0.9", new StringWriter(512));
        fail("0 releases not allowed!");
    } catch (IOException ex) {
        assertNotNull(ex);
    }
    releases.add(release);
    for (String type : generator.getSupportedFeedTypes()) {
        Writer writer = new StringWriter(512);
        generator.export(releases, type, writer);
        // TODO: save for inspection?
        String result = writer.toString();
        assertNotNull(result);
        assertTrue(result.length() > 0);
        writer.close();
    }
}
Also used : FeedGenerator(org.apache.maven.plugins.changes.FeedGenerator) StringWriter(java.io.StringWriter) ArrayList(java.util.ArrayList) IOException(java.io.IOException) Release(org.apache.maven.plugins.changes.model.Release) StringWriter(java.io.StringWriter) Writer(java.io.Writer)

Example 12 with Release

use of org.apache.maven.plugins.changes.model.Release in project maven-plugins by apache.

the class ReleaseUtilsTestCase method testMergeReleases.

public void testMergeReleases() throws Exception {
    Log log = new SilentLog();
    ReleaseUtils releaseUtils = new ReleaseUtils(log);
    List<Release> firstReleases = new ArrayList<Release>();
    List<Release> secondReleases = new ArrayList<Release>();
    List<Release> mergedReleases;
    mergedReleases = releaseUtils.mergeReleases(firstReleases, secondReleases);
    assertEquals("Both empty", 0, mergedReleases.size());
    Release release = new Release();
    release.setVersion("1.0");
    firstReleases.add(release);
    mergedReleases = releaseUtils.mergeReleases(firstReleases, secondReleases);
    assertEquals("One release in first", 1, mergedReleases.size());
    release = new Release();
    release.setVersion("1.1");
    secondReleases.add(release);
    mergedReleases = releaseUtils.mergeReleases(firstReleases, secondReleases);
    assertEquals("One release each", 2, mergedReleases.size());
    release = new Release();
    release.setVersion("1.1");
    firstReleases.add(release);
    mergedReleases = releaseUtils.mergeReleases(firstReleases, secondReleases);
    assertEquals("Two releases in first, one release in second with one version being the same", 2, mergedReleases.size());
    release = new Release();
    release.setVersion("1.2");
    secondReleases.add(release);
    mergedReleases = releaseUtils.mergeReleases(firstReleases, secondReleases);
    assertEquals("Two releases each with one version being the same", 3, mergedReleases.size());
}
Also used : ReleaseUtils(org.apache.maven.plugins.changes.ReleaseUtils) SilentLog(org.apache.maven.plugin.testing.SilentLog) Log(org.apache.maven.plugin.logging.Log) SilentLog(org.apache.maven.plugin.testing.SilentLog) ArrayList(java.util.ArrayList) Release(org.apache.maven.plugins.changes.model.Release)

Aggregations

Release (org.apache.maven.plugins.changes.model.Release)12 ArrayList (java.util.ArrayList)6 File (java.io.File)2 MojoExecutionException (org.apache.maven.plugin.MojoExecutionException)2 ChangesXML (org.apache.maven.plugins.changes.ChangesXML)2 Action (org.apache.maven.plugins.changes.model.Action)2 SyndEntry (com.sun.syndication.feed.synd.SyndEntry)1 SyndEntryImpl (com.sun.syndication.feed.synd.SyndEntryImpl)1 IOException (java.io.IOException)1 StringWriter (java.io.StringWriter)1 Writer (java.io.Writer)1 SimpleDateFormat (java.text.SimpleDateFormat)1 Date (java.util.Date)1 HashMap (java.util.HashMap)1 Locale (java.util.Locale)1 Properties (java.util.Properties)1 CaseInsensitiveMap (org.apache.commons.collections.map.CaseInsensitiveMap)1 Log (org.apache.maven.plugin.logging.Log)1 SilentLog (org.apache.maven.plugin.testing.SilentLog)1 FeedGenerator (org.apache.maven.plugins.changes.FeedGenerator)1