1 package org.apache.maven.plugins.site.render;
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22 import java.io.File;
23 import java.util.HashMap;
24
25 import org.apache.maven.doxia.tools.SiteTool;
26 import org.apache.maven.plugin.testing.AbstractMojoTestCase;
27 import org.apache.maven.plugins.site.render.SiteMojo;
28 import org.codehaus.plexus.util.FileUtils;
29 import org.junit.Before;
30 import org.junit.Test;
31 import org.junit.runner.RunWith;
32 import org.junit.runners.JUnit4;
33
34
35
36
37
38 @RunWith(JUnit4.class)
39 public class SiteMojoTest
40 extends AbstractMojoTestCase
41 {
42
43 @Before
44 public void setup()
45 throws Exception
46 {
47 super.setUp();
48 }
49
50
51
52
53
54
55 @SuppressWarnings( "rawtypes" )
56 @Test
57 public void testGetInterpolatedSiteDescriptorContent()
58 throws Exception
59 {
60 File pluginXmlFile = getTestFile( "src/test/resources/unit/interpolated-site/pom.xml" );
61 assertNotNull( pluginXmlFile );
62 assertTrue( pluginXmlFile.exists() );
63
64 SiteMojo siteMojo = (SiteMojo) lookupMojo( "site", pluginXmlFile );
65 assertNotNull( siteMojo );
66
67 File descriptorFile = getTestFile( "src/test/resources/unit/interpolated-site/src/site/site.xml" );
68 assertNotNull( descriptorFile );
69 assertTrue( descriptorFile.exists() );
70
71 String siteDescriptorContent = FileUtils.fileRead( descriptorFile );
72 assertNotNull( siteDescriptorContent );
73 assertTrue( siteDescriptorContent.contains( "${project.name}" ) );
74
75 SiteTool siteTool = (SiteTool) lookup( SiteTool.ROLE );
76 siteDescriptorContent =
77 siteTool.getInterpolatedSiteDescriptorContent( new HashMap<String, String>(), siteMojo.getProject(),
78 siteDescriptorContent );
79 assertNotNull( siteDescriptorContent );
80 assertTrue( !siteDescriptorContent.contains( "${project.name}" ) );
81 }
82 }