You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by ma...@apache.org on 2025/01/15 15:26:37 UTC

(tomcat-tck) branch 11.0.x updated (daa96b0 -> ac37578)

This is an automated email from the ASF dual-hosted git repository.

markt pushed a change to branch 11.0.x
in repository https://gitbox.apache.org/repos/asf/tomcat-tck.git


    from daa96b0  Update to latest snapshot
     new c383bf0  If deployment fails, ensure that the client uses the correct URL
     new ac37578  Increment the Tomcat version under test

The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 pom.xml                                            |  2 +-
 .../websocket/TomcatWebSocketTckConfiguration.java | 65 ++++++++++++++++++++++
 2 files changed, 66 insertions(+), 1 deletion(-)


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org


(tomcat-tck) 02/02: Increment the Tomcat version under test

Posted by ma...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

markt pushed a commit to branch 11.0.x
in repository https://gitbox.apache.org/repos/asf/tomcat-tck.git

commit ac37578ec03a61e2b13013950a1940a18e3bbfdd
Author: Mark Thomas <ma...@apache.org>
AuthorDate: Wed Jan 15 15:26:09 2025 +0000

    Increment the Tomcat version under test
---
 pom.xml | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/pom.xml b/pom.xml
index 78d9afc..3d3b1bd 100644
--- a/pom.xml
+++ b/pom.xml
@@ -31,7 +31,7 @@
         <maven.compiler.target>17</maven.compiler.target>
 
         <!-- Tomcat version to test -->
-        <tomcat.version>11.0.2-SNAPSHOT</tomcat.version>
+        <tomcat.version>11.0.3-SNAPSHOT</tomcat.version>
 
         <!-- Test run configuration -->
         <fork.count>4</fork.count>


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org


(tomcat-tck) 01/02: If deployment fails, ensure that the client uses the correct URL

Posted by ma...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

markt pushed a commit to branch 11.0.x
in repository https://gitbox.apache.org/repos/asf/tomcat-tck.git

commit c383bf0c82469fb0c7a172425ba2aca2f8ce3d03
Author: Mark Thomas <ma...@apache.org>
AuthorDate: Wed Jan 15 14:44:31 2025 +0000

    If deployment fails, ensure that the client uses the correct URL
    
    Prior to this change the client would use
    <scheme>://<host>:<port>/<context-path>/ if the deployment was
    successful but <scheme>://<host>:<port> if the deployment failed.
    
    Now the client always uses <scheme>://<host>:<port>/<context-path>/
---
 .../websocket/TomcatWebSocketTckConfiguration.java | 65 ++++++++++++++++++++++
 1 file changed, 65 insertions(+)

diff --git a/websocket-tck/src/test/java/org/apache/tomcat/tck/websocket/TomcatWebSocketTckConfiguration.java b/websocket-tck/src/test/java/org/apache/tomcat/tck/websocket/TomcatWebSocketTckConfiguration.java
index 13de86c..c8a79fa 100644
--- a/websocket-tck/src/test/java/org/apache/tomcat/tck/websocket/TomcatWebSocketTckConfiguration.java
+++ b/websocket-tck/src/test/java/org/apache/tomcat/tck/websocket/TomcatWebSocketTckConfiguration.java
@@ -19,14 +19,22 @@ package org.apache.tomcat.tck.websocket;
 import java.lang.reflect.Field;
 import java.net.URL;
 
+import org.apache.catalina.Container;
 import org.apache.catalina.Host;
+import org.apache.catalina.LifecycleState;
 import org.apache.catalina.connector.Connector;
 import org.apache.catalina.startup.Tomcat;
 import org.apache.tomcat.util.net.SSLHostConfig;
 import org.apache.tomcat.util.net.SSLHostConfigCertificate;
 import org.apache.tomcat.util.net.SSLHostConfigCertificate.Type;
 import org.apache.tomcat.util.scan.StandardJarScanner;
+import org.jboss.arquillian.container.spi.client.protocol.metadata.HTTPContext;
+import org.jboss.arquillian.container.spi.client.protocol.metadata.ProtocolMetaData;
+import org.jboss.arquillian.container.spi.client.protocol.metadata.Servlet;
+import org.jboss.arquillian.container.spi.event.container.AfterDeploy;
 import org.jboss.arquillian.container.spi.event.container.BeforeDeploy;
+import org.jboss.arquillian.core.api.Instance;
+import org.jboss.arquillian.core.api.annotation.Inject;
 import org.jboss.arquillian.core.api.annotation.Observes;
 import org.jboss.arquillian.core.spi.LoadableExtension;
 import org.jboss.arquillian.container.tomcat.embedded.EmbeddedContextConfig;
@@ -41,6 +49,10 @@ public class TomcatWebSocketTckConfiguration implements LoadableExtension {
 
     public static class WebSocketObserver {
 
+        @Inject
+        private Instance<ProtocolMetaData> protocolMetadata;
+
+
         public void configureContext(@Observes final BeforeDeploy beforeDeploy) {
             Tomcat10EmbeddedContainer container = (Tomcat10EmbeddedContainer) beforeDeploy.getDeployableContainer();
             try {
@@ -100,8 +112,61 @@ public class TomcatWebSocketTckConfiguration implements LoadableExtension {
                 throw new RuntimeException(e);
             }
         }
+
+
+        public void something(@Observes final AfterDeploy afterDeploy) {
+            Tomcat10EmbeddedContainer container = (Tomcat10EmbeddedContainer) afterDeploy.getDeployableContainer();
+            try {
+                // Obtain reference to Tomcat instance
+                Field tomcatField = Tomcat10EmbeddedContainer.class.getDeclaredField("tomcat");
+                tomcatField.setAccessible(true);
+                Tomcat tomcat = (Tomcat) tomcatField.get(container);
+
+                // There should be a single context
+                Container[] contexts = tomcat.getHost().findChildren();
+                if (contexts.length == 1) {
+                    Container context = contexts[0];
+                    if (LifecycleState.STOPPED == context.getState()) {
+                        /*
+                         * A LifecycleState of STOPPED means that the Context failed to deploy.
+                         *
+                         * To clean up resources associated with a failed deployment, stop() is called automatically if
+                         * start() fails. One of the consequences of this is that all the Servlet mappings are removed
+                         * from the Context.
+                         *
+                         * Because there are no servlet mappings, the HTTPContext generated in
+                         * Tomcat10EmbeddedContainer.deploy() will not have any Servlet mappings. The
+                         * URLResourceProvider uses the Servlet mappings to provide the context path for the URL that
+                         * the client uses for the tests.
+                         *
+                         * For the WebSocket tests, the client needs to use the context path for every request
+                         * regardless of whether the web application deployed successfully or not. Therefore, if the web
+                         * application failed to deploy we manually add a default Servlet to the HTTPContext for the
+                         * failed web application so that URLResourceProvider provides the correct URL to the client.
+                         *
+                         * This might not be the "right" way to do this with Arquillian. If not, advice from Arquillian
+                         * experts on the right way to do this would be appreciated (and a PR to fix it would be
+                         * fantastic!).
+                         */
+                        ProtocolMetaData metaData = protocolMetadata.get();
+                        if (metaData != null) {
+                            if (metaData.hasContext(HTTPContext.class)) {
+                                HTTPContext httpContext = metaData.getContexts(HTTPContext.class).iterator().next();
+                                // Confirm that there are no Servlets configured
+                                if (httpContext.getServlets().size() == 0) {
+                                    httpContext.add(new Servlet("default", context.getName()));
+                                }
+                            }
+                        }
+                    }
+                }
+            } catch (ReflectiveOperationException e) {
+                throw new RuntimeException(e);
+            }
+        }
     }
 
+
     public static class EmbeddedWebSocketContextConfig extends EmbeddedContextConfig {
 
         /*


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org