Commit 00ed16d9 authored by Yann Mombrun's avatar Yann Mombrun

Improve coverage with a few tests

Update log config for test to improve coverage
parent 22b4c9b0
......@@ -9,7 +9,7 @@ log4j.appender.console.layout.conversionPattern = %d{ISO8601} %-5p %c - %m%n
# Configuration of the Loggers
log4j.rootLogger = INFO, console
log4j.rootLogger = TRACE, console
#log4j.logger.org.springframework = DEBUG
#log4j.logger.org.apache.cxf = INFO
......
......@@ -18,6 +18,8 @@
package org.ow2.weblab;
import static org.junit.Assert.*;
import java.io.File;
import java.io.FileOutputStream;
import java.io.StringWriter;
......@@ -38,11 +40,16 @@ import org.junit.Test;
import org.ow2.weblab.core.extended.jaxb.WebLabMarshaller;
import org.ow2.weblab.core.model.Document;
import com.hp.hpl.jena.query.QuerySolutionMap;
import com.hp.hpl.jena.shared.PrefixMapping;
import com.hp.hpl.jena.shared.impl.PrefixMappingImpl;
public class TestDocumentRenderer {
@Test
public void testEmptyDoc() throws Exception {
final int pagenum = 1;
final String filename = "target/outputEmptyDoc.html";
......@@ -77,6 +84,7 @@ public class TestDocumentRenderer {
@Test
public void testArabicDoc() throws Exception {
final int pagenum = 1;
final String filename = "target/arabic.html";
......@@ -111,6 +119,7 @@ public class TestDocumentRenderer {
@Test
public void testProblematicPdf() throws Exception {
final int pagenum = 1;
final String filename = "target/serval.xml";
......@@ -145,6 +154,7 @@ public class TestDocumentRenderer {
@Test
public void testRenderMultiThread() throws Exception {
final int nbDocs = 20;
final int nbParallel = 10;
......@@ -197,12 +207,14 @@ public class TestDocumentRenderer {
public RendererCallable(final DocumentRendererBean rendererBean) {
this.rendererBean = rendererBean;
}
@Override
public String call() throws Exception {
final StringWriter sw = new StringWriter();
final XMLOutputFactory xof = XMLOutputFactory.newInstance();
final XMLStreamWriter xtw = xof.createXMLStreamWriter(sw);
......@@ -216,4 +228,62 @@ public class TestDocumentRenderer {
}
@Test
public void test4CoverageOnly() throws Exception {
Href h1 = new Href(0, 0, "");
Assert.assertEquals(0, h1.compareTo(h1));
Assert.assertEquals(-1, h1.compareTo(new Href(1, 0, "")));
Assert.assertEquals(-1, h1.compareTo(new Href(0, 1, "")));
Span s1 = new Span(0, 0, "", "", "", "", false, 0);
Span s2 = new Span(0, 0, "", "", "", "", false, 0);
Assert.assertEquals(0, s1.compareTo(s2));
s2.setDifferentiator(5);
Assert.assertEquals(-5, s1.compareTo(s2));
s2.setCandidate(true);
Assert.assertEquals(-1, s1.compareTo(s2));
Assert.assertEquals(1, s2.compareTo(s1));
s2.setNamedEntity("ne2");
Assert.assertEquals("".compareToIgnoreCase("ne2"), s1.compareTo(s2));
s2.setHref("h2");
Assert.assertEquals("".compareToIgnoreCase("h2"), s1.compareTo(s2));
s2.setStyleClassName("scn2");
Assert.assertEquals("".compareToIgnoreCase("scn2"), s1.compareTo(s2));
s2.setStyle("s2");
Assert.assertEquals("".compareToIgnoreCase("s2"), s1.compareTo(s2));
s2.setBegin(1);
Assert.assertEquals(-1, s1.compareTo(s2));
s2.setEnd(5);
Assert.assertEquals(-5, s1.compareTo(s2));
DocumentRendererBean drb = new DocumentRendererBean();
Assert.assertNull(drb.getDocURI());
drb.setDocURI("docUri");
Assert.assertEquals("docUri", drb.getDocURI());
drb.setSPARQLEndpoint("sparqlEndpoint");
drb.setShowInstanceLink(true);
Assert.assertTrue(drb.isShowInstanceLink());
drb.setShowToolTips(true);
Assert.assertTrue(drb.isShowToolTips());
drb.setSpanEntities(new HashMap<>());
Assert.assertTrue(drb.getSpanEntities().isEmpty());
drb.setSpanHrefs(new HashMap<>());
Assert.assertTrue(drb.getSpanHrefs().isEmpty());
Assert.assertNull(drb.getLegendUriClassMap());
drb.setForceNonNormalised(true);
Assert.assertTrue(drb.isForceNonNormalised());
Assert.assertNull(drb.getFindPageRequestType());
drb.setCurrentHref("currentHref");
Assert.assertEquals("currentHref", drb.getCurrentHref());
QueryTriplestoreParameterised qtp = new QueryTriplestoreParameterised("", "requests");
Assert.assertNull(qtp.getQuery());
qtp.readQueryString("notfound!");
Assert.assertNull(qtp.getQuery());
qtp.prepareParameterizedRequest("askIsStructured", new QuerySolutionMap(), DocumentRendererProcessor.createPrefixMapping());
Assert.assertNotNull(qtp.getQuery());
}
}
......@@ -3,8 +3,9 @@
#Console appender
log4j.appender.console=org.apache.log4j.ConsoleAppender
log4j.appender.console.layout=org.apache.log4j.PatternLayout
log4j.appender.console.threshold=FATAL
log4j.appender.console.layout.ConversionPattern = [%p] %m\n
# Root
log4j.rootLogger=FATAL, console
log4j.rootLogger=TRACE, console
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment