View Javadoc

1   package org.apache.maven.plugin.resources;
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.plugin.resources.stub.MavenProjectBasicStub;
23  import org.apache.maven.plugin.testing.AbstractMojoTestCase;
24  
25  public class ReflectionPropertiesTest
26      extends AbstractMojoTestCase
27  {
28      // data
29      final static protected String pomFilePath = "/target/test-classes/unit/reflectionproperties-test/plugin-config.xml";
30  
31  
32      protected void setUp()
33          throws Exception
34      {
35          super.setUp();
36      }
37  
38      protected void tearDown()
39          throws Exception
40      {
41  
42      }
43  
44      public void testGet_escapeBackslashCharacterInPath()
45          throws Exception
46      {
47          // setup data
48          MavenProjectBasicStub project = new MavenProjectBasicStub( "escapeBackSlashCharacterInPath" );
49  
50          // set dummy value
51          project.setDescription( "c:\\\\org\\apache\\test" );
52  
53          ReflectionProperties reflectProp = new ReflectionProperties( project, true );
54  
55          // project property to be verified
56          String reflectPropValue = (String) reflectProp.get( "description" );
57  
58          // expected value is c\:\\\\org\\apache\\test
59          assertTrue( reflectPropValue.equals( "c\\:\\\\\\\\org\\\\apache\\\\test" ) );
60      }
61  
62      public void testGet_dontEscapeBackslashCharacterInPath()
63          throws Exception
64      {
65          // setup data
66          MavenProjectBasicStub project = new MavenProjectBasicStub( "dontEscapeBackSlashCharacterInPath" );
67  
68          // set dummy value
69          project.setDescription( "c:\\\\org\\apache\\test" );
70  
71          // project property to be verified
72          ReflectionProperties reflectProp = new ReflectionProperties( project, false );
73  
74          // project property to be verified
75          String reflectPropValue = (String) reflectProp.get( "description" );
76  
77          // expected value is c:\\org\apache\test
78          assertTrue( reflectPropValue.equals( "c:\\\\org\\apache\\test" ) );
79      }
80  }