Skip to content

Commit 57fbb16

Browse files
committed
[SUREFIRE-1532] MIME type for javascript is now officially application/javascript
1 parent 628602f commit 57fbb16

File tree

5 files changed

+107
-54
lines changed

5 files changed

+107
-54
lines changed

maven-surefire-report-plugin/src/main/java/org/apache/maven/plugins/surefire/report/SurefireReportGenerator.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ public void doGenerateReport( LocalizedProperties bundle, Sink sink )
7878
sink.body();
7979

8080
SinkEventAttributeSet atts = new SinkEventAttributeSet();
81-
atts.addAttribute( TYPE, "text/javascript" );
81+
atts.addAttribute( TYPE, "application/javascript" );
8282
sink.unknown( "script", new Object[]{ HtmlMarkup.TAG_TYPE_START }, atts );
8383
sink.unknown( "cdata", new Object[]{ HtmlMarkup.CDATA_TYPE, javascriptToggleDisplayCode() }, null );
8484
sink.unknown( "script", new Object[]{ HtmlMarkup.TAG_TYPE_END }, null );

surefire-its/pom.xml

+26-1
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@
5656
<dependency>
5757
<groupId>net.sourceforge.htmlunit</groupId>
5858
<artifactId>htmlunit</artifactId>
59-
<version>2.8</version>
59+
<version>2.33</version>
6060
<scope>test</scope>
6161
</dependency>
6262
<dependency>
@@ -102,6 +102,31 @@
102102
</resource>
103103
</resources>
104104
<plugins>
105+
<plugin>
106+
<groupId>org.apache.maven.plugins</groupId>
107+
<artifactId>maven-enforcer-plugin</artifactId>
108+
<executions>
109+
<execution>
110+
<id>enforce-bytecode-version</id>
111+
<goals>
112+
<goal>enforce</goal>
113+
</goals>
114+
<configuration combine.self="append">
115+
<rules>
116+
<enforceBytecodeVersion>
117+
<maxJdkVersion>${maven.compiler.target}</maxJdkVersion>
118+
<excludes>
119+
<exclude>net.sourceforge.htmlunit:*</exclude>
120+
<exclude>org.eclipse.jetty.websocket:*</exclude>
121+
<exclude>org.eclipse.jetty:*</exclude>
122+
<exclude>org.apache.commons:commons-text</exclude>
123+
</excludes>
124+
</enforceBytecodeVersion>
125+
</rules>
126+
</configuration>
127+
</execution>
128+
</executions>
129+
</plugin>
105130
<plugin>
106131
<artifactId>maven-surefire-plugin</artifactId>
107132
<dependencies>

surefire-its/src/test/java/org/apache/maven/surefire/its/JUnit47RedirectOutputIT.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
* under the License.
2020
*/
2121

22-
import org.apache.commons.lang.StringUtils;
22+
import org.apache.commons.lang3.StringUtils;
2323
import org.apache.maven.surefire.its.fixture.OutputValidator;
2424
import org.apache.maven.surefire.its.fixture.SurefireJUnit4IntegrationTestCase;
2525
import org.apache.maven.surefire.its.fixture.SurefireLauncher;

surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire260TestWithIdenticalNamesIT.java

+23-16
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
import com.gargoylesoftware.htmlunit.html.HtmlPage;
3131
import org.junit.Test;
3232

33+
import static org.apache.maven.surefire.its.fixture.HelperAssertions.assumeJavaVersion;
3334
import static org.junit.Assert.assertFalse;
3435
import static org.junit.Assert.assertNotNull;
3536
import static org.junit.Assert.assertTrue;
@@ -47,26 +48,32 @@ public class Surefire260TestWithIdenticalNamesIT
4748
public void testWithIdenticalNames()
4849
throws IOException
4950
{
50-
SurefireLauncher surefireLauncher = unpack( "surefire-260-testWithIdenticalNames" ).failNever();
51-
surefireLauncher.executeTest();
52-
surefireLauncher.reset();
53-
OutputValidator validator = surefireLauncher.addSurefireReportGoal().executeCurrentGoals();
51+
assumeJavaVersion( 1.8d );
52+
OutputValidator validator = unpack( "surefire-260-testWithIdenticalNames" )
53+
.failNever()
54+
.addGoal( "site" )
55+
.addSurefireReportGoal()
56+
.executeCurrentGoals();
5457

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

58-
final WebClient webClient = new WebClient();
59-
webClient.setJavaScriptEnabled( true );
60-
final HtmlPage page = webClient.getPage( uri.toURL() );
61-
62-
final HtmlAnchor a =
63-
(HtmlAnchor) page.getByXPath( "//a[@href = \"javascript:toggleDisplay('surefire260.TestB.testDup');\"]" )
61+
WebClient webClient = new WebClient();
62+
try
63+
{
64+
HtmlPage page = webClient.getPage( uri.toURL() );
65+
HtmlAnchor a = ( HtmlAnchor ) page.getByXPath(
66+
"//a[@href = \"javascript:toggleDisplay('surefire260.TestB.testDup');\"]" )
6467
.get( 0 );
65-
final HtmlDivision content = (HtmlDivision) page.getElementById( "surefire260.TestB.testDup-failure" );
66-
assertNotNull( content );
67-
assertTrue( content.getAttribute( "style" ).contains( "none" ) );
68-
a.click();
69-
assertFalse( content.getAttribute( "style" ).contains( "none" ) );
70-
webClient.closeAllWindows();
68+
HtmlDivision content = ( HtmlDivision ) page.getElementById( "surefire260.TestB.testDup-failure" );
69+
assertNotNull( content );
70+
assertTrue( content.getAttribute( "style" ).contains( "none" ) );
71+
a.click();
72+
assertFalse( content.getAttribute( "style" ).contains( "none" ) );
73+
}
74+
finally
75+
{
76+
webClient.close();
77+
}
7178
}
7279
}

surefire-its/src/test/resources/surefire-260-testWithIdenticalNames/pom.xml

+56-35
Original file line numberDiff line numberDiff line change
@@ -21,44 +21,65 @@
2121
<project xmlns="http://maven.apache.org/POM/4.0.0"
2222
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
2323
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
24-
<modelVersion>4.0.0</modelVersion>
24+
<modelVersion>4.0.0</modelVersion>
2525

26-
<groupId>org.apache.maven.plugins.surefire</groupId>
27-
<artifactId>surefire-260-testsWithIdenticalNames</artifactId>
28-
<version>1.0-SNAPSHOT</version>
29-
<name>surefire-260-testsWithIdenticalNames</name>
26+
<groupId>org.apache.maven.plugins.surefire</groupId>
27+
<artifactId>surefire-260-testsWithIdenticalNames</artifactId>
28+
<version>1.0-SNAPSHOT</version>
29+
<name>surefire-260-testsWithIdenticalNames</name>
3030

31-
<properties>
32-
<maven.compiler.source>1.6</maven.compiler.source>
33-
<maven.compiler.target>1.6</maven.compiler.target>
34-
</properties>
31+
<properties>
32+
<maven.compiler.source>1.6</maven.compiler.source>
33+
<maven.compiler.target>1.6</maven.compiler.target>
34+
</properties>
3535

36-
<dependencies>
37-
<dependency>
38-
<groupId>junit</groupId>
39-
<artifactId>junit</artifactId>
40-
<version>4.8.1</version>
41-
<scope>test</scope>
42-
</dependency>
43-
</dependencies>
36+
<dependencies>
37+
<dependency>
38+
<groupId>junit</groupId>
39+
<artifactId>junit</artifactId>
40+
<version>4.8.1</version>
41+
<scope>test</scope>
42+
</dependency>
43+
</dependencies>
4444

45-
<build>
46-
<plugins>
47-
<plugin>
48-
<groupId>org.apache.maven.plugins</groupId>
49-
<artifactId>maven-surefire-plugin</artifactId>
50-
<version>${surefire.version}</version>
51-
<dependencies>
52-
</dependencies>
53-
</plugin>
54-
<plugin>
55-
<groupId>org.apache.maven.plugins</groupId>
56-
<artifactId>maven-surefire-report-plugin</artifactId>
57-
<version>${surefire.version}</version>
58-
<dependencies>
59-
</dependencies>
60-
</plugin>
61-
</plugins>
62-
</build>
45+
<build>
46+
<plugins>
47+
<plugin>
48+
<groupId>org.apache.maven.plugins</groupId>
49+
<artifactId>maven-surefire-plugin</artifactId>
50+
<version>${surefire.version}</version>
51+
</plugin>
52+
<plugin>
53+
<groupId>org.apache.maven.plugins</groupId>
54+
<artifactId>maven-surefire-report-plugin</artifactId>
55+
<version>${surefire.version}</version>
56+
</plugin>
57+
<plugin>
58+
<groupId>org.apache.maven.plugins</groupId>
59+
<artifactId>maven-site-plugin</artifactId>
60+
<version>3.7.1</version>
61+
</plugin>
62+
</plugins>
63+
</build>
64+
65+
<reporting>
66+
<plugins>
67+
<plugin>
68+
<groupId>org.apache.maven.plugins</groupId>
69+
<artifactId>maven-project-info-reports-plugin</artifactId>
70+
<version>3.0.0</version>
71+
<configuration>
72+
<dependencyLocationsEnabled>false</dependencyLocationsEnabled>
73+
</configuration>
74+
<reportSets>
75+
<reportSet>
76+
<reports>
77+
<report>index</report>
78+
</reports>
79+
</reportSet>
80+
</reportSets>
81+
</plugin>
82+
</plugins>
83+
</reporting>
6384

6485
</project>

0 commit comments

Comments
 (0)