Skip to content

Commit

Permalink
[SUREFIRE-1532] MIME type for javascript is now officially applicatio…
Browse files Browse the repository at this point in the history
…n/javascript
  • Loading branch information
Tibor17 committed Oct 5, 2018
1 parent 628602f commit 57fbb16
Show file tree
Hide file tree
Showing 5 changed files with 107 additions and 54 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ public void doGenerateReport( LocalizedProperties bundle, Sink sink )
sink.body();

SinkEventAttributeSet atts = new SinkEventAttributeSet();
atts.addAttribute( TYPE, "text/javascript" );
atts.addAttribute( TYPE, "application/javascript" );
sink.unknown( "script", new Object[]{ HtmlMarkup.TAG_TYPE_START }, atts );
sink.unknown( "cdata", new Object[]{ HtmlMarkup.CDATA_TYPE, javascriptToggleDisplayCode() }, null );
sink.unknown( "script", new Object[]{ HtmlMarkup.TAG_TYPE_END }, null );
Expand Down
27 changes: 26 additions & 1 deletion surefire-its/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@
<dependency>
<groupId>net.sourceforge.htmlunit</groupId>
<artifactId>htmlunit</artifactId>
<version>2.8</version>
<version>2.33</version>
<scope>test</scope>
</dependency>
<dependency>
Expand Down Expand Up @@ -102,6 +102,31 @@
</resource>
</resources>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-enforcer-plugin</artifactId>
<executions>
<execution>
<id>enforce-bytecode-version</id>
<goals>
<goal>enforce</goal>
</goals>
<configuration combine.self="append">
<rules>
<enforceBytecodeVersion>
<maxJdkVersion>${maven.compiler.target}</maxJdkVersion>
<excludes>
<exclude>net.sourceforge.htmlunit:*</exclude>
<exclude>org.eclipse.jetty.websocket:*</exclude>
<exclude>org.eclipse.jetty:*</exclude>
<exclude>org.apache.commons:commons-text</exclude>
</excludes>
</enforceBytecodeVersion>
</rules>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<artifactId>maven-surefire-plugin</artifactId>
<dependencies>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
* under the License.
*/

import org.apache.commons.lang.StringUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.maven.surefire.its.fixture.OutputValidator;
import org.apache.maven.surefire.its.fixture.SurefireJUnit4IntegrationTestCase;
import org.apache.maven.surefire.its.fixture.SurefireLauncher;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
import com.gargoylesoftware.htmlunit.html.HtmlPage;
import org.junit.Test;

import static org.apache.maven.surefire.its.fixture.HelperAssertions.assumeJavaVersion;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
Expand All @@ -47,26 +48,32 @@ public class Surefire260TestWithIdenticalNamesIT
public void testWithIdenticalNames()
throws IOException
{
SurefireLauncher surefireLauncher = unpack( "surefire-260-testWithIdenticalNames" ).failNever();
surefireLauncher.executeTest();
surefireLauncher.reset();
OutputValidator validator = surefireLauncher.addSurefireReportGoal().executeCurrentGoals();
assumeJavaVersion( 1.8d );
OutputValidator validator = unpack( "surefire-260-testWithIdenticalNames" )
.failNever()
.addGoal( "site" )
.addSurefireReportGoal()
.executeCurrentGoals();

TestFile siteFile = validator.getSiteFile( "surefire-report.html" );
final URI uri = siteFile.toURI();

final WebClient webClient = new WebClient();
webClient.setJavaScriptEnabled( true );
final HtmlPage page = webClient.getPage( uri.toURL() );

final HtmlAnchor a =
(HtmlAnchor) page.getByXPath( "//a[@href = \"javascript:toggleDisplay('surefire260.TestB.testDup');\"]" )
WebClient webClient = new WebClient();
try
{
HtmlPage page = webClient.getPage( uri.toURL() );
HtmlAnchor a = ( HtmlAnchor ) page.getByXPath(
"//a[@href = \"javascript:toggleDisplay('surefire260.TestB.testDup');\"]" )
.get( 0 );
final HtmlDivision content = (HtmlDivision) page.getElementById( "surefire260.TestB.testDup-failure" );
assertNotNull( content );
assertTrue( content.getAttribute( "style" ).contains( "none" ) );
a.click();
assertFalse( content.getAttribute( "style" ).contains( "none" ) );
webClient.closeAllWindows();
HtmlDivision content = ( HtmlDivision ) page.getElementById( "surefire260.TestB.testDup-failure" );
assertNotNull( content );
assertTrue( content.getAttribute( "style" ).contains( "none" ) );
a.click();
assertFalse( content.getAttribute( "style" ).contains( "none" ) );
}
finally
{
webClient.close();
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,44 +21,65 @@
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<modelVersion>4.0.0</modelVersion>

<groupId>org.apache.maven.plugins.surefire</groupId>
<artifactId>surefire-260-testsWithIdenticalNames</artifactId>
<version>1.0-SNAPSHOT</version>
<name>surefire-260-testsWithIdenticalNames</name>
<groupId>org.apache.maven.plugins.surefire</groupId>
<artifactId>surefire-260-testsWithIdenticalNames</artifactId>
<version>1.0-SNAPSHOT</version>
<name>surefire-260-testsWithIdenticalNames</name>

<properties>
<maven.compiler.source>1.6</maven.compiler.source>
<maven.compiler.target>1.6</maven.compiler.target>
</properties>
<properties>
<maven.compiler.source>1.6</maven.compiler.source>
<maven.compiler.target>1.6</maven.compiler.target>
</properties>

<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.8.1</version>
<scope>test</scope>
</dependency>
</dependencies>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.8.1</version>
<scope>test</scope>
</dependency>
</dependencies>

<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>${surefire.version}</version>
<dependencies>
</dependencies>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-report-plugin</artifactId>
<version>${surefire.version}</version>
<dependencies>
</dependencies>
</plugin>
</plugins>
</build>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>${surefire.version}</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-report-plugin</artifactId>
<version>${surefire.version}</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-site-plugin</artifactId>
<version>3.7.1</version>
</plugin>
</plugins>
</build>

<reporting>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-project-info-reports-plugin</artifactId>
<version>3.0.0</version>
<configuration>
<dependencyLocationsEnabled>false</dependencyLocationsEnabled>
</configuration>
<reportSets>
<reportSet>
<reports>
<report>index</report>
</reports>
</reportSet>
</reportSets>
</plugin>
</plugins>
</reporting>

</project>

0 comments on commit 57fbb16

Please sign in to comment.