hc-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ol...@apache.org
Subject svn commit: r558148 - in /jakarta/httpcomponents/httpclient/trunk/module-client/src: main/java/org/apache/http/client/protocol/ main/java/org/apache/http/impl/client/ test/java/org/apache/http/client/ test/java/org/apache/http/conn/ test/java/org/apach...
Date Fri, 20 Jul 2007 21:19:44 GMT
Author: olegk
Date: Fri Jul 20 14:19:39 2007
New Revision: 558148

URL: http://svn.apache.org/viewvc?view=rev&rev=558148
Log:
Added basic CookieStore and CredentialsProvider impls based on old HttpState class

Added:
    jakarta/httpcomponents/httpclient/trunk/module-client/src/main/java/org/apache/http/impl/client/BasicCookieStore.java
      - copied, changed from r558136, jakarta/httpcomponents/httpclient/trunk/module-client/src/main/java/org/apache/http/client/HttpState.java
    jakarta/httpcomponents/httpclient/trunk/module-client/src/main/java/org/apache/http/impl/client/BasicCredentialsProvider.java
      - copied, changed from r558136, jakarta/httpcomponents/httpclient/trunk/module-client/src/main/java/org/apache/http/client/HttpState.java
    jakarta/httpcomponents/httpclient/trunk/module-client/src/test/java/org/apache/http/impl/client/TestBasicCredentialsProvider.java
      - copied, changed from r558146, jakarta/httpcomponents/httpclient/trunk/module-client/src/test/java/org/apache/http/client/TestHttpState.java
Removed:
    jakarta/httpcomponents/httpclient/trunk/module-client/src/test/java/org/apache/http/client/TestHttpState.java
Modified:
    jakarta/httpcomponents/httpclient/trunk/module-client/src/main/java/org/apache/http/client/protocol/RequestAddCookies.java
    jakarta/httpcomponents/httpclient/trunk/module-client/src/main/java/org/apache/http/client/protocol/ResponseProcessCookies.java
    jakarta/httpcomponents/httpclient/trunk/module-client/src/test/java/org/apache/http/client/TestAll.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/TestRouteDirector.java
    jakarta/httpcomponents/httpclient/trunk/module-client/src/test/java/org/apache/http/impl/client/TestAllHttpClientImpl.java
    jakarta/httpcomponents/httpclient/trunk/module-client/src/test/java/org/apache/http/impl/conn/TestTSCCMNoServer.java
    jakarta/httpcomponents/httpclient/trunk/module-client/src/test/java/org/apache/http/mockup/SecureSocketFactoryMockup.java

Modified: jakarta/httpcomponents/httpclient/trunk/module-client/src/main/java/org/apache/http/client/protocol/RequestAddCookies.java
URL: http://svn.apache.org/viewvc/jakarta/httpcomponents/httpclient/trunk/module-client/src/main/java/org/apache/http/client/protocol/RequestAddCookies.java?view=diff&rev=558148&r1=558147&r2=558148
==============================================================================
--- jakarta/httpcomponents/httpclient/trunk/module-client/src/main/java/org/apache/http/client/protocol/RequestAddCookies.java
(original)
+++ jakarta/httpcomponents/httpclient/trunk/module-client/src/main/java/org/apache/http/client/protocol/RequestAddCookies.java
Fri Jul 20 14:19:39 2007
@@ -58,7 +58,7 @@
 
 /**
  * Request interceptor that matches cookies available in the current
- * {@link HttpState} to the request being executed and generates 
+ * {@link CookieStore} to the request being executed and generates 
  * corresponding cookierequest headers.
  *
  * @author <a href="mailto:oleg at ural.ru">Oleg Kalnichevski</a>

Modified: jakarta/httpcomponents/httpclient/trunk/module-client/src/main/java/org/apache/http/client/protocol/ResponseProcessCookies.java
URL: http://svn.apache.org/viewvc/jakarta/httpcomponents/httpclient/trunk/module-client/src/main/java/org/apache/http/client/protocol/ResponseProcessCookies.java?view=diff&rev=558148&r1=558147&r2=558148
==============================================================================
--- jakarta/httpcomponents/httpclient/trunk/module-client/src/main/java/org/apache/http/client/protocol/ResponseProcessCookies.java
(original)
+++ jakarta/httpcomponents/httpclient/trunk/module-client/src/main/java/org/apache/http/client/protocol/ResponseProcessCookies.java
Fri Jul 20 14:19:39 2007
@@ -48,7 +48,7 @@
 import org.apache.http.protocol.HttpContext;
 
 /**
- * Response interceptor that populates the current {@link HttpState} with data 
+ * Response interceptor that populates the current {@link CookieStore} with data 
  * contained in response cookies received in the given the HTTP response.
  *
  * @author <a href="mailto:oleg at ural.ru">Oleg Kalnichevski</a>

Copied: jakarta/httpcomponents/httpclient/trunk/module-client/src/main/java/org/apache/http/impl/client/BasicCookieStore.java
(from r558136, jakarta/httpcomponents/httpclient/trunk/module-client/src/main/java/org/apache/http/client/HttpState.java)
URL: http://svn.apache.org/viewvc/jakarta/httpcomponents/httpclient/trunk/module-client/src/main/java/org/apache/http/impl/client/BasicCookieStore.java?view=diff&rev=558148&p1=jakarta/httpcomponents/httpclient/trunk/module-client/src/main/java/org/apache/http/client/HttpState.java&r1=558136&p2=jakarta/httpcomponents/httpclient/trunk/module-client/src/main/java/org/apache/http/impl/client/BasicCookieStore.java&r2=558148
==============================================================================
--- jakarta/httpcomponents/httpclient/trunk/module-client/src/main/java/org/apache/http/client/HttpState.java
(original)
+++ jakarta/httpcomponents/httpclient/trunk/module-client/src/main/java/org/apache/http/impl/client/BasicCookieStore.java
Fri Jul 20 14:19:39 2007
@@ -28,25 +28,19 @@
  *
  */
 
-package org.apache.http.client;
+package org.apache.http.impl.client;
 
 import java.util.ArrayList;
 import java.util.Comparator;
 import java.util.Date;
-import java.util.HashMap;
 import java.util.Iterator;
 
-import org.apache.http.auth.AuthScope;
-import org.apache.http.auth.Credentials;
+import org.apache.http.client.CookieStore;
 import org.apache.http.cookie.Cookie;
 import org.apache.http.cookie.CookieIdentityComparator;
 
 /**
- * <p>
- * A container for HTTP attributes that may persist from request
- * to request, such as {@link Cookie cookies} and authentication
- * {@link Credentials credentials}.
- * </p>
+ * Default implementation of {@link CookieStore}
  * 
  * @author <a href="mailto:remm@apache.org">Remy Maucherat</a>
  * @author Rodney Waldhoff
@@ -57,23 +51,10 @@
  * @author <a href="mailto:mbowler@GargoyleSoftware.com">Mike Bowler</a>
  * @author <a href="mailto:adrian@intencha.com">Adrian Sutton</a>
  * 
- * @version $Revision$ $Date$
- * 
- * @deprecated
+ * @since 4.0
  */
-public class HttpState implements CookieStore, CredentialsProvider {
-
-    // ----------------------------------------------------- Instance Variables
-
-    /**
-     * Map of {@link Credentials credentials} by realm that this 
-     * HTTP state contains.
-     */
-    private final HashMap credMap;
+public class BasicCookieStore implements CookieStore {
 
-    /**
-     * Array of {@link Cookie cookies} that this HTTP state contains.
-     */
     private final ArrayList cookies;
 
     private final Comparator cookieComparator;
@@ -83,15 +64,12 @@
     /**
      * Default constructor.
      */
-    public HttpState() {
+    public BasicCookieStore() {
         super();
-        this.credMap = new HashMap();
         this.cookies = new ArrayList();
         this.cookieComparator = new CookieIdentityComparator();
     }
 
-    // ------------------------------------------------------------- Properties
-
     /**
      * Adds an {@link Cookie HTTP cookie}, replacing any existing equivalent cookies.
      * If the given cookie has already expired it will not be added, but existing 
@@ -154,7 +132,10 @@
      * 
      * @see Cookie#isExpired(Date)
      */
-    public synchronized boolean clearExpired(Date date) {
+    public synchronized boolean clearExpired(final Date date) {
+        if (date == null) {
+            return false;
+        }
         boolean removed = false;
         Iterator it = cookies.iterator();
         while (it.hasNext()) {
@@ -166,106 +147,15 @@
         return removed;
     }
 
-    
-    
-    /** 
-     * Sets the {@link Credentials credentials} for the given authentication 
-     * scope. Any previous credentials for the given scope will be overwritten.
-     * 
-     * @param authscope the {@link AuthScope authentication scope}
-     * @param credentials the authentication {@link Credentials credentials} 
-     * for the given scope.
-     * 
-     * @see #getCredentials(AuthScope)
-     */
-    public synchronized void setCredentials(final AuthScope authscope, final Credentials
credentials) {
-        if (authscope == null) {
-            throw new IllegalArgumentException("Authentication scope may not be null");
-        }
-        credMap.put(authscope, credentials);
-    }
-
-    /**
-     * Find matching {@link Credentials credentials} for the given authentication scope.
-     *
-     * @param map the credentials hash map
-     * @param token the {@link AuthScope authentication scope}
-     * @return the credentials 
-     * 
-     */
-    private static Credentials matchCredentials(final HashMap map, final AuthScope authscope)
{
-        // see if we get a direct hit
-        Credentials creds = (Credentials)map.get(authscope);
-        if (creds == null) {
-            // Nope.
-            // Do a full scan
-            int bestMatchFactor  = -1;
-            AuthScope bestMatch  = null;
-            Iterator items = map.keySet().iterator();
-            while (items.hasNext()) {
-                AuthScope current = (AuthScope)items.next();
-                int factor = authscope.match(current);
-                if (factor > bestMatchFactor) {
-                    bestMatchFactor = factor;
-                    bestMatch = current;
-                }
-            }
-            if (bestMatch != null) {
-                creds = (Credentials)map.get(bestMatch);
-            }
-        }
-        return creds;
-    }
-    
-    /**
-     * Get the {@link Credentials credentials} for the given authentication scope.
-     *
-     * @param authscope the {@link AuthScope authentication scope}
-     * @return the credentials 
-     * 
-     * @see #setCredentials(AuthScope, Credentials)
-     */
-    public synchronized Credentials getCredentials(final AuthScope authscope) {
-        if (authscope == null) {
-            throw new IllegalArgumentException("Authentication scope may not be null");
-        }
-        return matchCredentials(this.credMap, authscope);
-    }
-
-    /**
-     * Returns a string representation of this HTTP state.
-     * 
-     * @return The string representation of the HTTP state.
-     * 
-     * @see java.lang.Object#toString()
-     */
-    public synchronized String toString() {
-        StringBuffer buffer = new StringBuffer();
-        buffer.append(credMap);
-        buffer.append(cookies);
-        return buffer.toString();
-    }
-    
-    /**
-     * Clears all credentials.
-     */
-    public synchronized void clearCredentials() {
-        this.credMap.clear();
+    public String toString() {
+        return cookies.toString();
     }
     
     /**
      * Clears all cookies.
      */
-    public synchronized void clearCookies() {
-        this.cookies.clear();
-    }
-    
-    /**
-     * Clears the state information (all cookies, credentials and proxy credentials).
-     */
     public synchronized void clear() {
-        clearCookies();
-        clearCredentials();
+        cookies.clear();
     }
     
 }

Copied: jakarta/httpcomponents/httpclient/trunk/module-client/src/main/java/org/apache/http/impl/client/BasicCredentialsProvider.java
(from r558136, jakarta/httpcomponents/httpclient/trunk/module-client/src/main/java/org/apache/http/client/HttpState.java)
URL: http://svn.apache.org/viewvc/jakarta/httpcomponents/httpclient/trunk/module-client/src/main/java/org/apache/http/impl/client/BasicCredentialsProvider.java?view=diff&rev=558148&p1=jakarta/httpcomponents/httpclient/trunk/module-client/src/main/java/org/apache/http/client/HttpState.java&r1=558136&p2=jakarta/httpcomponents/httpclient/trunk/module-client/src/main/java/org/apache/http/impl/client/BasicCredentialsProvider.java&r2=558148
==============================================================================
--- jakarta/httpcomponents/httpclient/trunk/module-client/src/main/java/org/apache/http/client/HttpState.java
(original)
+++ jakarta/httpcomponents/httpclient/trunk/module-client/src/main/java/org/apache/http/impl/client/BasicCredentialsProvider.java
Fri Jul 20 14:19:39 2007
@@ -28,25 +28,17 @@
  *
  */
 
-package org.apache.http.client;
+package org.apache.http.impl.client;
 
-import java.util.ArrayList;
-import java.util.Comparator;
-import java.util.Date;
 import java.util.HashMap;
 import java.util.Iterator;
 
 import org.apache.http.auth.AuthScope;
 import org.apache.http.auth.Credentials;
-import org.apache.http.cookie.Cookie;
-import org.apache.http.cookie.CookieIdentityComparator;
+import org.apache.http.client.CredentialsProvider;
 
 /**
- * <p>
- * A container for HTTP attributes that may persist from request
- * to request, such as {@link Cookie cookies} and authentication
- * {@link Credentials credentials}.
- * </p>
+ * Default implementation of {@link CredentialsProvider}
  * 
  * @author <a href="mailto:remm@apache.org">Remy Maucherat</a>
  * @author Rodney Waldhoff
@@ -57,117 +49,20 @@
  * @author <a href="mailto:mbowler@GargoyleSoftware.com">Mike Bowler</a>
  * @author <a href="mailto:adrian@intencha.com">Adrian Sutton</a>
  * 
- * @version $Revision$ $Date$
- * 
- * @deprecated
+ * @since 4.0
  */
-public class HttpState implements CookieStore, CredentialsProvider {
-
-    // ----------------------------------------------------- Instance Variables
+public class BasicCredentialsProvider implements CredentialsProvider {
 
-    /**
-     * Map of {@link Credentials credentials} by realm that this 
-     * HTTP state contains.
-     */
     private final HashMap credMap;
 
     /**
-     * Array of {@link Cookie cookies} that this HTTP state contains.
-     */
-    private final ArrayList cookies;
-
-    private final Comparator cookieComparator;
-    
-    // -------------------------------------------------------- Class Variables
-
-    /**
      * Default constructor.
      */
-    public HttpState() {
+    public BasicCredentialsProvider() {
         super();
         this.credMap = new HashMap();
-        this.cookies = new ArrayList();
-        this.cookieComparator = new CookieIdentityComparator();
-    }
-
-    // ------------------------------------------------------------- Properties
-
-    /**
-     * Adds an {@link Cookie HTTP cookie}, replacing any existing equivalent cookies.
-     * If the given cookie has already expired it will not be added, but existing 
-     * values will still be removed.
-     * 
-     * @param cookie the {@link Cookie cookie} to be added
-     * 
-     * @see #addCookies(Cookie[])
-     * 
-     */
-    public synchronized void addCookie(Cookie cookie) {
-        if (cookie != null) {
-            // first remove any old cookie that is equivalent
-            for (Iterator it = cookies.iterator(); it.hasNext();) {
-                Cookie tmp = (Cookie) it.next();
-                if (cookieComparator.compare(cookie, tmp) == 0) {
-                    it.remove();
-                    break;
-                }
-            }
-            if (!cookie.isExpired(new Date())) {
-                cookies.add(cookie);
-            }
-        }
-    }
-
-    /**
-     * Adds an array of {@link Cookie HTTP cookies}. Cookies are added individually and 
-     * in the given array order. If any of the given cookies has already expired it will

-     * not be added, but existing values will still be removed.
-     * 
-     * @param cookies the {@link Cookie cookies} to be added
-     * 
-     * @see #addCookie(Cookie)
-     * 
-     */
-    public synchronized void addCookies(Cookie[] cookies) {
-        if (cookies != null) {
-            for (int i = 0; i < cookies.length; i++) {
-                this.addCookie(cookies[i]);
-            }
-        }
     }
 
-    /**
-     * Returns an array of {@link Cookie cookies} that this HTTP
-     * state currently contains.
-     * 
-     * @return an array of {@link Cookie cookies}.
-     */
-    public synchronized Cookie[] getCookies() {
-        return (Cookie[]) (cookies.toArray(new Cookie[cookies.size()]));
-    }
-
-    /**
-     * Removes all of {@link Cookie cookies} in this HTTP state
-     * that have expired by the specified {@link java.util.Date date}. 
-     * 
-     * @return true if any cookies were purged.
-     * 
-     * @see Cookie#isExpired(Date)
-     */
-    public synchronized boolean clearExpired(Date date) {
-        boolean removed = false;
-        Iterator it = cookies.iterator();
-        while (it.hasNext()) {
-            if (((Cookie) (it.next())).isExpired(date)) {
-                it.remove();
-                removed = true;
-            }
-        }
-        return removed;
-    }
-
-    
-    
     /** 
      * Sets the {@link Credentials credentials} for the given authentication 
      * scope. Any previous credentials for the given scope will be overwritten.
@@ -232,40 +127,15 @@
         return matchCredentials(this.credMap, authscope);
     }
 
-    /**
-     * Returns a string representation of this HTTP state.
-     * 
-     * @return The string representation of the HTTP state.
-     * 
-     * @see java.lang.Object#toString()
-     */
-    public synchronized String toString() {
-        StringBuffer buffer = new StringBuffer();
-        buffer.append(credMap);
-        buffer.append(cookies);
-        return buffer.toString();
+    public String toString() {
+        return credMap.toString();
     }
     
     /**
      * Clears all credentials.
      */
-    public synchronized void clearCredentials() {
-        this.credMap.clear();
-    }
-    
-    /**
-     * Clears all cookies.
-     */
-    public synchronized void clearCookies() {
-        this.cookies.clear();
-    }
-    
-    /**
-     * Clears the state information (all cookies, credentials and proxy credentials).
-     */
     public synchronized void clear() {
-        clearCookies();
-        clearCredentials();
+        this.credMap.clear();
     }
     
 }

Modified: jakarta/httpcomponents/httpclient/trunk/module-client/src/test/java/org/apache/http/client/TestAll.java
URL: http://svn.apache.org/viewvc/jakarta/httpcomponents/httpclient/trunk/module-client/src/test/java/org/apache/http/client/TestAll.java?view=diff&rev=558148&r1=558147&r2=558148
==============================================================================
--- jakarta/httpcomponents/httpclient/trunk/module-client/src/test/java/org/apache/http/client/TestAll.java
(original)
+++ jakarta/httpcomponents/httpclient/trunk/module-client/src/test/java/org/apache/http/client/TestAll.java
Fri Jul 20 14:19:39 2007
@@ -55,7 +55,6 @@
         suite.addTest(TestAllConn.suite());
         suite.addTest(TestAllConnImpl.suite());
         suite.addTest(TestAllSSL.suite());        
-        suite.addTest(TestHttpState.suite());        
         return suite;
     }
 

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?view=diff&rev=558148&r1=558147&r2=558148
==============================================================================
--- 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
Fri Jul 20 14:19:39 2007
@@ -245,7 +245,8 @@
         // for reference: this one should succeed
         HttpRoute route = new HttpRoute(TARGET1, null, chain1,
                                         false, true, false);
-
+        assertNotNull(route);
+        
         try {
             route = new HttpRoute(null, null, chain1,
                                   false, true, false);

Modified: jakarta/httpcomponents/httpclient/trunk/module-client/src/test/java/org/apache/http/conn/TestRouteDirector.java
URL: http://svn.apache.org/viewvc/jakarta/httpcomponents/httpclient/trunk/module-client/src/test/java/org/apache/http/conn/TestRouteDirector.java?view=diff&rev=558148&r1=558147&r2=558148
==============================================================================
--- jakarta/httpcomponents/httpclient/trunk/module-client/src/test/java/org/apache/http/conn/TestRouteDirector.java
(original)
+++ jakarta/httpcomponents/httpclient/trunk/module-client/src/test/java/org/apache/http/conn/TestRouteDirector.java
Fri Jul 20 14:19:39 2007
@@ -32,8 +32,6 @@
 
 
 import java.net.InetAddress;
-import java.util.HashSet;
-import java.util.Iterator;
 
 import junit.framework.Test;
 import junit.framework.TestCase;
@@ -199,7 +197,6 @@
         HttpHost[] chainA = { PROXY1 };
         HttpHost[] chainB = { PROXY1, PROXY2 };
         HttpHost[] chainC = { PROXY2, PROXY1 };
-        HttpHost[] chainD = { PROXY2 };
 
         RouteDirector rowdy = new RouteDirector();
         HttpRoute route1cA  = new HttpRoute(TARGET1, null, chainA,
@@ -210,7 +207,6 @@
                                             false, false, false);
         HttpRoute route1cD  = new HttpRoute(TARGET1, null, chainC,
                                             false, false, false);
-        HttpRoute route1c0  = new HttpRoute(TARGET1, null, false);
 
         int step = rowdy.nextStep(route1cA, null);
         assertEquals("wrong step to route1cA",

Modified: jakarta/httpcomponents/httpclient/trunk/module-client/src/test/java/org/apache/http/impl/client/TestAllHttpClientImpl.java
URL: http://svn.apache.org/viewvc/jakarta/httpcomponents/httpclient/trunk/module-client/src/test/java/org/apache/http/impl/client/TestAllHttpClientImpl.java?view=diff&rev=558148&r1=558147&r2=558148
==============================================================================
--- jakarta/httpcomponents/httpclient/trunk/module-client/src/test/java/org/apache/http/impl/client/TestAllHttpClientImpl.java
(original)
+++ jakarta/httpcomponents/httpclient/trunk/module-client/src/test/java/org/apache/http/impl/client/TestAllHttpClientImpl.java
Fri Jul 20 14:19:39 2007
@@ -42,6 +42,7 @@
 
     public static Test suite() {
         TestSuite suite = new TestSuite();
+        suite.addTest(TestBasicCredentialsProvider.suite());
         return suite;
     }
 

Copied: jakarta/httpcomponents/httpclient/trunk/module-client/src/test/java/org/apache/http/impl/client/TestBasicCredentialsProvider.java
(from r558146, jakarta/httpcomponents/httpclient/trunk/module-client/src/test/java/org/apache/http/client/TestHttpState.java)
URL: http://svn.apache.org/viewvc/jakarta/httpcomponents/httpclient/trunk/module-client/src/test/java/org/apache/http/impl/client/TestBasicCredentialsProvider.java?view=diff&rev=558148&p1=jakarta/httpcomponents/httpclient/trunk/module-client/src/test/java/org/apache/http/client/TestHttpState.java&r1=558146&p2=jakarta/httpcomponents/httpclient/trunk/module-client/src/test/java/org/apache/http/impl/client/TestBasicCredentialsProvider.java&r2=558148
==============================================================================
--- jakarta/httpcomponents/httpclient/trunk/module-client/src/test/java/org/apache/http/client/TestHttpState.java
(original)
+++ jakarta/httpcomponents/httpclient/trunk/module-client/src/test/java/org/apache/http/impl/client/TestBasicCredentialsProvider.java
Fri Jul 20 14:19:39 2007
@@ -26,7 +26,7 @@
  * <http://www.apache.org/>.
  */
 
-package org.apache.http.client;
+package org.apache.http.impl.client;
 
 import org.apache.http.auth.AuthScope;
 import org.apache.http.auth.Credentials;
@@ -36,7 +36,7 @@
 
 /**
  * 
- * Simple tests for {@link HttpState}.
+ * Simple tests for {@link BasicCredentialsProvider}.
  *
  * @author Rodney Waldhoff
  * @author <a href="mailto:jsdever@apache.org">Jeff Dever</a>
@@ -46,7 +46,7 @@
  * @version $Id$
  * 
  */
-public class TestHttpState extends TestCase {
+public class TestBasicCredentialsProvider extends TestCase {
 
     public final static Credentials CREDS1 = 
         new UsernamePasswordCredentials("user1", "pass1");
@@ -64,40 +64,40 @@
 
 
     // ------------------------------------------------------------ Constructor
-    public TestHttpState(String testName) {
+    public TestBasicCredentialsProvider(String testName) {
         super(testName);
     }
 
     // ------------------------------------------------------------------- Main
     public static void main(String args[]) {
-        String[] testCaseName = { TestHttpState.class.getName() };
+        String[] testCaseName = { TestBasicCredentialsProvider.class.getName() };
         junit.textui.TestRunner.main(testCaseName);
     }
 
     // ------------------------------------------------------- TestCase Methods
 
     public static Test suite() {
-        return new TestSuite(TestHttpState.class);
+        return new TestSuite(TestBasicCredentialsProvider.class);
     }
 
 
     // ----------------------------------------------------------- Test Methods
 
-    public void testHttpStateCredentials() {
-        HttpState state = new HttpState();
+    public void testBasicCredentialsProviderCredentials() {
+        BasicCredentialsProvider state = new BasicCredentialsProvider();
         state.setCredentials(SCOPE1, CREDS1);
         state.setCredentials(SCOPE2, CREDS2);
         assertEquals(CREDS1, state.getCredentials(SCOPE1));
         assertEquals(CREDS2, state.getCredentials(SCOPE2));
     }
 
-    public void testHttpStateNoCredentials() {
-        HttpState state = new HttpState();
+    public void testBasicCredentialsProviderNoCredentials() {
+        BasicCredentialsProvider state = new BasicCredentialsProvider();
         assertEquals(null, state.getCredentials(BOGUS));
     }
 
-    public void testHttpStateDefaultCredentials() {
-        HttpState state = new HttpState();
+    public void testBasicCredentialsProviderDefaultCredentials() {
+        BasicCredentialsProvider state = new BasicCredentialsProvider();
 	    state.setCredentials(AuthScope.ANY, CREDS1);
 	    state.setCredentials(SCOPE2, CREDS2);
         assertEquals(CREDS1, state.getCredentials(BOGUS));
@@ -106,7 +106,7 @@
     // --------------------------------- Test Methods for Selecting Credentials
     
     public void testDefaultCredentials() throws Exception {
-        HttpState state = new HttpState();
+        BasicCredentialsProvider state = new BasicCredentialsProvider();
         Credentials expected = new UsernamePasswordCredentials("name", "pass");
         state.setCredentials(AuthScope.ANY, expected);
         Credentials got = state.getCredentials(DEFSCOPE);
@@ -114,7 +114,7 @@
     }
     
     public void testRealmCredentials() throws Exception {
-        HttpState state = new HttpState();
+        BasicCredentialsProvider state = new BasicCredentialsProvider();
         Credentials expected = new UsernamePasswordCredentials("name", "pass");
         state.setCredentials(DEFSCOPE, expected);
         Credentials got = state.getCredentials(DEFSCOPE);
@@ -122,7 +122,7 @@
     }
     
     public void testHostCredentials() throws Exception {
-        HttpState state = new HttpState();
+        BasicCredentialsProvider state = new BasicCredentialsProvider();
         Credentials expected = new UsernamePasswordCredentials("name", "pass");
         state.setCredentials(
             new AuthScope("host", AuthScope.ANY_PORT, AuthScope.ANY_REALM), expected);
@@ -131,7 +131,7 @@
     }
     
     public void testWrongHostCredentials() throws Exception {
-        HttpState state = new HttpState();
+        BasicCredentialsProvider state = new BasicCredentialsProvider();
         Credentials expected = new UsernamePasswordCredentials("name", "pass");
         state.setCredentials(
             new AuthScope("host1", AuthScope.ANY_PORT, "realm"), expected);
@@ -141,7 +141,7 @@
     }
     
     public void testWrongRealmCredentials() throws Exception {
-        HttpState state = new HttpState();
+        BasicCredentialsProvider state = new BasicCredentialsProvider();
         Credentials cred = new UsernamePasswordCredentials("name", "pass");
         state.setCredentials(
             new AuthScope("host", AuthScope.ANY_PORT, "realm1"), cred);
@@ -196,7 +196,7 @@
         AuthScope scope2 = new AuthScope(AuthScope.ANY_HOST, AuthScope.ANY_PORT, "somerealm");
         AuthScope scope3 = new AuthScope("somehost", AuthScope.ANY_PORT, AuthScope.ANY_REALM);
         
-        HttpState state = new HttpState();
+        BasicCredentialsProvider state = new BasicCredentialsProvider();
         state.setCredentials(scope1, creds1);
         state.setCredentials(scope2, creds2);
         state.setCredentials(scope3, creds3);

Modified: jakarta/httpcomponents/httpclient/trunk/module-client/src/test/java/org/apache/http/impl/conn/TestTSCCMNoServer.java
URL: http://svn.apache.org/viewvc/jakarta/httpcomponents/httpclient/trunk/module-client/src/test/java/org/apache/http/impl/conn/TestTSCCMNoServer.java?view=diff&rev=558148&r1=558147&r2=558148
==============================================================================
--- jakarta/httpcomponents/httpclient/trunk/module-client/src/test/java/org/apache/http/impl/conn/TestTSCCMNoServer.java
(original)
+++ jakarta/httpcomponents/httpclient/trunk/module-client/src/test/java/org/apache/http/impl/conn/TestTSCCMNoServer.java
Fri Jul 20 14:19:39 2007
@@ -197,7 +197,9 @@
         HttpRoute route2 = new HttpRoute(target2, null, false);
 
         ManagedClientConnection conn1 = mgr.getConnection(route1);
+        assertNotNull(conn1);
         ManagedClientConnection conn2 = mgr.getConnection(route2);
+        assertNotNull(conn2);
 
         try {
             // this should fail quickly, connection has not been released
@@ -242,8 +244,11 @@
 
         // route 3, limit 3
         ManagedClientConnection conn1 = mgr.getConnection(route3, 10L);
+        assertNotNull(conn1);
         ManagedClientConnection conn2 = mgr.getConnection(route3, 10L);
+        assertNotNull(conn2);
         ManagedClientConnection conn3 = mgr.getConnection(route3, 10L);
+        assertNotNull(conn3);
         try {
             // should fail quickly, connection has not been released
             mgr.getConnection(route3, 10L);

Modified: jakarta/httpcomponents/httpclient/trunk/module-client/src/test/java/org/apache/http/mockup/SecureSocketFactoryMockup.java
URL: http://svn.apache.org/viewvc/jakarta/httpcomponents/httpclient/trunk/module-client/src/test/java/org/apache/http/mockup/SecureSocketFactoryMockup.java?view=diff&rev=558148&r1=558147&r2=558148
==============================================================================
--- jakarta/httpcomponents/httpclient/trunk/module-client/src/test/java/org/apache/http/mockup/SecureSocketFactoryMockup.java
(original)
+++ jakarta/httpcomponents/httpclient/trunk/module-client/src/test/java/org/apache/http/mockup/SecureSocketFactoryMockup.java
Fri Jul 20 14:19:39 2007
@@ -31,12 +31,8 @@
 package org.apache.http.mockup;
 
 import java.net.Socket;
-import java.net.InetAddress;
 
 import org.apache.http.conn.SecureSocketFactory;
-import org.apache.http.params.HttpParams;
-
-
 
 /**
  * {@link SecureSocketFactory} mockup implementation.



Mime
View raw message