Formatted and cleaned up code
Fixed Java warnings
This commit is contained in:
parent
d100aca9bb
commit
372e2581ce
40 changed files with 244 additions and 168 deletions
|
@ -19,11 +19,13 @@
|
|||
package org.rometools.certiorem;
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
* @author robert.cooper
|
||||
*/
|
||||
public class HttpStatusCodeException extends RuntimeException {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private final int status;
|
||||
|
||||
public HttpStatusCodeException(final int status, final String message, final Throwable cause) {
|
||||
|
|
|
@ -10,9 +10,10 @@ import org.rometools.fetcher.impl.FeedFetcherCache;
|
|||
import org.rometools.fetcher.impl.SyndFeedInfo;
|
||||
|
||||
/**
|
||||
* Wrapper FeedFetcherCache that wraps a backing FeedFetcherCache and makes sure that any SyndFeedInfo used within it are replaced with a DeltaSyndFeedInfo
|
||||
* Wrapper FeedFetcherCache that wraps a backing FeedFetcherCache and makes sure
|
||||
* that any SyndFeedInfo used within it are replaced with a DeltaSyndFeedInfo
|
||||
* which is capable of tracking changes to entries in the underlying feed.
|
||||
*
|
||||
*
|
||||
* @author najmi
|
||||
*/
|
||||
public class DeltaFeedInfoCache implements FeedFetcherCache {
|
||||
|
|
|
@ -18,18 +18,21 @@ import com.sun.syndication.feed.synd.SyndEntry;
|
|||
import com.sun.syndication.feed.synd.SyndFeed;
|
||||
|
||||
/**
|
||||
* Extends SyndFeedInfo to also track etags for individual entries. This may be used with DeltaFeedInfoCache to only return feed with a subset of entries that
|
||||
* have changed since last fetch.
|
||||
*
|
||||
* Extends SyndFeedInfo to also track etags for individual entries. This may be
|
||||
* used with DeltaFeedInfoCache to only return feed with a subset of entries
|
||||
* that have changed since last fetch.
|
||||
*
|
||||
* @author najmi
|
||||
*/
|
||||
public class DeltaSyndFeedInfo extends SyndFeedInfo {
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private static final long serialVersionUID = 1L;
|
||||
Map<String, String> entryTagsMap = new HashMap<String, String>();
|
||||
Map<String, Boolean> changedMap = new HashMap<String, Boolean>();
|
||||
|
||||
private DeltaSyndFeedInfo() {
|
||||
}
|
||||
|
||||
public DeltaSyndFeedInfo(final SyndFeedInfo backingFeedInfo) {
|
||||
setETag(backingFeedInfo.getETag());
|
||||
setId(backingFeedInfo.getId());
|
||||
|
@ -38,8 +41,9 @@ public class DeltaSyndFeedInfo extends SyndFeedInfo {
|
|||
}
|
||||
|
||||
/**
|
||||
* Gets a filtered version of the SyndFeed that only has entries that were changed in the last setSyndFeed() call.
|
||||
*
|
||||
* Gets a filtered version of the SyndFeed that only has entries that were
|
||||
* changed in the last setSyndFeed() call.
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
|
@ -65,8 +69,9 @@ public class DeltaSyndFeedInfo extends SyndFeedInfo {
|
|||
}
|
||||
|
||||
/**
|
||||
* Overrides super class method to update changedMap and entryTagsMap for tracking changed entries.
|
||||
*
|
||||
* Overrides super class method to update changedMap and entryTagsMap for
|
||||
* tracking changed entries.
|
||||
*
|
||||
* @param feed
|
||||
*/
|
||||
@Override
|
||||
|
@ -89,9 +94,12 @@ public class DeltaSyndFeedInfo extends SyndFeedInfo {
|
|||
|
||||
private String computeEntryTag(final SyndEntry entry) {
|
||||
|
||||
// Following hash algorithm suggested by Robert Cooper needs to be evaluated in future.
|
||||
// int hash = ( entry.getUri() != null ? entry.getUri().hashCode() : entry.getLink().hashCode() ) ^
|
||||
// (entry.getUpdatedDate() != null ? entry.getUpdatedDate().hashCode() : entry.getPublishedDate().hashCode()) ^
|
||||
// Following hash algorithm suggested by Robert Cooper needs to be
|
||||
// evaluated in future.
|
||||
// int hash = ( entry.getUri() != null ? entry.getUri().hashCode() :
|
||||
// entry.getLink().hashCode() ) ^
|
||||
// (entry.getUpdatedDate() != null ? entry.getUpdatedDate().hashCode() :
|
||||
// entry.getPublishedDate().hashCode()) ^
|
||||
// entry.getTitle().hashCode() ^
|
||||
// entry.getDescription().hashCode();
|
||||
|
||||
|
@ -102,7 +110,9 @@ public class DeltaSyndFeedInfo extends SyndFeedInfo {
|
|||
if (publishedDate != null) {
|
||||
updateDate = publishedDate;
|
||||
} else {
|
||||
// For misbehaving feeds that do not set updateDate or publishedDate we use current tiem which pretty mucg assures that it will be viewed as
|
||||
// For misbehaving feeds that do not set updateDate or
|
||||
// publishedDate we use current tiem which pretty mucg assures
|
||||
// that it will be viewed as
|
||||
// changed even when it is not
|
||||
updateDate = new Date();
|
||||
}
|
||||
|
|
|
@ -39,9 +39,10 @@ import org.rometools.fetcher.FeedFetcher;
|
|||
import com.sun.syndication.feed.synd.SyndFeed;
|
||||
|
||||
/**
|
||||
* The basic business logic controller for the Hub implementation. It is intended to be usable under a very thin servlet wrapper, or other, non-HTTP
|
||||
* The basic business logic controller for the Hub implementation. It is
|
||||
* intended to be usable under a very thin servlet wrapper, or other, non-HTTP
|
||||
* notification methods you might want to use.
|
||||
*
|
||||
*
|
||||
* @author robert.cooper
|
||||
*/
|
||||
public class Hub {
|
||||
|
@ -62,7 +63,7 @@ public class Hub {
|
|||
|
||||
/**
|
||||
* Constructs a new Hub instance
|
||||
*
|
||||
*
|
||||
* @param dao The persistence HubDAO to use
|
||||
* @param verifier The verification strategy to use.
|
||||
*/
|
||||
|
@ -72,18 +73,21 @@ public class Hub {
|
|||
this.notifier = notifier;
|
||||
this.fetcher = fetcher;
|
||||
validSchemes = STANDARD_SCHEMES;
|
||||
validPorts = Collections.EMPTY_SET;
|
||||
validTopics = Collections.EMPTY_SET;
|
||||
validPorts = Collections.emptySet();
|
||||
validTopics = Collections.emptySet();
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs a new Hub instance.
|
||||
*
|
||||
*
|
||||
* @param dao The persistence HubDAO to use
|
||||
* @param verifier The verification strategy to use
|
||||
* @param validSchemes A list of valid URI schemes for callbacks (default: http, https)
|
||||
* @param validPorts A list of valid port numbers for callbacks (default: any)
|
||||
* @param validTopics A set of valid topic URIs which can be subscribed to (default: any)
|
||||
* @param validSchemes A list of valid URI schemes for callbacks (default:
|
||||
* http, https)
|
||||
* @param validPorts A list of valid port numbers for callbacks (default:
|
||||
* any)
|
||||
* @param validTopics A set of valid topic URIs which can be subscribed to
|
||||
* (default: any)
|
||||
*/
|
||||
public Hub(final HubDAO dao, final Verifier verifier, final Notifier notifier, final FeedFetcher fetcher, final Set<String> validSchemes,
|
||||
final Set<Integer> validPorts, final Set<String> validTopics) {
|
||||
|
@ -96,18 +100,29 @@ public class Hub {
|
|||
this.validSchemes = readOnlySchemes == null ? STANDARD_SCHEMES : readOnlySchemes;
|
||||
|
||||
final Set<Integer> readOnlyPorts = Collections.unmodifiableSet(validPorts);
|
||||
this.validPorts = readOnlyPorts == null ? Collections.EMPTY_SET : readOnlyPorts;
|
||||
if (readOnlyPorts == null) {
|
||||
this.validPorts = Collections.emptySet();
|
||||
} else {
|
||||
this.validPorts = readOnlyPorts;
|
||||
}
|
||||
|
||||
final Set<String> readOnlyTopics = Collections.unmodifiableSet(validTopics);
|
||||
this.validTopics = readOnlyTopics == null ? Collections.EMPTY_SET : readOnlyTopics;
|
||||
if (validTopics == null) {
|
||||
this.validTopics = Collections.emptySet();
|
||||
} else {
|
||||
this.validTopics = readOnlyTopics;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Sends a notification to the subscribers
|
||||
*
|
||||
* @param requestHost the host name the hub is running on. (Used for the user agent)
|
||||
*
|
||||
* @param requestHost the host name the hub is running on. (Used for the
|
||||
* user agent)
|
||||
* @param topic the URL of the topic that was updated.
|
||||
* @throws HttpStatusCodeException a wrapper exception with a recommended status code for the request.
|
||||
* @throws HttpStatusCodeException a wrapper exception with a recommended
|
||||
* status code for the request.
|
||||
*/
|
||||
public void sendNotification(final String requestHost, final String topic) {
|
||||
assert validTopics.isEmpty() || validTopics.contains(topic) : "That topic is not supported by this hub. " + topic;
|
||||
|
@ -120,7 +135,7 @@ public class Hub {
|
|||
return;
|
||||
}
|
||||
|
||||
final List<SubscriptionSummary> summaries = (List<SubscriptionSummary>) dao.summariesForTopic(topic);
|
||||
final List<? extends SubscriptionSummary> summaries = dao.summariesForTopic(topic);
|
||||
int total = 0;
|
||||
final StringBuilder hosts = new StringBuilder();
|
||||
|
||||
|
@ -135,7 +150,7 @@ public class Hub {
|
|||
.append(" subscribers)").append(hosts);
|
||||
final SyndFeed feed = fetcher.retrieveFeed(userAgent.toString(), new URL(topic));
|
||||
Logger.getLogger(Hub.class.getName()).log(Level.FINE, "Got feed for {0} Sending to {1} subscribers.", new Object[] { topic, subscribers.size() });
|
||||
notifier.notifySubscribers((List<Subscriber>) subscribers, feed, new SubscriptionSummaryCallback() {
|
||||
notifier.notifySubscribers(subscribers, feed, new SubscriptionSummaryCallback() {
|
||||
@Override
|
||||
public void onSummaryInfo(final SubscriptionSummary summary) {
|
||||
dao.handleSummary(topic, summary);
|
||||
|
@ -149,16 +164,18 @@ public class Hub {
|
|||
|
||||
/**
|
||||
* Subscribes to a topic.
|
||||
*
|
||||
*
|
||||
* @param callback Callback URI
|
||||
* @param topic Topic URI
|
||||
* @param verify Verification Type
|
||||
* @param lease_seconds Duration of the lease
|
||||
* @param secret Secret value
|
||||
* @param verify_token verify_token;
|
||||
* @return Boolean.TRUE if the subscription succeeded synchronously, Boolean.FALSE if the subscription failed synchronously, or null if the request is
|
||||
* asynchronous.
|
||||
* @throws HttpStatusCodeException a wrapper exception with a recommended status code for the request.
|
||||
* @return Boolean.TRUE if the subscription succeeded synchronously,
|
||||
* Boolean.FALSE if the subscription failed synchronously, or null
|
||||
* if the request is asynchronous.
|
||||
* @throws HttpStatusCodeException a wrapper exception with a recommended
|
||||
* status code for the request.
|
||||
*/
|
||||
public Boolean subscribe(final String callback, final String topic, final String verify, final long lease_seconds, final String secret,
|
||||
final String verify_token) {
|
||||
|
|
|
@ -26,25 +26,27 @@ import org.rometools.certiorem.hub.data.SubscriptionSummary;
|
|||
import com.sun.syndication.feed.synd.SyndFeed;
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
* @author robert.cooper
|
||||
*/
|
||||
public interface Notifier {
|
||||
/**
|
||||
* Instructs the notifier to begin sending notifications to the list of subscribers
|
||||
*
|
||||
* Instructs the notifier to begin sending notifications to the list of
|
||||
* subscribers
|
||||
*
|
||||
* @param subscribers Subscribers to notify
|
||||
* @param value The SyndFeed to send them
|
||||
* @param callback A callback that is invoked each time a subscriber is notified.
|
||||
* @param callback A callback that is invoked each time a subscriber is
|
||||
* notified.
|
||||
*/
|
||||
public void notifySubscribers(List<Subscriber> subscribers, SyndFeed value, SubscriptionSummaryCallback callback);
|
||||
public void notifySubscribers(List<? extends Subscriber> subscribers, SyndFeed value, SubscriptionSummaryCallback callback);
|
||||
|
||||
/**
|
||||
* A callback that is invoked each time a subscriber is notified.
|
||||
*/
|
||||
public static interface SubscriptionSummaryCallback {
|
||||
/**
|
||||
*
|
||||
*
|
||||
* @param summary A summary of the data received from the subscriber
|
||||
*/
|
||||
public void onSummaryInfo(SubscriptionSummary summary);
|
||||
|
|
|
@ -22,7 +22,7 @@ import org.rometools.certiorem.hub.data.Subscriber;
|
|||
|
||||
/**
|
||||
* A strategy interface for verification of subscriptions.
|
||||
*
|
||||
*
|
||||
* @author robert.cooper
|
||||
*/
|
||||
public interface Verifier {
|
||||
|
@ -38,7 +38,7 @@ public interface Verifier {
|
|||
|
||||
/**
|
||||
* Verifies a subscriber (possibly) asyncronously
|
||||
*
|
||||
*
|
||||
* @param subscriber the Subscriber to verify
|
||||
* @param callback a callback with the result of the verification.
|
||||
*/
|
||||
|
@ -46,7 +46,7 @@ public interface Verifier {
|
|||
|
||||
/**
|
||||
* Verifies a subscriber syncronously
|
||||
*
|
||||
*
|
||||
* @param subscriber The subscriber data
|
||||
* @return boolean result;
|
||||
*/
|
||||
|
@ -54,7 +54,7 @@ public interface Verifier {
|
|||
|
||||
/**
|
||||
* Verifies am unsubscribe (possibly) asyncronously
|
||||
*
|
||||
*
|
||||
* @param subscriber The subscriber data
|
||||
* @param callback result
|
||||
*/
|
||||
|
@ -62,18 +62,19 @@ public interface Verifier {
|
|||
|
||||
/**
|
||||
* Verifies an unsubscribe syncronously
|
||||
*
|
||||
*
|
||||
* @param subscriber The subscriber data
|
||||
* @return boolean result;
|
||||
*/
|
||||
public boolean verifyUnsubcribeSyncronously(Subscriber subscriber);
|
||||
|
||||
/**
|
||||
* An interface for capturing the result of a verification (subscribe or unsubscribe)
|
||||
* An interface for capturing the result of a verification (subscribe or
|
||||
* unsubscribe)
|
||||
*/
|
||||
public static interface VerificationCallback {
|
||||
/**
|
||||
*
|
||||
*
|
||||
* @param verified success state of the verification
|
||||
*/
|
||||
public void onVerify(boolean verified);
|
||||
|
|
|
@ -21,7 +21,7 @@ package org.rometools.certiorem.hub.data;
|
|||
import java.util.List;
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
* @author robert.cooper
|
||||
*/
|
||||
public interface HubDAO {
|
||||
|
|
|
@ -21,10 +21,14 @@ package org.rometools.certiorem.hub.data;
|
|||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
* @author robert.cooper
|
||||
*/
|
||||
public class Subscriber implements Serializable {
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private static final long serialVersionUID = 1L;
|
||||
public static final String VERIFY_SYNC = "sync";
|
||||
public static final String VERIFY_ASYNC = "async";
|
||||
private String callback;
|
||||
|
@ -37,7 +41,7 @@ public class Subscriber implements Serializable {
|
|||
|
||||
/**
|
||||
* Set the value of callback
|
||||
*
|
||||
*
|
||||
* @param newcallback new value of callback
|
||||
*/
|
||||
public void setCallback(final String newcallback) {
|
||||
|
@ -46,7 +50,7 @@ public class Subscriber implements Serializable {
|
|||
|
||||
/**
|
||||
* Get the value of callback
|
||||
*
|
||||
*
|
||||
* @return the value of callback
|
||||
*/
|
||||
public String getCallback() {
|
||||
|
@ -55,7 +59,7 @@ public class Subscriber implements Serializable {
|
|||
|
||||
/**
|
||||
* Set the value of creationTime
|
||||
*
|
||||
*
|
||||
* @param newcreationTime new value of creationTime
|
||||
*/
|
||||
public void setCreationTime(final long newcreationTime) {
|
||||
|
@ -64,7 +68,7 @@ public class Subscriber implements Serializable {
|
|||
|
||||
/**
|
||||
* Get the value of creationTime
|
||||
*
|
||||
*
|
||||
* @return the value of creationTime
|
||||
*/
|
||||
public long getCreationTime() {
|
||||
|
@ -73,7 +77,7 @@ public class Subscriber implements Serializable {
|
|||
|
||||
/**
|
||||
* Set the value of leaseSeconds
|
||||
*
|
||||
*
|
||||
* @param newleaseSeconds new value of leaseSeconds
|
||||
*/
|
||||
public void setLeaseSeconds(final long newleaseSeconds) {
|
||||
|
@ -82,7 +86,7 @@ public class Subscriber implements Serializable {
|
|||
|
||||
/**
|
||||
* Get the value of leaseSeconds
|
||||
*
|
||||
*
|
||||
* @return the value of leaseSeconds
|
||||
*/
|
||||
public long getLeaseSeconds() {
|
||||
|
@ -91,7 +95,7 @@ public class Subscriber implements Serializable {
|
|||
|
||||
/**
|
||||
* Set the value of secret
|
||||
*
|
||||
*
|
||||
* @param newsecret new value of secret
|
||||
*/
|
||||
public void setSecret(final String newsecret) {
|
||||
|
@ -100,7 +104,7 @@ public class Subscriber implements Serializable {
|
|||
|
||||
/**
|
||||
* Get the value of secret
|
||||
*
|
||||
*
|
||||
* @return the value of secret
|
||||
*/
|
||||
public String getSecret() {
|
||||
|
@ -109,7 +113,7 @@ public class Subscriber implements Serializable {
|
|||
|
||||
/**
|
||||
* Set the value of topic
|
||||
*
|
||||
*
|
||||
* @param newtopic new value of topic
|
||||
*/
|
||||
public void setTopic(final String newtopic) {
|
||||
|
@ -118,7 +122,7 @@ public class Subscriber implements Serializable {
|
|||
|
||||
/**
|
||||
* Get the value of topic
|
||||
*
|
||||
*
|
||||
* @return the value of topic
|
||||
*/
|
||||
public String getTopic() {
|
||||
|
@ -127,7 +131,7 @@ public class Subscriber implements Serializable {
|
|||
|
||||
/**
|
||||
* Set the value of verify
|
||||
*
|
||||
*
|
||||
* @param newverify new value of verify
|
||||
*/
|
||||
public void setVerify(final String newverify) {
|
||||
|
@ -136,7 +140,7 @@ public class Subscriber implements Serializable {
|
|||
|
||||
/**
|
||||
* Get the value of verify
|
||||
*
|
||||
*
|
||||
* @return the value of verify
|
||||
*/
|
||||
public String getVerify() {
|
||||
|
@ -145,7 +149,7 @@ public class Subscriber implements Serializable {
|
|||
|
||||
/**
|
||||
* Set the value of vertifyToken
|
||||
*
|
||||
*
|
||||
* @param newvertifyToken new value of vertifyToken
|
||||
*/
|
||||
public void setVertifyToken(final String newvertifyToken) {
|
||||
|
@ -154,7 +158,7 @@ public class Subscriber implements Serializable {
|
|||
|
||||
/**
|
||||
* Get the value of vertifyToken
|
||||
*
|
||||
*
|
||||
* @return the value of vertifyToken
|
||||
*/
|
||||
public String getVertifyToken() {
|
||||
|
|
|
@ -21,17 +21,21 @@ package org.rometools.certiorem.hub.data;
|
|||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
* @author robert.cooper
|
||||
*/
|
||||
public class SubscriptionSummary implements Serializable {
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private static final long serialVersionUID = 1L;
|
||||
private String host;
|
||||
private boolean lastPublishSuccessful = true;
|
||||
private int subscribers = 0;
|
||||
|
||||
/**
|
||||
* Set the value of host
|
||||
*
|
||||
*
|
||||
* @param newhost new value of host
|
||||
*/
|
||||
public void setHost(final String newhost) {
|
||||
|
@ -40,7 +44,7 @@ public class SubscriptionSummary implements Serializable {
|
|||
|
||||
/**
|
||||
* Get the value of host
|
||||
*
|
||||
*
|
||||
* @return the value of host
|
||||
*/
|
||||
public String getHost() {
|
||||
|
@ -49,7 +53,7 @@ public class SubscriptionSummary implements Serializable {
|
|||
|
||||
/**
|
||||
* Set the value of lastPublishSuccessful
|
||||
*
|
||||
*
|
||||
* @param newlastPublishSuccessful new value of lastPublishSuccessful
|
||||
*/
|
||||
public void setLastPublishSuccessful(final boolean newlastPublishSuccessful) {
|
||||
|
@ -58,7 +62,7 @@ public class SubscriptionSummary implements Serializable {
|
|||
|
||||
/**
|
||||
* Get the value of lastPublishSuccessful
|
||||
*
|
||||
*
|
||||
* @return the value of lastPublishSuccessful
|
||||
*/
|
||||
public boolean isLastPublishSuccessful() {
|
||||
|
@ -67,7 +71,7 @@ public class SubscriptionSummary implements Serializable {
|
|||
|
||||
/**
|
||||
* Set the value of subscribers
|
||||
*
|
||||
*
|
||||
* @param newsubscribers new value of subscribers
|
||||
*/
|
||||
public void setSubscribers(final int newsubscribers) {
|
||||
|
@ -76,7 +80,7 @@ public class SubscriptionSummary implements Serializable {
|
|||
|
||||
/**
|
||||
* Get the value of subscribers
|
||||
*
|
||||
*
|
||||
* @return the value of subscribers
|
||||
*/
|
||||
public int getSubscribers() {
|
||||
|
|
|
@ -33,7 +33,7 @@ import org.rometools.certiorem.hub.data.Subscriber;
|
|||
import org.rometools.certiorem.hub.data.SubscriptionSummary;
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
* @author robert.cooper
|
||||
*/
|
||||
public class JPADAO implements HubDAO {
|
||||
|
@ -57,7 +57,9 @@ public class JPADAO implements HubDAO {
|
|||
query.setParameter("topic", topic);
|
||||
|
||||
try {
|
||||
for (final JPASubscriber subscriber : (List<JPASubscriber>) query.getResultList()) {
|
||||
@SuppressWarnings("unchecked")
|
||||
final List<JPASubscriber> subscribers = query.getResultList();
|
||||
for (final JPASubscriber subscriber : subscribers) {
|
||||
if (subscriber.getLeaseSeconds() == -1) {
|
||||
result.add(subscriber);
|
||||
continue;
|
||||
|
|
|
@ -31,19 +31,23 @@ import javax.persistence.TemporalType;
|
|||
import org.rometools.certiorem.hub.data.Subscriber;
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
* @author robert.cooper
|
||||
*/
|
||||
@Entity
|
||||
@NamedQueries({ @NamedQuery(name = "Subcriber.forTopic", query = "SELECT o FROM JPASubscriber o WHERE o.topic = :topic AND o.expired = false ORDER BY o.subscribedAt") })
|
||||
public class JPASubscriber extends Subscriber implements Serializable {
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private static final long serialVersionUID = 1L;
|
||||
private Date subscribedAt = new Date();
|
||||
private String id;
|
||||
private boolean expired = false;
|
||||
|
||||
/**
|
||||
* Set the value of expired
|
||||
*
|
||||
*
|
||||
* @param newexpired new value of expired
|
||||
*/
|
||||
public void setExpired(final boolean newexpired) {
|
||||
|
@ -52,7 +56,7 @@ public class JPASubscriber extends Subscriber implements Serializable {
|
|||
|
||||
/**
|
||||
* Get the value of expired
|
||||
*
|
||||
*
|
||||
* @return the value of expired
|
||||
*/
|
||||
public boolean isExpired() {
|
||||
|
@ -61,7 +65,7 @@ public class JPASubscriber extends Subscriber implements Serializable {
|
|||
|
||||
/**
|
||||
* Set the value of id
|
||||
*
|
||||
*
|
||||
* @param newid new value of id
|
||||
*/
|
||||
public void setId(final String newid) {
|
||||
|
@ -70,7 +74,7 @@ public class JPASubscriber extends Subscriber implements Serializable {
|
|||
|
||||
/**
|
||||
* Get the value of id
|
||||
*
|
||||
*
|
||||
* @return the value of id
|
||||
*/
|
||||
@Id
|
||||
|
@ -80,7 +84,7 @@ public class JPASubscriber extends Subscriber implements Serializable {
|
|||
|
||||
/**
|
||||
* Set the value of subscribedAt
|
||||
*
|
||||
*
|
||||
* @param newsubscribedAt new value of subscribedAt
|
||||
*/
|
||||
public void setSubscribedAt(final Date newsubscribedAt) {
|
||||
|
@ -89,7 +93,7 @@ public class JPASubscriber extends Subscriber implements Serializable {
|
|||
|
||||
/**
|
||||
* Get the value of subscribedAt
|
||||
*
|
||||
*
|
||||
* @return the value of subscribedAt
|
||||
*/
|
||||
@Temporal(TemporalType.TIMESTAMP)
|
||||
|
|
|
@ -30,7 +30,7 @@ import org.rometools.certiorem.hub.data.SubscriptionSummary;
|
|||
|
||||
/**
|
||||
* A Simple In-Memory HubDAO for subscribers.
|
||||
*
|
||||
*
|
||||
* @author robert.cooper
|
||||
*/
|
||||
public class InMemoryHubDAO implements HubDAO {
|
||||
|
@ -89,7 +89,7 @@ public class InMemoryHubDAO implements HubDAO {
|
|||
|
||||
return result;
|
||||
} else {
|
||||
return Collections.EMPTY_LIST;
|
||||
return Collections.emptyList();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -38,22 +38,24 @@ import com.sun.syndication.io.FeedException;
|
|||
import com.sun.syndication.io.SyndFeedOutput;
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
* @author robert.cooper
|
||||
*/
|
||||
public abstract class AbstractNotifier implements Notifier {
|
||||
/**
|
||||
* This method will serialize the synd feed and build Notifications for the implementation class to handle.
|
||||
*
|
||||
* This method will serialize the synd feed and build Notifications for the
|
||||
* implementation class to handle.
|
||||
*
|
||||
* @see enqueueNotification
|
||||
*
|
||||
*
|
||||
* @param subscribers List of subscribers to notify
|
||||
* @param value The SyndFeed object to send
|
||||
* @param callback A callback that will be invoked each time a subscriber is notified.
|
||||
*
|
||||
* @param callback A callback that will be invoked each time a subscriber is
|
||||
* notified.
|
||||
*
|
||||
*/
|
||||
@Override
|
||||
public void notifySubscribers(final List<Subscriber> subscribers, final SyndFeed value, final SubscriptionSummaryCallback callback) {
|
||||
public void notifySubscribers(final List<? extends Subscriber> subscribers, final SyndFeed value, final SubscriptionSummaryCallback callback) {
|
||||
String mimeType = null;
|
||||
|
||||
if (value.getFeedType().startsWith("rss")) {
|
||||
|
@ -92,15 +94,16 @@ public abstract class AbstractNotifier implements Notifier {
|
|||
|
||||
/**
|
||||
* Implementation method that queues/sends a notification
|
||||
*
|
||||
*
|
||||
* @param not notification to send.
|
||||
*/
|
||||
protected abstract void enqueueNotification(Notification not);
|
||||
|
||||
/**
|
||||
* POSTs the payload to the subscriber's callback and returns a SubscriptionSummary with subscriber counts (where possible) and the success state of the
|
||||
* notification.
|
||||
*
|
||||
* POSTs the payload to the subscriber's callback and returns a
|
||||
* SubscriptionSummary with subscriber counts (where possible) and the
|
||||
* success state of the notification.
|
||||
*
|
||||
* @param subscriber subscriber data.
|
||||
* @param mimeType MIME type for the request
|
||||
* @param payload payload of the feed to send
|
||||
|
|
|
@ -22,7 +22,7 @@ import org.rometools.certiorem.hub.Notifier.SubscriptionSummaryCallback;
|
|||
import org.rometools.certiorem.hub.data.Subscriber;
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
* @author robert.cooper
|
||||
*/
|
||||
public class Notification {
|
||||
|
|
|
@ -28,8 +28,9 @@ import java.util.concurrent.TimeUnit;
|
|||
import org.rometools.certiorem.hub.data.SubscriptionSummary;
|
||||
|
||||
/**
|
||||
* A notifier implementation that uses a thread pool to deliver notifications to subscribers
|
||||
*
|
||||
* A notifier implementation that uses a thread pool to deliver notifications to
|
||||
* subscribers
|
||||
*
|
||||
* @author robert.cooper
|
||||
*/
|
||||
public class ThreadPoolNotifier extends AbstractNotifier {
|
||||
|
@ -51,9 +52,10 @@ public class ThreadPoolNotifier extends AbstractNotifier {
|
|||
}
|
||||
|
||||
/**
|
||||
* Enqueues a notification to run. If the notification fails, it will be retried every two minutes until 5 attempts are completed. Notifications to the same
|
||||
* callback should be delivered successfully in order.
|
||||
*
|
||||
* Enqueues a notification to run. If the notification fails, it will be
|
||||
* retried every two minutes until 5 attempts are completed. Notifications
|
||||
* to the same callback should be delivered successfully in order.
|
||||
*
|
||||
* @param not
|
||||
*/
|
||||
@Override
|
||||
|
@ -82,7 +84,7 @@ public class ThreadPoolNotifier extends AbstractNotifier {
|
|||
|
||||
/**
|
||||
* Schedules a notification to retry in two minutes.
|
||||
*
|
||||
*
|
||||
* @param not Notification to retry
|
||||
*/
|
||||
protected void retry(final Notification not) {
|
||||
|
|
|
@ -18,30 +18,27 @@
|
|||
|
||||
package org.rometools.certiorem.hub.notify.standard;
|
||||
|
||||
import java.util.concurrent.ConcurrentSkipListSet;
|
||||
|
||||
import org.rometools.certiorem.hub.data.SubscriptionSummary;
|
||||
|
||||
/**
|
||||
* A notifier that does not use threads. All calls are blocking and synchronous.
|
||||
*
|
||||
*
|
||||
* @author robert.cooper
|
||||
*/
|
||||
public class UnthreadedNotifier extends AbstractNotifier {
|
||||
private final ConcurrentSkipListSet<Notification> retries = new ConcurrentSkipListSet<Notification>();
|
||||
|
||||
/**
|
||||
* A blocking call that performs a notification. If there are pending retries that are older than two minutes old, they will be retried before the method
|
||||
* returns.
|
||||
*
|
||||
* A blocking call that performs a notification. If there are pending
|
||||
* retries that are older than two minutes old, they will be retried before
|
||||
* the method returns.
|
||||
*
|
||||
* @param not
|
||||
*/
|
||||
@Override
|
||||
protected void enqueueNotification(final Notification not) {
|
||||
not.lastRun = System.currentTimeMillis();
|
||||
|
||||
final SubscriptionSummary summary = postNotification(not.subscriber, not.mimeType, not.payload);
|
||||
|
||||
not.callback.onSummaryInfo(summary);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -34,8 +34,9 @@ import org.rometools.certiorem.hub.Verifier;
|
|||
import org.rometools.certiorem.hub.data.Subscriber;
|
||||
|
||||
/**
|
||||
* An abstract verifier based on the java.net HTTP classes. This implements only synchronous operations, and expects a child class to do Async ops.
|
||||
*
|
||||
* An abstract verifier based on the java.net HTTP classes. This implements only
|
||||
* synchronous operations, and expects a child class to do Async ops.
|
||||
*
|
||||
* @author robert.cooper
|
||||
*/
|
||||
public abstract class AbstractVerifier implements Verifier {
|
||||
|
@ -68,7 +69,8 @@ public abstract class AbstractVerifier implements Verifier {
|
|||
final HttpURLConnection connection = (HttpURLConnection) url.openConnection();
|
||||
connection.setDoInput(true);
|
||||
// connection.setRequestProperty("Host", url.getHost());
|
||||
// connection.setRequestProperty("Port", Integer.toString(url.getPort()));
|
||||
// connection.setRequestProperty("Port",
|
||||
// Integer.toString(url.getPort()));
|
||||
connection.setRequestProperty("User-Agent", "ROME-Certiorem");
|
||||
connection.connect();
|
||||
final int rc = connection.getResponseCode();
|
||||
|
|
|
@ -26,7 +26,7 @@ import org.rometools.certiorem.hub.data.Subscriber;
|
|||
|
||||
/**
|
||||
* Uses a ThreadPoolExecutor to do async verifications.
|
||||
*
|
||||
*
|
||||
* @author robert.cooper
|
||||
*/
|
||||
public class ThreadPoolVerifier extends AbstractVerifier {
|
||||
|
|
|
@ -21,7 +21,7 @@ package org.rometools.certiorem.hub.verify.standard;
|
|||
import java.util.concurrent.ThreadPoolExecutor;
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
* @author robert.cooper
|
||||
*/
|
||||
public class ThreadpoolVerifierAdvanced extends ThreadPoolVerifier {
|
||||
|
|
|
@ -22,7 +22,7 @@ import org.rometools.certiorem.hub.data.Subscriber;
|
|||
|
||||
/**
|
||||
* A verifier that does not use threads. Suitable for Google App Engine.
|
||||
*
|
||||
*
|
||||
* @author robert.cooper
|
||||
*/
|
||||
public class UnthreadedVerifier extends AbstractVerifier {
|
||||
|
|
|
@ -19,11 +19,16 @@
|
|||
package org.rometools.certiorem.pub;
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
* @author robert.cooper
|
||||
*/
|
||||
public class NotificationException extends Exception {
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
public NotificationException(final String message) {
|
||||
super(message);
|
||||
}
|
||||
|
|
|
@ -33,20 +33,22 @@ import com.sun.syndication.feed.synd.SyndLink;
|
|||
|
||||
/**
|
||||
* A class for sending update notifications to a hub.
|
||||
*
|
||||
*
|
||||
* @author robert.cooper
|
||||
*/
|
||||
public class Publisher {
|
||||
private ThreadPoolExecutor executor;
|
||||
|
||||
/**
|
||||
* Constructs a new publisher. This publisher will spawn a new thread for each async send.
|
||||
* Constructs a new publisher. This publisher will spawn a new thread for
|
||||
* each async send.
|
||||
*/
|
||||
public Publisher() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs a new publisher with an optional ThreadPoolExector for sending updates.
|
||||
* Constructs a new publisher with an optional ThreadPoolExector for sending
|
||||
* updates.
|
||||
*/
|
||||
public Publisher(final ThreadPoolExecutor executor) {
|
||||
this.executor = executor;
|
||||
|
@ -54,7 +56,7 @@ public class Publisher {
|
|||
|
||||
/**
|
||||
* Sends the HUB url a notification of a change in topic
|
||||
*
|
||||
*
|
||||
* @param hub URL of the hub to notify.
|
||||
* @param topic The Topic that has changed
|
||||
* @throws NotificationException Any failure
|
||||
|
@ -91,8 +93,9 @@ public class Publisher {
|
|||
}
|
||||
|
||||
/**
|
||||
* Sends a notification for a feed located at "topic". The feed MUST contain rel="hub".
|
||||
*
|
||||
* Sends a notification for a feed located at "topic". The feed MUST contain
|
||||
* rel="hub".
|
||||
*
|
||||
* @param topic URL for the feed
|
||||
* @param feed The feed itself
|
||||
* @throws NotificationException Any failure
|
||||
|
@ -109,8 +112,9 @@ public class Publisher {
|
|||
}
|
||||
|
||||
/**
|
||||
* Sends a notification for a feed. The feed MUST contain rel="hub" and rel="self" links.
|
||||
*
|
||||
* Sends a notification for a feed. The feed MUST contain rel="hub" and
|
||||
* rel="self" links.
|
||||
*
|
||||
* @param feed The feed to notify
|
||||
* @throws NotificationException Any failure
|
||||
*/
|
||||
|
@ -145,7 +149,7 @@ public class Publisher {
|
|||
|
||||
/**
|
||||
* Sends the HUB url a notification of a change in topic asynchronously
|
||||
*
|
||||
*
|
||||
* @param hub URL of the hub to notify.
|
||||
* @param topic The Topic that has changed
|
||||
* @param callback A callback invoked when the notification completes.
|
||||
|
@ -172,8 +176,9 @@ public class Publisher {
|
|||
}
|
||||
|
||||
/**
|
||||
* Asynchronously sends a notification for a feed located at "topic". The feed MUST contain rel="hub".
|
||||
*
|
||||
* Asynchronously sends a notification for a feed located at "topic". The
|
||||
* feed MUST contain rel="hub".
|
||||
*
|
||||
* @param topic URL for the feed
|
||||
* @param feed The feed itself
|
||||
* @param callback A callback invoked when the notification completes.
|
||||
|
@ -200,8 +205,9 @@ public class Publisher {
|
|||
}
|
||||
|
||||
/**
|
||||
* Asyncronously sends a notification for a feed. The feed MUST contain rel="hub" and rel="self" links.
|
||||
*
|
||||
* Asyncronously sends a notification for a feed. The feed MUST contain
|
||||
* rel="hub" and rel="self" links.
|
||||
*
|
||||
* @param feed The feed to notify
|
||||
* @param callback A callback invoked when the notification completes.
|
||||
* @throws NotificationException Any failure
|
||||
|
@ -232,7 +238,7 @@ public class Publisher {
|
|||
public static interface AsyncNotificationCallback {
|
||||
/**
|
||||
* Called when a notification fails
|
||||
*
|
||||
*
|
||||
* @param thrown Whatever was thrown during the failure
|
||||
*/
|
||||
public void onFailure(Throwable thrown);
|
||||
|
|
|
@ -21,7 +21,7 @@ package org.rometools.certiorem.sub;
|
|||
import org.rometools.certiorem.sub.data.Subscription;
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
* @author robert.cooper
|
||||
*/
|
||||
public interface Requester {
|
||||
|
|
|
@ -45,7 +45,7 @@ import com.sun.syndication.io.FeedException;
|
|||
import com.sun.syndication.io.SyndFeedInput;
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
* @author robert.cooper
|
||||
*/
|
||||
public class Subscriptions {
|
||||
|
|
|
@ -19,7 +19,7 @@
|
|||
package org.rometools.certiorem.sub.data;
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
* @author robert.cooper
|
||||
*/
|
||||
public interface SubDAO {
|
||||
|
|
|
@ -21,10 +21,14 @@ package org.rometools.certiorem.sub.data;
|
|||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
* @author robert.cooper
|
||||
*/
|
||||
public class Subscription implements Serializable {
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private static final long serialVersionUID = 1L;
|
||||
private String id;
|
||||
private String sourceUrl;
|
||||
private String verifyToken;
|
||||
|
@ -35,7 +39,7 @@ public class Subscription implements Serializable {
|
|||
|
||||
/**
|
||||
* Set the value of expirationTime
|
||||
*
|
||||
*
|
||||
* @param newexpirationTime new value of expirationTime
|
||||
*/
|
||||
public void setExpirationTime(final long newexpirationTime) {
|
||||
|
@ -44,7 +48,7 @@ public class Subscription implements Serializable {
|
|||
|
||||
/**
|
||||
* Get the value of expirationTime
|
||||
*
|
||||
*
|
||||
* @return the value of expirationTime
|
||||
*/
|
||||
public long getExpirationTime() {
|
||||
|
@ -53,7 +57,7 @@ public class Subscription implements Serializable {
|
|||
|
||||
/**
|
||||
* Set the value of id
|
||||
*
|
||||
*
|
||||
* @param newid new value of id
|
||||
*/
|
||||
public void setId(final String newid) {
|
||||
|
@ -62,7 +66,7 @@ public class Subscription implements Serializable {
|
|||
|
||||
/**
|
||||
* Get the value of id
|
||||
*
|
||||
*
|
||||
* @return the value of id
|
||||
*/
|
||||
public String getId() {
|
||||
|
@ -71,7 +75,7 @@ public class Subscription implements Serializable {
|
|||
|
||||
/**
|
||||
* Set the value of sourceUrl
|
||||
*
|
||||
*
|
||||
* @param newsourceUrl new value of sourceUrl
|
||||
*/
|
||||
public void setSourceUrl(final String newsourceUrl) {
|
||||
|
@ -80,7 +84,7 @@ public class Subscription implements Serializable {
|
|||
|
||||
/**
|
||||
* Get the value of sourceUrl
|
||||
*
|
||||
*
|
||||
* @return the value of sourceUrl
|
||||
*/
|
||||
public String getSourceUrl() {
|
||||
|
@ -89,7 +93,7 @@ public class Subscription implements Serializable {
|
|||
|
||||
/**
|
||||
* Set the value of unsubscribed
|
||||
*
|
||||
*
|
||||
* @param newunsubscribed new value of unsubscribed
|
||||
*/
|
||||
public void setUnsubscribed(final boolean newunsubscribed) {
|
||||
|
@ -98,7 +102,7 @@ public class Subscription implements Serializable {
|
|||
|
||||
/**
|
||||
* Get the value of unsubscribed
|
||||
*
|
||||
*
|
||||
* @return the value of unsubscribed
|
||||
*/
|
||||
public boolean isUnsubscribed() {
|
||||
|
@ -107,7 +111,7 @@ public class Subscription implements Serializable {
|
|||
|
||||
/**
|
||||
* Set the value of validated
|
||||
*
|
||||
*
|
||||
* @param newvalidated new value of validated
|
||||
*/
|
||||
public void setValidated(final boolean newvalidated) {
|
||||
|
@ -116,7 +120,7 @@ public class Subscription implements Serializable {
|
|||
|
||||
/**
|
||||
* Get the value of validated
|
||||
*
|
||||
*
|
||||
* @return the value of validated
|
||||
*/
|
||||
public boolean isValidated() {
|
||||
|
@ -125,7 +129,7 @@ public class Subscription implements Serializable {
|
|||
|
||||
/**
|
||||
* Set the value of verifyToken
|
||||
*
|
||||
*
|
||||
* @param newverifyToken new value of verifyToken
|
||||
*/
|
||||
public void setVerifyToken(final String newverifyToken) {
|
||||
|
@ -134,7 +138,7 @@ public class Subscription implements Serializable {
|
|||
|
||||
/**
|
||||
* Get the value of verifyToken
|
||||
*
|
||||
*
|
||||
* @return the value of verifyToken
|
||||
*/
|
||||
public String getVerifyToken() {
|
||||
|
|
|
@ -8,7 +8,7 @@ package org.rometools.certiorem.sub.data;
|
|||
import org.rometools.fetcher.impl.SyndFeedInfo;
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
* @author najmi
|
||||
*/
|
||||
public interface SubscriptionCallback {
|
||||
|
|
|
@ -32,7 +32,7 @@ import org.rometools.certiorem.sub.data.SubDAO;
|
|||
import org.rometools.certiorem.sub.data.Subscription;
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
* @author robert.cooper
|
||||
*/
|
||||
public class InMemorySubDAO implements SubDAO {
|
||||
|
|
|
@ -27,7 +27,7 @@ import org.rometools.certiorem.sub.Requester;
|
|||
import org.rometools.certiorem.sub.data.Subscription;
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
* @author robert.cooper
|
||||
*/
|
||||
public abstract class AbstractRequester implements Requester {
|
||||
|
|
|
@ -26,7 +26,7 @@ import org.rometools.certiorem.sub.data.Subscription;
|
|||
|
||||
/**
|
||||
* A simple requester implementation that always makes requests as Async.
|
||||
*
|
||||
*
|
||||
* @author robert.cooper
|
||||
*/
|
||||
public class AsyncRequester extends AbstractRequester {
|
||||
|
|
|
@ -30,7 +30,7 @@ import org.rometools.certiorem.sub.data.Subscription;
|
|||
|
||||
/**
|
||||
* A simple requester implementation that always makes requests as Async.
|
||||
*
|
||||
*
|
||||
* @author Farrukh Najmi
|
||||
*/
|
||||
public class SyncRequester extends AbstractRequester {
|
||||
|
|
|
@ -30,10 +30,14 @@ import org.rometools.certiorem.HttpStatusCodeException;
|
|||
import org.rometools.certiorem.hub.Hub;
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
* @author robert.cooper
|
||||
*/
|
||||
public abstract class AbstractHubServlet extends HttpServlet {
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private static final long serialVersionUID = 1L;
|
||||
public static final String HUBMODE = "hub.mode";
|
||||
private final Hub hub;
|
||||
|
||||
|
|
|
@ -30,11 +30,15 @@ import org.rometools.certiorem.HttpStatusCodeException;
|
|||
import org.rometools.certiorem.sub.Subscriptions;
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
* @author robert.cooper
|
||||
*/
|
||||
public class AbstractSubServlet extends HttpServlet {
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private static final long serialVersionUID = 1L;
|
||||
private final Subscriptions subscriptions;
|
||||
|
||||
protected AbstractSubServlet(final Subscriptions subscriptions) {
|
||||
|
|
|
@ -21,7 +21,7 @@ package org.rometools.certiorem.hub;
|
|||
import org.rometools.certiorem.hub.data.Subscriber;
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
* @author robert.cooper
|
||||
*/
|
||||
public class AlwaysVerifier implements Verifier {
|
||||
|
|
|
@ -36,7 +36,7 @@ import org.rometools.fetcher.impl.HashMapFeedInfoCache;
|
|||
import org.rometools.fetcher.impl.HttpURLFeedFetcher;
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
* @author robert.cooper
|
||||
*/
|
||||
public class ControllerTest {
|
||||
|
|
|
@ -19,7 +19,7 @@ import com.sun.syndication.feed.synd.SyndEntry;
|
|||
import com.sun.syndication.feed.synd.SyndFeed;
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
* @author najmi
|
||||
*/
|
||||
public class DeltaSyndFeedInfoTest {
|
||||
|
@ -44,7 +44,8 @@ public class DeltaSyndFeedInfoTest {
|
|||
List<SyndEntry> entries = feed.getEntries();
|
||||
assertTrue(!entries.isEmpty());
|
||||
|
||||
// Fetch again and this time the entries should be empty as none have changed.
|
||||
// Fetch again and this time the entries should be empty as none have
|
||||
// changed.
|
||||
feed = feedFetcher.retrieveFeed(getFeedUrl());
|
||||
entries = feed.getEntries();
|
||||
assertTrue(entries.isEmpty());
|
||||
|
@ -52,7 +53,8 @@ public class DeltaSyndFeedInfoTest {
|
|||
|
||||
private URL getFeedUrl() throws IOException {
|
||||
final URL feedUrl = new URL("http://news.google.com/news?pz=1&cf=all&ned=us&hl=en&output=rss");
|
||||
// URL feedUrl = new URL("http://newsrss.bbc.co.uk/rss/newsonline_world_edition/front_page/rss.xml");
|
||||
// URL feedUrl = new
|
||||
// URL("http://newsrss.bbc.co.uk/rss/newsonline_world_edition/front_page/rss.xml");
|
||||
return feedUrl;
|
||||
}
|
||||
|
||||
|
|
|
@ -21,7 +21,7 @@ package org.rometools.certiorem.hub;
|
|||
import org.rometools.certiorem.hub.data.Subscriber;
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
* @author robert.cooper
|
||||
*/
|
||||
public class ExceptionVerifier implements Verifier {
|
||||
|
|
|
@ -21,7 +21,7 @@ package org.rometools.certiorem.hub;
|
|||
import org.rometools.certiorem.hub.data.Subscriber;
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
* @author robert.cooper
|
||||
*/
|
||||
public class NeverVerifier implements Verifier {
|
||||
|
|
|
@ -25,7 +25,7 @@ import java.util.logging.Logger;
|
|||
import org.junit.Test;
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
* @author robert.cooper
|
||||
*/
|
||||
public abstract class AbstractDAOTest {
|
||||
|
@ -46,7 +46,7 @@ public abstract class AbstractDAOTest {
|
|||
|
||||
assert result.equals(subscriber) : "Subscriber not equal.";
|
||||
|
||||
final List<Subscriber> subscribers = (List<Subscriber>) instance.subscribersForTopic(subscriber.getTopic());
|
||||
final List<? extends Subscriber> subscribers = instance.subscribersForTopic(subscriber.getTopic());
|
||||
|
||||
assert subscribers.contains(result) : "Subscriber not in result.";
|
||||
}
|
||||
|
@ -65,11 +65,11 @@ public abstract class AbstractDAOTest {
|
|||
|
||||
assert subscriber.equals(result) : "Subscriber not equal.";
|
||||
// quick test for store.
|
||||
List<Subscriber> subscribers = (List<Subscriber>) instance.subscribersForTopic(subscriber.getTopic());
|
||||
List<? extends Subscriber> subscribers = instance.subscribersForTopic(subscriber.getTopic());
|
||||
assert subscribers.contains(result) : "Subscriber not in result.";
|
||||
// sleep past expiration
|
||||
Thread.sleep(1100);
|
||||
subscribers = (List<Subscriber>) instance.subscribersForTopic(subscriber.getTopic());
|
||||
subscribers = instance.subscribersForTopic(subscriber.getTopic());
|
||||
assert !subscribers.contains(result) : "Subscriber should have expired";
|
||||
}
|
||||
|
||||
|
@ -83,8 +83,8 @@ public abstract class AbstractDAOTest {
|
|||
subscriber.setLeaseSeconds(1);
|
||||
subscriber.setVerify("VerifyMe");
|
||||
|
||||
final Subscriber result = instance.addSubscriber(subscriber);
|
||||
// TODO
|
||||
// final Subscriber result = instance.addSubscriber(subscriber);
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -22,7 +22,7 @@ import org.rometools.certiorem.hub.data.AbstractDAOTest;
|
|||
import org.rometools.certiorem.hub.data.HubDAO;
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
* @author robert.cooper
|
||||
*/
|
||||
public class InMemoryDAOTest extends AbstractDAOTest {
|
||||
|
|
Loading…
Reference in a new issue