[java-opensaml COMMIT] in /trunk/opensaml-saml-impl/src/test/java/org/opensaml/saml/metadata/resolver/impl: FileBacke...
noreply at shibboleth.net
noreply at shibboleth.net
Mon Feb 23 21:44:14 EST 2015
Author: putmanb
Date: Mon Feb 23 21:44:14 2015
New Revision: 4237
URL: http://svn.shibboleth.net/view/java-opensaml?rev=4237&view=rev
Log:
Update old HTTP metadata resolver unit tests to use an HttpClientBuilder rather than new-ing a legacy DefaultHttpClient directly.
Modified:
trunk/opensaml-saml-impl/src/test/java/org/opensaml/saml/metadata/resolver/impl/FileBackedHTTPMetadataResolverTest.java
trunk/opensaml-saml-impl/src/test/java/org/opensaml/saml/metadata/resolver/impl/HTTPMetadataResolverTest.java
Modified: trunk/opensaml-saml-impl/src/test/java/org/opensaml/saml/metadata/resolver/impl/FileBackedHTTPMetadataResolverTest.java
URL: http://svn.shibboleth.net/view/java-opensaml/trunk/opensaml-saml-impl/src/test/java/org/opensaml/saml/metadata/resolver/impl/FileBackedHTTPMetadataResolverTest.java?rev=4237&r1=4236&r2=4237&view=diff
==============================================================================
--- trunk/opensaml-saml-impl/src/test/java/org/opensaml/saml/metadata/resolver/impl/FileBackedHTTPMetadataResolverTest.java (original)
+++ trunk/opensaml-saml-impl/src/test/java/org/opensaml/saml/metadata/resolver/impl/FileBackedHTTPMetadataResolverTest.java Mon Feb 23 21:44:14 2015
@@ -20,11 +20,10 @@
import java.io.File;
import net.shibboleth.utilities.java.support.component.ComponentInitializationException;
+import net.shibboleth.utilities.java.support.httpclient.HttpClientBuilder;
import net.shibboleth.utilities.java.support.resolver.CriteriaSet;
import net.shibboleth.utilities.java.support.resolver.ResolverException;
-import org.apache.http.client.params.AllClientPNames;
-import org.apache.http.impl.client.DefaultHttpClient;
import org.opensaml.core.criterion.EntityIdCriterion;
import org.opensaml.core.xml.XMLObjectBaseTestCase;
import org.opensaml.saml.saml2.metadata.EntityDescriptor;
@@ -38,7 +37,7 @@
*/
public class FileBackedHTTPMetadataResolverTest extends XMLObjectBaseTestCase {
- private DefaultHttpClient httpClient;
+ private HttpClientBuilder httpClientBuilder;
private String mdUrl;
private String badMDURL;
@@ -49,8 +48,7 @@
@BeforeMethod
protected void setUp() throws Exception {
- httpClient = new DefaultHttpClient();
- httpClient.getParams().setIntParameter(AllClientPNames.CONNECTION_TIMEOUT, 1000 * 5);
+ httpClientBuilder = new HttpClientBuilder();
mdUrl="http://svn.shibboleth.net/view/java-opensaml/trunk/opensaml-saml-impl/src/test/resources/data/org/opensaml/saml/saml2/metadata/ukfederation-metadata.xml?content-type=text%2Fplain&view=co";
entityID = "urn:mace:ac.uk:sdss.ac.uk:provider:service:target.iay.org.uk";
@@ -73,8 +71,8 @@
* @throws ResolverException
*/
@Test
- public void testGetEntityDescriptor() throws ComponentInitializationException, ResolverException {
- metadataProvider = new FileBackedHTTPMetadataResolver(httpClient, mdUrl, backupFilePath);
+ public void testGetEntityDescriptor() throws Exception {
+ metadataProvider = new FileBackedHTTPMetadataResolver(httpClientBuilder.buildClient(), mdUrl, backupFilePath);
metadataProvider.setParserPool(parserPool);
metadataProvider.setId("test");
metadataProvider.initialize();
@@ -88,8 +86,8 @@
* Test fail-fast = true with known bad metadata URL.
*/
@Test
- public void testFailFastBadURL() throws ResolverException {
- metadataProvider = new FileBackedHTTPMetadataResolver(httpClient, badMDURL, backupFilePath);
+ public void testFailFastBadURL() throws Exception {
+ metadataProvider = new FileBackedHTTPMetadataResolver(httpClientBuilder.buildClient(), badMDURL, backupFilePath);
metadataProvider.setFailFastInitialization(true);
metadataProvider.setParserPool(parserPool);
@@ -106,8 +104,8 @@
* Test fail-fast = false with known bad metadata URL.
*/
@Test
- public void testNoFailFastBadURL() throws ResolverException {
- metadataProvider = new FileBackedHTTPMetadataResolver(httpClient, badMDURL, backupFilePath);
+ public void testNoFailFastBadURL() throws Exception {
+ metadataProvider = new FileBackedHTTPMetadataResolver(httpClientBuilder.buildClient(), badMDURL, backupFilePath);
metadataProvider.setFailFastInitialization(false);
metadataProvider.setId("test");
@@ -127,10 +125,10 @@
* Test fail-fast = true and bad backup file
*/
@Test
- public void testFailFastBadBackupFile() {
+ public void testFailFastBadBackupFile() throws Exception {
try {
// Use a known existing directory as backup file path, which is an invalid argument.
- metadataProvider = new FileBackedHTTPMetadataResolver(httpClient, mdUrl, System.getProperty("java.io.tmpdir"));
+ metadataProvider = new FileBackedHTTPMetadataResolver(httpClientBuilder.buildClient(), mdUrl, System.getProperty("java.io.tmpdir"));
} catch (ResolverException e) {
Assert.fail("Provider failed bad backup file in constructor");
[... 103 lines stripped ...]
More information about the commits
mailing list