diff --git a/pom.xml b/pom.xml index 222ebf6..df38a6a 100644 --- a/pom.xml +++ b/pom.xml @@ -52,51 +52,29 @@ UTF-8 + UTF-8 central.staging - Nexus Release Repository http://oss.sonatype.org/service/local/staging/deploy/maven2 sonatype.snapshots - My Nexus Snapshots Repository - https://oss.sonatype.org/content/repositories/snapshots/ + https://oss.sonatype.org/content/repositories/snapshots + + + sonatype.snapshots + https://oss.sonatype.org/content/repositories/snapshots + + + - install - src/java - src/test - - - src/java - - **/*.properties - - - - - - src/test - - **/*.xml - **/*.properties - - - - - org.apache.maven.plugins - maven-release-plugin - 2.4.1 - - forked-path - - org.apache.maven.plugins maven-compiler-plugin @@ -106,22 +84,10 @@ 1.6 - - maven-surefire-plugin - - - **/Abstract*.java - **/*Servlet.java - - - **/*Test.java - - - org.apache.maven.plugins - maven-resources-plugin - 2.6 + maven-release-plugin + 2.4.1 org.apache.maven.plugins @@ -148,7 +114,6 @@ 2.2.1 - attach-sources jar @@ -161,7 +126,6 @@ 2.9.1 - attach-javadocs jar @@ -202,7 +166,7 @@ - org.rometools + com.rometools rome 2.0.0-SNAPSHOT @@ -212,42 +176,36 @@ 2.11.0 - commons-httpclient commons-httpclient 3.1 - commons-logging commons-logging 1.1.3 - commons-logging commons-logging-api 1.1 - javax.servlet servlet-api 2.5 test - jetty jetty 4.2.12 test - junit junit 4.11 diff --git a/src/java/org/rometools/fetcher/FeedFetcher.java b/src/main/java/org/rometools/fetcher/FeedFetcher.java similarity index 100% rename from src/java/org/rometools/fetcher/FeedFetcher.java rename to src/main/java/org/rometools/fetcher/FeedFetcher.java diff --git a/src/java/org/rometools/fetcher/FetcherEvent.java b/src/main/java/org/rometools/fetcher/FetcherEvent.java similarity index 100% rename from src/java/org/rometools/fetcher/FetcherEvent.java rename to src/main/java/org/rometools/fetcher/FetcherEvent.java diff --git a/src/java/org/rometools/fetcher/FetcherException.java b/src/main/java/org/rometools/fetcher/FetcherException.java similarity index 100% rename from src/java/org/rometools/fetcher/FetcherException.java rename to src/main/java/org/rometools/fetcher/FetcherException.java diff --git a/src/java/org/rometools/fetcher/FetcherListener.java b/src/main/java/org/rometools/fetcher/FetcherListener.java similarity index 100% rename from src/java/org/rometools/fetcher/FetcherListener.java rename to src/main/java/org/rometools/fetcher/FetcherListener.java diff --git a/src/java/org/rometools/fetcher/impl/AbstractFeedFetcher.java b/src/main/java/org/rometools/fetcher/impl/AbstractFeedFetcher.java similarity index 100% rename from src/java/org/rometools/fetcher/impl/AbstractFeedFetcher.java rename to src/main/java/org/rometools/fetcher/impl/AbstractFeedFetcher.java diff --git a/src/java/org/rometools/fetcher/impl/AbstractFeedFetcherBeanInfo.java b/src/main/java/org/rometools/fetcher/impl/AbstractFeedFetcherBeanInfo.java similarity index 100% rename from src/java/org/rometools/fetcher/impl/AbstractFeedFetcherBeanInfo.java rename to src/main/java/org/rometools/fetcher/impl/AbstractFeedFetcherBeanInfo.java diff --git a/src/java/org/rometools/fetcher/impl/DiskFeedInfoCache.java b/src/main/java/org/rometools/fetcher/impl/DiskFeedInfoCache.java similarity index 100% rename from src/java/org/rometools/fetcher/impl/DiskFeedInfoCache.java rename to src/main/java/org/rometools/fetcher/impl/DiskFeedInfoCache.java diff --git a/src/java/org/rometools/fetcher/impl/FeedFetcherCache.java b/src/main/java/org/rometools/fetcher/impl/FeedFetcherCache.java similarity index 100% rename from src/java/org/rometools/fetcher/impl/FeedFetcherCache.java rename to src/main/java/org/rometools/fetcher/impl/FeedFetcherCache.java diff --git a/src/java/org/rometools/fetcher/impl/HashMapFeedInfoCache.java b/src/main/java/org/rometools/fetcher/impl/HashMapFeedInfoCache.java similarity index 100% rename from src/java/org/rometools/fetcher/impl/HashMapFeedInfoCache.java rename to src/main/java/org/rometools/fetcher/impl/HashMapFeedInfoCache.java diff --git a/src/java/org/rometools/fetcher/impl/HttpClientFeedFetcher.java b/src/main/java/org/rometools/fetcher/impl/HttpClientFeedFetcher.java similarity index 100% rename from src/java/org/rometools/fetcher/impl/HttpClientFeedFetcher.java rename to src/main/java/org/rometools/fetcher/impl/HttpClientFeedFetcher.java diff --git a/src/java/org/rometools/fetcher/impl/HttpURLFeedFetcher.java b/src/main/java/org/rometools/fetcher/impl/HttpURLFeedFetcher.java similarity index 100% rename from src/java/org/rometools/fetcher/impl/HttpURLFeedFetcher.java rename to src/main/java/org/rometools/fetcher/impl/HttpURLFeedFetcher.java diff --git a/src/java/org/rometools/fetcher/impl/LinkedHashMapFeedInfoCache.java b/src/main/java/org/rometools/fetcher/impl/LinkedHashMapFeedInfoCache.java similarity index 100% rename from src/java/org/rometools/fetcher/impl/LinkedHashMapFeedInfoCache.java rename to src/main/java/org/rometools/fetcher/impl/LinkedHashMapFeedInfoCache.java diff --git a/src/java/org/rometools/fetcher/impl/ResponseHandler.java b/src/main/java/org/rometools/fetcher/impl/ResponseHandler.java similarity index 100% rename from src/java/org/rometools/fetcher/impl/ResponseHandler.java rename to src/main/java/org/rometools/fetcher/impl/ResponseHandler.java diff --git a/src/java/org/rometools/fetcher/impl/SyndFeedInfo.java b/src/main/java/org/rometools/fetcher/impl/SyndFeedInfo.java similarity index 100% rename from src/java/org/rometools/fetcher/impl/SyndFeedInfo.java rename to src/main/java/org/rometools/fetcher/impl/SyndFeedInfo.java diff --git a/src/java/org/rometools/fetcher/samples/FeedAggregator.java b/src/main/java/org/rometools/fetcher/samples/FeedAggregator.java similarity index 100% rename from src/java/org/rometools/fetcher/samples/FeedAggregator.java rename to src/main/java/org/rometools/fetcher/samples/FeedAggregator.java diff --git a/src/java/org/rometools/fetcher/samples/FeedReader.java b/src/main/java/org/rometools/fetcher/samples/FeedReader.java similarity index 100% rename from src/java/org/rometools/fetcher/samples/FeedReader.java rename to src/main/java/org/rometools/fetcher/samples/FeedReader.java diff --git a/src/test/org/rometools/test/AbstractJettyTest.java b/src/test/java/org/rometools/test/AbstractJettyTest.java similarity index 100% rename from src/test/org/rometools/test/AbstractJettyTest.java rename to src/test/java/org/rometools/test/AbstractJettyTest.java diff --git a/src/test/org/rometools/test/DiskFeedInfoCacheTest.java b/src/test/java/org/rometools/test/DiskFeedInfoCacheTest.java similarity index 100% rename from src/test/org/rometools/test/DiskFeedInfoCacheTest.java rename to src/test/java/org/rometools/test/DiskFeedInfoCacheTest.java diff --git a/src/test/java/org/rometools/test/FetcherTestServlet.java b/src/test/java/org/rometools/test/FetcherTestServlet.java new file mode 100644 index 0000000..cfe918f --- /dev/null +++ b/src/test/java/org/rometools/test/FetcherTestServlet.java @@ -0,0 +1,245 @@ +/* + * Copyright 2004 Sun Microsystems, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +package org.rometools.test; + +import java.io.BufferedReader; +import java.io.IOException; +import java.io.InputStream; +import java.io.InputStreamReader; +import java.io.OutputStream; +import java.io.OutputStreamWriter; +import java.text.DateFormat; +import java.text.ParseException; +import java.text.SimpleDateFormat; +import java.util.ArrayList; +import java.util.List; +import java.util.zip.GZIPOutputStream; + +import javax.servlet.ServletException; +import javax.servlet.http.HttpServlet; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + +import com.sun.syndication.feed.synd.SyndContent; +import com.sun.syndication.feed.synd.SyndContentImpl; +import com.sun.syndication.feed.synd.SyndEntry; +import com.sun.syndication.feed.synd.SyndEntryImpl; +import com.sun.syndication.feed.synd.SyndFeed; +import com.sun.syndication.feed.synd.SyndFeedImpl; +import com.sun.syndication.io.FeedException; +import com.sun.syndication.io.SyndFeedOutput; + +public class FetcherTestServlet extends HttpServlet { + + public static final String ETAG_1 = "ETAG-1"; + public static final String ETAG_2 = "ETAG-2"; + + public static final String DELTA_FEED_TITLE = "Delta Encoded Feed"; + public static final String DELTA_FEED_ENTRY_TITLE = "Delta Encoded Feed Entry"; + + public static final String SERVLET_MAPPING = "/FetcherTestServlet/*"; + public static final String SERVLET_MAPPING2 = "/FetcherTestServlet2/*"; + + /** + * @throws IOException + * @throws + * @see javax.servlet.http.HttpServlet#doGet(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse) + */ + @Override + protected void doGet(final HttpServletRequest request, final HttpServletResponse response) throws ServletException, IOException { + + if ("TRUE".equalsIgnoreCase(request.getParameter("redirect"))) { + // testing redirection support + response.sendRedirect("/rome/FetcherTestServlet2/"); + return; + } else if (request.getParameter("error") != null) { + // response.sendError(HttpServletResponse.SC_NOT_FOUND); + final int errorToThrow = Integer.parseInt(request.getParameter("error")); + response.sendError(errorToThrow); + return; + } else { + + // We manually set the date headers using strings + // instead of the get/setDateHeader methods because + // those methods return longs, which has too much + // precision for the real date headers + // this is just a random date + String lastModifiedDate = "Thu, 08 Jan 2009 23:06:39 GMT"; + String eTag = ETAG_1; + + if ("TRUE".equalsIgnoreCase(request.getParameter("refreshfeed"))) { + lastModifiedDate = "Fri, 09 Jan 2009 12:06:39 GMT"; + eTag = ETAG_2; + } + + final boolean serveFeed = checkModified(request, lastModifiedDate, eTag) || "TRUE".equalsIgnoreCase(request.getParameter("deltaencode")); + final boolean gzip = "TRUE".equalsIgnoreCase(request.getParameter("gzipfeed")); + + if (serveFeed) { + final String aimHeader = request.getHeader("A-IM"); + final boolean serveDeltaEncodedFeed = aimHeader != null && aimHeader.indexOf("feed") >= 0 + && "TRUE".equalsIgnoreCase(request.getParameter("deltaencode")); + if (serveDeltaEncodedFeed) { + try { + sendDeltaEncodedData(response, lastModifiedDate, request.getHeader("If-None-Match"), eTag, gzip); + } catch (final FeedException e) { + throw new ServletException(e); + } + } else { + sendFeedData(response, lastModifiedDate, eTag, gzip); + } + return; + } else { + response.sendError(HttpServletResponse.SC_NOT_MODIFIED); + return; + } + } + } + + private boolean checkModified(final HttpServletRequest request, final String lastModifiedDate, final String eTag) { + + final String requestedETag = request.getHeader("If-None-Match"); + final String requestedLastModified = request.getHeader("If-Modified-Since"); + boolean modified = true; + boolean mustServer = false; + if (requestedETag != null) { + if (eTag.equals(requestedETag)) { + modified = false; + } else { + modified = true; + mustServer = true; + } + } + if (requestedLastModified != null) { + if (lastModifiedDate.equals(requestedLastModified)) { + modified = false; + } else { + modified = true; + mustServer = true; + } + } + final boolean serveFeed = modified || mustServer; + return serveFeed; + } + + /** + * @param request + * @param lastModifiedDate + * @param tag + * @param gzip + * @throws IOException + * @throws FeedException + */ + private void sendDeltaEncodedData(final HttpServletResponse response, final String lastModifiedDate, final String requestedETag, final String responseETag, + final boolean gzip) throws IOException, FeedException { + if (ETAG_1.equals(requestedETag) || ETAG_2.equals(requestedETag)) { + OutputStream out = null; + if (gzip) { + response.setHeader("Content-Encoding", "gzip"); + out = new GZIPOutputStream(response.getOutputStream()); + } else { + out = response.getOutputStream(); + } + + response.setContentType("text/xml"); + response.setStatus(226); + if (gzip) { + response.setHeader("IM", "feed, gzip"); + } else { + response.setHeader("IM", "feed"); + } + + if (responseETag != null) { + response.setHeader("ETag", responseETag); + } + if (lastModifiedDate != null) { + response.setHeader("Last-Modified", lastModifiedDate); + } + + final SyndFeed feed = new SyndFeedImpl(); + feed.setFeedType("atom_1.0"); + + feed.setTitle(DELTA_FEED_TITLE); + feed.setLink("http://rome.dev.java.net"); + feed.setDescription("This tests using rfc3229 delta encoding."); + + final List entries = new ArrayList(); + SyndEntry entry; + SyndContent description; + + entry = new SyndEntryImpl(); + entry.setTitle(DELTA_FEED_ENTRY_TITLE); + entry.setLink("http://bobwyman.pubsub.com/main/2004/09/using_rfc3229_w.html"); + try { + final DateFormat dateParser = new SimpleDateFormat("yyyy-MM-dd"); + entry.setPublishedDate(dateParser.parse("2004-11-25")); + } catch (final ParseException ex) { + // + } + description = new SyndContentImpl(); + description.setType("text/plain"); + description.setValue("Test for RFC3229 Delta Encoding"); + entry.setDescription(description); + entries.add(entry); + + feed.setEntries(entries); + + final SyndFeedOutput output = new SyndFeedOutput(); + output.output(feed, new OutputStreamWriter(out)); + } else { + sendFeedData(response, lastModifiedDate, responseETag, gzip); + } + } + + private void sendFeedData(final HttpServletResponse response, final String lastModifiedDate, final String eTag, final boolean gzip) throws IOException { + OutputStream out = null; + if (gzip) { + response.setHeader("Content-Encoding", "gzip"); + out = new GZIPOutputStream(response.getOutputStream()); + } else { + out = response.getOutputStream(); + } + + response.setContentType("text/xml"); + if (eTag != null) { + response.setHeader("ETag", eTag); + } + if (lastModifiedDate != null) { + response.setHeader("Last-Modified", lastModifiedDate); + } + + InputStream inputStream = Thread.currentThread().getContextClassLoader().getResourceAsStream("/atom_1.0.xml"); + if (inputStream == null) { + inputStream = this.getClass().getResourceAsStream("/atom_1.0.xml"); + } + + final BufferedReader reader = new BufferedReader(new InputStreamReader(inputStream)); + try { + String line; + while ((line = reader.readLine()) != null) { + out.write(line.getBytes()); + line = null; + } + } finally { + if (reader != null) { + reader.close(); + } + } + + out.close(); + } +} diff --git a/src/test/org/rometools/test/HashMapFeedInfoCacheTest.java b/src/test/java/org/rometools/test/HashMapFeedInfoCacheTest.java similarity index 100% rename from src/test/org/rometools/test/HashMapFeedInfoCacheTest.java rename to src/test/java/org/rometools/test/HashMapFeedInfoCacheTest.java diff --git a/src/test/org/rometools/test/HttpClientFeedFetcherTest.java b/src/test/java/org/rometools/test/HttpClientFeedFetcherTest.java similarity index 100% rename from src/test/org/rometools/test/HttpClientFeedFetcherTest.java rename to src/test/java/org/rometools/test/HttpClientFeedFetcherTest.java diff --git a/src/test/org/rometools/test/HttpURLFeedFetcherTest.java b/src/test/java/org/rometools/test/HttpURLFeedFetcherTest.java similarity index 100% rename from src/test/org/rometools/test/HttpURLFeedFetcherTest.java rename to src/test/java/org/rometools/test/HttpURLFeedFetcherTest.java diff --git a/src/test/org/rometools/test/ResponseHandlerTest.java b/src/test/java/org/rometools/test/ResponseHandlerTest.java similarity index 100% rename from src/test/org/rometools/test/ResponseHandlerTest.java rename to src/test/java/org/rometools/test/ResponseHandlerTest.java diff --git a/src/test/org/rometools/test/TestBasicAuthenticator.java b/src/test/java/org/rometools/test/TestBasicAuthenticator.java similarity index 100% rename from src/test/org/rometools/test/TestBasicAuthenticator.java rename to src/test/java/org/rometools/test/TestBasicAuthenticator.java diff --git a/src/test/org/rometools/test/FetcherTestServlet.java b/src/test/org/rometools/test/FetcherTestServlet.java deleted file mode 100644 index af38dc0..0000000 --- a/src/test/org/rometools/test/FetcherTestServlet.java +++ /dev/null @@ -1,244 +0,0 @@ -/* - * Copyright 2004 Sun Microsystems, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.rometools.test; - -import java.io.BufferedReader; -import java.io.IOException; -import java.io.InputStream; -import java.io.InputStreamReader; -import java.io.OutputStream; -import java.io.OutputStreamWriter; -import java.text.DateFormat; -import java.text.ParseException; -import java.text.SimpleDateFormat; -import java.util.ArrayList; -import java.util.List; -import java.util.zip.GZIPOutputStream; - -import javax.servlet.ServletException; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -import com.sun.syndication.feed.synd.SyndContent; -import com.sun.syndication.feed.synd.SyndContentImpl; -import com.sun.syndication.feed.synd.SyndEntry; -import com.sun.syndication.feed.synd.SyndEntryImpl; -import com.sun.syndication.feed.synd.SyndFeed; -import com.sun.syndication.feed.synd.SyndFeedImpl; -import com.sun.syndication.io.FeedException; -import com.sun.syndication.io.SyndFeedOutput; - - -public class FetcherTestServlet extends javax.servlet.http.HttpServlet { - public static final String ETAG_1 = "ETAG-1"; - public static final String ETAG_2 = "ETAG-2"; - - public static final String DELTA_FEED_TITLE = "Delta Encoded Feed"; - public static final String DELTA_FEED_ENTRY_TITLE = "Delta Encoded Feed Entry"; - - public static final String SERVLET_MAPPING = "/FetcherTestServlet/*"; - public static final String SERVLET_MAPPING2 = "/FetcherTestServlet2/*"; - - /** - * @throws IOException - * @throws - * @see javax.servlet.http.HttpServlet#doGet(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse) - */ - protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { - - if ("TRUE".equalsIgnoreCase(request.getParameter("redirect"))) { - // testing redirection support - response.sendRedirect("/rome/FetcherTestServlet2/"); - return; - } else if (request.getParameter("error") != null) { - //response.sendError(HttpServletResponse.SC_NOT_FOUND); - int errorToThrow = Integer.parseInt(request.getParameter("error")); - response.sendError(errorToThrow); - return; - } else { - - // We manually set the date headers using strings - // instead of the get/setDateHeader methods because - // those methods return longs, which has too much - // precision for the real date headers - // this is just a random date - String lastModifiedDate = "Thu, 08 Jan 2009 23:06:39 GMT"; - String eTag = ETAG_1; - - if ("TRUE".equalsIgnoreCase(request.getParameter("refreshfeed"))) { - lastModifiedDate = "Fri, 09 Jan 2009 12:06:39 GMT"; - eTag = ETAG_2; - } - - boolean serveFeed = checkModified(request, lastModifiedDate, eTag) || ("TRUE".equalsIgnoreCase(request.getParameter("deltaencode"))); - boolean gzip = "TRUE".equalsIgnoreCase(request.getParameter("gzipfeed")); - - if (serveFeed) { - String aimHeader = request.getHeader("A-IM"); - boolean serveDeltaEncodedFeed = ((aimHeader != null) && (aimHeader.indexOf("feed") >=0) && "TRUE".equalsIgnoreCase(request.getParameter("deltaencode"))); - if (serveDeltaEncodedFeed) { - try { - sendDeltaEncodedData(response, lastModifiedDate, request.getHeader("If-None-Match"), eTag, gzip); - } catch (FeedException e) { - throw new ServletException(e); - } - } else { - sendFeedData(response, lastModifiedDate, eTag, gzip); - } - return; - } else { - response.sendError(HttpServletResponse.SC_NOT_MODIFIED); - return; - } - } - } - - - - private boolean checkModified(HttpServletRequest request, String lastModifiedDate, String eTag) { - - String requestedETag = request.getHeader("If-None-Match"); - String requestedLastModified = request.getHeader("If-Modified-Since"); - boolean modified = true; - boolean mustServer = false; - if (requestedETag != null) { - if (eTag.equals(requestedETag)) { - modified = false; - } else { - modified = true; - mustServer = true; - } - } - if (requestedLastModified != null) { - if (lastModifiedDate.equals(requestedLastModified)) { - modified = false; - } else { - modified = true; - mustServer = true; - } - } - boolean serveFeed = (modified || mustServer); - return serveFeed; - } - - /** - * @param request - * @param lastModifiedDate - * @param tag - * @param gzip - * @throws IOException - * @throws FeedException - */ - private void sendDeltaEncodedData(HttpServletResponse response, String lastModifiedDate, String requestedETag, String responseETag, boolean gzip) throws IOException, FeedException { - if (ETAG_1.equals(requestedETag) || ETAG_2.equals(requestedETag)) { - OutputStream out = null; - if (gzip) { - response.setHeader("Content-Encoding", "gzip"); - out = new GZIPOutputStream(response.getOutputStream()); - } else { - out = response.getOutputStream(); - } - - response.setContentType("text/xml"); - response.setStatus(226); - if (gzip) { - response.setHeader("IM", "feed, gzip"); - } else { - response.setHeader("IM", "feed"); - } - - if (responseETag != null) { - response.setHeader("ETag", responseETag); - } - if (lastModifiedDate != null) { - response.setHeader("Last-Modified", lastModifiedDate); - } - - SyndFeed feed = new SyndFeedImpl(); - feed.setFeedType("atom_1.0"); - - feed.setTitle(DELTA_FEED_TITLE); - feed.setLink("http://rome.dev.java.net"); - feed.setDescription("This tests using rfc3229 delta encoding."); - - List entries = new ArrayList(); - SyndEntry entry; - SyndContent description; - - entry = new SyndEntryImpl(); - entry.setTitle(DELTA_FEED_ENTRY_TITLE); - entry.setLink("http://bobwyman.pubsub.com/main/2004/09/using_rfc3229_w.html"); - try { - DateFormat dateParser = new SimpleDateFormat("yyyy-MM-dd"); - entry.setPublishedDate(dateParser.parse("2004-11-25")); - } - catch (ParseException ex) { - // - } - description = new SyndContentImpl(); - description.setType("text/plain"); - description.setValue("Test for RFC3229 Delta Encoding"); - entry.setDescription(description); - entries.add(entry); - - feed.setEntries(entries); - - SyndFeedOutput output = new SyndFeedOutput(); - output.output(feed, new OutputStreamWriter(out)); - } else { - sendFeedData(response, lastModifiedDate, responseETag, gzip); - } - } - - private void sendFeedData(HttpServletResponse response, String lastModifiedDate, String eTag, boolean gzip) throws IOException { - OutputStream out = null; - if (gzip) { - response.setHeader("Content-Encoding", "gzip"); - out = new GZIPOutputStream(response.getOutputStream()); - } else { - out = response.getOutputStream(); - } - - response.setContentType("text/xml"); - if (eTag != null) { - response.setHeader("ETag", eTag); - } - if (lastModifiedDate != null) { - response.setHeader("Last-Modified", lastModifiedDate); - } - - InputStream inputStream = Thread.currentThread().getContextClassLoader().getResourceAsStream("/atom_1.0.xml"); - if (inputStream == null) { - inputStream = this.getClass().getResourceAsStream("/atom_1.0.xml"); - } - - BufferedReader reader = new BufferedReader(new InputStreamReader(inputStream)); - try { - String line; - while ((line = reader.readLine()) != null) { - out.write(line.getBytes()); - line = null; - } - } finally { - if (reader != null) { - reader.close(); - } - } - - out.close(); - } -} diff --git a/src/test/atom_1.0.xml b/src/test/resources/atom_1.0.xml similarity index 100% rename from src/test/atom_1.0.xml rename to src/test/resources/atom_1.0.xml diff --git a/src/test/testuser.properties b/src/test/resources/testuser.properties similarity index 100% rename from src/test/testuser.properties rename to src/test/resources/testuser.properties