Migrated logging to SLF4J

This commit is contained in:
Patrick Gotthard 2014-04-14 19:10:23 +02:00
parent bf527ec7aa
commit 00c4101063
12 changed files with 141 additions and 114 deletions

View file

@ -78,6 +78,15 @@
<artifactId>persistence-api</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
</dependency>
<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>

View file

@ -25,8 +25,6 @@ import java.util.Collections;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import java.util.logging.Level;
import java.util.logging.Logger;
import org.rometools.certiorem.HttpStatusCodeException;
import org.rometools.certiorem.hub.Notifier.SubscriptionSummaryCallback;
@ -35,17 +33,21 @@ import org.rometools.certiorem.hub.data.HubDAO;
import org.rometools.certiorem.hub.data.Subscriber;
import org.rometools.certiorem.hub.data.SubscriptionSummary;
import org.rometools.fetcher.FeedFetcher;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
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
* notification methods you might want to use.
* 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 {
private static final Logger LOG = LoggerFactory.getLogger(Hub.class);
private static final HashSet<String> STANDARD_SCHEMES = new HashSet<String>();
static {
@ -82,12 +84,9 @@ 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) {
@ -118,20 +117,19 @@ public class Hub {
/**
* 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;
Logger.getLogger(Hub.class.getName()).log(Level.FINE, "Sending notification for {0}", topic);
LOG.debug("Sending notification for {}", topic);
try {
final List<? extends Subscriber> subscribers = dao.subscribersForTopic(topic);
if (subscribers.isEmpty()) {
Logger.getLogger(Hub.class.getName()).log(Level.FINE, "No subscribers to notify for {0}", topic);
LOG.debug("No subscribers to notify for {}", topic);
return;
}
@ -149,7 +147,7 @@ public class Hub {
final StringBuilder userAgent = new StringBuilder("ROME-Certiorem (+http://").append(requestHost).append("; ").append(total)
.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() });
LOG.debug("Got feed for {} Sending to {} subscribers.", topic, subscribers.size());
notifier.notifySubscribers(subscribers, feed, new SubscriptionSummaryCallback() {
@Override
public void onSummaryInfo(final SubscriptionSummary summary) {
@ -157,7 +155,7 @@ public class Hub {
}
});
} catch (final Exception ex) {
Logger.getLogger(Hub.class.getName()).log(Level.SEVERE, "Exception getting " + topic, ex);
LOG.debug("Exception getting " + topic, ex);
throw new HttpStatusCodeException(500, ex.getMessage(), ex);
}
}
@ -171,15 +169,14 @@ 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) {
Logger.getLogger(Hub.class.getName()).log(Level.FINE, "{0} wants to subscribe to {1}", new Object[] { callback, topic });
LOG.debug("{} wants to subscribe to {}", callback, topic);
try {
try {
assert callback != null : "Callback URL is required.";
@ -206,8 +203,7 @@ public class Hub {
@Override
public void onVerify(final boolean verified) {
if (verified) {
Logger.getLogger(Hub.class.getName()).log(Level.FINE, "Verified {0} subscribed to {1}",
new Object[] { subscriber.getCallback(), subscriber.getTopic() });
LOG.debug("Verified {} subscribed to {}", subscriber.getCallback(), subscriber.getTopic());
dao.addSubscriber(subscriber);
}
}
@ -248,8 +244,7 @@ public class Hub {
@Override
public void onVerify(final boolean verified) {
Logger.getLogger(Hub.class.getName()).log(Level.FINE, "Unsubscribe for {0} at {1} verified {2}",
new Object[] { subscriber.getTopic(), subscriber.getCallback(), verified });
LOG.debug("Unsubscribe for {} at {} verified {}", subscriber.getTopic(), subscriber.getCallback(), verified);
if (verified) {
dao.removeSubscriber(topic, callback);
}

View file

@ -26,12 +26,12 @@ import java.net.HttpURLConnection;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.List;
import java.util.logging.Level;
import java.util.logging.Logger;
import org.rometools.certiorem.hub.Notifier;
import org.rometools.certiorem.hub.data.Subscriber;
import org.rometools.certiorem.hub.data.SubscriptionSummary;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.sun.syndication.feed.synd.SyndFeed;
import com.sun.syndication.io.FeedException;
@ -42,20 +42,23 @@ import com.sun.syndication.io.SyndFeedOutput;
* @author robert.cooper
*/
public abstract class AbstractNotifier implements Notifier {
private static final Logger LOG = LoggerFactory.getLogger(AbstractNotifier.class);
/**
* 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<? extends Subscriber> subscribers, final SyndFeed value, final SubscriptionSummaryCallback callback) {
String mimeType = null;
if (value.getFeedType().startsWith("rss")) {
@ -71,10 +74,10 @@ public abstract class AbstractNotifier implements Notifier {
output.output(value, new OutputStreamWriter(baos));
baos.close();
} catch (final IOException ex) {
Logger.getLogger(AbstractNotifier.class.getName()).log(Level.SEVERE, null, ex);
LOG.error("Unable to output the feed", ex);
throw new RuntimeException("Unable to output the feed.", ex);
} catch (final FeedException ex) {
Logger.getLogger(AbstractNotifier.class.getName()).log(Level.SEVERE, null, ex);
LOG.error("Unable to output the feed", ex);
throw new RuntimeException("Unable to output the feed.", ex);
}
@ -100,9 +103,8 @@ 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
@ -114,7 +116,7 @@ public abstract class AbstractNotifier implements Notifier {
try {
final URL target = new URL(subscriber.getCallback());
Logger.getLogger(AbstractNotifier.class.getName()).log(Level.INFO, "Posting notification to subscriber {0}", subscriber.getCallback());
LOG.info("Posting notification to subscriber {}", subscriber.getCallback());
result.setHost(target.getHost());
final HttpURLConnection connection = (HttpURLConnection) target.openConnection();
@ -132,9 +134,8 @@ public abstract class AbstractNotifier implements Notifier {
connection.disconnect();
if (responseCode != 200) {
Logger.getLogger(AbstractNotifier.class.getName()).log(Level.WARNING, "Got code " + responseCode + " from " + target);
LOG.warn("Got code {} from {}", responseCode, target);
result.setLastPublishSuccessful(false);
return result;
}
@ -142,17 +143,17 @@ public abstract class AbstractNotifier implements Notifier {
try {
result.setSubscribers(Integer.parseInt(subscribers));
} catch (final NumberFormatException nfe) {
Logger.getLogger(AbstractNotifier.class.getName()).log(Level.WARNING, "Invalid subscriber value " + subscribers + " " + target, nfe);
LOG.warn("Invalid subscriber value " + subscribers + " " + target, nfe);
result.setSubscribers(-1);
}
} else {
result.setSubscribers(-1);
}
} catch (final MalformedURLException ex) {
Logger.getLogger(AbstractNotifier.class.getName()).log(Level.WARNING, null, ex);
LOG.warn(null, ex);
result.setLastPublishSuccessful(false);
} catch (final IOException ex) {
Logger.getLogger(AbstractNotifier.class.getName()).log(Level.SEVERE, null, ex);
LOG.error(null, ex);
result.setLastPublishSuccessful(false);
}

View file

@ -27,19 +27,22 @@ import java.net.HttpURLConnection;
import java.net.URL;
import java.net.URLEncoder;
import java.util.UUID;
import java.util.logging.Level;
import java.util.logging.Logger;
import org.rometools.certiorem.hub.Verifier;
import org.rometools.certiorem.hub.data.Subscriber;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
* 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 {
private static final Logger LOG = LoggerFactory.getLogger(AbstractVerifier.class);
@Override
public boolean verifySubcribeSyncronously(final Subscriber subscriber) {
return doOp(Verifier.MODE_SUBSCRIBE, subscriber);
@ -85,11 +88,10 @@ public abstract class AbstractVerifier implements Verifier {
return true;
}
} catch (final UnsupportedEncodingException ex) {
Logger.getLogger(AbstractVerifier.class.getName()).log(Level.SEVERE, null, ex);
LOG.error("Unsupported encoding", ex);
throw new RuntimeException("Should not happen. UTF-8 threw unsupported encoding", ex);
} catch (final IOException ex) {
Logger.getLogger(AbstractVerifier.class.getName()).log(Level.SEVERE, null, ex);
LOG.error("An IOException occured", ex);
return false;
}
}

View file

@ -25,8 +25,9 @@ import java.net.HttpURLConnection;
import java.net.URL;
import java.net.URLEncoder;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.logging.Level;
import java.util.logging.Logger;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.sun.syndication.feed.synd.SyndFeed;
import com.sun.syndication.feed.synd.SyndLink;
@ -37,18 +38,19 @@ import com.sun.syndication.feed.synd.SyndLink;
* @author robert.cooper
*/
public class Publisher {
private static final Logger LOG = LoggerFactory.getLogger(Publisher.class);
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;
@ -84,17 +86,16 @@ public class Publisher {
}
} catch (final UnsupportedEncodingException ex) {
Logger.getLogger(Publisher.class.getName()).log(Level.SEVERE, null, ex);
LOG.error("Could not encode URL", ex);
throw new NotificationException("Could not encode URL", ex);
} catch (final IOException ex) {
Logger.getLogger(Publisher.class.getName()).log(Level.SEVERE, null, ex);
LOG.error("Communication error", ex);
throw new NotificationException("Unable to communicate with " + hub, ex);
}
}
/**
* 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
@ -112,8 +113,7 @@ 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
@ -176,8 +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
@ -205,8 +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.

View file

@ -28,8 +28,6 @@ import java.net.URI;
import java.net.URISyntaxException;
import java.net.URL;
import java.util.UUID;
import java.util.logging.Level;
import java.util.logging.Logger;
import org.rometools.certiorem.HttpStatusCodeException;
import org.rometools.certiorem.sub.Requester.RequestCallback;
@ -38,6 +36,8 @@ import org.rometools.certiorem.sub.data.Subscription;
import org.rometools.certiorem.sub.data.SubscriptionCallback;
import org.rometools.fetcher.impl.FeedFetcherCache;
import org.rometools.fetcher.impl.SyndFeedInfo;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.sun.syndication.feed.synd.SyndFeed;
import com.sun.syndication.feed.synd.SyndLink;
@ -50,7 +50,7 @@ import com.sun.syndication.io.SyndFeedInput;
*/
public class Subscriptions {
private static final Logger LOGGER = Logger.getLogger(Subscriptions.class.getName());
private static final Logger LOG = LoggerFactory.getLogger(Subscriptions.class);
// TODO unsubscribe.
private FeedFetcherCache cache;
@ -72,7 +72,7 @@ public class Subscriptions {
try {
this.callback(callbackPath, feed.getBytes("UTF-8"));
} catch (final UnsupportedEncodingException ex) {
LOGGER.log(Level.SEVERE, null, ex);
LOG.error("Unable to parse feed", ex);
throw new HttpStatusCodeException(400, "Unable to parse feed.", ex);
}
}
@ -83,10 +83,10 @@ public class Subscriptions {
try {
this.callback(callbackPath, input.build(new InputStreamReader(feed)));
} catch (final IllegalArgumentException ex) {
LOGGER.log(Level.SEVERE, null, ex);
LOG.error("Unable to parse feed", ex);
throw new HttpStatusCodeException(500, "Unable to parse feed.", ex);
} catch (final FeedException ex) {
LOGGER.log(Level.SEVERE, null, ex);
LOG.error("Unable to parse feed", ex);
throw new HttpStatusCodeException(400, "Unable to parse feed.", ex);
}
}
@ -102,7 +102,7 @@ public class Subscriptions {
}
final String id = callbackPath.substring(callbackPrefix.length());
LOGGER.log(Level.FINE, "Got callback for {0}", id);
LOG.debug("Got callback for {}", id);
final Subscription s = dao.findById(id);
if (s == null) {
@ -118,7 +118,7 @@ public class Subscriptions {
url = new URL(s.getSourceUrl());
info = cache.getFeedInfo(url);
} catch (final MalformedURLException ex) {
LOGGER.log(Level.SEVERE, null, ex);
LOG.error("Malformed URL", ex);
}
if (info == null) {
@ -196,7 +196,7 @@ public class Subscriptions {
}
final String id = callbackPath.substring(callbackPrefix.length());
LOGGER.log(Level.FINE, "Handling validation request for id {0}", id);
LOG.debug("Handling validation request for id {}", id);
final Subscription s = dao.findById(id);
if (s == null) {
throw new HttpStatusCodeException(404, "Not a valid subscription id", null);
@ -221,7 +221,7 @@ public class Subscriptions {
} else {
throw new HttpStatusCodeException(400, "Unsupported mode " + mode, null);
}
LOGGER.log(Level.FINE, "Validated. Returning {0}", challenge);
LOG.debug("Validated. Returning {}", challenge);
return challenge;
}
@ -248,7 +248,7 @@ public class Subscriptions {
break;
} catch (final URISyntaxException ex) {
LOGGER.log(Level.SEVERE, null, ex);
LOG.error(null, ex);
}
}
}

View file

@ -25,11 +25,11 @@ package org.rometools.certiorem.sub.data.ram;
import java.util.Date;
import java.util.concurrent.ConcurrentHashMap;
import java.util.logging.Level;
import java.util.logging.Logger;
import org.rometools.certiorem.sub.data.SubDAO;
import org.rometools.certiorem.sub.data.Subscription;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
*
@ -37,6 +37,8 @@ import org.rometools.certiorem.sub.data.Subscription;
*/
public class InMemorySubDAO implements SubDAO {
private static final Logger LOG = LoggerFactory.getLogger(InMemorySubDAO.class);
private final ConcurrentHashMap<String, Subscription> subscriptions = new ConcurrentHashMap<String, Subscription>();
@Override
@ -46,8 +48,7 @@ public class InMemorySubDAO implements SubDAO {
return null;
}
if (s.getExpirationTime() > 0 && s.getExpirationTime() <= System.currentTimeMillis()) {
Logger.getLogger(InMemorySubDAO.class.getName()).log(Level.FINE, "Subscription {0} expired at {1}",
new Object[] { s.getSourceUrl(), new Date(s.getExpirationTime()) });
LOG.debug("Subscription {} expired at {}", s.getSourceUrl(), new Date(s.getExpirationTime()));
subscriptions.remove(id);
return null;
@ -58,7 +59,7 @@ public class InMemorySubDAO implements SubDAO {
@Override
public Subscription addSubscription(final Subscription s) {
subscriptions.put(s.getId(), s);
Logger.getLogger(InMemorySubDAO.class.getName()).log(Level.FINE, "Stored subscription {0} {1}", new Object[] { s.getSourceUrl(), s.getId() });
LOG.debug("Stored subscription {} {}", s.getSourceUrl(), s.getId());
return s;
}

View file

@ -19,10 +19,10 @@
package org.rometools.certiorem.sub.request;
import java.io.IOException;
import java.util.logging.Level;
import java.util.logging.Logger;
import org.rometools.certiorem.sub.data.Subscription;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
* A simple requester implementation that always makes requests as Async.
@ -30,18 +30,20 @@ import org.rometools.certiorem.sub.data.Subscription;
* @author robert.cooper
*/
public class AsyncRequester extends AbstractRequester {
private static final Logger LOG = LoggerFactory.getLogger(AsyncRequester.class);
@Override
public void sendSubscribeRequest(final String hubUrl, final Subscription subscription, final String verifySync, final long leaseSeconds,
final String secret, final String callbackUrl, final RequestCallback callback) {
Logger.getLogger(AsyncRequester.class.getName()).log(Level.FINE, "Sending subscribe request to {0} for {1} to {2}",
new Object[] { hubUrl, subscription.getSourceUrl(), callbackUrl });
LOG.debug("Sending subscribe request to {} for {} to {}", hubUrl, subscription.getSourceUrl(), callbackUrl);
final Runnable r = new Runnable() {
@Override
public void run() {
try {
sendRequest(hubUrl, "subscribe", subscription, verifySync, leaseSeconds, secret, callbackUrl, callback);
} catch (final Exception ex) {
Logger.getLogger(AsyncRequester.class.getName()).log(Level.SEVERE, null, ex);
LOG.error(null, ex);
callback.onFailure(ex);
}
}
@ -52,15 +54,14 @@ public class AsyncRequester extends AbstractRequester {
@Override
public void sendUnsubscribeRequest(final String hubUrl, final Subscription subscription, final String verifySync, final String secret,
final String callbackUrl, final RequestCallback callback) {
Logger.getLogger(AsyncRequester.class.getName()).log(Level.FINE, "Sending unsubscribe request to {0} for {1} to {2}",
new Object[] { hubUrl, subscription.getSourceUrl(), callbackUrl });
LOG.debug("Sending unsubscribe request to {} for {} to {}", hubUrl, subscription.getSourceUrl(), callbackUrl);
final Runnable r = new Runnable() {
@Override
public void run() {
try {
sendRequest(hubUrl, "unsubscribe", subscription, verifySync, -1, secret, callbackUrl, callback);
} catch (final IOException ex) {
Logger.getLogger(AsyncRequester.class.getName()).log(Level.SEVERE, null, ex);
LOG.error(null, ex);
callback.onFailure(ex);
}
}

View file

@ -23,10 +23,10 @@
package org.rometools.certiorem.sub.request;
import java.io.IOException;
import java.util.logging.Level;
import java.util.logging.Logger;
import org.rometools.certiorem.sub.data.Subscription;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
* A simple requester implementation that always makes requests as Async.
@ -34,16 +34,18 @@ import org.rometools.certiorem.sub.data.Subscription;
* @author Farrukh Najmi
*/
public class SyncRequester extends AbstractRequester {
private static final Logger LOG = LoggerFactory.getLogger(SyncRequester.class);
@Override
public void sendSubscribeRequest(final String hubUrl, final Subscription subscription, final String verifySync, final long leaseSeconds,
final String secret, final String callbackUrl, final RequestCallback callback) {
Logger.getLogger(SyncRequester.class.getName()).log(Level.INFO, "Sending subscribe request to {0} for {1} to {2}",
new Object[] { hubUrl, subscription.getSourceUrl(), callbackUrl });
LOG.info("Sending subscribe request to {} for {} to {}", hubUrl, subscription.getSourceUrl(), callbackUrl);
try {
sendRequest(hubUrl, "subscribe", subscription, verifySync, leaseSeconds, secret, callbackUrl, callback);
callback.onSuccess();
} catch (final Exception ex) {
Logger.getLogger(SyncRequester.class.getName()).log(Level.SEVERE, null, ex);
LOG.error(null, ex);
callback.onFailure(ex);
}
}
@ -51,13 +53,12 @@ public class SyncRequester extends AbstractRequester {
@Override
public void sendUnsubscribeRequest(final String hubUrl, final Subscription subscription, final String verifySync, final String secret,
final String callbackUrl, final RequestCallback callback) {
Logger.getLogger(SyncRequester.class.getName()).log(Level.INFO, "Sending unsubscribe request to {0} for {1} to {2}",
new Object[] { hubUrl, subscription.getSourceUrl(), callbackUrl });
LOG.info("Sending unsubscribe request to {} for {} to {}", hubUrl, subscription.getSourceUrl(), callbackUrl);
try {
sendRequest(hubUrl, "unsubscribe", subscription, verifySync, -1, secret, callbackUrl, callback);
callback.onSuccess();
} catch (final IOException ex) {
Logger.getLogger(SyncRequester.class.getName()).log(Level.SEVERE, null, ex);
LOG.error(null, ex);
callback.onFailure(ex);
}
}

View file

@ -21,8 +21,6 @@ package org.rometools.certiorem.hub;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.fail;
import java.util.logging.Logger;
import org.junit.After;
import org.junit.AfterClass;
import org.junit.Before;
@ -34,12 +32,17 @@ import org.rometools.certiorem.hub.data.ram.InMemoryHubDAO;
import org.rometools.fetcher.FeedFetcher;
import org.rometools.fetcher.impl.HashMapFeedInfoCache;
import org.rometools.fetcher.impl.HttpURLFeedFetcher;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
*
* @author robert.cooper
*/
public class ControllerTest {
private static final Logger LOG = LoggerFactory.getLogger(ControllerTest.class);
public ControllerTest() {
}
@ -64,7 +67,8 @@ public class ControllerTest {
*/
@Test
public void testSubscribe() {
Logger.getLogger(ControllerTest.class.getName()).info("subscribe");
LOG.info("subscribe");
final String callback = "http://localhost/doNothing";
final String topic = "http://feeds.feedburner.com/screaming-penguin";
@ -92,7 +96,7 @@ public class ControllerTest {
fail();
} catch (final HttpStatusCodeException e) {
assertEquals(400, e.getStatus());
Logger.getLogger(ControllerTest.class.getName()).info(e.getMessage());
LOG.info(e.getMessage());
}
try {
@ -100,7 +104,7 @@ public class ControllerTest {
fail();
} catch (final HttpStatusCodeException e) {
assertEquals(400, e.getStatus());
Logger.getLogger(ControllerTest.class.getName()).info(e.getMessage());
LOG.info(e.getMessage());
}
try {
@ -108,7 +112,7 @@ public class ControllerTest {
fail();
} catch (final HttpStatusCodeException e) {
assertEquals(400, e.getStatus());
Logger.getLogger(ControllerTest.class.getName()).info(e.getMessage());
LOG.info(e.getMessage());
}
// test general exception

View file

@ -19,10 +19,10 @@
package org.rometools.certiorem.hub.data;
import java.util.List;
import java.util.logging.Level;
import java.util.logging.Logger;
import org.junit.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
*
@ -30,14 +30,14 @@ import org.junit.Test;
*/
public abstract class AbstractDAOTest {
private static final Logger LOGGER = Logger.getLogger(AbstractDAOTest.class.getName());
private static final Logger LOG = LoggerFactory.getLogger(AbstractDAOTest.class);
protected abstract HubDAO get();
@Test
public void testSubscribe() {
final HubDAO instance = get();
LOGGER.log(Level.INFO, "{0} testSubscribe", instance.getClass().getName());
LOG.info("{} testSubscribe", instance.getClass().getName());
final Subscriber subscriber = new Subscriber();
subscriber.setCallback("http://localhost:9797/noop");
subscriber.setTopic("http://feeds.feedburner.com/screaming-penguin");
@ -56,7 +56,7 @@ public abstract class AbstractDAOTest {
@Test
public void testLeaseExpire() throws InterruptedException {
final HubDAO instance = get();
LOGGER.log(Level.INFO, "{0} testLeaseExpire", instance.getClass().getName());
LOG.info("{} testLeaseExpire", instance.getClass().getName());
final Subscriber subscriber = new Subscriber();
subscriber.setCallback("http://localhost:9797/noop");
subscriber.setTopic("http://feeds.feedburner.com/screaming-penguin");
@ -78,7 +78,7 @@ public abstract class AbstractDAOTest {
@Test
public void testUnsubscribe() throws InterruptedException {
final HubDAO instance = get();
LOGGER.log(Level.INFO, "{0} testUnsubscribe", instance.getClass().getName());
LOG.info("{} testUnsubscribe", instance.getClass().getName());
final Subscriber subscriber = new Subscriber();
subscriber.setCallback("http://localhost:9797/noop");
subscriber.setTopic("http://feeds.feedburner.com/screaming-penguin");

View file

@ -0,0 +1,13 @@
<configuration>
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
<encoder>
<pattern>%d{HH:mm:ss.SSS} [%thread] %-5level %logger - %msg%n</pattern>
</encoder>
</appender>
<root level="warn">
<appender-ref ref="STDOUT" />
</root>
</configuration>