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
|
@ -24,6 +24,8 @@ package org.rometools.certiorem;
|
|||
*/
|
||||
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,7 +10,8 @@ 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
|
||||
|
|
|
@ -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,7 +41,8 @@ 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
|
||||
*/
|
||||
|
@ -65,7 +69,8 @@ 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
|
||||
*/
|
||||
|
@ -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,7 +39,8 @@ 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
|
||||
|
@ -72,8 +73,8 @@ 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();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -81,9 +82,12 @@ public class Hub {
|
|||
*
|
||||
* @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);
|
||||
|
@ -156,9 +171,11 @@ public class Hub {
|
|||
* @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) {
|
||||
|
|
|
@ -31,13 +31,15 @@ import com.sun.syndication.feed.synd.SyndFeed;
|
|||
*/
|
||||
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.
|
||||
|
|
|
@ -69,7 +69,8 @@ public interface Verifier {
|
|||
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 {
|
||||
/**
|
||||
|
|
|
@ -25,6 +25,10 @@ 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;
|
||||
|
|
|
@ -25,6 +25,10 @@ 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;
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -37,6 +37,10 @@ import org.rometools.certiorem.hub.data.Subscriber;
|
|||
@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;
|
||||
|
|
|
@ -89,7 +89,7 @@ public class InMemoryHubDAO implements HubDAO {
|
|||
|
||||
return result;
|
||||
} else {
|
||||
return Collections.EMPTY_LIST;
|
||||
return Collections.emptyList();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -43,17 +43,19 @@ import com.sun.syndication.io.SyndFeedOutput;
|
|||
*/
|
||||
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")) {
|
||||
|
@ -98,8 +100,9 @@ public abstract class AbstractNotifier implements Notifier {
|
|||
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
|
||||
|
|
|
@ -28,7 +28,8 @@ 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
|
||||
*/
|
||||
|
@ -51,8 +52,9 @@ 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
|
||||
*/
|
||||
|
|
|
@ -18,8 +18,6 @@
|
|||
|
||||
package org.rometools.certiorem.hub.notify.standard;
|
||||
|
||||
import java.util.concurrent.ConcurrentSkipListSet;
|
||||
|
||||
import org.rometools.certiorem.hub.data.SubscriptionSummary;
|
||||
|
||||
/**
|
||||
|
@ -28,20 +26,19 @@ import org.rometools.certiorem.hub.data.SubscriptionSummary;
|
|||
* @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,7 +34,8 @@ 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
|
||||
*/
|
||||
|
@ -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();
|
||||
|
|
|
@ -24,6 +24,11 @@ package org.rometools.certiorem.pub;
|
|||
*/
|
||||
public class NotificationException extends Exception {
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
public NotificationException(final String message) {
|
||||
super(message);
|
||||
}
|
||||
|
|
|
@ -40,13 +40,15 @@ 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;
|
||||
|
@ -91,7 +93,8 @@ 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
|
||||
|
@ -109,7 +112,8 @@ 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
|
||||
|
@ -172,7 +176,8 @@ 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
|
||||
|
@ -200,7 +205,8 @@ 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.
|
||||
|
|
|
@ -25,6 +25,10 @@ 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;
|
||||
|
|
|
@ -34,6 +34,10 @@ 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;
|
||||
|
||||
|
|
|
@ -35,6 +35,10 @@ import org.rometools.certiorem.sub.Subscriptions;
|
|||
*/
|
||||
public class AbstractSubServlet extends HttpServlet {
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private static final long serialVersionUID = 1L;
|
||||
private final Subscriptions subscriptions;
|
||||
|
||||
protected AbstractSubServlet(final Subscriptions subscriptions) {
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
@ -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);
|
||||
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue