-
Notifications
You must be signed in to change notification settings - Fork 691
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
attempt to fix JAX-RS TCK after TOMEE-4406
- Loading branch information
Showing
5 changed files
with
113 additions
and
4 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<!-- | ||
Licensed to the Apache Software Foundation (ASF) under one or more | ||
contributor license agreements. See the NOTICE file distributed with | ||
this work for additional information regarding copyright ownership. | ||
The ASF licenses this file to You under the Apache License, Version 2.0 | ||
(the "License"); you may not use this file except in compliance with | ||
the License. You may obtain a copy of the License at | ||
http://www.apache.org/licenses/LICENSE-2.0 | ||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. | ||
--> | ||
<web-app xmlns="https://jakarta.ee/xml/ns/jakartaee" | ||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:schemaLocation="https://jakarta.ee/xml/ns/jakartaee | ||
https://jakarta.ee/xml/ns/jakartaee/web-app_6_0.xsd" | ||
version="6.0"> | ||
|
||
<!-- NotFoundServlet is injected into deployments using JaxRsTckExtension, | ||
but we use this global web.xml because it is more convenient than overwriting web.xml in said Extension --> | ||
<servlet> | ||
<servlet-name>default</servlet-name> | ||
<servlet-class>org.apache.tomee.tck.jaxrs.NotFoundServlet</servlet-class> | ||
</servlet> | ||
<servlet-mapping> | ||
<servlet-name>default</servlet-name> | ||
<url-pattern>/</url-pattern> | ||
</servlet-mapping> | ||
</web-app> |
38 changes: 38 additions & 0 deletions
38
tck/jax-rs/jax-rs-tests/src/test/java/org/apache/tomee/tck/jaxrs/JaxRsTckExtension.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,38 @@ | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one | ||
* or more contributor license agreements. See the NOTICE file | ||
* distributed with this work for additional information | ||
* regarding copyright ownership. The ASF licenses this file | ||
* to you under the Apache License, Version 2.0 (the | ||
* "License"); you may not use this file except in compliance | ||
* with the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, | ||
* software distributed under the License is distributed on an | ||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
* KIND, either express or implied. See the License for the | ||
* specific language governing permissions and limitations | ||
* under the License. | ||
*/ | ||
package org.apache.tomee.tck.jaxrs; | ||
|
||
import org.jboss.arquillian.container.spi.event.container.BeforeDeploy; | ||
import org.jboss.arquillian.core.api.annotation.Observes; | ||
import org.jboss.arquillian.core.spi.LoadableExtension; | ||
import org.jboss.shrinkwrap.api.container.ClassContainer; | ||
|
||
// inject NotFoundServlet into the deployment to make our global web.xml override work | ||
public class JaxRsTckExtension implements LoadableExtension { | ||
@Override | ||
public void register(ExtensionBuilder builder) { | ||
builder.observer(getClass()); | ||
} | ||
|
||
public void observeDeployment(@Observes BeforeDeploy bd) { | ||
if (bd.getDeployment().getArchive() instanceof ClassContainer<?> classContainer) { | ||
classContainer.addClass(NotFoundServlet.class); | ||
} | ||
} | ||
} |
36 changes: 36 additions & 0 deletions
36
tck/jax-rs/jax-rs-tests/src/test/java/org/apache/tomee/tck/jaxrs/NotFoundServlet.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,36 @@ | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one | ||
* or more contributor license agreements. See the NOTICE file | ||
* distributed with this work for additional information | ||
* regarding copyright ownership. The ASF licenses this file | ||
* to you under the Apache License, Version 2.0 (the | ||
* "License"); you may not use this file except in compliance | ||
* with the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, | ||
* software distributed under the License is distributed on an | ||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
* KIND, either express or implied. See the License for the | ||
* specific language governing permissions and limitations | ||
* under the License. | ||
*/ | ||
package org.apache.tomee.tck.jaxrs; | ||
|
||
import jakarta.servlet.http.HttpServlet; | ||
import jakarta.servlet.http.HttpServletRequest; | ||
import jakarta.servlet.http.HttpServletResponse; | ||
|
||
import java.io.IOException; | ||
|
||
/** | ||
* TCK likes to send requests to unknown URLs, which can cause a 405 in tomcats default servlet with non GET requests. | ||
* This servlet will instead always return a 404 to make the TCK happy | ||
*/ | ||
public class NotFoundServlet extends HttpServlet { | ||
@Override | ||
protected void service(HttpServletRequest request, HttpServletResponse response) throws IOException { | ||
response.sendError(HttpServletResponse.SC_NOT_FOUND); | ||
} | ||
} |
1 change: 1 addition & 0 deletions
1
...ests/src/test/resources/META-INF/services/org.jboss.arquillian.core.spi.LoadableExtension
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 @@ | ||
org.apache.tomee.tck.jaxrs.JaxRsTckExtension |
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