SEC-1710: Added shutdown method to OpenID4JavaConsumer that invokes MultiThreadedHttpConnectionManager.shutdownAll()
This commit is contained in:
@@ -3,9 +3,15 @@ package org.springframework.security.openid;
|
||||
import static org.junit.Assert.*;
|
||||
import static org.mockito.Matchers.*;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.never;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
import static org.powermock.api.mockito.PowerMockito.*;
|
||||
|
||||
import org.apache.commons.httpclient.MultiThreadedHttpConnectionManager;
|
||||
import org.junit.*;
|
||||
import org.junit.runner.RunWith;
|
||||
|
||||
import org.openid4java.association.AssociationException;
|
||||
import org.openid4java.consumer.ConsumerException;
|
||||
import org.openid4java.consumer.ConsumerManager;
|
||||
@@ -19,13 +25,21 @@ import org.openid4java.message.MessageException;
|
||||
import org.openid4java.message.ParameterList;
|
||||
import org.openid4java.message.ax.AxMessage;
|
||||
import org.openid4java.message.ax.FetchResponse;
|
||||
|
||||
import org.springframework.mock.web.MockHttpServletRequest;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
import org.powermock.core.classloader.annotations.PrepareForTest;
|
||||
import org.powermock.modules.junit4.PowerMockRunner;
|
||||
import org.springframework.mock.web.MockHttpServletRequest;
|
||||
|
||||
/**
|
||||
* @author Luke Taylor
|
||||
* @author Rob Winch
|
||||
*/
|
||||
@RunWith(PowerMockRunner.class)
|
||||
@PrepareForTest(MultiThreadedHttpConnectionManager.class)
|
||||
public class OpenID4JavaConsumerTests {
|
||||
List<OpenIDAttribute> attributes = Arrays.asList(new OpenIDAttribute("a","b"), new OpenIDAttribute("b","b", Arrays.asList("c")));
|
||||
|
||||
@@ -194,4 +208,24 @@ public class OpenID4JavaConsumerTests {
|
||||
new OpenID4JavaConsumer(attributes);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void destroyInvokesShutdownAll() throws Exception {
|
||||
mockStatic(MultiThreadedHttpConnectionManager.class);
|
||||
new OpenID4JavaConsumer().destroy();
|
||||
|
||||
verifyStatic();
|
||||
MultiThreadedHttpConnectionManager.shutdownAll();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void destroyOverrideShutdownAll() throws Exception {
|
||||
mockStatic(MultiThreadedHttpConnectionManager.class);
|
||||
OpenID4JavaConsumer consumer = new OpenID4JavaConsumer();
|
||||
consumer.setSkipShutdownConnectionManager(true);
|
||||
|
||||
consumer.destroy();
|
||||
|
||||
verifyStatic(never());
|
||||
MultiThreadedHttpConnectionManager.shutdownAll();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user