hc-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ggreg...@apache.org
Subject svn commit: r1749987 - in /httpcomponents/httpcore/branches/4.4.x/httpcore/src/test/java/org/apache/http: ./ impl/io/ integration/ protocol/ ssl/
Date Thu, 23 Jun 2016 19:40:27 GMT
Author: ggregory
Date: Thu Jun 23 19:40:26 2016
New Revision: 1749987

URL: http://svn.apache.org/viewvc?rev=1749987&view=rev
Log:
Add final modifier to local variables.

Modified:
    httpcomponents/httpcore/branches/4.4.x/httpcore/src/test/java/org/apache/http/TestHttpHost.java
    httpcomponents/httpcore/branches/4.4.x/httpcore/src/test/java/org/apache/http/impl/io/TestChunkCoding.java
    httpcomponents/httpcore/branches/4.4.x/httpcore/src/test/java/org/apache/http/impl/io/TestSessionInOutBuffers.java
    httpcomponents/httpcore/branches/4.4.x/httpcore/src/test/java/org/apache/http/integration/TestSyncHttp.java
    httpcomponents/httpcore/branches/4.4.x/httpcore/src/test/java/org/apache/http/protocol/TestUriPatternMatcher.java
    httpcomponents/httpcore/branches/4.4.x/httpcore/src/test/java/org/apache/http/ssl/TestSSLContextBuilder.java

Modified: httpcomponents/httpcore/branches/4.4.x/httpcore/src/test/java/org/apache/http/TestHttpHost.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/branches/4.4.x/httpcore/src/test/java/org/apache/http/TestHttpHost.java?rev=1749987&r1=1749986&r2=1749987&view=diff
==============================================================================
--- httpcomponents/httpcore/branches/4.4.x/httpcore/src/test/java/org/apache/http/TestHttpHost.java
(original)
+++ httpcomponents/httpcore/branches/4.4.x/httpcore/src/test/java/org/apache/http/TestHttpHost.java
Thu Jun 23 19:40:26 2016
@@ -210,17 +210,17 @@ public class TestHttpHost {
         try {
             HttpHost.create(null);
             Assert.fail("IllegalArgumentException expected");
-        } catch (IllegalArgumentException expected) {
+        } catch (final IllegalArgumentException expected) {
         }
         try {
             HttpHost.create(" host ");
             Assert.fail("IllegalArgumentException expected");
-        } catch (IllegalArgumentException expected) {
+        } catch (final IllegalArgumentException expected) {
         }
         try {
             HttpHost.create("host :8080");
             Assert.fail("IllegalArgumentException expected");
-        } catch (IllegalArgumentException expected) {
+        } catch (final IllegalArgumentException expected) {
         }
     }
 

Modified: httpcomponents/httpcore/branches/4.4.x/httpcore/src/test/java/org/apache/http/impl/io/TestChunkCoding.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/branches/4.4.x/httpcore/src/test/java/org/apache/http/impl/io/TestChunkCoding.java?rev=1749987&r1=1749986&r2=1749987&view=diff
==============================================================================
--- httpcomponents/httpcore/branches/4.4.x/httpcore/src/test/java/org/apache/http/impl/io/TestChunkCoding.java
(original)
+++ httpcomponents/httpcore/branches/4.4.x/httpcore/src/test/java/org/apache/http/impl/io/TestChunkCoding.java
Thu Jun 23 19:40:26 2016
@@ -297,7 +297,7 @@ public class TestChunkCoding {
         try {
             in.read();
             Assert.fail("MalformedChunkCodingException expected");
-        } catch (MalformedChunkCodingException ex) {
+        } catch (final MalformedChunkCodingException ex) {
         }
         in.close();
     }
@@ -331,11 +331,11 @@ public class TestChunkCoding {
         try {
             in2.read(buffer);
             Assert.fail("MessageConstraintException expected");
-        } catch (MessageConstraintException ex) {
+        } catch (final MessageConstraintException ex) {
         } finally {
             try {
                 in2.close();
-            } catch (MessageConstraintException ex) {
+            } catch (final MessageConstraintException ex) {
             }
         }
     }

Modified: httpcomponents/httpcore/branches/4.4.x/httpcore/src/test/java/org/apache/http/impl/io/TestSessionInOutBuffers.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/branches/4.4.x/httpcore/src/test/java/org/apache/http/impl/io/TestSessionInOutBuffers.java?rev=1749987&r1=1749986&r2=1749987&view=diff
==============================================================================
--- httpcomponents/httpcore/branches/4.4.x/httpcore/src/test/java/org/apache/http/impl/io/TestSessionInOutBuffers.java
(original)
+++ httpcomponents/httpcore/branches/4.4.x/httpcore/src/test/java/org/apache/http/impl/io/TestSessionInOutBuffers.java
Thu Jun 23 19:40:26 2016
@@ -373,7 +373,7 @@ public class TestSessionInOutBuffers {
         try {
             inbuffer2.readLine();
             Assert.fail("MessageConstraintException expected");
-        } catch (MessageConstraintException ex) {
+        } catch (final MessageConstraintException ex) {
         }
     }
 
@@ -394,7 +394,7 @@ public class TestSessionInOutBuffers {
         try {
             inbuffer2.readLine();
             Assert.fail("MessageConstraintException expected");
-        } catch (MessageConstraintException ex) {
+        } catch (final MessageConstraintException ex) {
         }
     }
 

Modified: httpcomponents/httpcore/branches/4.4.x/httpcore/src/test/java/org/apache/http/integration/TestSyncHttp.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/branches/4.4.x/httpcore/src/test/java/org/apache/http/integration/TestSyncHttp.java?rev=1749987&r1=1749986&r2=1749987&view=diff
==============================================================================
--- httpcomponents/httpcore/branches/4.4.x/httpcore/src/test/java/org/apache/http/integration/TestSyncHttp.java
(original)
+++ httpcomponents/httpcore/branches/4.4.x/httpcore/src/test/java/org/apache/http/integration/TestSyncHttp.java
Thu Jun 23 19:40:26 2016
@@ -543,7 +543,7 @@ public class TestSyncHttp {
                     final HttpContext context) throws HttpException {
                 final Header someheader = request.getFirstHeader("Secret");
                 if (someheader != null) {
-                    int secretNumber;
+                    final int secretNumber;
                     try {
                         secretNumber = Integer.parseInt(someheader.getValue());
                     } catch (final NumberFormatException ex) {
@@ -612,8 +612,7 @@ public class TestSyncHttp {
         public RepeatingEntity(final String content, final Charset charset, final int n)
{
             super();
             final Charset cs = charset != null ? charset : Charset.forName("US-ASCII");
-            byte[] b;
-            b = content.getBytes(cs);
+            final byte[] b = content.getBytes(cs);
             this.raw = b;
             this.n = n;
         }

Modified: httpcomponents/httpcore/branches/4.4.x/httpcore/src/test/java/org/apache/http/protocol/TestUriPatternMatcher.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/branches/4.4.x/httpcore/src/test/java/org/apache/http/protocol/TestUriPatternMatcher.java?rev=1749987&r1=1749986&r2=1749987&view=diff
==============================================================================
--- httpcomponents/httpcore/branches/4.4.x/httpcore/src/test/java/org/apache/http/protocol/TestUriPatternMatcher.java
(original)
+++ httpcomponents/httpcore/branches/4.4.x/httpcore/src/test/java/org/apache/http/protocol/TestUriPatternMatcher.java
Thu Jun 23 19:40:26 2016
@@ -133,9 +133,7 @@ public class TestUriPatternMatcher {
         matcher.register("/ma*", h1);
         matcher.register("*tch", h2);
 
-        Object h;
-
-        h = matcher.lookup("/match");
+        final Object h = matcher.lookup("/match");
         Assert.assertNotNull(h);
         Assert.assertTrue(h1 == h);
     }

Modified: httpcomponents/httpcore/branches/4.4.x/httpcore/src/test/java/org/apache/http/ssl/TestSSLContextBuilder.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/branches/4.4.x/httpcore/src/test/java/org/apache/http/ssl/TestSSLContextBuilder.java?rev=1749987&r1=1749986&r2=1749987&view=diff
==============================================================================
--- httpcomponents/httpcore/branches/4.4.x/httpcore/src/test/java/org/apache/http/ssl/TestSSLContextBuilder.java
(original)
+++ httpcomponents/httpcore/branches/4.4.x/httpcore/src/test/java/org/apache/http/ssl/TestSSLContextBuilder.java
Thu Jun 23 19:40:26 2016
@@ -33,6 +33,7 @@ import java.io.OutputStream;
 import java.net.InetSocketAddress;
 import java.net.ServerSocket;
 import java.net.Socket;
+import java.net.SocketException;
 import java.net.URL;
 import java.security.KeyStore;
 import java.security.Principal;
@@ -318,7 +319,7 @@ public class TestSSLContextBuilder {
                     final SSLSession session = socket.getSession();
                     try {
                         clientPrincipal = session.getPeerPrincipal();
-                    } catch (SSLPeerUnverifiedException ignore) {
+                    } catch (final SSLPeerUnverifiedException ignore) {
                     }
                     final OutputStream outputStream = socket.getOutputStream();
                     outputStream.write(new byte [] {'H', 'i'});
@@ -559,7 +560,7 @@ public class TestSSLContextBuilder {
         }
     }
 
-    @Test(expected = SSLHandshakeException.class)
+    @Test
     public void testSSLHanskshakeProtocolMismatch2() throws Exception {
         final URL resource1 = getClass().getResource("/test-server.keystore");
         final String storePassword = "nopassword";
@@ -577,7 +578,7 @@ public class TestSSLContextBuilder {
         final Set<String> supportedServerProtocols = new LinkedHashSet<String>(Arrays.asList(serverSocket.getSupportedProtocols()));
         Assert.assertTrue(supportedServerProtocols.contains("SSLv3"));
         serverSocket.setEnabledProtocols(new String[] {"SSLv3"});
-        serverSocket.bind(new InetSocketAddress(0));
+        serverSocket.bind(new InetSocketAddress("localhost", 0));
 
         this.executorService = Executors.newSingleThreadExecutor();
         this.executorService.submit(new Callable<Boolean>() {
@@ -596,11 +597,20 @@ public class TestSSLContextBuilder {
         final int localPort = serverSocket.getLocalPort();
         final SSLSocket clientSocket = (SSLSocket) clientSslContext.getSocketFactory().createSocket();
         try {
-            final Set<String> supportedClientProtocols = new LinkedHashSet<String>(Arrays.asList(clientSocket.getSupportedProtocols()));
+            final Set<String> supportedClientProtocols = new LinkedHashSet<String>(
+                    Arrays.asList(clientSocket.getSupportedProtocols()));
             Assert.assertTrue(supportedClientProtocols.contains("TLSv1"));
-            clientSocket.setEnabledProtocols(new String[] {"TLSv1"});
+            clientSocket.setEnabledProtocols(new String[] { "TLSv1" });
             clientSocket.connect(new InetSocketAddress("localhost", localPort), 5000);
-            clientSocket.startHandshake();
+            final boolean isWindows = System.getProperty("os.name").contains("Windows");
+            final Class<? extends IOException> expectedExceptionClass = isWindows ?
SocketException.class
+                    : SSLHandshakeException.class;
+            try {
+                clientSocket.startHandshake();
+                Assert.fail();
+            } catch (final Exception e) {
+                Assert.assertEquals(expectedExceptionClass, e.getClass());
+            }
         } finally {
             clientSocket.close();
         }



Mime
View raw message