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.junit.Assert.assertFalse;
34  import static org.junit.Assert.assertTrue;
35  
36  /**
37   * Test Surefire-570 Multiple report directories
38   *
39   * @author Kristian Rosenvold
40   */
41  public class Surefire260TestWithIdenticalNamesIT
42      extends SurefireJUnit4IntegrationTestCase
43  {
44  
45      @Test
46      public void testWithIdenticalNames()
47          throws IOException
48      {
49          SurefireLauncher surefireLauncher = unpack( "surefire-260-testWithIdenticalNames" ).failNever();
50          surefireLauncher.executeTest();
51          surefireLauncher.reset();
52          OutputValidator validator = surefireLauncher.addSurefireReportGoal().executeCurrentGoals();
53  
54          TestFile siteFile = validator.getSiteFile( "surefire-report.html" );
55          final URI uri = siteFile.toURI();
56  
57          final WebClient webClient = new WebClient();
58          webClient.setJavaScriptEnabled( true );
59          final HtmlPage page = webClient.getPage( uri.toURL() );
60  
61          final HtmlAnchor a =
62              (HtmlAnchor) page.getByXPath( "//a[contains(@href, 'surefire260_TestB_testDup')]" ).get( 0 );
63          final HtmlDivision content = (HtmlDivision) page.getElementById( "surefire260_TestB_testDuperror" );
64          assertTrue( content.getAttribute( "style" ).contains( "none" ) );
65          a.click();
66          assertFalse( content.getAttribute( "style" ).contains( "none" ) );
67          webClient.closeAllWindows();
68      }
69  }