This is an automated email from the ASF dual-hosted git repository. markt pushed a commit to branch main in repository https://gitbox.apache.org/repos/asf/tomcat.git
The following commit(s) were added to refs/heads/main by this push: new b73b3410d8 Remove deprecated code b73b3410d8 is described below commit b73b3410d8e988894947a0776564848eda35a4e9 Author: Mark Thomas <ma...@apache.org> AuthorDate: Tue Oct 11 20:57:57 2022 +0100 Remove deprecated code --- java/org/apache/catalina/Context.java | 10 -- .../apache/catalina/filters/RemoteIpFilter.java | 27 ----- .../apache/catalina/realm/GenericPrincipal.java | 76 -------------- java/org/apache/catalina/users/MemoryGroup.java | 71 ------------- java/org/apache/catalina/users/MemoryRole.java | 67 ------------- java/org/apache/catalina/users/MemoryUser.java | 105 -------------------- java/org/apache/coyote/Request.java | 9 -- .../org/apache/coyote/ajp/AbstractAjpProtocol.java | 22 ----- java/org/apache/coyote/http2/Http2Parser.java | 20 ---- java/org/apache/tomcat/websocket/Constants.java | 31 ------ .../tomcat/websocket/WsWebSocketContainer.java | 46 +-------- .../websocket/TestWebSocketFrameClientSSL.java | 110 --------------------- .../websocket/TestWsWebSocketContainerSSL.java | 40 -------- 13 files changed, 1 insertion(+), 633 deletions(-) diff --git a/java/org/apache/catalina/Context.java b/java/org/apache/catalina/Context.java index a24e215773..83a9a02674 100644 --- a/java/org/apache/catalina/Context.java +++ b/java/org/apache/catalina/Context.java @@ -761,16 +761,6 @@ public interface Context extends Container, ContextBind { public String getContainerSciFilter(); - /** - * @return the value of the parallel annotation scanning flag. If true, - * it will dispatch scanning to the utility executor. - * @deprecated This method will be removed in Tomcat 11 onwards - */ - @Deprecated - public default boolean isParallelAnnotationScanning() { - return getParallelAnnotationScanning(); - } - /** * @return the value of the parallel annotation scanning flag. If true, * it will dispatch scanning to the utility executor. diff --git a/java/org/apache/catalina/filters/RemoteIpFilter.java b/java/org/apache/catalina/filters/RemoteIpFilter.java index 6a4570800d..c485ea3fdc 100644 --- a/java/org/apache/catalina/filters/RemoteIpFilter.java +++ b/java/org/apache/catalina/filters/RemoteIpFilter.java @@ -25,7 +25,6 @@ import java.util.Collections; import java.util.Deque; import java.util.Enumeration; import java.util.HashMap; -import java.util.Iterator; import java.util.LinkedList; import java.util.List; import java.util.Map; @@ -706,32 +705,6 @@ public class RemoteIpFilter extends GenericFilter { .split(commaDelimitedStrings); } - /** - * Convert a list of strings in a comma delimited string. - * - * @param stringList List of strings - * @return concatenated string - * - * @deprecated Unused. Will be removed in Tomcat 11 onwards - */ - @Deprecated - protected static String listToCommaDelimitedString(List<String> stringList) { - if (stringList == null) { - return ""; - } - StringBuilder result = new StringBuilder(); - for (Iterator<String> it = stringList.iterator(); it.hasNext();) { - Object element = it.next(); - if (element != null) { - result.append(element); - if (it.hasNext()) { - result.append(", "); - } - } - } - return result.toString(); - } - /** * @see #setHttpServerPort(int) */ diff --git a/java/org/apache/catalina/realm/GenericPrincipal.java b/java/org/apache/catalina/realm/GenericPrincipal.java index 584c10449f..039539330d 100644 --- a/java/org/apache/catalina/realm/GenericPrincipal.java +++ b/java/org/apache/catalina/realm/GenericPrincipal.java @@ -63,21 +63,6 @@ public class GenericPrincipal implements TomcatPrincipal, Serializable { this(name, roles, null); } - /** - * Construct a new Principal, associated with the specified Realm, for the - * specified username, with the specified role names (as Strings). - * - * @param name The username of the user represented by this Principal - * @param password Unused - * @param roles List of roles (must be Strings) possessed by this user - * - * @deprecated This method will be removed in Tomcat 11 onwards - */ - @Deprecated - public GenericPrincipal(String name, String password, List<String> roles) { - this(name, roles, null); - } - /** * Construct a new Principal, associated with the specified Realm, for the * specified username, with the specified role names (as Strings). @@ -92,24 +77,6 @@ public class GenericPrincipal implements TomcatPrincipal, Serializable { this(name, roles, userPrincipal, null); } - /** - * Construct a new Principal, associated with the specified Realm, for the - * specified username, with the specified role names (as Strings). - * - * @param name The username of the user represented by this Principal - * @param password Unused - * @param roles List of roles (must be Strings) possessed by this user - * @param userPrincipal - the principal to be returned from the request - * getUserPrincipal call if not null; if null, this will be returned - * - * @deprecated This method will be removed in Tomcat 11 onwards - */ - @Deprecated - public GenericPrincipal(String name, String password, List<String> roles, - Principal userPrincipal) { - this(name, roles, userPrincipal, null); - } - /** * Construct a new Principal, associated with the specified Realm, for the * specified username, with the specified role names (as Strings). @@ -126,26 +93,6 @@ public class GenericPrincipal implements TomcatPrincipal, Serializable { this(name, roles, userPrincipal, loginContext, null, null); } - /** - * Construct a new Principal, associated with the specified Realm, for the - * specified username, with the specified role names (as Strings). - * - * @param name The username of the user represented by this Principal - * @param password Unused - * @param roles List of roles (must be Strings) possessed by this user - * @param userPrincipal - the principal to be returned from the request - * getUserPrincipal call if not null; if null, this will be returned - * @param loginContext - If provided, this will be used to log out the user - * at the appropriate time - * - * @deprecated This method will be removed in Tomcat 11 onwards - */ - @Deprecated - public GenericPrincipal(String name, String password, List<String> roles, - Principal userPrincipal, LoginContext loginContext) { - this(name, roles, userPrincipal, loginContext, null, null); - } - /** * Construct a new Principal, associated with the specified Realm, for the * specified username, with the specified role names (as Strings). @@ -180,29 +127,6 @@ public class GenericPrincipal implements TomcatPrincipal, Serializable { } - /** - * Construct a new Principal, associated with the specified Realm, for the - * specified username, with the specified role names (as Strings). - * - * @param name The username of the user represented by this Principal - * @param password Unused - * @param roles List of roles (must be Strings) possessed by this user - * @param userPrincipal - the principal to be returned from the request - * getUserPrincipal call if not null; if null, this will be returned - * @param loginContext - If provided, this will be used to log out the user - * at the appropriate time - * @param gssCredential - If provided, the user's delegated credentials - * - * @deprecated This method will be removed in Tomcat 11 onwards - */ - @Deprecated - public GenericPrincipal(String name, String password, List<String> roles, - Principal userPrincipal, LoginContext loginContext, - GSSCredential gssCredential) { - this(name, roles, userPrincipal, loginContext, gssCredential, null); - } - - // -------------------------------------------------------------- Properties /** diff --git a/java/org/apache/catalina/users/MemoryGroup.java b/java/org/apache/catalina/users/MemoryGroup.java deleted file mode 100644 index 7f5d90eb2b..0000000000 --- a/java/org/apache/catalina/users/MemoryGroup.java +++ /dev/null @@ -1,71 +0,0 @@ -/* - * 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.catalina.users; - - -import org.apache.catalina.UserDatabase; -import org.apache.tomcat.util.buf.StringUtils; -import org.apache.tomcat.util.security.Escape; - -/** - * <p>Concrete implementation of {@link org.apache.catalina.Group} for the - * {@link MemoryUserDatabase} implementation of {@link UserDatabase}.</p> - * - * @author Craig R. McClanahan - * @since 4.1 - * @deprecated Use {@link GenericGroup} instead. - */ -@Deprecated -public class MemoryGroup extends GenericGroup<MemoryUserDatabase> { - - - /** - * Package-private constructor used by the factory method in - * {@link MemoryUserDatabase}. - * - * @param database The {@link MemoryUserDatabase} that owns this group - * @param groupname Group name of this group - * @param description Description of this group - */ - MemoryGroup(MemoryUserDatabase database, - String groupname, String description) { - super(database, groupname, description, null); - } - - - /** - * <p>Return a String representation of this group in XML format.</p> - */ - @Override - public String toString() { - StringBuilder sb = new StringBuilder("<group groupname=\""); - sb.append(Escape.xml(groupname)); - sb.append("\""); - if (description != null) { - sb.append(" description=\""); - sb.append(Escape.xml(description)); - sb.append("\""); - } - sb.append(" roles=\""); - StringBuilder rsb = new StringBuilder(); - StringUtils.join(roles, ',', (x) -> Escape.xml(x.getRolename()), rsb); - sb.append(rsb); - sb.append("\""); - sb.append("/>"); - return sb.toString(); - } -} diff --git a/java/org/apache/catalina/users/MemoryRole.java b/java/org/apache/catalina/users/MemoryRole.java deleted file mode 100644 index 08f6cec0bf..0000000000 --- a/java/org/apache/catalina/users/MemoryRole.java +++ /dev/null @@ -1,67 +0,0 @@ -/* - * 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.catalina.users; - - -import org.apache.catalina.UserDatabase; -import org.apache.tomcat.util.security.Escape; - -/** - * <p>Concrete implementation of {@link org.apache.catalina.Role} for the - * {@link MemoryUserDatabase} implementation of {@link UserDatabase}.</p> - * - * @author Craig R. McClanahan - * @since 4.1 - * @deprecated Use {@link GenericRole} instead. - */ -@Deprecated -public class MemoryRole extends GenericRole<MemoryUserDatabase> { - - - /** - * Package-private constructor used by the factory method in - * {@link MemoryUserDatabase}. - * - * @param database The {@link MemoryUserDatabase} that owns this role - * @param rolename Role name of this role - * @param description Description of this role - */ - MemoryRole(MemoryUserDatabase database, - String rolename, String description) { - super(database, rolename, description); - } - - - /** - * <p>Return a String representation of this role in XML format.</p> - */ - @Override - public String toString() { - StringBuilder sb = new StringBuilder("<role rolename=\""); - sb.append(Escape.xml(rolename)); - sb.append("\""); - if (description != null) { - sb.append(" description=\""); - sb.append(Escape.xml(description)); - sb.append("\""); - } - sb.append("/>"); - return sb.toString(); - } - - -} diff --git a/java/org/apache/catalina/users/MemoryUser.java b/java/org/apache/catalina/users/MemoryUser.java deleted file mode 100644 index 4d241fe6f5..0000000000 --- a/java/org/apache/catalina/users/MemoryUser.java +++ /dev/null @@ -1,105 +0,0 @@ -/* - * 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.catalina.users; - - -import org.apache.catalina.UserDatabase; -import org.apache.tomcat.util.buf.StringUtils; -import org.apache.tomcat.util.security.Escape; - -/** - * <p>Concrete implementation of {@link org.apache.catalina.User} for the - * {@link MemoryUserDatabase} implementation of {@link UserDatabase}.</p> - * - * @author Craig R. McClanahan - * @since 4.1 - * @deprecated Use {@link GenericUser} instead. - */ -@Deprecated -public class MemoryUser extends GenericUser<MemoryUserDatabase> { - - - /** - * Package-private constructor used by the factory method in - * {@link MemoryUserDatabase}. - * - * @param database The {@link MemoryUserDatabase} that owns this user - * @param username Logon username of the new user - * @param password Logon password of the new user - * @param fullName Full name of the new user - */ - MemoryUser(MemoryUserDatabase database, String username, - String password, String fullName) { - super(database, username, password, fullName, null, null); - } - - - /** - * <p>Return a String representation of this user in XML format.</p> - * - * <p><strong>IMPLEMENTATION NOTE</strong> - For backwards compatibility, - * the reader that processes this entry will accept either - * <code>username</code> or <code>name</code> for the username - * property.</p> - * @return the XML representation - */ - public String toXml() { - - StringBuilder sb = new StringBuilder("<user username=\""); - sb.append(Escape.xml(username)); - sb.append("\" password=\""); - sb.append(Escape.xml(password)); - sb.append("\""); - if (fullName != null) { - sb.append(" fullName=\""); - sb.append(Escape.xml(fullName)); - sb.append("\""); - } - sb.append(" groups=\""); - StringUtils.join(groups, ',', (x) -> Escape.xml(x.getGroupname()), sb); - sb.append("\""); - sb.append(" roles=\""); - StringUtils.join(roles, ',', (x) -> Escape.xml(x.getRolename()), sb); - sb.append("\""); - sb.append("/>"); - return sb.toString(); - } - - - /** - * <p>Return a String representation of this user.</p> - */ - @Override - public String toString() { - - StringBuilder sb = new StringBuilder("User username=\""); - sb.append(Escape.xml(username)); - sb.append("\""); - if (fullName != null) { - sb.append(", fullName=\""); - sb.append(Escape.xml(fullName)); - sb.append("\""); - } - sb.append(", groups=\""); - StringUtils.join(groups, ',', (x) -> Escape.xml(x.getGroupname()), sb); - sb.append("\""); - sb.append(", roles=\""); - StringUtils.join(roles, ',', (x) -> Escape.xml(x.getRolename()), sb); - sb.append("\""); - return sb.toString(); - } -} diff --git a/java/org/apache/coyote/Request.java b/java/org/apache/coyote/Request.java index 8a289966d7..6908cdb7f0 100644 --- a/java/org/apache/coyote/Request.java +++ b/java/org/apache/coyote/Request.java @@ -721,15 +721,6 @@ public final class Request { return System.currentTimeMillis() - TimeUnit.NANOSECONDS.toMillis(System.nanoTime() - startTimeNanos); } - /** - * - * @param startTime time - * @deprecated This setter will be removed in Tomcat 11 - */ - @Deprecated - public void setStartTime(long startTime) { - } - public long getStartTimeNanos() { return startTimeNanos; } diff --git a/java/org/apache/coyote/ajp/AbstractAjpProtocol.java b/java/org/apache/coyote/ajp/AbstractAjpProtocol.java index e822c29af9..b62fe988a8 100644 --- a/java/org/apache/coyote/ajp/AbstractAjpProtocol.java +++ b/java/org/apache/coyote/ajp/AbstractAjpProtocol.java @@ -153,28 +153,6 @@ public abstract class AbstractAjpProtocol<S> extends AbstractProtocol<S> { protected String getSecret() { return secret; } - /** - * Set the required secret that must be included with every request. - * - * @param requiredSecret The required secret - * - * @deprecated Replaced by {@link #setSecret(String)}. - * Will be removed in Tomcat 11 onwards - */ - @Deprecated - public void setRequiredSecret(String requiredSecret) { - setSecret(requiredSecret); - } - /** - * @return The current secret - * - * @deprecated Replaced by {@link #getSecret()}. - * Will be removed in Tomcat 11 onwards - */ - @Deprecated - protected String getRequiredSecret() { - return getSecret(); - } private boolean secretRequired = true; diff --git a/java/org/apache/coyote/http2/Http2Parser.java b/java/org/apache/coyote/http2/Http2Parser.java index 72c30532e1..60669491d5 100644 --- a/java/org/apache/coyote/http2/Http2Parser.java +++ b/java/org/apache/coyote/http2/Http2Parser.java @@ -55,26 +55,6 @@ class Http2Parser { } - /** - * Read and process a single frame. Once the start of a frame is read, the - * remainder will be read using blocking IO. - * - * @param block Should this method block until a frame is available if no - * frame is available immediately? - * - * @return <code>true</code> if a frame was read otherwise - * <code>false</code> - * - * @throws IOException If an IO error occurs while trying to read a frame - * - * @deprecated Unused. Will be removed in Tomcat 11 onwards. - */ - @Deprecated - boolean readFrame(boolean block) throws Http2Exception, IOException { - return readFrame(block, null); - } - - /** * Read and process a single frame. The initial read is non-blocking to * determine if a frame is present. Once the start of a frame is read, the diff --git a/java/org/apache/tomcat/websocket/Constants.java b/java/org/apache/tomcat/websocket/Constants.java index c83ab4c431..55deb20c0b 100644 --- a/java/org/apache/tomcat/websocket/Constants.java +++ b/java/org/apache/tomcat/websocket/Constants.java @@ -20,7 +20,6 @@ import java.util.ArrayList; import java.util.Collections; import java.util.List; -import jakarta.websocket.ClientEndpointConfig; import jakarta.websocket.Extension; /** @@ -47,36 +46,6 @@ public class Constants { .intValue(); // Client connection - /** - * Property name to set to configure the value that is passed to - * {@link javax.net.ssl.SSLEngine#setEnabledProtocols(String[])}. The value - * should be a comma separated string. - * - * @deprecated This will be removed in Tomcat 11. - * Use {@link ClientEndpointConfig#getSSLContext()} - */ - @Deprecated(forRemoval = true, since = "Tomcat 10.1.x") - public static final String SSL_PROTOCOLS_PROPERTY = - "org.apache.tomcat.websocket.SSL_PROTOCOLS"; - @Deprecated(forRemoval = true, since = "Tomcat 10.1.x") - public static final String SSL_TRUSTSTORE_PROPERTY = - "org.apache.tomcat.websocket.SSL_TRUSTSTORE"; - @Deprecated(forRemoval = true, since = "Tomcat 10.1.x") - public static final String SSL_TRUSTSTORE_PWD_PROPERTY = - "org.apache.tomcat.websocket.SSL_TRUSTSTORE_PWD"; - @Deprecated(forRemoval = true, since = "Tomcat 10.1.x") - public static final String SSL_TRUSTSTORE_PWD_DEFAULT = "changeit"; - /** - * Property name to set to configure used SSLContext. The value should be an - * instance of SSLContext. If this property is present, the SSL_TRUSTSTORE* - * properties are ignored. - * - * @deprecated This will be removed in Tomcat 11. - * Use {@link ClientEndpointConfig#getSSLContext()} - */ - @Deprecated(forRemoval = true, since = "Tomcat 10.1.x") - public static final String SSL_CONTEXT_PROPERTY = - "org.apache.tomcat.websocket.SSL_CONTEXT"; /** * Property name to set to configure the timeout (in milliseconds) when * establishing a WebSocket connection to server. The default is diff --git a/java/org/apache/tomcat/websocket/WsWebSocketContainer.java b/java/org/apache/tomcat/websocket/WsWebSocketContainer.java index 05bf453eaa..2db1226084 100644 --- a/java/org/apache/tomcat/websocket/WsWebSocketContainer.java +++ b/java/org/apache/tomcat/websocket/WsWebSocketContainer.java @@ -17,10 +17,7 @@ package org.apache.tomcat.websocket; import java.io.EOFException; -import java.io.File; -import java.io.FileInputStream; import java.io.IOException; -import java.io.InputStream; import java.net.InetSocketAddress; import java.net.Proxy; import java.net.ProxySelector; @@ -31,7 +28,6 @@ import java.nio.ByteBuffer; import java.nio.channels.AsynchronousChannelGroup; import java.nio.channels.AsynchronousSocketChannel; import java.nio.charset.StandardCharsets; -import java.security.KeyStore; import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; @@ -53,7 +49,6 @@ import javax.net.ssl.SSLContext; import javax.net.ssl.SSLEngine; import javax.net.ssl.SSLException; import javax.net.ssl.SSLParameters; -import javax.net.ssl.TrustManagerFactory; import jakarta.websocket.ClientEndpoint; import jakarta.websocket.ClientEndpointConfig; @@ -74,7 +69,6 @@ import org.apache.tomcat.util.buf.StringUtils; import org.apache.tomcat.util.codec.binary.Base64; import org.apache.tomcat.util.collections.CaseInsensitiveKeyMap; import org.apache.tomcat.util.res.StringManager; -import org.apache.tomcat.util.security.KeyStoreUtil; public class WsWebSocketContainer implements WebSocketContainer, BackgroundProcess { @@ -923,59 +917,21 @@ public class WsWebSocketContainer implements WebSocketContainer, BackgroundProce } - @SuppressWarnings("removal") private SSLEngine createSSLEngine(ClientEndpointConfig clientEndpointConfig, String host, int port) throws DeploymentException { - Map<String,Object> userProperties = clientEndpointConfig.getUserProperties(); try { // See if a custom SSLContext has been provided SSLContext sslContext = clientEndpointConfig.getSSLContext(); - // If no SSLContext is found, try the pre WebSocket 2.1 Tomcat - // specific method - if (sslContext == null) { - sslContext = (SSLContext) userProperties.get(Constants.SSL_CONTEXT_PROPERTY); - } - if (sslContext == null) { // Create the SSL Context sslContext = SSLContext.getInstance("TLS"); - - // Trust store - String sslTrustStoreValue = - (String) userProperties.get(Constants.SSL_TRUSTSTORE_PROPERTY); - if (sslTrustStoreValue != null) { - String sslTrustStorePwdValue = (String) userProperties.get( - Constants.SSL_TRUSTSTORE_PWD_PROPERTY); - if (sslTrustStorePwdValue == null) { - sslTrustStorePwdValue = Constants.SSL_TRUSTSTORE_PWD_DEFAULT; - } - - File keyStoreFile = new File(sslTrustStoreValue); - KeyStore ks = KeyStore.getInstance("JKS"); - try (InputStream is = new FileInputStream(keyStoreFile)) { - KeyStoreUtil.load(ks, is, sslTrustStorePwdValue.toCharArray()); - } - - TrustManagerFactory tmf = TrustManagerFactory.getInstance( - TrustManagerFactory.getDefaultAlgorithm()); - tmf.init(ks); - - sslContext.init(null, tmf.getTrustManagers(), null); - } else { - sslContext.init(null, null, null); - } + sslContext.init(null, null, null); } SSLEngine engine = sslContext.createSSLEngine(host, port); - String sslProtocolsValue = - (String) userProperties.get(Constants.SSL_PROTOCOLS_PROPERTY); - if (sslProtocolsValue != null) { - engine.setEnabledProtocols(sslProtocolsValue.split(",")); - } - engine.setUseClientMode(true); // Enable host verification diff --git a/test/org/apache/tomcat/websocket/TestWebSocketFrameClientSSL.java b/test/org/apache/tomcat/websocket/TestWebSocketFrameClientSSL.java index 9b334db66a..b887ba6522 100644 --- a/test/org/apache/tomcat/websocket/TestWebSocketFrameClientSSL.java +++ b/test/org/apache/tomcat/websocket/TestWebSocketFrameClientSSL.java @@ -81,52 +81,6 @@ public class TestWebSocketFrameClientSSL extends WebSocketBaseTest { public String sslImplementationName; - @SuppressWarnings("removal") - @Test - public void testConnectToServerEndpointLegacy() throws Exception { - Tomcat tomcat = getTomcatInstance(); - // No file system docBase required - Context ctx = tomcat.addContext("", null); - ctx.addApplicationListener(TesterFirehoseServer.ConfigInline.class.getName()); - Tomcat.addServlet(ctx, "default", new DefaultServlet()); - ctx.addServletMappingDecoded("/", "default"); - - tomcat.start(); - - WebSocketContainer wsContainer = - ContainerProvider.getWebSocketContainer(); - ClientEndpointConfig clientEndpointConfig = - ClientEndpointConfig.Builder.create().build(); - clientEndpointConfig.getUserProperties().put( - Constants.SSL_TRUSTSTORE_PROPERTY, - TesterSupport.CA_JKS); - Session wsSession = wsContainer.connectToServer( - TesterProgrammaticEndpoint.class, - clientEndpointConfig, - new URI("wss://localhost:" + getPort() + - TesterFirehoseServer.PATH)); - CountDownLatch latch = - new CountDownLatch(TesterFirehoseServer.MESSAGE_COUNT); - BasicText handler = new BasicText(latch); - wsSession.addMessageHandler(handler); - wsSession.getBasicRemote().sendText("Hello"); - - System.out.println("Sent Hello message, waiting for data"); - - // Ignore the latch result as the message count test below will tell us - // if the right number of messages arrived - handler.getLatch().await(TesterFirehoseServer.WAIT_TIME_MILLIS, - TimeUnit.MILLISECONDS); - - Queue<String> messages = handler.getMessages(); - Assert.assertEquals( - TesterFirehoseServer.MESSAGE_COUNT, messages.size()); - for (String message : messages) { - Assert.assertEquals(TesterFirehoseServer.MESSAGE, message); - } - } - - @Test public void testConnectToServerEndpoint() throws Exception { Tomcat tomcat = getTomcatInstance(); @@ -181,70 +135,6 @@ public class TestWebSocketFrameClientSSL extends WebSocketBaseTest { } - @SuppressWarnings("removal") - @Test - public void testBug56032Legacy() throws Exception { - Tomcat tomcat = getTomcatInstance(); - // No file system docBase required - Context ctx = tomcat.addContext("", null); - ctx.addApplicationListener(TesterFirehoseServer.ConfigInline.class.getName()); - Tomcat.addServlet(ctx, "default", new DefaultServlet()); - ctx.addServletMappingDecoded("/", "default"); - - tomcat.start(); - - WebSocketContainer wsContainer = - ContainerProvider.getWebSocketContainer(); - ClientEndpointConfig clientEndpointConfig = - ClientEndpointConfig.Builder.create().build(); - clientEndpointConfig.getUserProperties().put( - Constants.SSL_TRUSTSTORE_PROPERTY, - TesterSupport.CA_JKS); - Session wsSession = wsContainer.connectToServer( - TesterProgrammaticEndpoint.class, - clientEndpointConfig, - new URI("wss://localhost:" + getPort() + - TesterFirehoseServer.PATH)); - - // Process incoming messages very slowly - MessageHandler handler = new SleepingText(5000); - wsSession.addMessageHandler(handler); - wsSession.getBasicRemote().sendText("Hello"); - - // Wait long enough for the buffers to fill and the send to timeout - int count = 0; - int limit = TesterFirehoseServer.WAIT_TIME_MILLIS / 100; - - System.out.println("Waiting for server to report an error"); - while (TesterFirehoseServer.Endpoint.getErrorCount() == 0 && count < limit) { - Thread.sleep(100); - count ++; - } - - if (TesterFirehoseServer.Endpoint.getErrorCount() == 0) { - Assert.fail("No error reported by Endpoint when timeout was expected"); - } - - // Wait again for the connection to be closed - - // should be a lot faster. - System.out.println("Waiting for connection to be closed"); - count = 0; - limit = TesterFirehoseServer.WAIT_TIME_MILLIS / 100; - while (TesterFirehoseServer.Endpoint.getOpenConnectionCount() != 0 && count < limit) { - Thread.sleep(100); - count ++; - } - - int openConnectionCount = TesterFirehoseServer.Endpoint.getOpenConnectionCount(); - if (openConnectionCount != 0) { - Assert.fail("There are [" + openConnectionCount + "] connections still open"); - } - - // Close the client session. - wsSession.close(); - } - - @Test public void testBug56032() throws Exception { Tomcat tomcat = getTomcatInstance(); diff --git a/test/org/apache/tomcat/websocket/TestWsWebSocketContainerSSL.java b/test/org/apache/tomcat/websocket/TestWsWebSocketContainerSSL.java index 9e5070d83b..65a755e0f2 100644 --- a/test/org/apache/tomcat/websocket/TestWsWebSocketContainerSSL.java +++ b/test/org/apache/tomcat/websocket/TestWsWebSocketContainerSSL.java @@ -81,46 +81,6 @@ public class TestWsWebSocketContainerSSL extends WebSocketBaseTest { private static final String MESSAGE_STRING_1 = "qwerty"; - @SuppressWarnings("removal") - @Test - public void testConnectToServerEndpointSslLegacy() throws Exception { - - Tomcat tomcat = getTomcatInstance(); - // No file system docBase required - Context ctx = tomcat.addContext("", null); - ctx.addApplicationListener(TesterEchoServer.Config.class.getName()); - Tomcat.addServlet(ctx, "default", new DefaultServlet()); - ctx.addServletMappingDecoded("/", "default"); - - tomcat.start(); - - WebSocketContainer wsContainer = - ContainerProvider.getWebSocketContainer(); - ClientEndpointConfig clientEndpointConfig = - ClientEndpointConfig.Builder.create().build(); - clientEndpointConfig.getUserProperties().put( - org.apache.tomcat.websocket.Constants.SSL_TRUSTSTORE_PROPERTY, - TesterSupport.CA_JKS); - Session wsSession = wsContainer.connectToServer( - TesterProgrammaticEndpoint.class, - clientEndpointConfig, - new URI("wss://localhost:" + getPort() + - TesterEchoServer.Config.PATH_ASYNC)); - CountDownLatch latch = new CountDownLatch(1); - BasicText handler = new BasicText(latch); - wsSession.addMessageHandler(handler); - wsSession.getBasicRemote().sendText(MESSAGE_STRING_1); - - boolean latchResult = handler.getLatch().await(10, TimeUnit.SECONDS); - - Assert.assertTrue(latchResult); - - Queue<String> messages = handler.getMessages(); - Assert.assertEquals(1, messages.size()); - Assert.assertEquals(MESSAGE_STRING_1, messages.peek()); - } - - @Test public void testConnectToServerEndpointSSL() throws Exception { --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org For additional commands, e-mail: dev-h...@tomcat.apache.org