1 package org.apache.maven.plugin.changelog;
2
3 /*
4 * Licensed to the Apache Software Foundation (ASF) under one
5 * or more contributor license agreements. See the NOTICE file
6 * distributed with this work for additional information
7 * regarding copyright ownership. The ASF licenses this file
8 * to you under the Apache License, Version 2.0 (the
9 * "License"); you may not use this file except in compliance
10 * with the License. You may obtain a copy of the License at
11 *
12 * http://www.apache.org/licenses/LICENSE-2.0
13 *
14 * Unless required by applicable law or agreed to in writing,
15 * software distributed under the License is distributed on an
16 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
17 * KIND, either express or implied. See the License for the
18 * specific language governing permissions and limitations
19 * under the License.
20 */
21
22 import java.io.File;
23 import java.io.IOException;
24 import java.io.Writer;
25
26 import org.apache.maven.doxia.site.decoration.DecorationModel;
27 import org.apache.maven.doxia.siterenderer.RendererException;
28 import org.apache.maven.doxia.siterenderer.SiteRenderingContext;
29 import org.apache.maven.doxia.siterenderer.sink.SiteRendererSink;
30 import org.apache.maven.plugin.testing.AbstractMojoTestCase;
31 import org.codehaus.plexus.util.IOUtil;
32 import org.codehaus.plexus.util.WriterFactory;
33
34 /**
35 * @author <a href="mailto:vincent.siveton@gmail.com">Vincent Siveton</a>
36 * @version $Id: AbstractChangeLogReportTest.java 803814 2009-08-13 09:24:45Z vsiveton $
37 * @since 2.2
38 */
39 public abstract class AbstractChangeLogReportTest
40 extends AbstractMojoTestCase
41 {
42 /**
43 * Renderer the sink from the report mojo.
44 *
45 * @param mojo not null
46 * @param outputHtml not null
47 * @throws RendererException if any
48 * @throws IOException if any
49 */
50 protected void renderer( ChangeLogReport mojo, File outputHtml )
51 throws RendererException, IOException
52 {
53 Writer writer = null;
54 SiteRenderingContext context = new SiteRenderingContext();
55 context.setDecoration( new DecorationModel() );
56 context.setTemplateName( "org/apache/maven/doxia/siterenderer/resources/default-site.vm" );
57
58 try
59 {
60 outputHtml.getParentFile().mkdirs();
61 writer = WriterFactory.newXmlWriter( outputHtml );
62
63 mojo.getSiteRenderer().generateDocument( writer, (SiteRendererSink) mojo.getSink(),
64 context );
65 }
66 finally
67 {
68 IOUtil.close( writer );
69 }
70 }
71 }