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: CimReportTest.java 1100791 2011-05-08 19:01:22Z hboutemy $
34 */
35 public class CimReportTest
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( "cim", "cim-plugin-config.xml" );
52 assertTrue( "Test html generated", getGeneratedReport( "integration.html" ).exists() );
53
54 URL reportURL = getGeneratedReport( "integration.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.cim.title" ), response.getTitle() );
67
68 // Test the texts
69 TextBlock[] textBlocks = response.getTextBlocks();
70 assertEquals( getString( "report.cim.name" ), textBlocks[0].getText() );
71 assertEquals( getString( "report.cim.nocim" ), textBlocks[1].getText() );
72 }
73 }