View Javadoc
1   package org.apache.maven.it;
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 org.apache.maven.it.util.ResourceExtractor;
23  
24  import java.io.File;
25  import java.util.Properties;
26  
27  /**
28   * This is a test set for <a href="https://issues.apache.org/jira/browse/MNG-3827">MNG-3827</a>.
29   *
30   * @author Benjamin Bentmann
31   *
32   */
33  public class MavenITmng3827PluginConfigTest
34      extends AbstractMavenIntegrationTestCase
35  {
36  
37      public MavenITmng3827PluginConfigTest()
38      {
39          super( ALL_MAVEN_VERSIONS );
40      }
41  
42      /**
43       * Verify that plain plugin configuration works correctly.
44       *
45       * @throws Exception in case of failure
46       */
47      public void testitMNG3827()
48          throws Exception
49      {
50          File testDir = ResourceExtractor.simpleExtractResources( getClass(), "/mng-3827" );
51  
52          Verifier verifier = newVerifier( testDir.getAbsolutePath() );
53          verifier.setAutoclean( false );
54          verifier.deleteDirectory( "target" );
55          verifier.executeGoal( "validate" );
56          verifier.verifyErrorFreeLog();
57          verifier.resetStreams();
58  
59          Properties props = verifier.loadProperties( "target/plugin-config.properties" );
60  
61          assertCanonicalFileEquals( new File( testDir, "pom.xml" ), new File( props.getProperty( "fileParam" ) ) );
62          assertEquals( "true", props.getProperty( "booleanParam" ) );
63          assertEquals( "42", props.getProperty( "byteParam" ) );
64          assertEquals( "-12345", props.getProperty( "shortParam" ) );
65          assertEquals( "0", props.getProperty( "integerParam" ) );
66          assertEquals( "9876543210", props.getProperty( "longParam" ) );
67          assertEquals( "0.0", props.getProperty( "floatParam" ) );
68          assertEquals( "-1.5", props.getProperty( "doubleParam" ) );
69          assertEquals( "X", props.getProperty( "characterParam" ) );
70          assertEquals( "Hello World!", props.getProperty( "stringParam" ) );
71          assertEquals( "2008-11-09 11:59:03", props.getProperty( "dateParam" ) );
72          assertEquals( "http://maven.apache.org/", props.getProperty( "urlParam" ) );
73  
74          assertEquals( "4", props.getProperty( "stringParams" ) );
75          assertEquals( "one", props.getProperty( "stringParams.0" ) );
76          assertEquals( "two", props.getProperty( "stringParams.1" ) );
77          assertEquals( "three", props.getProperty( "stringParams.2" ) );
78          assertEquals( "four", props.getProperty( "stringParams.3" ) );
79  
80          assertEquals( "4", props.getProperty( "listParam" ) );
81          assertEquals( "one", props.getProperty( "listParam.0" ) );
82          assertEquals( "two", props.getProperty( "listParam.1" ) );
83          assertEquals( "three", props.getProperty( "listParam.2" ) );
84          assertEquals( "four", props.getProperty( "listParam.3" ) );
85  
86          assertEquals( "1", props.getProperty( "setParam" ) );
87          assertEquals( "item", props.getProperty( "setParam.0" ) );
88  
89          assertEquals( "2", props.getProperty( "mapParam" ) );
90          assertEquals( "value1", props.getProperty( "mapParam.key1" ) );
91          assertEquals( "value2", props.getProperty( "mapParam.key2" ) );
92  
93          assertEquals( "2", props.getProperty( "propertiesParam" ) );
94          assertEquals( "value1", props.getProperty( "propertiesParam.key1" ) );
95          assertEquals( "value2", props.getProperty( "propertiesParam.key2" ) );
96  
97          assertEquals( "field", props.getProperty( "beanParam.fieldParam" ) );
98          assertEquals( "setter", props.getProperty( "beanParam.setterParam" ) );
99          assertEquals( "true", props.getProperty( "beanParam.setterCalled" ) );
100 
101         assertEquals( "4", props.getProperty( "domParam.children" ) );
102         assertEquals( "one", props.getProperty( "domParam.children.echo.0.value" ) );
103         assertEquals( "two", props.getProperty( "domParam.children.echo.1.value" ) );
104         assertEquals( "three", props.getProperty( "domParam.children.echo.2.value" ) );
105         assertEquals( "four", props.getProperty( "domParam.children.echo.3.value" ) );
106     }
107 
108 }