示例#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)));
  }