Remove System.out.print in test sources

This removes the 'System.out.print' commands in the test sources by
replacing them with simple LOGGER.debug commands (fixes #36).
This commit is contained in:
Christian Mayer 2016-04-19 12:19:07 +02:00
parent c6d6c3d2b9
commit 88668158f6
4 changed files with 46 additions and 32 deletions

View File

@ -13,6 +13,8 @@ import junit.framework.Assert;
import org.apache.commons.io.FileUtils;
import org.junit.Before;
import org.junit.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.core.io.ClassPathResource;
/**
@ -24,6 +26,8 @@ import org.springframework.core.io.ClassPathResource;
*/
public class LayerDecoder21Test{
private final static Logger LOGGER = LoggerFactory.getLogger(LayerDecoder21Test.class);
RESTLayer21 layer;
@Before
@ -42,7 +46,7 @@ public class LayerDecoder21Test{
public void testAuthorityURLs() {
List<GSAuthorityURLInfoEncoder> authorityURLs = layer
.getEncodedAuthorityURLInfoList();
System.out.println(authorityURLs.size());
LOGGER.debug("Number of authority URLs: " + authorityURLs.size());
Assert.assertEquals("authority1", authorityURLs.get(0).getName());
Assert.assertEquals("http://www.authority1.org", authorityURLs.get(0)
.getHref());

View File

@ -35,6 +35,9 @@ import it.geosolutions.geoserver.rest.decoder.utils.NameLinkElem;
import java.util.List;
import org.junit.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import static org.junit.Assert.*;
@ -44,6 +47,8 @@ import static org.junit.Assert.*;
*/
public class GeoserverRESTReaderTest extends GeoserverRESTTest {
private final static Logger LOGGER = LoggerFactory.getLogger(GeoserverRESTReaderTest.class);
/**
* Test of getLayers method, of class GeoServerRESTReader.
*/
@ -56,16 +61,16 @@ public class GeoserverRESTReaderTest extends GeoserverRESTTest {
// assertEquals(/*CHANGEME*/19, result.getChildren("layer").size()); // value in default gs installation
// System.out.println("Layers:" + result.getChildren("layer").size());
System.out.println("Layers:" + result.size());
System.out.print("Layers:" );
LOGGER.debug("Layers: " + result.size());
// LOGGER.debug("Layers:" );
for (NameLinkElem shlayer : result) {
assertNotNull(shlayer.getName());
System.out.print(shlayer.getName() + " ");
LOGGER.debug(shlayer.getName() + " ");
}
// for (Element layer : (List<Element>)result.getChildren("layer")) {
// System.out.print(layer.getChildText("name") + " ");
// }
System.out.println();
LOGGER.debug("");
}
/**
@ -79,25 +84,25 @@ public class GeoserverRESTReaderTest extends GeoserverRESTTest {
assertNotNull(wslist);
// assertEquals(7, wslist.size()); // value in default gs installation
System.out.println("Workspaces: " + wslist.size());
LOGGER.debug("Workspaces: " + wslist.size());
int dsnum = 0;
for (RESTWorkspaceList.RESTShortWorkspace ws : wslist) {
System.out.println("Getting DSlist for WS " + ws.getName() + "..." );
LOGGER.debug("Getting DSlist for WS " + ws.getName() + "..." );
RESTDataStoreList result = reader.getDatastores(ws.getName());
assertNotNull(result);
dsnum += result.size();
for (NameLinkElem ds : result) {
assertNotNull(ds.getName());
System.out.print(ds.getName() + " " );
LOGGER.debug(ds.getName() + " " );
RESTDataStore datastore = reader.getDatastore(ws.getName(), ds.getName());
assertNotNull(datastore);
assertEquals(ds.getName(), datastore.getName());
assertEquals(ws.getName(), datastore.getWorkspaceName());
}
System.out.println();
LOGGER.debug("");
}
System.out.println();
System.out.println("Datastores:" + dsnum); // value in default gs installation
LOGGER.debug("");
LOGGER.debug("Datastores:" + dsnum); // value in default gs installation
// assertEquals(4, dsnum); // value in default gs installation
}
@ -157,14 +162,14 @@ public class GeoserverRESTReaderTest extends GeoserverRESTTest {
assertNotNull(names);
assertEquals(names.size(), result.size()); // value in default gs installation
System.out.println("Namespaces:" + result.size());
System.out.print("Namespaces:" );
LOGGER.debug("Namespaces:" + result.size());
LOGGER.debug("Namespaces:" );
int namesIdx = 0;
for (RESTNamespaceList.RESTShortNamespace ns : result) {
assertEquals("namespace mismatch", names.get(namesIdx++), ns.getName());
System.out.print(ns.getName() + " " );
LOGGER.debug(ns.getName() + " " );
}
System.out.println();
LOGGER.debug("");
}
/**
@ -178,12 +183,12 @@ public class GeoserverRESTReaderTest extends GeoserverRESTTest {
assertNotNull(names);
// assertEquals(7, names.size()); // value in default gs installation
System.out.println("Namespaces:" + names.size());
System.out.print("Namespaces:");
LOGGER.debug("Namespaces:" + names.size());
LOGGER.debug("Namespaces:");
for (String name : names) {
System.out.print(name + " ");
LOGGER.debug(name + " ");
}
System.out.println();
LOGGER.debug("");
}
/**
@ -197,12 +202,12 @@ public class GeoserverRESTReaderTest extends GeoserverRESTTest {
assertNotNull(wslist);
// assertEquals(7, wslist.size()); // value in default gs installation
System.out.println("Workspaces:" + wslist.size());
System.out.print("Workspaces:");
LOGGER.debug("Workspaces:" + wslist.size());
LOGGER.debug("Workspaces:");
for (RESTWorkspaceList.RESTShortWorkspace ws : wslist) {
System.out.print(ws.getName() + " ");
LOGGER.debug(ws.getName() + " ");
}
System.out.println();
LOGGER.debug("");
assertEquals(wslist.size(), reader.getWorkspaceNames().size());
}
@ -217,12 +222,12 @@ public class GeoserverRESTReaderTest extends GeoserverRESTTest {
assertNotNull(names);
// assertEquals(7, names.size()); // value in default gs installation
System.out.println("Workspaces:" + names.size());
System.out.print("Workspaces:");
LOGGER.debug("Workspaces:" + names.size());
LOGGER.debug("Workspaces:");
for (String name : names) {
System.out.print(name + " ");
LOGGER.debug(name + " ");
}
System.out.println();
LOGGER.debug("");
}
}

View File

@ -135,17 +135,17 @@ public abstract class GeoserverRESTTest {
+ RESTURL);
}
} else if (existgs == false){
System.out.println("Failing tests : geoserver not found");
LOGGER.debug("Failing tests : geoserver not found");
fail("GeoServer not found");
}
GSVersionDecoder v=reader.getGeoserverVersion();
if (v.compareTo(VERSION.getVersion(GS_VERSION))!=0){
System.out.println("Failing tests : geoserver version does not match.\nAccepted versions: "+VERSION.print());
LOGGER.debug("Failing tests : geoserver version does not match.\nAccepted versions: "+VERSION.print());
fail("GeoServer version ("+v.getVersion()+") does not match the desired one ("+GS_VERSION+")");
}
} else {
System.out.println("Skipping tests ");
LOGGER.debug("Skipping tests ");
LOGGER.warn("Tests are disabled. Please read the documentation to enable them.");
}
}

View File

@ -29,6 +29,9 @@ import it.geosolutions.geoserver.rest.decoder.RESTStyle;
import java.io.File;
import java.io.IOException;
import org.junit.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import static org.junit.Assert.*;
import org.springframework.core.io.ClassPathResource;
@ -38,6 +41,8 @@ import org.springframework.core.io.ClassPathResource;
*/
public class UtilTest extends GeoserverRESTTest {
private final static Logger LOGGER = LoggerFactory.getLogger(UtilTest.class);
@Test
public void testSearchStyle() throws IOException {
if (!enabled()) {
@ -75,7 +80,7 @@ public class UtilTest extends GeoserverRESTTest {
for(RESTStyle style : Util.searchStyles(reader, STYLENAME))
{
System.out.println(style.getWorkspace() + " :: " + style.getName());
LOGGER.debug(style.getWorkspace() + " :: " + style.getName());
}
// there's a bug in geoserver here: the global style will include workspace info