From 519eb88dd4f628b7e3c72c58a919b75639ae4f82 Mon Sep 17 00:00:00 2001 From: Enrico Daga Date: Fri, 27 Jan 2023 17:39:18 +0000 Subject: [PATCH] Replaced some with loggers -- see #199 --- .../github/sparqlanything/bib/BibtexTriplifier.java | 2 +- .../com/github/sparqlanything/bib/test/BaseTest.java | 8 +++++--- .../bib/test/BibtexTriplifierTest.java | 6 ++++-- .../sparqlanything/binary/BinaryTriplifier.java | 2 +- .../binary/test/BinaryTriplifierTest.java | 5 ++++- .../sparqlanything/docs/test/TestTriplifier.java | 12 +++++++----- .../github/sparqlanything/fuseki/YASGUIServlet.java | 6 ++++-- 7 files changed, 26 insertions(+), 15 deletions(-) diff --git a/sparql-anything-bib/src/main/java/com/github/sparqlanything/bib/BibtexTriplifier.java b/sparql-anything-bib/src/main/java/com/github/sparqlanything/bib/BibtexTriplifier.java index bd34f99a..61cfd59e 100644 --- a/sparql-anything-bib/src/main/java/com/github/sparqlanything/bib/BibtexTriplifier.java +++ b/sparql-anything-bib/src/main/java/com/github/sparqlanything/bib/BibtexTriplifier.java @@ -70,7 +70,7 @@ public void triplify(Properties properties, FacadeXGraphBuilder builder) throws try { builder.addType(dataSourceId, containerIdChild, new URI(namespace + entry.getType().toString())); } catch (URISyntaxException e) { - e.printStackTrace(); + logger.error("",e); } builder.addContainer(dataSourceId, root, count.incrementAndGet(), containerIdChild); entry.getFields().forEach((keyField, valueField) -> { diff --git a/sparql-anything-bib/src/test/java/com/github/sparqlanything/bib/test/BaseTest.java b/sparql-anything-bib/src/test/java/com/github/sparqlanything/bib/test/BaseTest.java index 84424516..9f693764 100644 --- a/sparql-anything-bib/src/test/java/com/github/sparqlanything/bib/test/BaseTest.java +++ b/sparql-anything-bib/src/test/java/com/github/sparqlanything/bib/test/BaseTest.java @@ -29,6 +29,8 @@ import org.apache.jena.sparql.graph.GraphFactory; import org.apache.jena.vocabulary.RDF; import org.junit.Test; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import java.io.IOException; import java.util.Properties; @@ -37,7 +39,7 @@ import static org.junit.Assert.assertTrue; public class BaseTest { - + final static Logger logger = LoggerFactory.getLogger(BaseTest.class); @Test public void testContent() throws TriplifierHTTPException { @@ -61,7 +63,7 @@ public void testContent() throws TriplifierHTTPException { assertTrue(g1.getDefaultGraph().isIsomorphicWith(expected)); } catch (IOException e1) { - e1.printStackTrace(); + logger.error("",e1); } } @@ -86,7 +88,7 @@ public void testBlankNodeFalse() throws TriplifierHTTPException { }); } catch (IOException e1) { - e1.printStackTrace(); + logger.error("",e1); } } diff --git a/sparql-anything-bib/src/test/java/com/github/sparqlanything/bib/test/BibtexTriplifierTest.java b/sparql-anything-bib/src/test/java/com/github/sparqlanything/bib/test/BibtexTriplifierTest.java index 43a0b982..7459e63f 100644 --- a/sparql-anything-bib/src/test/java/com/github/sparqlanything/bib/test/BibtexTriplifierTest.java +++ b/sparql-anything-bib/src/test/java/com/github/sparqlanything/bib/test/BibtexTriplifierTest.java @@ -29,6 +29,8 @@ import org.apache.jena.sparql.graph.GraphFactory; import org.apache.jena.vocabulary.RDF; import org.junit.Test; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import java.io.IOException; import java.util.Properties; @@ -36,7 +38,7 @@ import static org.junit.Assert.assertTrue; public class BibtexTriplifierTest { - + final static Logger logger = LoggerFactory.getLogger(BibtexTriplifierTest.class); @Test public void test1() { BibtexTriplifier jt = new BibtexTriplifier(); @@ -79,7 +81,7 @@ public void test1() { assertTrue(expectedGraph.isIsomorphicWith(g1.getDefaultGraph())); } catch (IOException e1) { - e1.printStackTrace(); + logger.error("",e1); } } diff --git a/sparql-anything-binary/src/main/java/com/github/sparqlanything/binary/BinaryTriplifier.java b/sparql-anything-binary/src/main/java/com/github/sparqlanything/binary/BinaryTriplifier.java index 3b28c905..e673fb3d 100644 --- a/sparql-anything-binary/src/main/java/com/github/sparqlanything/binary/BinaryTriplifier.java +++ b/sparql-anything-binary/src/main/java/com/github/sparqlanything/binary/BinaryTriplifier.java @@ -99,7 +99,7 @@ private byte[] downloadUrl(URL toDownload) { } } catch (IOException e) { - e.printStackTrace(); + logger.error("",e); return null; } diff --git a/sparql-anything-binary/src/test/java/com/github/sparqlanything/binary/test/BinaryTriplifierTest.java b/sparql-anything-binary/src/test/java/com/github/sparqlanything/binary/test/BinaryTriplifierTest.java index 95464e9b..58d80742 100644 --- a/sparql-anything-binary/src/test/java/com/github/sparqlanything/binary/test/BinaryTriplifierTest.java +++ b/sparql-anything-binary/src/test/java/com/github/sparqlanything/binary/test/BinaryTriplifierTest.java @@ -30,6 +30,8 @@ import org.apache.jena.sparql.graph.GraphFactory; import org.apache.jena.vocabulary.RDF; import org.junit.Test; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import java.io.File; import java.io.IOException; @@ -40,6 +42,7 @@ import static org.junit.Assert.assertTrue; public class BinaryTriplifierTest { + final static Logger logger = LoggerFactory.getLogger(BinaryTriplifierTest.class); @Test public void testBase64() throws MalformedURLException { @@ -60,7 +63,7 @@ public void testBase64() throws MalformedURLException { assertTrue(dg.getDefaultGraph().isIsomorphicWith(expectedGraph)); assertTrue(dg.getGraph(NodeFactory.createURI(Triplifier.getRootArgument(p))).isIsomorphicWith(expectedGraph)); } catch (IOException e) { - e.printStackTrace(); + logger.error("",e); } } diff --git a/sparql-anything-docs/src/test/java/com/github/sparqlanything/docs/test/TestTriplifier.java b/sparql-anything-docs/src/test/java/com/github/sparqlanything/docs/test/TestTriplifier.java index bfde4bf1..008b3fa7 100644 --- a/sparql-anything-docs/src/test/java/com/github/sparqlanything/docs/test/TestTriplifier.java +++ b/sparql-anything-docs/src/test/java/com/github/sparqlanything/docs/test/TestTriplifier.java @@ -34,6 +34,8 @@ import org.apache.jena.vocabulary.RDF; import org.junit.Ignore; import org.junit.Test; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import java.io.IOException; import java.net.URL; @@ -43,7 +45,7 @@ import static org.junit.Assert.assertTrue; public class TestTriplifier { - + final static Logger logger = LoggerFactory.getLogger(TestTriplifier.class); @Ignore @Test public void test1() { @@ -102,7 +104,7 @@ public void test1() { .isIsomorphicWith(expectedGraph)); } catch (IOException e) { - e.printStackTrace(); + logger.error("",e); } } @@ -133,7 +135,7 @@ public void testNoBlankNodes() { // assertTrue(dg.getGraph(NodeFactory.createURI(doc.toString())).isIsomorphicWith(expectedGraph)); } catch (IOException e) { - e.printStackTrace(); + logger.error("",e); } } @@ -226,7 +228,7 @@ public void test2() { } } catch (IOException e) { - e.printStackTrace(); + logger.error("",e); } } @@ -308,7 +310,7 @@ public void test3() { .isIsomorphicWith(expectedGraph)); } catch (IOException e) { - e.printStackTrace(); + logger.error("",e); } } diff --git a/sparql-anything-fuseki/src/main/java/com/github/sparqlanything/fuseki/YASGUIServlet.java b/sparql-anything-fuseki/src/main/java/com/github/sparqlanything/fuseki/YASGUIServlet.java index acfa9c5c..33ca3107 100644 --- a/sparql-anything-fuseki/src/main/java/com/github/sparqlanything/fuseki/YASGUIServlet.java +++ b/sparql-anything-fuseki/src/main/java/com/github/sparqlanything/fuseki/YASGUIServlet.java @@ -19,6 +19,8 @@ import freemarker.template.Configuration; import freemarker.template.Template; import freemarker.template.TemplateException; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import javax.servlet.ServletException; import javax.servlet.http.HttpServlet; @@ -30,7 +32,7 @@ import java.util.Map; public class YASGUIServlet extends HttpServlet { - + final static Logger logger = LoggerFactory.getLogger(YASGUIServlet.class); private static final long serialVersionUID = 1L; private String fxPrefix, endpointPath; @@ -57,7 +59,7 @@ public void doGet(HttpServletRequest req, HttpServletResponse res) throws Servle temp.process(var, pw); // temp.process(var, sw); } catch (TemplateException | IOException e1) { - e1.printStackTrace(); + logger.error("",e1); } pw.close(); // System.out.println(sw.toString());