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

Commit 42b20f4

Browse files
committed
replace System.out.printlns with Logger
1 parent a655d05 commit 42b20f4

16 files changed

+97
-52
lines changed

src/main/java/com/alchemyapi/api/AlchemyApi.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -604,7 +604,7 @@ private Document parseXml(final String response, final Parameters parameters) {
604604

605605
private Document praseRdf(final String response, final Parameters parameters) {
606606
final Document document = Jsoup.parse(response, parameters.getEncoding(), Parser.xmlParser());
607-
System.out.println("RAW: " + response);
607+
LOGGER.info("RAW: " + response);
608608
final Element status = document.select("rdf|RDF > rdf|Description > aapi|ResultStatus").first();
609609
if (status == null || !status.text().equals("OK")) {
610610
throw new AlchemyApiException("Error making API call: " + status);

src/test/java/com/alchemyapi/STestAuthor.java

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import com.alchemyapi.api.AlchemyApi;
44
import com.alchemyapi.helpers.ResourceUtils;
55
import com.alchemyapi.helpers.TestApiFactory;
6+
import org.apache.log4j.Logger;
67
import org.jsoup.nodes.Document;
78
import org.junit.Test;
89

@@ -13,19 +14,21 @@
1314
*/
1415
public class STestAuthor {
1516

17+
private static final Logger LOGGER = Logger.getLogger(STestAuthor.class);
18+
1619
private final AlchemyApi alchemyApi = TestApiFactory.build(new File(System.getProperty("user.home"), ".alchemy/api.key"));
1720

1821
@Test
1922
public void html() {
2023
final String html = ResourceUtils.toString("data/example.html");
2124
final Document document = alchemyApi.htmlGetAuthor(html, "http://www.test.com/");
22-
System.out.println(document);
25+
LOGGER.info(document);
2326
}
2427

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

3134
}

src/test/java/com/alchemyapi/STestCategory.java

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
import com.alchemyapi.api.parameters.Parameters;
66
import com.alchemyapi.helpers.ResourceUtils;
77
import com.alchemyapi.helpers.TestApiFactory;
8+
import org.apache.log4j.Logger;
89
import org.jsoup.nodes.Document;
910
import org.junit.Test;
1011

@@ -15,25 +16,27 @@
1516
*/
1617
public class STestCategory {
1718

19+
private static final Logger LOGGER = Logger.getLogger(STestCategory.class);
20+
1821
private final AlchemyApi alchemyApi = TestApiFactory.build(new File(System.getProperty("user.home"), ".alchemy/api.key"));
1922

2023
@Test
2124
public void url() {
2225
final Document document = alchemyApi.urlGetCategory("http://www.techcrunch.com/");
23-
System.out.println(document);
26+
LOGGER.info(document);
2427
}
2528

2629
@Test
2730
public void text() {
2831
final Document document = alchemyApi.textGetCategory("Latest on the War in Iraq.");
29-
System.out.println(document);
32+
LOGGER.info(document);
3033
}
3134

3235
@Test
3336
public void html() {
3437
final String html = ResourceUtils.toString("data/example.html");
3538
final Document document = alchemyApi.htmlGetCategory(html, "http://www.test.com/");
36-
System.out.println(document);
39+
LOGGER.info(document);
3740
}
3841

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

4851
}

src/test/java/com/alchemyapi/STestCombined.java

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import com.alchemyapi.api.AlchemyApi;
44
import com.alchemyapi.api.parameters.CombinedParameters;
55
import com.alchemyapi.helpers.TestApiFactory;
6+
import org.apache.log4j.Logger;
67
import org.jsoup.nodes.Document;
78
import org.junit.Test;
89

@@ -13,27 +14,29 @@
1314
*/
1415
public class STestCombined {
1516

17+
private static final Logger LOGGER = Logger.getLogger(STestCombined.class);
18+
1619
private final AlchemyApi alchemyApi = TestApiFactory.build(new File(System.getProperty("user.home"), ".alchemy/api.key"));
1720

1821
@Test
1922
public void url() {
2023
final Document document = alchemyApi.urlGetCombined("http://www.techcrunch.com/");
21-
System.out.println(document);
24+
LOGGER.info(document);
2225
}
2326

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

3033
// Only extract entities & keywords
3134
final CombinedParameters combinedParams = new CombinedParameters();
3235
combinedParams.setSentiment(true);
3336
combinedParams.setExtract("entity");
3437
combinedParams.setExtract("keyword");
3538
final Document document2 = alchemyApi.textGetCombined("Madonna enjoys tasty Pepsi. I love her style.", combinedParams);
36-
System.out.println(document2);
39+
LOGGER.info(document2);
3740
}
3841

3942
}

src/test/java/com/alchemyapi/STestConcept.java

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import com.alchemyapi.api.AlchemyApi;
44
import com.alchemyapi.helpers.ResourceUtils;
55
import com.alchemyapi.helpers.TestApiFactory;
6+
import org.apache.log4j.Logger;
67
import org.jsoup.nodes.Document;
78
import org.junit.Test;
89

@@ -13,26 +14,28 @@
1314
*/
1415
public class STestConcept {
1516

17+
private static final Logger LOGGER = Logger.getLogger(STestConcept.class);
18+
1619
private final AlchemyApi alchemyApi = TestApiFactory.build(new File(System.getProperty("user.home"), ".alchemy/api.key"));
1720

1821
@Test
1922
public void url() {
2023
final Document document = alchemyApi.urlGetRankedConcepts("http://www.techcrunch.com/");
21-
System.out.println(document);
24+
LOGGER.info(document);
2225
}
2326

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

3134
@Test
3235
public void html() {
3336
final String html = ResourceUtils.toString("data/example.html");
3437
final Document document = alchemyApi.htmlGetRankedConcepts(html, "http://www.test.com/");
35-
System.out.println(document);
38+
LOGGER.info(document);
3639
}
3740

3841
}

src/test/java/com/alchemyapi/STestConstraintQuery.java

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import com.alchemyapi.api.AlchemyApi;
44
import com.alchemyapi.helpers.ResourceUtils;
55
import com.alchemyapi.helpers.TestApiFactory;
6+
import org.apache.log4j.Logger;
67
import org.jsoup.nodes.Document;
78
import org.junit.Test;
89

@@ -13,19 +14,21 @@
1314
*/
1415
public class STestConstraintQuery {
1516

17+
private static final Logger LOGGER = Logger.getLogger(STestConstraintQuery.class);
18+
1619
private final AlchemyApi alchemyApi = TestApiFactory.build(new File(System.getProperty("user.home"), ".alchemy/api.key"));
1720

1821
@Test
1922
public void url() {
2023
final Document document = alchemyApi.urlGetConstraintQuery("http://microformats.org/wiki/hcard", "1st link");
21-
System.out.println(document);
24+
LOGGER.info(document);
2225
}
2326

2427
@Test
2528
public void html() {
2629
final String html = ResourceUtils.toString("data/example.html");
2730
final Document document = alchemyApi.htmlGetConstraintQuery(html, "http://www.test.com/", "1st link");
28-
System.out.println(document);
31+
LOGGER.info(document);
2932
}
3033

3134
}

src/test/java/com/alchemyapi/STestEntity.java

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import com.alchemyapi.api.AlchemyApi;
44
import com.alchemyapi.helpers.ResourceUtils;
55
import com.alchemyapi.helpers.TestApiFactory;
6+
import org.apache.log4j.Logger;
67
import org.jsoup.nodes.Document;
78
import org.junit.Test;
89

@@ -13,26 +14,28 @@
1314
*/
1415
public class STestEntity {
1516

17+
private static final Logger LOGGER = Logger.getLogger(STestEntity.class);
18+
1619
private final AlchemyApi alchemyApi = TestApiFactory.build(new File(System.getProperty("user.home"), ".alchemy/api.key"));
1720

1821
@Test
1922
public void url() {
2023
final Document document = alchemyApi.urlGetRankedNamedEntities("http://www.techcrunch.com/");
21-
System.out.println(document);
24+
LOGGER.info(document);
2225
}
2326

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

3134
@Test
3235
public void html() {
3336
final String html = ResourceUtils.toString("data/example.html");
3437
final Document document = alchemyApi.htmlGetRankedNamedEntities(html, "http://www.test.com/");
35-
System.out.println(document);
38+
LOGGER.info(document);
3639
}
3740

3841
}

src/test/java/com/alchemyapi/STestFeedLinks.java

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import com.alchemyapi.api.AlchemyApi;
44
import com.alchemyapi.helpers.ResourceUtils;
55
import com.alchemyapi.helpers.TestApiFactory;
6+
import org.apache.log4j.Logger;
67
import org.jsoup.nodes.Document;
78
import org.junit.Test;
89

@@ -13,19 +14,21 @@
1314
*/
1415
public class STestFeedLinks {
1516

17+
private static final Logger LOGGER = Logger.getLogger(STestFeedLinks.class);
18+
1619
private final AlchemyApi alchemyApi = TestApiFactory.build(new File(System.getProperty("user.home"), ".alchemy/api.key"));
1720

1821
@Test
1922
public void url() {
2023
final Document document = alchemyApi.urlGetFeedLinks("http://www.techcrunch.com/");
21-
System.out.println(document);
24+
LOGGER.info(document);
2225
}
2326

2427
@Test
2528
public void html() {
2629
final String html = ResourceUtils.toString("data/example.html");
2730
final Document document = alchemyApi.htmlGetFeedLinks(html, "http://www.test.com/");
28-
System.out.println(document);
31+
LOGGER.info(document);
2932
}
3033

3134
}

src/test/java/com/alchemyapi/STestImage.java

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
import com.alchemyapi.api.parameters.ImageParameters;
55
import com.alchemyapi.helpers.ResourceUtils;
66
import com.alchemyapi.helpers.TestApiFactory;
7+
import org.apache.log4j.Logger;
78
import org.jsoup.nodes.Document;
89
import org.junit.Test;
910

@@ -14,18 +15,20 @@
1415
*/
1516
public class STestImage {
1617

18+
private static final Logger LOGGER = Logger.getLogger(STestImage.class);
19+
1720
private final AlchemyApi alchemyApi = TestApiFactory.build(new File(System.getProperty("user.home"), ".alchemy/api.key"));
1821

1922
@Test
2023
public void url() {
2124
final Document document = alchemyApi.urlGetImage("http://www.techcrunch.com/");
22-
System.out.println(document);
25+
LOGGER.info(document);
2326
}
2427

2528
@Test
2629
public void imageUrl() {
2730
final Document document = alchemyApi.urlGetRankedImageKeywords("http://farm4.staticflickr.com/3726/11043305726_fdcb7785ec_m.jpg");
28-
System.out.println(document);
31+
LOGGER.info(document);
2932
}
3033

3134
@Test
@@ -35,7 +38,7 @@ public void imageFile() {
3538
imageParams.setImage(imageBytes);
3639
imageParams.setImagePostMode(ImageParameters.RAW);
3740
final Document document = alchemyApi.imageGetRankedImageKeywords(imageParams);
38-
System.out.println(document);
41+
LOGGER.info(document);
3942
}
4043

4144
}

src/test/java/com/alchemyapi/STestKeyword.java

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import com.alchemyapi.api.AlchemyApi;
44
import com.alchemyapi.helpers.ResourceUtils;
55
import com.alchemyapi.helpers.TestApiFactory;
6+
import org.apache.log4j.Logger;
67
import org.jsoup.nodes.Document;
78
import org.junit.Test;
89

@@ -13,26 +14,28 @@
1314
*/
1415
public class STestKeyword {
1516

17+
private static final Logger LOGGER = Logger.getLogger(STestKeyword.class);
18+
1619
private final AlchemyApi alchemyApi = TestApiFactory.build(new File(System.getProperty("user.home"), ".alchemy/api.key"));
1720

1821
@Test
1922
public void url() {
2023
final Document document = alchemyApi.urlGetRankedKeywords("http://www.techcrunch.com/");
21-
System.out.println(document);
24+
LOGGER.info(document);
2225
}
2326

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

3134
@Test
3235
public void html() {
3336
final String html = ResourceUtils.toString("data/example.html");
3437
final Document document = alchemyApi.htmlGetRankedKeywords(html, "http://www.test.com/");
35-
System.out.println(document);
38+
LOGGER.info(document);
3639
}
3740

3841
}

0 commit comments

Comments
 (0)