View Javadoc

1   package org.apache.maven.report.projectinfo;
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.net.URL;
23  
24  import com.meterware.httpunit.GetMethodWebRequest;
25  import com.meterware.httpunit.TextBlock;
26  import com.meterware.httpunit.WebConversation;
27  import com.meterware.httpunit.WebRequest;
28  import com.meterware.httpunit.WebResponse;
29  
30  /**
31   * @author Edwin Punzalan
32   * @author <a href="mailto:vincent.siveton@gmail.com">Vincent Siveton</a>
33   * @version $Id: TeamListReportTest.java 1100761 2011-05-08 16:14:18Z hboutemy $
34   */
35  public class TeamListReportTest
36      extends AbstractProjectInfoTestCase
37  {
38      /**
39       * WebConversation object
40       */
41      private static final WebConversation WEB_CONVERSATION = new WebConversation();
42  
43      /**
44       * Test report
45       *
46       * @throws Exception if any
47       */
48      public void testReport()
49          throws Exception
50      {
51          generateReport( "project-team", "project-team-plugin-config.xml" );
52          assertTrue( "Test html generated", getGeneratedReport( "team-list.html" ).exists() );
53  
54          URL reportURL = getGeneratedReport( "team-list.html" ).toURI().toURL();
55          assertNotNull( reportURL );
56  
57          // HTTPUnit
58          WebRequest request = new GetMethodWebRequest( reportURL.toString() );
59          WebResponse response = WEB_CONVERSATION.getResponse( request );
60  
61          // Basic HTML tests
62          assertTrue( response.isHTML() );
63          assertTrue( response.getContentLength() > 0 );
64  
65          // Test the Page title
66          assertEquals( getString( "report.team-list.title" ), response.getTitle() );
67  
68          // Test the texts
69          TextBlock[] textBlocks = response.getTextBlocks();
70  
71          assertEquals( textBlocks.length, 7 );
72  
73          assertEquals( getString( "report.team-list.intro.title" ), textBlocks[0].getText() );
74          assertEquals( getString( "report.team-list.intro.description1" ), textBlocks[1].getText() );
75          assertEquals( getString( "report.team-list.intro.description2" ), textBlocks[2].getText() );
76          assertEquals( getString( "report.team-list.developers.title" ), textBlocks[3].getText() );
77          assertEquals( getString( "report.team-list.developers.intro" ), textBlocks[4].getText() );
78          assertEquals( getString( "report.team-list.contributors.title" ), textBlocks[5].getText() );
79          assertEquals( getString( "report.team-list.nocontributor" ), textBlocks[6].getText() );
80      }
81  }