null check in ProxyGrantingTicketStorageImpl.
This commit is contained in:
Scott Battaglia 2013-01-06 18:14:42 -05:00
parent 1a6c1aa002
commit e86cf7518e
2 changed files with 23 additions and 6 deletions

View File

@ -25,6 +25,7 @@ import java.util.concurrent.ConcurrentMap;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.jasig.cas.client.util.CommonUtils;
/**
* Implementation of {@link ProxyGrantingTicketStorage} that is backed by a
@ -82,6 +83,10 @@ public final class ProxyGrantingTicketStorageImpl implements ProxyGrantingTicket
* Its removed after retrieval.
*/
public String retrieve(final String proxyGrantingTicketIou) {
if (CommonUtils.isBlank(proxyGrantingTicketIou)) {
return null;
}
final ProxyGrantingTicketHolder holder = this.cache.get(proxyGrantingTicketIou);
if (holder == null) {

View File

@ -20,25 +20,37 @@
package org.jasig.cas.client.proxy;
import junit.framework.TestCase;
import org.junit.Assert;
import org.junit.Test;
/**
* Unit test for {@link ProxyGrantingTicketStorageImpl}
*
* @author Brad Cupit (brad [at] lsu {dot} edu)
*/
public class ProxyGrantingTicketStorageImplTest extends TestCase {
public void testCleanUp() throws Exception {
public class ProxyGrantingTicketStorageImplTest {
private static final int TIME_OUT = 250;
private ProxyGrantingTicketStorage storage = new ProxyGrantingTicketStorageImpl(TIME_OUT);
@Test
public void cleanUp() throws Exception {
String proxyGrantingTicketIou = "proxyGrantingTicketIou";
int timeout = 250;
ProxyGrantingTicketStorageImpl storage = new ProxyGrantingTicketStorageImpl(timeout);
storage.save(proxyGrantingTicketIou, "proxyGrantingTicket");
this.storage.save(proxyGrantingTicketIou, "proxyGrantingTicket");
// sleep long enough for the ticket to timeout
Thread.sleep(timeout * 2);
storage.cleanUp();
this.storage.cleanUp();
assertNull(storage.retrieve(proxyGrantingTicketIou));
Assert.assertNull(this.storage.retrieve(proxyGrantingTicketIou));
}
@Test
public void nullPGTIOU() {
Assert.assertNull(this.storage.retrieve(null));
}
}