예제 #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));
  }
예제 #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));
  }
예제 #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));
  }
예제 #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());
  }
예제 #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"))));
  }
예제 #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 -->"))));
  }
예제 #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"))));
  }
예제 #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"))));
  }
예제 #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)));
  }