Remove Apache Commons IO dependency and split into smaller methods (#942)

* Fix the requested changes

* Split into smaller methods

* Split into smaller methods

* Remove apache dependency and split into smaller methods

* Add unit tests
This commit is contained in:
Luís Soares
2017-01-09 14:06:46 +00:00
committed by KevinGilmore
parent 729c8990d0
commit 6a60defc94
3 changed files with 71 additions and 32 deletions

View File

@@ -0,0 +1,36 @@
package com.baeldung.jsoup;
import java.io.IOException;
import org.jsoup.HttpStatusException;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import org.junit.Before;
import org.junit.Test;
public class JsoupParserTest {
JsoupParser jsoupParser;
@Before
public void setUp() {
jsoupParser = new JsoupParser();
}
@Test
public void test404() throws IOException {
try {
jsoupParser.loadDocument("https://spring.io/will-not-be-found");
} catch (HttpStatusException ex) {
assertEquals(404, ex.getStatusCode());
}
}
@Test
public void testChange() throws IOException {
jsoupParser.loadDocument("http://spring.io/blog");
jsoupParser.examplesModifying();
assertTrue(jsoupParser.getTidyHtml().contains("http://baeldung.com"));
}
}