1 package org.apache.maven.model.converter.plugins;
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22 import junit.framework.Assert;
23 import org.apache.maven.model.converter.ProjectConverterException;
24
25 import java.io.IOException;
26
27
28
29
30
31 public class PCCCheckstyleTest
32 extends AbstractPCCTest
33 {
34 protected void setUp()
35 throws Exception
36 {
37 super.setUp();
38
39 pluginConfigurationConverter = new PCCCheckstyle();
40 }
41
42 public void testBuildConfiguration1()
43 {
44 try
45 {
46 projectProperties.load( getClassLoader().getResourceAsStream( "PCCCheckstyleTest1.properties" ) );
47
48 pluginConfigurationConverter.buildConfiguration( configuration, v3Model, projectProperties );
49
50 String value = configuration.getChild( "cacheFile" ).getValue();
51 Assert.assertEquals( "check cacheFile value", "target/checkstyle/myCachefile", value );
52
53 value = configuration.getChild( "configLocation" ).getValue();
54 Assert.assertEquals( "check configLocation value", "config/sun_checks.xml", value );
55
56 value = configuration.getChild( "excludes" ).getValue();
57 Assert.assertEquals( "check excludes value", "**/*.html", value );
58
59 value = configuration.getChild( "failsOnError" ).getValue();
60 Assert.assertEquals( "check failsOnError value", "true", value );
61
62 value = configuration.getChild( "headerLocation" ).getValue();
63 Assert.assertEquals( "check headerLocation value", "src/main/resources/HEADER.txt", value );
64
65 value = configuration.getChild( "includes" ).getValue();
66 Assert.assertEquals( "check includes value", "**/*.java", value );
67
68 value = configuration.getChild( "outputFile" ).getValue();
69 Assert.assertEquals( "check outputFile value", "target/checkstyle/checkstyle-raw-report.txt", value );
70
71 value = configuration.getChild( "outputFileFormat" ).getValue();
72 Assert.assertEquals( "check outputFileFormat value", "plain", value );
73
74 value = configuration.getChild( "suppressionsLocation" ).getValue();
75 Assert.assertEquals( "check suppressionsLocation value", "src/main/resources/mySuppressions.xml", value );
76
77 value = configuration.getChild( "useFile" ).getValue();
78 Assert.assertEquals( "check useFile value", "true", value );
79 }
80 catch ( ProjectConverterException e )
81 {
82 Assert.fail( e.getMessage() );
83 }
84 catch ( IOException e )
85 {
86 Assert.fail( "Unable to find the requested resource." );
87 }
88 }
89
90 public void testBuildConfiguration2()
91 {
92 try
93 {
94 projectProperties.load( getClassLoader().getResourceAsStream( "PCCCheckstyleTest2.properties" ) );
95
96 pluginConfigurationConverter.buildConfiguration( configuration, v3Model, projectProperties );
97
98 String value = configuration.getChild( "configLocation" ).getValue();
99 Assert.assertEquals( "check configLocation value",
100 "http://svn.apache.org/repos/asf/maven/plugins/trunk/maven-checkstyle-plugin/src/main/resources/config/avalon_checks.xml",
101 value );
102
103 value = configuration.getChild( "outputFile" ).getValue();
104 Assert.assertEquals( "check outputFile value", "target/checkstyle/checkstyle-raw-report.xml", value );
105
106 value = configuration.getChild( "outputFileFormat" ).getValue();
107 Assert.assertEquals( "check outputFileFormat value", "xml", value );
108 }
109 catch ( ProjectConverterException e )
110 {
111 Assert.fail( e.getMessage() );
112 }
113 catch ( IOException e )
114 {
115 Assert.fail( "Unable to find the requested resource." );
116 }
117 }
118
119 public void testBuildConfiguration3()
120 {
121 try
122 {
123 projectProperties.load( getClassLoader().getResourceAsStream( "PCCCheckstyleTest3.properties" ) );
124
125 pluginConfigurationConverter.buildConfiguration( configuration, v3Model, projectProperties );
126
127 String value = configuration.getChild( "configLocation" ).getValue();
128 Assert.assertEquals( "check configLocation value", "checkstyle.xml", value );
129 }
130 catch ( ProjectConverterException e )
131 {
132 Assert.fail( e.getMessage() );
133 }
134 catch ( IOException e )
135 {
136 Assert.fail( "Unable to find the requested resource." );
137 }
138 }
139 }