Beispiel #1
0
  @Test
  public void testFeed6() throws Exception {
    mockServer.expect(requestTo("url")).andRespond(withBadRequest());

    FetchResult irrelevant = parser.parse("url", "lastModified");
    assertThat(irrelevant.getUrl(), is("url"));
    assertThat(irrelevant.getLastModified(), nullValue());
    assertThat(irrelevant.getEntries(), hasSize(0));
  }
Beispiel #2
0
  @Test
  public void testFeed1() throws Exception {
    mockServer
        .expect(requestTo(HTTP_EXAMPLE_COM))
        .andExpect(method(GET))
        .andRespond(withSuccess(new ClassPathResource("rss/feed1.xml"), TEXT_XML));

    FetchResult result = parser.parse(HTTP_EXAMPLE_COM);
    assertThat(result.getEntries(), hasSize(2));
    assertThat(result.getResultSizePerFetch(), is(2));
  }
Beispiel #3
0
  @Test
  public void testInvalidCharacter() throws Exception {
    // test [^\u0020-\uD7FF]+
    mockServer
        .expect(requestTo(HTTP_EXAMPLE_COM))
        .andExpect(method(GET))
        .andRespond(withSuccess(new ClassPathResource("rss/feed7.xml"), TEXT_XML));

    FetchResult result = parser.parse(HTTP_EXAMPLE_COM);
    assertThat(result.getEntries(), hasSize(6));
  }
Beispiel #4
0
  @Test
  public void testFeed8() throws Exception {
    mockServer
        .expect(requestTo("irrelevant"))
        .andExpect(method(GET))
        .andExpect(header("If-Modified-Since", is("lastModified")))
        .andRespond(withStatus(HttpStatus.NOT_MODIFIED));

    FetchResult result = parser.parse("irrelevant", "lastModified");
    assertThat(result.getEntries(), empty());
  }
Beispiel #5
0
  @Test
  public void testFeed7() throws Exception {
    mockServer
        .expect(requestTo(HTTP_EXAMPLE_COM))
        .andExpect(method(GET))
        .andRespond(withSuccess(new ClassPathResource("rss/feed2.xml"), TEXT_XML));

    FetchResult result = parser.parse(HTTP_EXAMPLE_COM);
    assertThat(
        result.getEntries(),
        hasItems(hasProperty("url", is("http://www.javaspecialists.eu/archive/Issue220b.html"))));
  }
Beispiel #6
0
  @Test
  public void testFeed4() throws Exception {
    mockServer
        .expect(requestTo("https://github.com/ksokol.private.atom"))
        .andExpect(method(GET))
        .andRespond(withSuccess(new ClassPathResource("rss/feed4.xml"), TEXT_XML));

    FetchResult result = parser.parse("https://github.com/ksokol.private.atom");
    assertThat(
        result.getEntries(),
        hasItems(hasProperty("content", startsWith("<!-- issue_comment -->"))));
  }
Beispiel #7
0
  @Test
  public void testFeed3() throws Exception {
    mockServer
        .expect(requestTo(HTTP_EXAMPLE_COM))
        .andExpect(method(GET))
        .andRespond(withSuccess(new ClassPathResource("rss/feed3.xml"), TEXT_XML));

    FetchResult result = parser.parse(HTTP_EXAMPLE_COM);
    assertThat(
        result.getEntries(),
        hasItems(
            hasProperty("url", is(HTTP_EXAMPLE_COM + "/12539.htm")),
            hasProperty("url", is(HTTP_EXAMPLE_COM + "/12673.htm"))));
  }
Beispiel #8
0
  @Test
  public void testFeed5() throws Exception {
    mockServer
        .expect(requestTo("http://neusprech.org/feed/"))
        .andExpect(method(GET))
        .andRespond(withSuccess(new ClassPathResource("rss/feed5.xml"), TEXT_XML));

    FetchResult result = parser.parse("http://neusprech.org/feed/");
    assertThat(
        result.getEntries(),
        hasItems(
            hasProperty(
                "content", startsWith("Ein Gastbeitrag von Erik W. Ende Juni 2014 sagte"))));
  }
Beispiel #9
0
  @Test
  public void testAdjustedResponseContentType() {
    String url = "https://feeds.feedwrench.com/AdventuresInAngular.rss";

    mockServer
        .expect(requestTo(url))
        .andExpect(method(GET))
        .andRespond(
            withSuccess(new ClassPathResource("rss/feed7.xml"), TEXT_XML)
                .contentType(MediaType.TEXT_PLAIN));

    FetchResult result = parser.parse(url);

    assertThat(result.getEntries(), hasSize(greaterThan(0)));
  }