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 import org.codehaus.plexus.util.xml.Xpp3Dom;
25
26 import java.io.IOException;
27
28
29
30
31
32 public class PCCPmdTest
33 extends AbstractPCCTest
34 {
35 protected void setUp()
36 throws Exception
37 {
38 super.setUp();
39
40 pluginConfigurationConverter = new PCCPmd();
41 }
42
43 public void testBuildConfiguration()
44 {
45 try
46 {
47 projectProperties.load( getClassLoader().getResourceAsStream( "PCCPmdTest.properties" ) );
48
49 pluginConfigurationConverter.buildConfiguration( configuration, v3Model, projectProperties );
50
51 String value = configuration.getChild( "excludes" ).getValue();
52 Assert.assertEquals( "check excludes value", "**/*PropertyListParser*", value );
53
54 value = configuration.getChild( "failOnViolation" ).getValue();
55 Assert.assertEquals( "check failOnViolation value", "true", value );
56
57 value = configuration.getChild( "minimumTokens" ).getValue();
58 Assert.assertEquals( "check minimumTokens value", "50", value );
59
60 Xpp3Dom rulesets = configuration.getChild( "rulesets" );
61 if ( rulesets.getChildCount() == 3 )
62 {
63 Xpp3Dom rulesetOne = rulesets.getChild( 0 );
64 Assert.assertEquals( "check rulesets/ruleset value", "fileupload_basic.xml", rulesetOne.getValue() );
65
66 Xpp3Dom rulesetTwo = rulesets.getChild( 1 );
67 Assert.assertEquals( "check rulesets/ruleset value", "/rulesets/unusedcode.xml",
68 rulesetTwo.getValue() );
69
70 Xpp3Dom rulesetThree = rulesets.getChild( 2 );
71 Assert.assertEquals( "check rulesets/ruleset value", "/rulesets/imports.xml", rulesetThree.getValue() );
72 }
73 else
74 {
75 Assert.fail( "Wrong number of ruleset elements" );
76 }
77
78 value = configuration.getChild( "targetJdk" ).getValue();
79 Assert.assertEquals( "check targetJdk value", "1.4", value );
80 }
81 catch ( ProjectConverterException e )
82 {
83 Assert.fail( e.getMessage() );
84 }
85 catch ( IOException e )
86 {
87 Assert.fail( "Unable to find the requested resource." );
88 }
89 }
90 }