1   package org.apache.maven.usability.plugin;
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 junit.framework.TestCase;
23  
24  import org.apache.maven.usability.plugin.io.xpp3.ParamdocXpp3Reader;
25  import org.codehaus.plexus.util.xml.pull.XmlPullParserException;
26  
27  import java.io.IOException;
28  import java.io.InputStream;
29  import java.io.InputStreamReader;
30  import java.util.Map;
31  import java.util.Properties;
32  
33  public class Xpp3ParseTest
34      extends TestCase
35  {
36      
37      public void testParse() throws IOException, XmlPullParserException
38      {
39          InputStream testDocStream = getClass().getClassLoader().getResourceAsStream( "test.paramdoc.xml" );
40          ParamdocXpp3Reader reader = new ParamdocXpp3Reader();
41          
42          ExpressionDocumentation documentation = reader.read(new InputStreamReader( testDocStream ) );
43          
44          Map exprs = documentation.getExpressionsBySyntax();
45          
46          Expression expr = (Expression) exprs.get( "localRepository" );
47          
48          assertNotNull( expr );
49          
50          Properties p = expr.getCliOptions();
51          
52          assertNotNull( p );
53          
54          assertEquals( 1, p.size() );
55          
56          assertEquals( "Override the local repository location on a per-build basis.", p.getProperty( "-Dmaven.repo.local=/path/to/local/repo" ) );
57          
58      }
59  
60  }