@@ -0,0 +1,2792 @@
+package net.kencochrane.raven;%0A%0Aimport com.fasterxml.jackson.databind.ObjectMapper;%0A%0Aimport java.io.IOException;%0Aimport java.net.HttpURLConnection;%0Aimport java.net.MalformedURLException;%0Aimport java.net.URL;%0Aimport java.util.Map;%0Aimport java.util.logging.Level;%0Aimport java.util.logging.Logger;%0A%0Apublic class SentryStub %7B%0A    private static final Logger logger = Logger.getLogger(SentryStub.class.getCanonicalName());%0A    private static final URL DEFAULT_URL;%0A    private final URL url;%0A    private final ObjectMapper mapper = new ObjectMapper();%0A%0A    static %7B%0A        URL url = null;%0A        try %7B%0A            url = new URL(%22http://localhost:8080/stub/%22);%0A        %7D catch (MalformedURLException e) %7B%0A            logger.log(Level.FINE, %22Couldn't create the URL http://localhost:8080/stub%22, e);%0A        %7D%0A%0A        DEFAULT_URL = url;%0A    %7D%0A%0A    public SentryStub() %7B%0A        this(DEFAULT_URL);%0A    %7D%0A%0A    public SentryStub(URL url) %7B%0A        this.url = url;%0A    %7D%0A%0A    public int getEventCount() %7B%0A        try %7B%0A            HttpURLConnection connection = connnectTo(%22count%22);%0A            connection.setRequestMethod(%22GET%22);%0A            return (Integer) getContent(connection).get(%22count%22);%0A        %7D catch (Exception e) %7B%0A            logger.log(Level.SEVERE, %22Couldn't get the number of events created.%22, e);%0A            return -1;%0A        %7D%0A    %7D%0A%0A    public void removeEvents() %7B%0A        try %7B%0A            HttpURLConnection connection = connnectTo(%22cleanup%22);%0A            connection.setRequestMethod(%22DELETE%22);%0A            connection.setDoOutput(false);%0A            connection.connect();%0A            connection.getInputStream().close();%0A        %7D catch (Exception e) %7B%0A            logger.log(Level.SEVERE, %22Couldn't remove stub events.%22, e);%0A        %7D%0A    %7D%0A%0A    private Map%3CString, Object%3E getContent(HttpURLConnection connection) %7B%0A        try %7B%0A            connection.setDoInput(true);%0A            connection.connect();%0A            try %7B%0A                connection.getOutputStream().close();%0A            %7D catch (IOException e) %7B%0A                logger.log(Level.FINE, %22Couldn't open and close the outputstream%22, e);%0A            %7D%0A            return (Map%3CString, Object%3E) mapper.readValue(connection.getInputStream(), Map.class);%0A        %7D catch (Exception e) %7B%0A            throw new IllegalStateException(%0A                    %22Couldn't get the JSON content for the connection '%22 + connection + %22'%22, e);%0A        %7D%0A    %7D%0A%0A    private HttpURLConnection connnectTo(String path) %7B%0A        try %7B%0A            URL test = new URL(url, path);%0A            return (HttpURLConnection) test.openConnection();%0A        %7D catch (Exception e) %7B%0A            throw new IllegalStateException(%0A                    %22Couldn't open a connection to the path '%22 + path + %22' in '%22 + url + %22'%22, e);%0A        %7D%0A    %7D%0A%7D%0A

Create a SentryStub client for ITs