hc-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ol...@apache.org
Subject svn commit: r603871 - in /jakarta/httpcomponents/httpclient/trunk/module-client/src/test/java/org/apache/http: client/methods/ client/protocol/ conn/ localserver/
Date Thu, 13 Dec 2007 10:33:26 GMT
Author: olegk
Date: Thu Dec 13 02:33:25 2007
New Revision: 603871

URL: http://svn.apache.org/viewvc?rev=603871&view=rev
Log:
Generics in test cases

Modified:
    jakarta/httpcomponents/httpclient/trunk/module-client/src/test/java/org/apache/http/client/methods/TestHttpOptions.java
    jakarta/httpcomponents/httpclient/trunk/module-client/src/test/java/org/apache/http/client/protocol/TestRedirects.java
    jakarta/httpcomponents/httpclient/trunk/module-client/src/test/java/org/apache/http/conn/TestHttpRoute.java
    jakarta/httpcomponents/httpclient/trunk/module-client/src/test/java/org/apache/http/conn/TestRouteTracker.java
    jakarta/httpcomponents/httpclient/trunk/module-client/src/test/java/org/apache/http/conn/TestScheme.java
    jakarta/httpcomponents/httpclient/trunk/module-client/src/test/java/org/apache/http/localserver/LocalTestServer.java

Modified: jakarta/httpcomponents/httpclient/trunk/module-client/src/test/java/org/apache/http/client/methods/TestHttpOptions.java
URL: http://svn.apache.org/viewvc/jakarta/httpcomponents/httpclient/trunk/module-client/src/test/java/org/apache/http/client/methods/TestHttpOptions.java?rev=603871&r1=603870&r2=603871&view=diff
==============================================================================
--- jakarta/httpcomponents/httpclient/trunk/module-client/src/test/java/org/apache/http/client/methods/TestHttpOptions.java
(original)
+++ jakarta/httpcomponents/httpclient/trunk/module-client/src/test/java/org/apache/http/client/methods/TestHttpOptions.java
Thu Dec 13 02:33:25 2007
@@ -1,7 +1,7 @@
 /*
- * $HeadURL:$
- * $Revision:$
- * $Date:$
+ * $HeadURL$
+ * $Revision$
+ * $Date$
  * ====================================================================
  * Licensed to the Apache Software Foundation (ASF) under one
  * or more contributor license agreements.  See the NOTICE file
@@ -68,7 +68,7 @@
         resp.addHeader("Allow", "GET");
 
         HttpOptions opt = new HttpOptions();
-        Set methodsName = opt.getAllowedMethods(resp);
+        Set<String> methodsName = opt.getAllowedMethods(resp);
         
         assertTrue(methodsName.contains("POST"));
         assertTrue(methodsName.contains("GET"));

Modified: jakarta/httpcomponents/httpclient/trunk/module-client/src/test/java/org/apache/http/client/protocol/TestRedirects.java
URL: http://svn.apache.org/viewvc/jakarta/httpcomponents/httpclient/trunk/module-client/src/test/java/org/apache/http/client/protocol/TestRedirects.java?rev=603871&r1=603870&r2=603871&view=diff
==============================================================================
--- jakarta/httpcomponents/httpclient/trunk/module-client/src/test/java/org/apache/http/client/protocol/TestRedirects.java
(original)
+++ jakarta/httpcomponents/httpclient/trunk/module-client/src/test/java/org/apache/http/client/protocol/TestRedirects.java
Thu Dec 13 02:33:25 2007
@@ -647,7 +647,7 @@
         DefaultHttpClient client = new DefaultHttpClient(); 
         HttpContext context = client.getDefaultContext();
 
-        List defaultHeaders = new ArrayList(1);
+        List<Header> defaultHeaders = new ArrayList<Header>(1);
         defaultHeaders.add(new BasicHeader(HTTP.USER_AGENT, "my-test-client"));
         
         client.getParams().setParameter(ClientPNames.DEFAULT_HEADERS, defaultHeaders);

Modified: jakarta/httpcomponents/httpclient/trunk/module-client/src/test/java/org/apache/http/conn/TestHttpRoute.java
URL: http://svn.apache.org/viewvc/jakarta/httpcomponents/httpclient/trunk/module-client/src/test/java/org/apache/http/conn/TestHttpRoute.java?rev=603871&r1=603870&r2=603871&view=diff
==============================================================================
--- jakarta/httpcomponents/httpclient/trunk/module-client/src/test/java/org/apache/http/conn/TestHttpRoute.java
(original)
+++ jakarta/httpcomponents/httpclient/trunk/module-client/src/test/java/org/apache/http/conn/TestHttpRoute.java
Thu Dec 13 02:33:25 2007
@@ -198,7 +198,7 @@
         assertTrue ("routettt.layer" , routettt.isLayered());
 
 
-        HashSet routes = new HashSet();
+        HashSet<HttpRoute> routes = new HashSet<HttpRoute>();
         routes.add(routefff);
         routes.add(routefft);
         routes.add(routeftf);
@@ -211,7 +211,7 @@
 
         // we can't test hashCode in general due to it's dependency
         // on InetAddress and HttpHost, but we can check for the flags
-        HashSet routecodes = new HashSet();
+        HashSet<Integer> routecodes = new HashSet<Integer>();
         routecodes.add(new Integer(routefff.hashCode()));
         routecodes.add(new Integer(routefft.hashCode()));
         routecodes.add(new Integer(routeftf.hashCode()));
@@ -223,7 +223,7 @@
         assertEquals("some flagged routes have same hashCode",
                      8, routecodes.size());
 
-        HashSet routestrings = new HashSet();
+        HashSet<String> routestrings = new HashSet<String>();
         routestrings.add(routefff.toString());
         routestrings.add(routefft.toString());
         routestrings.add(routeftf.toString());
@@ -390,7 +390,7 @@
 
         // now check that all of the routes are different from eachother
         // except for those that aren't :-)
-        HashSet routes = new HashSet();
+        HashSet<HttpRoute> routes = new HashSet<HttpRoute>();
         routes.add(route1a);
         routes.add(route2a);
         routes.add(route2b);
@@ -406,16 +406,16 @@
         assertEquals("some routes are equal", 11, routes.size());
 
         // and a run of cloning over the set
-        Iterator iter = routes.iterator();
+        Iterator<HttpRoute> iter = routes.iterator();
         while (iter.hasNext()) {
-            HttpRoute origin = (HttpRoute) iter.next();
+            HttpRoute origin = iter.next();
             HttpRoute cloned = (HttpRoute) origin.clone();
             assertEquals("clone of " + origin, origin, cloned);
             assertTrue("clone of " + origin, routes.contains(cloned));
         }
 
         // and don't forget toString
-        HashSet routestrings = new HashSet();
+        HashSet<String> routestrings = new HashSet<String>();
         routestrings.add(route1a.toString());
         routestrings.add(route2a.toString());
         routestrings.add(route2b.toString());

Modified: jakarta/httpcomponents/httpclient/trunk/module-client/src/test/java/org/apache/http/conn/TestRouteTracker.java
URL: http://svn.apache.org/viewvc/jakarta/httpcomponents/httpclient/trunk/module-client/src/test/java/org/apache/http/conn/TestRouteTracker.java?rev=603871&r1=603870&r2=603871&view=diff
==============================================================================
--- jakarta/httpcomponents/httpclient/trunk/module-client/src/test/java/org/apache/http/conn/TestRouteTracker.java
(original)
+++ jakarta/httpcomponents/httpclient/trunk/module-client/src/test/java/org/apache/http/conn/TestRouteTracker.java
Thu Dec 13 02:33:25 2007
@@ -33,7 +33,7 @@
 
 import java.net.InetAddress;
 import java.util.HashSet;
-import java.util.Iterator;
+import java.util.Set;
 
 import junit.framework.Test;
 import junit.framework.TestCase;
@@ -414,14 +414,14 @@
         // rt0 -> direct connection
         // rt1 -> via single proxy
         // rt2 -> via proxy chain
-        HashSet hs = new HashSet();
+        Set<RouteTracker> hs = new HashSet<RouteTracker>();
 
         // we also collect hashcodes for the different paths
         // since we can't guarantee what influence the HttpHost hashcodes have,
         // we keep separate sets here
-        HashSet hc0 = new HashSet();
-        HashSet hc4 = new HashSet();
-        HashSet hc6 = new HashSet();
+        Set<Integer> hc0 = new HashSet<Integer>();
+        Set<Integer> hc4 = new HashSet<Integer>();
+        Set<Integer> hc6 = new HashSet<Integer>();
 
         RouteTracker rt = null;
 
@@ -447,106 +447,104 @@
         // proxy (insecure) -> tunnel (insecure) -> layer (secure)
         rt = (RouteTracker) rt4.clone();
         rt.connectProxy(PROXY1, false);
-        assertTrue(hs.add(rt.clone()));
+        assertTrue(hs.add((RouteTracker) rt.clone()));
         // this is not guaranteed to be unique...
         assertTrue(hc4.add(new Integer(rt.hashCode())));
 
         rt.tunnelTarget(false);
-        assertTrue(hs.add(rt.clone()));
+        assertTrue(hs.add((RouteTracker) rt.clone()));
         assertTrue(hc4.add(new Integer(rt.hashCode())));
 
         rt.layerProtocol(true);
-        assertTrue(hs.add(rt.clone()));
+        assertTrue(hs.add((RouteTracker) rt.clone()));
         assertTrue(hc4.add(new Integer(rt.hashCode())));
 
 
         // proxy (secure) -> tunnel (secure) -> layer (insecure)
         rt = (RouteTracker) rt4.clone();
         rt.connectProxy(PROXY1, true);
-        assertTrue(hs.add(rt.clone()));
+        assertTrue(hs.add((RouteTracker) rt.clone()));
         // this is not guaranteed to be unique...
         assertTrue(hc4.add(new Integer(rt.hashCode())));
 
         rt.tunnelTarget(true);
-        assertTrue(hs.add(rt.clone()));
+        assertTrue(hs.add((RouteTracker) rt.clone()));
         assertTrue(hc4.add(new Integer(rt.hashCode())));
 
         rt.layerProtocol(false);
-        assertTrue(hs.add(rt.clone()));
+        assertTrue(hs.add((RouteTracker) rt.clone()));
         assertTrue(hc4.add(new Integer(rt.hashCode())));
 
 
         // PROXY1/i -> PROXY2/i -> tunnel/i -> layer/s
         rt = (RouteTracker) rt6.clone();
         rt.connectProxy(PROXY1, false);
-        assertTrue(hs.add(rt.clone()));
+        assertTrue(hs.add((RouteTracker) rt.clone()));
         // this is not guaranteed to be unique...
         assertTrue(hc6.add(new Integer(rt.hashCode())));
 
         rt.tunnelProxy(PROXY2, false);
-        assertTrue(hs.add(rt.clone()));
+        assertTrue(hs.add((RouteTracker) rt.clone()));
         // this is not guaranteed to be unique...
         assertTrue(hc6.add(new Integer(rt.hashCode())));
 
         rt.tunnelTarget(false);
-        assertTrue(hs.add(rt.clone()));
+        assertTrue(hs.add((RouteTracker) rt.clone()));
         assertTrue(hc6.add(new Integer(rt.hashCode())));
 
         rt.layerProtocol(true);
-        assertTrue(hs.add(rt.clone()));
+        assertTrue(hs.add((RouteTracker) rt.clone()));
         assertTrue(hc6.add(new Integer(rt.hashCode())));
 
 
         // PROXY1/s -> PROXY2/s -> tunnel/s -> layer/i
         rt = (RouteTracker) rt6.clone();
         rt.connectProxy(PROXY1, true);
-        assertTrue(hs.add(rt.clone()));
+        assertTrue(hs.add((RouteTracker) rt.clone()));
         // this is not guaranteed to be unique...
         assertTrue(hc6.add(new Integer(rt.hashCode())));
 
         rt.tunnelProxy(PROXY2, true);
-        assertTrue(hs.add(rt.clone()));
+        assertTrue(hs.add((RouteTracker) rt.clone()));
         // this is not guaranteed to be unique...
         assertTrue(hc6.add(new Integer(rt.hashCode())));
 
         rt.tunnelTarget(true);
-        assertTrue(hs.add(rt.clone()));
+        assertTrue(hs.add((RouteTracker) rt.clone()));
         assertTrue(hc6.add(new Integer(rt.hashCode())));
 
         rt.layerProtocol(false);
-        assertTrue(hs.add(rt.clone()));
+        assertTrue(hs.add((RouteTracker) rt.clone()));
         assertTrue(hc6.add(new Integer(rt.hashCode())));
 
 
         // PROXY2/i -> PROXY1/i -> tunnel/i -> layer/s
         rt = (RouteTracker) rt6.clone();
         rt.connectProxy(PROXY2, false);
-        assertTrue(hs.add(rt.clone()));
+        assertTrue(hs.add((RouteTracker) rt.clone()));
         // this is not guaranteed to be unique...
         assertTrue(hc6.add(new Integer(rt.hashCode())));
 
         rt.tunnelProxy(PROXY1, false);
-        assertTrue(hs.add(rt.clone()));
+        assertTrue(hs.add((RouteTracker) rt.clone()));
         // proxy chain sequence does not affect hashcode, so duplicate:
         // assertTrue(hc6.add(new Integer(rt.hashCode())));
 
         rt.tunnelTarget(false);
-        assertTrue(hs.add(rt.clone()));
+        assertTrue(hs.add((RouteTracker) rt.clone()));
         // proxy chain sequence does not affect hashcode, so duplicate:
         // assertTrue(hc6.add(new Integer(rt.hashCode())));
 
         rt.layerProtocol(true);
-        assertTrue(hs.add(rt.clone()));
+        assertTrue(hs.add((RouteTracker) rt.clone()));
         // proxy chain sequence does not affect hashcode, so duplicate:
         // assertTrue(hc6.add(new Integer(rt.hashCode())));
 
 
         // check that all toString are OK and different
-        HashSet rtstrings = new HashSet();
-        Iterator iter = hs.iterator();
-        while (iter.hasNext()) {
-            rt = (RouteTracker) iter.next();
-            final String rts = checkToString(rt);
+        Set<String> rtstrings = new HashSet<String>();
+        for (RouteTracker current: hs) {
+            final String rts = checkToString(current);
             assertTrue("duplicate toString: " + rts, rtstrings.add(rts));
         }
     }

Modified: jakarta/httpcomponents/httpclient/trunk/module-client/src/test/java/org/apache/http/conn/TestScheme.java
URL: http://svn.apache.org/viewvc/jakarta/httpcomponents/httpclient/trunk/module-client/src/test/java/org/apache/http/conn/TestScheme.java?rev=603871&r1=603870&r2=603871&view=diff
==============================================================================
--- jakarta/httpcomponents/httpclient/trunk/module-client/src/test/java/org/apache/http/conn/TestScheme.java
(original)
+++ jakarta/httpcomponents/httpclient/trunk/module-client/src/test/java/org/apache/http/conn/TestScheme.java
Thu Dec 13 02:33:25 2007
@@ -150,7 +150,7 @@
     public void testIterator() {
         SchemeRegistry schmreg = new SchemeRegistry();
 
-        List names = schmreg.getSchemeNames();
+        List<String> names = schmreg.getSchemeNames();
         assertNotNull(names);
         assertTrue(names.isEmpty());
 

Modified: jakarta/httpcomponents/httpclient/trunk/module-client/src/test/java/org/apache/http/localserver/LocalTestServer.java
URL: http://svn.apache.org/viewvc/jakarta/httpcomponents/httpclient/trunk/module-client/src/test/java/org/apache/http/localserver/LocalTestServer.java?rev=603871&r1=603870&r2=603871&view=diff
==============================================================================
--- jakarta/httpcomponents/httpclient/trunk/module-client/src/test/java/org/apache/http/localserver/LocalTestServer.java
(original)
+++ jakarta/httpcomponents/httpclient/trunk/module-client/src/test/java/org/apache/http/localserver/LocalTestServer.java
Thu Dec 13 02:33:25 2007
@@ -285,8 +285,8 @@
     public class RequestListener implements Runnable {
 
         /** The workers launched from here. */
-        private Set workerThreads =
-            Collections.synchronizedSet(new HashSet());
+        private Set<Thread> workerThreads =
+            Collections.synchronizedSet(new HashSet<Thread>());
 
 
         public void run() {



Mime
View raw message