-
Notifications
You must be signed in to change notification settings - Fork 351
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Bug 31362657 - USING JSPS WITH JERSEY 2.X DROP HEADERS IN 14.1.1
Signed-off-by: Jorge Bescos Gascon <[email protected]>
- Loading branch information
Showing
8 changed files
with
341 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,98 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<!-- | ||
Copyright (c) 2020 Oracle and/or its affiliates. All rights reserved. | ||
This program and the accompanying materials are made available under the | ||
terms of the Eclipse Public License v. 2.0, which is available at | ||
http://www.eclipse.org/legal/epl-2.0. | ||
This Source Code may also be made available under the following Secondary | ||
Licenses when the conditions for such availability set forth in the | ||
Eclipse Public License v. 2.0 are satisfied: GNU General Public License, | ||
version 2 with the GNU Classpath Exception, which is available at | ||
https://www.gnu.org/software/classpath/license.html. | ||
SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 | ||
--> | ||
|
||
<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> | ||
|
||
<parent> | ||
<groupId>org.glassfish.jersey.tests.integration</groupId> | ||
<artifactId>project</artifactId> | ||
<version>2.32.0-SNAPSHOT</version> | ||
</parent> | ||
|
||
<artifactId>servlet-2.5-mvc-4</artifactId> | ||
<packaging>war</packaging> | ||
<name>jersey-tests-integration-servlet-2.5-mvc-4</name> | ||
|
||
<description>Servlet integration test - servlet-2.5-mvc-4 - filter - MVC - jersey.config.servlet.JspTemplatesBasePath</description> | ||
|
||
<dependencies> | ||
<dependency> | ||
<groupId>org.glassfish.jersey.containers</groupId> | ||
<artifactId>jersey-container-servlet-core</artifactId> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.glassfish.jersey.ext</groupId> | ||
<artifactId>jersey-mvc</artifactId> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.glassfish.jersey.ext</groupId> | ||
<artifactId>jersey-mvc-jsp</artifactId> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>javax.servlet</groupId> | ||
<artifactId>servlet-api</artifactId> | ||
<version>${servlet2.version}</version> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>org.glassfish.jersey.test-framework.providers</groupId> | ||
<artifactId>jersey-test-framework-provider-external</artifactId> | ||
<scope>test</scope> | ||
</dependency> | ||
</dependencies> | ||
|
||
<build> | ||
<plugins> | ||
<plugin> | ||
<groupId>org.apache.maven.plugins</groupId> | ||
<artifactId>maven-compiler-plugin</artifactId> | ||
</plugin> | ||
<plugin> | ||
<groupId>org.apache.maven.plugins</groupId> | ||
<artifactId>maven-failsafe-plugin</artifactId> | ||
</plugin> | ||
<plugin> | ||
<groupId>org.eclipse.jetty</groupId> | ||
<artifactId>jetty-maven-plugin</artifactId> | ||
</plugin> | ||
</plugins> | ||
</build> | ||
|
||
<profiles> | ||
<profile> | ||
<id>jdk11+</id> | ||
<activation> | ||
<jdk>[11,)</jdk> | ||
</activation> | ||
<dependencies> | ||
<dependency> | ||
<groupId>jakarta.xml.bind</groupId> | ||
<artifactId>jakarta.xml.bind-api</artifactId> | ||
</dependency> | ||
<dependency> | ||
<groupId>com.sun.xml.bind</groupId> | ||
<artifactId>jaxb-osgi</artifactId> | ||
</dependency> | ||
</dependencies> | ||
</profile> | ||
</profiles> | ||
|
||
</project> |
35 changes: 35 additions & 0 deletions
35
.../src/main/java/org/glassfish/jersey/tests/integration/servlet_25_mvc_4/MyApplication.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
/* | ||
* Copyright (c) 2020 Oracle and/or its affiliates. All rights reserved. | ||
* | ||
* This program and the accompanying materials are made available under the | ||
* terms of the Eclipse Public License v. 2.0, which is available at | ||
* http://www.eclipse.org/legal/epl-2.0. | ||
* | ||
* This Source Code may also be made available under the following Secondary | ||
* Licenses when the conditions for such availability set forth in the | ||
* Eclipse Public License v. 2.0 are satisfied: GNU General Public License, | ||
* version 2 with the GNU Classpath Exception, which is available at | ||
* https://www.gnu.org/software/classpath/license.html. | ||
* | ||
* SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 | ||
*/ | ||
|
||
package org.glassfish.jersey.tests.integration.servlet_25_mvc_4; | ||
|
||
import org.glassfish.jersey.message.GZipEncoder; | ||
import org.glassfish.jersey.server.ResourceConfig; | ||
import org.glassfish.jersey.server.filter.EncodingFilter; | ||
import org.glassfish.jersey.server.mvc.jsp.JspMvcFeature; | ||
import org.glassfish.jersey.tests.integration.servlet_25_mvc_4.resource.ExampleResource; | ||
|
||
public class MyApplication extends ResourceConfig { | ||
|
||
public MyApplication() { | ||
property("jersey.config.server.mvc.templateBasePath.jsp", "/WEB-INF/jsp"); | ||
property("jersey.config.servlet.filter.forwardOn404", "true"); | ||
property("jersey.config.servlet.filter.staticContentRegex", "/WEB-INF/.*\\.jsp"); | ||
packages(ExampleResource.class.getPackage().getName()); | ||
EncodingFilter.enableFor(this, new Class[] {GZipEncoder.class}); | ||
register(JspMvcFeature.class); | ||
} | ||
} |
42 changes: 42 additions & 0 deletions
42
...ava/org/glassfish/jersey/tests/integration/servlet_25_mvc_4/resource/ExampleResource.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
/* | ||
* Copyright (c) 2020 Oracle and/or its affiliates. All rights reserved. | ||
* | ||
* This program and the accompanying materials are made available under the | ||
* terms of the Eclipse Public License v. 2.0, which is available at | ||
* http://www.eclipse.org/legal/epl-2.0. | ||
* | ||
* This Source Code may also be made available under the following Secondary | ||
* Licenses when the conditions for such availability set forth in the | ||
* Eclipse Public License v. 2.0 are satisfied: GNU General Public License, | ||
* version 2 with the GNU Classpath Exception, which is available at | ||
* https://www.gnu.org/software/classpath/license.html. | ||
* | ||
* SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 | ||
*/ | ||
|
||
package org.glassfish.jersey.tests.integration.servlet_25_mvc_4.resource; | ||
|
||
import javax.ws.rs.GET; | ||
import javax.ws.rs.Path; | ||
import javax.ws.rs.PathParam; | ||
import javax.ws.rs.Produces; | ||
|
||
import org.glassfish.jersey.server.mvc.Viewable; | ||
|
||
@Path("/{client}") | ||
public class ExampleResource { | ||
|
||
@GET | ||
@Path("html") | ||
@Produces({ "text/html" }) | ||
public Viewable displayMain(@PathParam("client") String inClientId) { | ||
return new Viewable("/main"); | ||
} | ||
|
||
@GET | ||
@Path("string") | ||
@Produces({ "text/html" }) | ||
public String string(@PathParam("client") String inClientId) { | ||
return "string string string string string string"; | ||
} | ||
} |
28 changes: 28 additions & 0 deletions
28
tests/integration/servlet-2.5-mvc-4/src/main/webapp/WEB-INF/jsp/main.jsp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
<%-- | ||
Copyright (c) 2020 Oracle and/or its affiliates. All rights reserved. | ||
This program and the accompanying materials are made available under the | ||
terms of the Eclipse Public License v. 2.0, which is available at | ||
http://www.eclipse.org/legal/epl-2.0. | ||
This Source Code may also be made available under the following Secondary | ||
Licenses when the conditions for such availability set forth in the | ||
Eclipse Public License v. 2.0 are satisfied: GNU General Public License, | ||
version 2 with the GNU Classpath Exception, which is available at | ||
https://www.gnu.org/software/classpath/license.html. | ||
SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 | ||
--%> | ||
|
||
<html> | ||
<head> | ||
<meta charset="utf-8"> | ||
<title>Test</title> | ||
|
||
</head> | ||
<body> | ||
find this string | ||
</body> | ||
</html> |
33 changes: 33 additions & 0 deletions
33
tests/integration/servlet-2.5-mvc-4/src/main/webapp/WEB-INF/web.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<!-- | ||
Copyright (c) 2020 Oracle and/or its affiliates. All rights reserved. | ||
This program and the accompanying materials are made available under the | ||
terms of the Eclipse Public License v. 2.0, which is available at | ||
http://www.eclipse.org/legal/epl-2.0. | ||
This Source Code may also be made available under the following Secondary | ||
Licenses when the conditions for such availability set forth in the | ||
Eclipse Public License v. 2.0 are satisfied: GNU General Public License, | ||
version 2 with the GNU Classpath Exception, which is available at | ||
https://www.gnu.org/software/classpath/license.html. | ||
SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 | ||
--> | ||
|
||
<web-app version="2.5" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"> | ||
<filter> | ||
<filter-name>org.glassfish.jersey.tests.integration.servlet_25_mvc_4.MyApplication</filter-name> | ||
<filter-class>org.glassfish.jersey.servlet.ServletContainer</filter-class> | ||
<init-param> | ||
<param-name>javax.ws.rs.Application</param-name> | ||
<param-value>org.glassfish.jersey.tests.integration.servlet_25_mvc_4.MyApplication</param-value> | ||
</init-param> | ||
</filter> | ||
<filter-mapping> | ||
<filter-name>org.glassfish.jersey.tests.integration.servlet_25_mvc_4.MyApplication</filter-name> | ||
<url-pattern>/*</url-pattern> | ||
</filter-mapping> | ||
</web-app> |
50 changes: 50 additions & 0 deletions
50
...c-4/src/test/java/org/glassfish/jersey/tests/integration/servlet_25_mvc_4/GzipITCase.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
/* | ||
* Copyright (c) 2020 Oracle and/or its affiliates. All rights reserved. | ||
* | ||
* This program and the accompanying materials are made available under the | ||
* terms of the Eclipse Public License v. 2.0, which is available at | ||
* http://www.eclipse.org/legal/epl-2.0. | ||
* | ||
* This Source Code may also be made available under the following Secondary | ||
* Licenses when the conditions for such availability set forth in the | ||
* Eclipse Public License v. 2.0 are satisfied: GNU General Public License, | ||
* version 2 with the GNU Classpath Exception, which is available at | ||
* https://www.gnu.org/software/classpath/license.html. | ||
* | ||
* SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 | ||
*/ | ||
|
||
package org.glassfish.jersey.tests.integration.servlet_25_mvc_4; | ||
|
||
import static org.junit.Assert.assertFalse; | ||
|
||
import org.glassfish.jersey.message.GZipEncoder; | ||
import org.junit.Test; | ||
|
||
public class GzipITCase extends TestSupport { | ||
|
||
@Test | ||
public void testString() throws Exception { | ||
String response = target("/client/string").register(GZipEncoder.class) | ||
.request("text/html").acceptEncoding("gzip").get(String.class); | ||
assertResponseContains(response, "string string string string string string"); | ||
} | ||
|
||
@Test | ||
public void testJsp() throws Exception { | ||
String response = target("/client/html").register(GZipEncoder.class) | ||
.request("text/html", "application/xhtml+xml", "application/xml;q=0.9", "*/*;q=0.8").acceptEncoding("gzip") | ||
.get(String.class); | ||
assertHtmlResponse(response); | ||
assertResponseContains(response, "find this string"); | ||
} | ||
|
||
@Test | ||
public void testJspNotDecoded() throws Exception { | ||
String response = target("/client/html") | ||
.request("text/html", "application/xhtml+xml", "application/xml;q=0.9", "*/*;q=0.8").acceptEncoding("gzip") | ||
.get(String.class); | ||
assertFalse(response.contains("find this string")); | ||
} | ||
|
||
} |
54 changes: 54 additions & 0 deletions
54
...-4/src/test/java/org/glassfish/jersey/tests/integration/servlet_25_mvc_4/TestSupport.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
/* | ||
* Copyright (c) 2020 Oracle and/or its affiliates. All rights reserved. | ||
* | ||
* This program and the accompanying materials are made available under the | ||
* terms of the Eclipse Public License v. 2.0, which is available at | ||
* http://www.eclipse.org/legal/epl-2.0. | ||
* | ||
* This Source Code may also be made available under the following Secondary | ||
* Licenses when the conditions for such availability set forth in the | ||
* Eclipse Public License v. 2.0 are satisfied: GNU General Public License, | ||
* version 2 with the GNU Classpath Exception, which is available at | ||
* https://www.gnu.org/software/classpath/license.html. | ||
* | ||
* SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 | ||
*/ | ||
|
||
package org.glassfish.jersey.tests.integration.servlet_25_mvc_4; | ||
|
||
import javax.ws.rs.core.Application; | ||
|
||
import org.glassfish.jersey.test.JerseyTest; | ||
import org.glassfish.jersey.test.TestProperties; | ||
import org.glassfish.jersey.test.external.ExternalTestContainerFactory; | ||
import org.glassfish.jersey.test.spi.TestContainerException; | ||
import org.glassfish.jersey.test.spi.TestContainerFactory; | ||
|
||
import static org.junit.Assert.assertNotNull; | ||
import static org.junit.Assert.assertTrue; | ||
|
||
public abstract class TestSupport extends JerseyTest { | ||
|
||
@Override | ||
protected Application configure() { | ||
enable(TestProperties.LOG_TRAFFIC); | ||
enable(TestProperties.DUMP_ENTITY); | ||
return new MyApplication(); | ||
} | ||
|
||
@Override | ||
protected TestContainerFactory getTestContainerFactory() throws TestContainerException { | ||
return new ExternalTestContainerFactory(); | ||
} | ||
|
||
protected void assertHtmlResponse(final String response) { | ||
assertNotNull("No text returned!", response); | ||
|
||
assertResponseContains(response, "<html>"); | ||
assertResponseContains(response, "</html>"); | ||
} | ||
|
||
protected void assertResponseContains(final String response, final String text) { | ||
assertTrue("Response should contain " + text + " but was: " + response, response.contains(text)); | ||
} | ||
} |