diff --git a/test/org/loklak/TestRunner.java b/test/org/loklak/TestRunner.java index 60a22bec1..51b16f699 100644 --- a/test/org/loklak/TestRunner.java +++ b/test/org/loklak/TestRunner.java @@ -6,6 +6,7 @@ import org.loklak.harvester.YoutubeScraperTest; import org.loklak.api.search.GithubProfileScraperTest; import org.loklak.api.search.QuoraProfileScraperTest; +import org.loklak.api.search.InstagramProfileScraperTest; /* TestRunner for harvesters @@ -15,7 +16,8 @@ TwitterScraperTest.class, YoutubeScraperTest.class, GithubProfileScraperTest.class, - QuoraProfileScraperTest.class + QuoraProfileScraperTest.class, + InstagramProfileScraperTest.class }) public class TestRunner { } diff --git a/test/org/loklak/api/search/InstagramProfileScraperTest.java b/test/org/loklak/api/search/InstagramProfileScraperTest.java new file mode 100644 index 000000000..5a7ddcdaf --- /dev/null +++ b/test/org/loklak/api/search/InstagramProfileScraperTest.java @@ -0,0 +1,66 @@ +package org.loklak.api.search; + +import java.io.BufferedReader; +import java.io.IOException; +import org.junit.Test; +import org.loklak.api.search.InstagramProfileScraper; +import org.loklak.data.DAO; +import org.loklak.http.ClientConnection; +import org.json.JSONArray; +import org.json.JSONObject; + +import static org.hamcrest.core.Is.is; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertThat; +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.assertNotNull; + +/** + * These unit-tests test org.loklak.api.search.InstagramProfileScraper.java + */ + +public class InstagramProfileScraperTest { + + @Test + public void instagramProfileScraperUserTest() { + + InstagramProfileScraper instagramScraper = new InstagramProfileScraper(); + String url = "https://www.instagram.com/fossasia/"; + BufferedReader br = null; + + try { + ClientConnection connection = new ClientConnection(url); + //Check Network issue + assertThat(connection.getStatusCode(), is(200)); + br = instagramScraper.getHtml(connection); + } catch (IOException e) { + DAO.log("InstagramProfileScraperTest.instagramProfileScraperUserTest() failed to connect to network. url:" + url); + } + + JSONArray instaProfile = new JSONArray(); + instaProfile = instagramScraper.scrapeInstagram(br, url); + + String hostname = "www.instagram.com"; + for(int i=0; i