This is an automated email from the ASF dual-hosted git repository. markt pushed a commit to branch 8.5.x in repository https://gitbox.apache.org/repos/asf/tomcat.git
commit 906698fee92f0e571ca54db98ec0e163972285a2 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 --- .../connector/TestCoyoteAdapterRequestFuzzing.java | 2 +- .../apache/catalina/core/TestAsyncContextImpl.java | 3 +- .../catalina/core/TestSwallowAbortedUploads.java | 2 +- .../apache/catalina/startup/TomcatBaseTest.java | 7 ++-- .../apache/coyote/http11/TestHttp11Processor.java | 46 +++++++++++----------- .../util/http/TestMimeHeadersIntegration.java | 3 +- test/org/apache/tomcat/util/net/TesterSupport.java | 2 +- .../tomcat/websocket/TestConnectionLimit.java | 3 +- 8 files changed, 33 insertions(+), 35 deletions(-) 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 b82b2bb..f4ef44c 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/TestSwallowAbortedUploads.java b/test/org/apache/catalina/core/TestSwallowAbortedUploads.java index 72e3a7b..83b1634 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 ac7c3f5..75e588d 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 4707a09..174793e 100644 --- a/test/org/apache/coyote/http11/TestHttp11Processor.java +++ b/test/org/apache/coyote/http11/TestHttp11Processor.java @@ -70,7 +70,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); @@ -1025,7 +1025,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); @@ -1061,7 +1061,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); @@ -1094,7 +1094,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); @@ -1125,9 +1125,9 @@ 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")); - tomcat.getConnector().setAttribute("allowHostHeaderMismatch", "false"); + Assert.assertTrue(tomcat.getConnector().setProperty("allowHostHeaderMismatch", "false")); // No file system docBase required Context ctx = tomcat.addContext("", null); @@ -1159,9 +1159,9 @@ 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")); - tomcat.getConnector().setAttribute("allowHostHeaderMismatch", "false"); + Assert.assertTrue(tomcat.getConnector().setProperty("allowHostHeaderMismatch", "false")); // No file system docBase required Context ctx = tomcat.addContext("", null); @@ -1193,9 +1193,9 @@ 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")); - tomcat.getConnector().setAttribute("allowHostHeaderMismatch", "false"); + Assert.assertTrue(tomcat.getConnector().setProperty("allowHostHeaderMismatch", "false")); // No file system docBase required Context ctx = tomcat.addContext("", null); @@ -1232,9 +1232,9 @@ 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")); - tomcat.getConnector().setAttribute("allowHostHeaderMismatch", "false"); + Assert.assertTrue(tomcat.getConnector().setProperty("allowHostHeaderMismatch", "false")); // No file system docBase required Context ctx = tomcat.addContext("", null); @@ -1271,9 +1271,9 @@ 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")); - tomcat.getConnector().setAttribute("allowHostHeaderMismatch", "false"); + Assert.assertTrue(tomcat.getConnector().setProperty("allowHostHeaderMismatch", "false")); // No file system docBase required Context ctx = tomcat.addContext("", null); @@ -1310,9 +1310,9 @@ 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")); - tomcat.getConnector().setAttribute("allowHostHeaderMismatch", "false"); + Assert.assertTrue(tomcat.getConnector().setProperty("allowHostHeaderMismatch", "false")); // No file system docBase required Context ctx = tomcat.addContext("", null); @@ -1348,7 +1348,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); @@ -1384,7 +1384,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); @@ -1422,7 +1422,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); @@ -1460,7 +1460,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); @@ -1499,7 +1499,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); @@ -1561,8 +1561,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 93ddab3..b697dd7 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 3f27bb5..ad8c064 100644 --- a/test/org/apache/tomcat/util/net/TesterSupport.java +++ b/test/org/apache/tomcat/util/net/TesterSupport.java @@ -152,7 +152,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 85c2a0f..5d966e2 100644 --- a/test/org/apache/tomcat/websocket/TestConnectionLimit.java +++ b/test/org/apache/tomcat/websocket/TestConnectionLimit.java @@ -25,6 +25,7 @@ import javax.websocket.ContainerProvider; import javax.websocket.DeploymentException; import javax.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