View Javadoc
1   package org.apache.maven.doxia.siterenderer;
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 java.io.File;
23  
24  import org.apache.maven.doxia.siterenderer.RenderingContext;
25  import org.codehaus.plexus.PlexusTestCase;
26  
27  /**
28   * @author <a href="mailto:olamy@apache.org">olamy</a>
29   * @since 20 oct. 07
30   * @version $Id: RenderingContextTest.html 999810 2016-10-23 12:53:12Z hboutemy $
31   */
32  public class RenderingContextTest
33      extends PlexusTestCase
34  {
35  
36      /**
37       * Test getRelativePath() with various file names.
38       *
39       * @throws java.lang.Exception if any.
40       */
41      public void testFileNameWithDot()
42          throws Exception
43      {
44          File baseDir = new File( getBasedir() + File.separatorChar + "test" + File.separatorChar + "resources" );
45          String docName = "file.with.dot.in.name.xml";
46  
47          RenderingContext renderingContext = new RenderingContext( baseDir, docName, "", "xml" );
48          assertEquals( "file.with.dot.in.name.html", renderingContext.getOutputName() );
49          assertEquals( ".", renderingContext.getRelativePath() );
50  
51          renderingContext = new RenderingContext( baseDir, docName );
52          assertEquals( "file.with.dot.in.name.html", renderingContext.getOutputName() );
53          assertEquals( ".", renderingContext.getRelativePath() );
54  
55          docName = "index.xml.vm";
56  
57          renderingContext = new RenderingContext( baseDir, docName, "", "xml" );
58          assertEquals( "index.html", renderingContext.getOutputName() );
59          assertEquals( ".", renderingContext.getRelativePath() );
60  
61          docName = "download.apt.vm";
62  
63          renderingContext = new RenderingContext( baseDir, docName, "", "apt" );
64          assertEquals( "download.html", renderingContext.getOutputName() );
65          assertEquals( ".", renderingContext.getRelativePath() );
66      }
67  
68  }