View Javadoc
1   package org.apache.maven.surefire.its.jiras;
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.IOException;
23  import java.net.URI;
24  
25  import org.apache.maven.surefire.its.fixture.*;
26  
27  import com.gargoylesoftware.htmlunit.WebClient;
28  import com.gargoylesoftware.htmlunit.html.HtmlAnchor;
29  import com.gargoylesoftware.htmlunit.html.HtmlDivision;
30  import com.gargoylesoftware.htmlunit.html.HtmlPage;
31  import org.junit.Test;
32  
33  import static org.apache.maven.surefire.its.fixture.HelperAssertions.assumeJavaVersion;
34  import static org.junit.Assert.assertFalse;
35  import static org.junit.Assert.assertNotNull;
36  import static org.junit.Assert.assertTrue;
37  
38  /**
39   * Test Surefire-570 Multiple report directories
40   *
41   * @author Kristian Rosenvold
42   */
43  public class Surefire260TestWithIdenticalNamesIT
44      extends SurefireJUnit4IntegrationTestCase
45  {
46  
47      @Test
48      public void testWithIdenticalNames()
49          throws IOException
50      {
51          assumeJavaVersion( 1.8d );
52          OutputValidator validator = unpack( "surefire-260-testWithIdenticalNames" )
53                  .failNever()
54                  .addGoal( "site" )
55                  .addSurefireReportGoal()
56                  .executeCurrentGoals();
57  
58          TestFile siteFile = validator.getSiteFile( "surefire-report.html" );
59          final URI uri = siteFile.toURI();
60  
61          try ( WebClient webClient = new WebClient() )
62          {
63              HtmlPage page = webClient.getPage( uri.toURL() );
64              HtmlAnchor a = ( HtmlAnchor ) page.getByXPath(
65                      "//a[@href = \"javascript:toggleDisplay('surefire260.TestB.testDup');\"]" )
66                      .get( 0 );
67              HtmlDivision content = ( HtmlDivision ) page.getElementById( "surefire260.TestB.testDup-failure" );
68              assertNotNull( content );
69              assertTrue( content.getAttribute( "style" ).contains( "none" ) );
70              a.click();
71              assertFalse( content.getAttribute( "style" ).contains( "none" ) );
72          }
73      }
74  }