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

markt pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/tomcat.git

commit 13b03a8fe99db5189c8fabb7d63a5b151db6fa60
Author: Mark Thomas <ma...@apache.org>
AuthorDate: Wed Jan 15 19:40:52 2020 +0000

    Use setProperty and test return value in preference to setAttribute
---
 .../apache/catalina/core/ApplicationContext.java   |  2 +-
 .../connector/TestCoyoteAdapterRequestFuzzing.java |  2 +-
 .../apache/catalina/core/TestAsyncContextImpl.java |  3 +-
 .../apache/catalina/core/TestStandardService.java  |  3 +-
 .../catalina/core/TestSwallowAbortedUploads.java   |  2 +-
 .../apache/catalina/startup/TomcatBaseTest.java    |  7 ++---
 .../apache/coyote/http11/TestHttp11Processor.java  | 34 +++++++++++-----------
 .../util/http/TestMimeHeadersIntegration.java      |  3 +-
 test/org/apache/tomcat/util/net/TesterSupport.java |  2 +-
 .../tomcat/websocket/TestConnectionLimit.java      |  3 +-
 10 files changed, 30 insertions(+), 31 deletions(-)

diff --git a/java/org/apache/catalina/core/ApplicationContext.java 
b/java/org/apache/catalina/core/ApplicationContext.java
index 44f297d..026a763 100644
--- a/java/org/apache/catalina/core/ApplicationContext.java
+++ b/java/org/apache/catalina/core/ApplicationContext.java
@@ -1014,7 +1014,7 @@ public class ApplicationContext implements ServletContext 
{
         Connector[] connectors = service.findConnectors();
         // Need at least one SSL enabled connector to use the SSL session ID.
         for (Connector connector : connectors) {
-            if (Boolean.TRUE.equals(connector.getAttribute("SSLEnabled"))) {
+            if (Boolean.TRUE.equals(connector.getProperty("SSLEnabled"))) {
                 supportedSessionTrackingModes.add(SessionTrackingMode.SSL);
                 break;
             }
diff --git 
a/test/org/apache/catalina/connector/TestCoyoteAdapterRequestFuzzing.java 
b/test/org/apache/catalina/connector/TestCoyoteAdapterRequestFuzzing.java
index dc8ac5e..f2edf46 100644
--- a/test/org/apache/catalina/connector/TestCoyoteAdapterRequestFuzzing.java
+++ b/test/org/apache/catalina/connector/TestCoyoteAdapterRequestFuzzing.java
@@ -110,7 +110,7 @@ public class TestCoyoteAdapterRequestFuzzing extends 
TomcatBaseTest {
     @Test
     public void doTest() throws Exception {
         Tomcat tomcat = getTomcatInstance();
-        tomcat.getConnector().setAttribute("restrictedUserAgents", 
"value-not-important");
+        
Assert.assertTrue(tomcat.getConnector().setProperty("restrictedUserAgents", 
"value-not-important"));
 
         File appDir = new File("test/webapp");
         Context ctxt = tomcat.addContext("", appDir.getAbsolutePath());
diff --git a/test/org/apache/catalina/core/TestAsyncContextImpl.java 
b/test/org/apache/catalina/core/TestAsyncContextImpl.java
index 347fbb3..cd90776 100644
--- a/test/org/apache/catalina/core/TestAsyncContextImpl.java
+++ b/test/org/apache/catalina/core/TestAsyncContextImpl.java
@@ -171,8 +171,7 @@ public class TestAsyncContextImpl extends TomcatBaseTest {
         Tomcat tomcat = getTomcatInstance();
 
         // Minimise pauses during test
-        tomcat.getConnector().setAttribute(
-                "connectionTimeout", Integer.valueOf(3000));
+        
Assert.assertTrue(tomcat.getConnector().setProperty("connectionTimeout", 
"3000"));
 
         // No file system docBase required
         Context ctx = tomcat.addContext("", null);
diff --git a/test/org/apache/catalina/core/TestStandardService.java 
b/test/org/apache/catalina/core/TestStandardService.java
index 0ec93ce..ba1e954 100644
--- a/test/org/apache/catalina/core/TestStandardService.java
+++ b/test/org/apache/catalina/core/TestStandardService.java
@@ -18,6 +18,7 @@ package org.apache.catalina.core;
 
 import java.net.InetAddress;
 
+import org.junit.Assert;
 import org.junit.Test;
 
 import org.apache.catalina.connector.Connector;
@@ -49,7 +50,7 @@ public class TestStandardService extends TomcatBaseTest {
         Connector c2 = new Connector("HTTP/1.1");
         c2.setThrowOnFailure(throwOnFailure);
 
-        c2.setAttribute("address", ((InetAddress) 
connector.getAttribute("address")).getHostAddress());
+        Assert.assertTrue(c2.setProperty("address", ((InetAddress) 
connector.getProperty("address")).getHostAddress()));
         c2.setPort(connector.getLocalPort());
 
         tomcat.getService().addConnector(c2);
diff --git a/test/org/apache/catalina/core/TestSwallowAbortedUploads.java 
b/test/org/apache/catalina/core/TestSwallowAbortedUploads.java
index a90d4a6..1d0c077 100644
--- a/test/org/apache/catalina/core/TestSwallowAbortedUploads.java
+++ b/test/org/apache/catalina/core/TestSwallowAbortedUploads.java
@@ -431,7 +431,7 @@ public class TestSwallowAbortedUploads extends 
TomcatBaseTest {
         // No need for target to exist.
 
         if (!limit) {
-            tomcat.getConnector().setAttribute("maxSwallowSize", "-1");
+            
Assert.assertTrue(tomcat.getConnector().setProperty("maxSwallowSize", "-1"));
         }
 
         tomcat.start();
diff --git a/test/org/apache/catalina/startup/TomcatBaseTest.java 
b/test/org/apache/catalina/startup/TomcatBaseTest.java
index 274d2fb..1494b77 100644
--- a/test/org/apache/catalina/startup/TomcatBaseTest.java
+++ b/test/org/apache/catalina/startup/TomcatBaseTest.java
@@ -170,12 +170,11 @@ public abstract class TomcatBaseTest extends 
LoggingBaseTest {
         String protocol = getProtocol();
         Connector connector = new Connector(protocol);
         // Listen only on localhost
-        connector.setAttribute("address",
-                InetAddress.getByName("localhost").getHostAddress());
+        Assert.assertTrue(connector.setProperty("address", 
InetAddress.getByName("localhost").getHostAddress()));
         // Use random free port
         connector.setPort(0);
         // Mainly set to reduce timeouts during async tests
-        connector.setAttribute("connectionTimeout", "3000");
+        Assert.assertTrue(connector.setProperty("connectionTimeout", "3000"));
         tomcat.getService().addConnector(connector);
         tomcat.setConnector(connector);
 
@@ -185,7 +184,7 @@ public abstract class TomcatBaseTest extends 
LoggingBaseTest {
             AprLifecycleListener listener = new AprLifecycleListener();
             listener.setSSLRandomSeed("/dev/urandom");
             server.addLifecycleListener(listener);
-            connector.setAttribute("pollerThreadCount", Integer.valueOf(1));
+            Assert.assertTrue(connector.setProperty("pollerThreadCount", "1"));
         }
 
         File catalinaBase = getTemporaryDirectory();
diff --git a/test/org/apache/coyote/http11/TestHttp11Processor.java 
b/test/org/apache/coyote/http11/TestHttp11Processor.java
index cbbc89e..be2fdf4 100644
--- a/test/org/apache/coyote/http11/TestHttp11Processor.java
+++ b/test/org/apache/coyote/http11/TestHttp11Processor.java
@@ -68,7 +68,7 @@ public class TestHttp11Processor extends TomcatBaseTest {
 
         // This setting means the connection will be closed at the end of the
         // request
-        tomcat.getConnector().setAttribute("maxKeepAliveRequests", "1");
+        
Assert.assertTrue(tomcat.getConnector().setProperty("maxKeepAliveRequests", 
"1"));
 
         // No file system docBase required
         Context ctx = tomcat.addContext("", null);
@@ -1020,7 +1020,7 @@ public class TestHttp11Processor extends TomcatBaseTest {
 
         // This setting means the connection will be closed at the end of the
         // request
-        tomcat.getConnector().setAttribute("maxKeepAliveRequests", "1");
+        
Assert.assertTrue(tomcat.getConnector().setProperty("maxKeepAliveRequests", 
"1"));
 
         // No file system docBase required
         Context ctx = tomcat.addContext("", null);
@@ -1056,7 +1056,7 @@ public class TestHttp11Processor extends TomcatBaseTest {
 
         // This setting means the connection will be closed at the end of the
         // request
-        tomcat.getConnector().setAttribute("maxKeepAliveRequests", "1");
+        
Assert.assertTrue(tomcat.getConnector().setProperty("maxKeepAliveRequests", 
"1"));
 
         // No file system docBase required
         Context ctx = tomcat.addContext("", null);
@@ -1089,7 +1089,7 @@ public class TestHttp11Processor extends TomcatBaseTest {
 
         // This setting means the connection will be closed at the end of the
         // request
-        tomcat.getConnector().setAttribute("maxKeepAliveRequests", "1");
+        
Assert.assertTrue(tomcat.getConnector().setProperty("maxKeepAliveRequests", 
"1"));
 
         // No file system docBase required
         Context ctx = tomcat.addContext("", null);
@@ -1120,7 +1120,7 @@ public class TestHttp11Processor extends TomcatBaseTest {
 
         // This setting means the connection will be closed at the end of the
         // request
-        tomcat.getConnector().setAttribute("maxKeepAliveRequests", "1");
+        
Assert.assertTrue(tomcat.getConnector().setProperty("maxKeepAliveRequests", 
"1"));
 
         // No file system docBase required
         Context ctx = tomcat.addContext("", null);
@@ -1152,7 +1152,7 @@ public class TestHttp11Processor extends TomcatBaseTest {
 
         // This setting means the connection will be closed at the end of the
         // request
-        tomcat.getConnector().setAttribute("maxKeepAliveRequests", "1");
+        
Assert.assertTrue(tomcat.getConnector().setProperty("maxKeepAliveRequests", 
"1"));
 
         // No file system docBase required
         Context ctx = tomcat.addContext("", null);
@@ -1184,7 +1184,7 @@ public class TestHttp11Processor extends TomcatBaseTest {
 
         // This setting means the connection will be closed at the end of the
         // request
-        tomcat.getConnector().setAttribute("maxKeepAliveRequests", "1");
+        
Assert.assertTrue(tomcat.getConnector().setProperty("maxKeepAliveRequests", 
"1"));
 
         // No file system docBase required
         Context ctx = tomcat.addContext("", null);
@@ -1221,7 +1221,7 @@ public class TestHttp11Processor extends TomcatBaseTest {
 
         // This setting means the connection will be closed at the end of the
         // request
-        tomcat.getConnector().setAttribute("maxKeepAliveRequests", "1");
+        
Assert.assertTrue(tomcat.getConnector().setProperty("maxKeepAliveRequests", 
"1"));
 
         // No file system docBase required
         Context ctx = tomcat.addContext("", null);
@@ -1258,7 +1258,7 @@ public class TestHttp11Processor extends TomcatBaseTest {
 
         // This setting means the connection will be closed at the end of the
         // request
-        tomcat.getConnector().setAttribute("maxKeepAliveRequests", "1");
+        
Assert.assertTrue(tomcat.getConnector().setProperty("maxKeepAliveRequests", 
"1"));
 
         // No file system docBase required
         Context ctx = tomcat.addContext("", null);
@@ -1295,7 +1295,7 @@ public class TestHttp11Processor extends TomcatBaseTest {
 
         // This setting means the connection will be closed at the end of the
         // request
-        tomcat.getConnector().setAttribute("maxKeepAliveRequests", "1");
+        
Assert.assertTrue(tomcat.getConnector().setProperty("maxKeepAliveRequests", 
"1"));
 
         // No file system docBase required
         Context ctx = tomcat.addContext("", null);
@@ -1331,7 +1331,7 @@ public class TestHttp11Processor extends TomcatBaseTest {
 
         // This setting means the connection will be closed at the end of the
         // request
-        tomcat.getConnector().setAttribute("maxKeepAliveRequests", "1");
+        
Assert.assertTrue(tomcat.getConnector().setProperty("maxKeepAliveRequests", 
"1"));
 
         // No file system docBase required
         Context ctx = tomcat.addContext("", null);
@@ -1367,7 +1367,7 @@ public class TestHttp11Processor extends TomcatBaseTest {
 
         // This setting means the connection will be closed at the end of the
         // request
-        tomcat.getConnector().setAttribute("maxKeepAliveRequests", "1");
+        
Assert.assertTrue(tomcat.getConnector().setProperty("maxKeepAliveRequests", 
"1"));
 
         // No file system docBase required
         Context ctx = tomcat.addContext("", null);
@@ -1405,7 +1405,7 @@ public class TestHttp11Processor extends TomcatBaseTest {
 
         // This setting means the connection will be closed at the end of the
         // request
-        tomcat.getConnector().setAttribute("maxKeepAliveRequests", "1");
+        
Assert.assertTrue(tomcat.getConnector().setProperty("maxKeepAliveRequests", 
"1"));
 
         // No file system docBase required
         Context ctx = tomcat.addContext("", null);
@@ -1443,7 +1443,7 @@ public class TestHttp11Processor extends TomcatBaseTest {
 
         // This setting means the connection will be closed at the end of the
         // request
-        tomcat.getConnector().setAttribute("maxKeepAliveRequests", "1");
+        
Assert.assertTrue(tomcat.getConnector().setProperty("maxKeepAliveRequests", 
"1"));
 
         // No file system docBase required
         Context ctx = tomcat.addContext("", null);
@@ -1482,7 +1482,7 @@ public class TestHttp11Processor extends TomcatBaseTest {
 
         // This setting means the connection will be closed at the end of the
         // request
-        tomcat.getConnector().setAttribute("maxKeepAliveRequests", "1");
+        
Assert.assertTrue(tomcat.getConnector().setProperty("maxKeepAliveRequests", 
"1"));
 
         // No file system docBase required
         Context ctx = tomcat.addContext("", null);
@@ -1544,8 +1544,8 @@ public class TestHttp11Processor extends TomcatBaseTest {
             int maxKeepAliveRequests) throws Exception {
         Tomcat tomcat = getTomcatInstance();
 
-        tomcat.getConnector().setAttribute("keepAliveTimeout", 
Integer.valueOf(keepAliveTimeout));
-        tomcat.getConnector().setAttribute("maxKeepAliveRequests", 
Integer.valueOf(maxKeepAliveRequests));
+        tomcat.getConnector().setProperty("keepAliveTimeout", 
Integer.toString(keepAliveTimeout));
+        tomcat.getConnector().setProperty("maxKeepAliveRequests", 
Integer.toString(maxKeepAliveRequests));
 
         // No file system docBase required
         Context ctx = tomcat.addContext("", null);
diff --git a/test/org/apache/tomcat/util/http/TestMimeHeadersIntegration.java 
b/test/org/apache/tomcat/util/http/TestMimeHeadersIntegration.java
index b91fede..a24255c 100644
--- a/test/org/apache/tomcat/util/http/TestMimeHeadersIntegration.java
+++ b/test/org/apache/tomcat/util/http/TestMimeHeadersIntegration.java
@@ -105,8 +105,7 @@ public class TestMimeHeadersIntegration extends 
TomcatBaseTest {
         if (maxHeaderCount > 0) {
             Assert.assertEquals(maxHeaderCount, alv.arraySize);
         } else if (maxHeaderCount < 0) {
-            int maxHttpHeaderSize = ((Integer) tomcat.getConnector()
-                    .getAttribute("maxHttpHeaderSize")).intValue();
+            int maxHttpHeaderSize = ((Integer) 
tomcat.getConnector().getProperty("maxHttpHeaderSize")).intValue();
             int headerCount = Math.min(count,
                     maxHttpHeaderSize / header.length() + 1);
             int arraySize = 1;
diff --git a/test/org/apache/tomcat/util/net/TesterSupport.java 
b/test/org/apache/tomcat/util/net/TesterSupport.java
index 37d69c8..9af4a71 100644
--- a/test/org/apache/tomcat/util/net/TesterSupport.java
+++ b/test/org/apache/tomcat/util/net/TesterSupport.java
@@ -155,7 +155,7 @@ public final class TesterSupport {
                 AprLifecycleListener listener = new AprLifecycleListener();
                 listener.setSSLRandomSeed("/dev/urandom");
                 server.addLifecycleListener(listener);
-                connector.setAttribute("sslImplementationName", 
sslImplementation);
+                
Assert.assertTrue(connector.setProperty("sslImplementationName", 
sslImplementation));
             }
             sslHostConfig.setSslProtocol("tls");
             certificate.setCertificateKeystoreFile(new 
File(keystore).getAbsolutePath());
diff --git a/test/org/apache/tomcat/websocket/TestConnectionLimit.java 
b/test/org/apache/tomcat/websocket/TestConnectionLimit.java
index 9335fdc..26acf83 100644
--- a/test/org/apache/tomcat/websocket/TestConnectionLimit.java
+++ b/test/org/apache/tomcat/websocket/TestConnectionLimit.java
@@ -25,6 +25,7 @@ import jakarta.websocket.ContainerProvider;
 import jakarta.websocket.DeploymentException;
 import jakarta.websocket.WebSocketContainer;
 
+import org.junit.Assert;
 import org.junit.Ignore;
 import org.junit.Test;
 
@@ -50,7 +51,7 @@ public class TestConnectionLimit extends TomcatBaseTest {
         Tomcat.addServlet(ctx, "default", new DefaultServlet());
         ctx.addServletMappingDecoded("/", "default");
 
-        tomcat.getConnector().setAttribute("maxConnections", "-1");
+        Assert.assertTrue(tomcat.getConnector().setProperty("maxConnections", 
"-1"));
 
         tomcat.start();
 


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

Reply via email to