Skip to content
This repository has been archived by the owner on Oct 30, 2018. It is now read-only.

Commit

Permalink
replace System.out.printlns with Logger
Browse files Browse the repository at this point in the history
  • Loading branch information
kennycason committed Aug 2, 2015
1 parent a655d05 commit 42b20f4
Show file tree
Hide file tree
Showing 16 changed files with 97 additions and 52 deletions.
2 changes: 1 addition & 1 deletion src/main/java/com/alchemyapi/api/AlchemyApi.java
Original file line number Diff line number Diff line change
Expand Up @@ -604,7 +604,7 @@ private Document parseXml(final String response, final Parameters parameters) {

private Document praseRdf(final String response, final Parameters parameters) {
final Document document = Jsoup.parse(response, parameters.getEncoding(), Parser.xmlParser());
System.out.println("RAW: " + response);
LOGGER.info("RAW: " + response);
final Element status = document.select("rdf|RDF > rdf|Description > aapi|ResultStatus").first();
if (status == null || !status.text().equals("OK")) {
throw new AlchemyApiException("Error making API call: " + status);
Expand Down
7 changes: 5 additions & 2 deletions src/test/java/com/alchemyapi/STestAuthor.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import com.alchemyapi.api.AlchemyApi;
import com.alchemyapi.helpers.ResourceUtils;
import com.alchemyapi.helpers.TestApiFactory;
import org.apache.log4j.Logger;
import org.jsoup.nodes.Document;
import org.junit.Test;

Expand All @@ -13,19 +14,21 @@
*/
public class STestAuthor {

private static final Logger LOGGER = Logger.getLogger(STestAuthor.class);

private final AlchemyApi alchemyApi = TestApiFactory.build(new File(System.getProperty("user.home"), ".alchemy/api.key"));

@Test
public void html() {
final String html = ResourceUtils.toString("data/example.html");
final Document document = alchemyApi.htmlGetAuthor(html, "http://www.test.com/");
System.out.println(document);
LOGGER.info(document);
}

@Test
public void url() {
final Document document = alchemyApi.urlGetAuthor("http://www.politico.com/blogs/media/2012/02/detroit-news-ed-upset-over-romney-edit-115247.html");
System.out.println(document);
LOGGER.info(document);
}

}
11 changes: 7 additions & 4 deletions src/test/java/com/alchemyapi/STestCategory.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import com.alchemyapi.api.parameters.Parameters;
import com.alchemyapi.helpers.ResourceUtils;
import com.alchemyapi.helpers.TestApiFactory;
import org.apache.log4j.Logger;
import org.jsoup.nodes.Document;
import org.junit.Test;

Expand All @@ -15,25 +16,27 @@
*/
public class STestCategory {

private static final Logger LOGGER = Logger.getLogger(STestCategory.class);

private final AlchemyApi alchemyApi = TestApiFactory.build(new File(System.getProperty("user.home"), ".alchemy/api.key"));

@Test
public void url() {
final Document document = alchemyApi.urlGetCategory("http://www.techcrunch.com/");
System.out.println(document);
LOGGER.info(document);
}

@Test
public void text() {
final Document document = alchemyApi.textGetCategory("Latest on the War in Iraq.");
System.out.println(document);
LOGGER.info(document);
}

@Test
public void html() {
final String html = ResourceUtils.toString("data/example.html");
final Document document = alchemyApi.htmlGetCategory(html, "http://www.test.com/");
System.out.println(document);
LOGGER.info(document);
}

@Test
Expand All @@ -42,7 +45,7 @@ public void htmlRdfFormat() {
final CategoryParameters categoryParameters = new CategoryParameters();
categoryParameters.setOutputMode(Parameters.OUTPUT_RDF);
final Document document2 = alchemyApi.htmlGetCategory(html, "http://www.test.com/", categoryParameters);
System.out.println(document2);
LOGGER.info(document2);
}

}
9 changes: 6 additions & 3 deletions src/test/java/com/alchemyapi/STestCombined.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import com.alchemyapi.api.AlchemyApi;
import com.alchemyapi.api.parameters.CombinedParameters;
import com.alchemyapi.helpers.TestApiFactory;
import org.apache.log4j.Logger;
import org.jsoup.nodes.Document;
import org.junit.Test;

Expand All @@ -13,27 +14,29 @@
*/
public class STestCombined {

private static final Logger LOGGER = Logger.getLogger(STestCombined.class);

private final AlchemyApi alchemyApi = TestApiFactory.build(new File(System.getProperty("user.home"), ".alchemy/api.key"));

@Test
public void url() {
final Document document = alchemyApi.urlGetCombined("http://www.techcrunch.com/");
System.out.println(document);
LOGGER.info(document);
}

@Test
public void text() {
final Document document = alchemyApi.textGetCombined(
"Hello there, my name is Bob Jones. I live in the United States of America. Where do you live, Fred?");
System.out.println(document);
LOGGER.info(document);

// Only extract entities & keywords
final CombinedParameters combinedParams = new CombinedParameters();
combinedParams.setSentiment(true);
combinedParams.setExtract("entity");
combinedParams.setExtract("keyword");
final Document document2 = alchemyApi.textGetCombined("Madonna enjoys tasty Pepsi. I love her style.", combinedParams);
System.out.println(document2);
LOGGER.info(document2);
}

}
9 changes: 6 additions & 3 deletions src/test/java/com/alchemyapi/STestConcept.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import com.alchemyapi.api.AlchemyApi;
import com.alchemyapi.helpers.ResourceUtils;
import com.alchemyapi.helpers.TestApiFactory;
import org.apache.log4j.Logger;
import org.jsoup.nodes.Document;
import org.junit.Test;

Expand All @@ -13,26 +14,28 @@
*/
public class STestConcept {

private static final Logger LOGGER = Logger.getLogger(STestConcept.class);

private final AlchemyApi alchemyApi = TestApiFactory.build(new File(System.getProperty("user.home"), ".alchemy/api.key"));

@Test
public void url() {
final Document document = alchemyApi.urlGetRankedConcepts("http://www.techcrunch.com/");
System.out.println(document);
LOGGER.info(document);
}

@Test
public void text() {
final Document document = alchemyApi.textGetRankedConcepts(
"This thing has a steering wheel, tires, and an engine. Do you know what it is?");
System.out.println(document);
LOGGER.info(document);
}

@Test
public void html() {
final String html = ResourceUtils.toString("data/example.html");
final Document document = alchemyApi.htmlGetRankedConcepts(html, "http://www.test.com/");
System.out.println(document);
LOGGER.info(document);
}

}
7 changes: 5 additions & 2 deletions src/test/java/com/alchemyapi/STestConstraintQuery.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import com.alchemyapi.api.AlchemyApi;
import com.alchemyapi.helpers.ResourceUtils;
import com.alchemyapi.helpers.TestApiFactory;
import org.apache.log4j.Logger;
import org.jsoup.nodes.Document;
import org.junit.Test;

Expand All @@ -13,19 +14,21 @@
*/
public class STestConstraintQuery {

private static final Logger LOGGER = Logger.getLogger(STestConstraintQuery.class);

private final AlchemyApi alchemyApi = TestApiFactory.build(new File(System.getProperty("user.home"), ".alchemy/api.key"));

@Test
public void url() {
final Document document = alchemyApi.urlGetConstraintQuery("http://microformats.org/wiki/hcard", "1st link");
System.out.println(document);
LOGGER.info(document);
}

@Test
public void html() {
final String html = ResourceUtils.toString("data/example.html");
final Document document = alchemyApi.htmlGetConstraintQuery(html, "http://www.test.com/", "1st link");
System.out.println(document);
LOGGER.info(document);
}

}
9 changes: 6 additions & 3 deletions src/test/java/com/alchemyapi/STestEntity.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import com.alchemyapi.api.AlchemyApi;
import com.alchemyapi.helpers.ResourceUtils;
import com.alchemyapi.helpers.TestApiFactory;
import org.apache.log4j.Logger;
import org.jsoup.nodes.Document;
import org.junit.Test;

Expand All @@ -13,26 +14,28 @@
*/
public class STestEntity {

private static final Logger LOGGER = Logger.getLogger(STestEntity.class);

private final AlchemyApi alchemyApi = TestApiFactory.build(new File(System.getProperty("user.home"), ".alchemy/api.key"));

@Test
public void url() {
final Document document = alchemyApi.urlGetRankedNamedEntities("http://www.techcrunch.com/");
System.out.println(document);
LOGGER.info(document);
}

@Test
public void text() {
final Document document = alchemyApi.textGetRankedNamedEntities(
"Hello there, my name is Bob Jones. I live in the United States of America. Where do you live, Fred?");
System.out.println(document);
LOGGER.info(document);
}

@Test
public void html() {
final String html = ResourceUtils.toString("data/example.html");
final Document document = alchemyApi.htmlGetRankedNamedEntities(html, "http://www.test.com/");
System.out.println(document);
LOGGER.info(document);
}

}
7 changes: 5 additions & 2 deletions src/test/java/com/alchemyapi/STestFeedLinks.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import com.alchemyapi.api.AlchemyApi;
import com.alchemyapi.helpers.ResourceUtils;
import com.alchemyapi.helpers.TestApiFactory;
import org.apache.log4j.Logger;
import org.jsoup.nodes.Document;
import org.junit.Test;

Expand All @@ -13,19 +14,21 @@
*/
public class STestFeedLinks {

private static final Logger LOGGER = Logger.getLogger(STestFeedLinks.class);

private final AlchemyApi alchemyApi = TestApiFactory.build(new File(System.getProperty("user.home"), ".alchemy/api.key"));

@Test
public void url() {
final Document document = alchemyApi.urlGetFeedLinks("http://www.techcrunch.com/");
System.out.println(document);
LOGGER.info(document);
}

@Test
public void html() {
final String html = ResourceUtils.toString("data/example.html");
final Document document = alchemyApi.htmlGetFeedLinks(html, "http://www.test.com/");
System.out.println(document);
LOGGER.info(document);
}

}
9 changes: 6 additions & 3 deletions src/test/java/com/alchemyapi/STestImage.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import com.alchemyapi.api.parameters.ImageParameters;
import com.alchemyapi.helpers.ResourceUtils;
import com.alchemyapi.helpers.TestApiFactory;
import org.apache.log4j.Logger;
import org.jsoup.nodes.Document;
import org.junit.Test;

Expand All @@ -14,18 +15,20 @@
*/
public class STestImage {

private static final Logger LOGGER = Logger.getLogger(STestImage.class);

private final AlchemyApi alchemyApi = TestApiFactory.build(new File(System.getProperty("user.home"), ".alchemy/api.key"));

@Test
public void url() {
final Document document = alchemyApi.urlGetImage("http://www.techcrunch.com/");
System.out.println(document);
LOGGER.info(document);
}

@Test
public void imageUrl() {
final Document document = alchemyApi.urlGetRankedImageKeywords("http://farm4.staticflickr.com/3726/11043305726_fdcb7785ec_m.jpg");
System.out.println(document);
LOGGER.info(document);
}

@Test
Expand All @@ -35,7 +38,7 @@ public void imageFile() {
imageParams.setImage(imageBytes);
imageParams.setImagePostMode(ImageParameters.RAW);
final Document document = alchemyApi.imageGetRankedImageKeywords(imageParams);
System.out.println(document);
LOGGER.info(document);
}

}
9 changes: 6 additions & 3 deletions src/test/java/com/alchemyapi/STestKeyword.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import com.alchemyapi.api.AlchemyApi;
import com.alchemyapi.helpers.ResourceUtils;
import com.alchemyapi.helpers.TestApiFactory;
import org.apache.log4j.Logger;
import org.jsoup.nodes.Document;
import org.junit.Test;

Expand All @@ -13,26 +14,28 @@
*/
public class STestKeyword {

private static final Logger LOGGER = Logger.getLogger(STestKeyword.class);

private final AlchemyApi alchemyApi = TestApiFactory.build(new File(System.getProperty("user.home"), ".alchemy/api.key"));

@Test
public void url() {
final Document document = alchemyApi.urlGetRankedKeywords("http://www.techcrunch.com/");
System.out.println(document);
LOGGER.info(document);
}

@Test
public void text() {
final Document document = alchemyApi.textGetRankedKeywords(
"Hello there, my name is Bob Jones. I live in the United States of America. Where do you live, Fred?");
System.out.println(document);
LOGGER.info(document);
}

@Test
public void html() {
final String html = ResourceUtils.toString("data/example.html");
final Document document = alchemyApi.htmlGetRankedKeywords(html, "http://www.test.com/");
System.out.println(document);
LOGGER.info(document);
}

}
Loading

0 comments on commit 42b20f4

Please sign in to comment.