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

View File

@ -35,6 +35,9 @@ import it.geosolutions.geoserver.rest.decoder.utils.NameLinkElem;
import java.util.List; import java.util.List;
import org.junit.Test; import org.junit.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import static org.junit.Assert.*; import static org.junit.Assert.*;
@ -44,6 +47,8 @@ import static org.junit.Assert.*;
*/ */
public class GeoserverRESTReaderTest extends GeoserverRESTTest { public class GeoserverRESTReaderTest extends GeoserverRESTTest {
private final static Logger LOGGER = LoggerFactory.getLogger(GeoserverRESTReaderTest.class);
/** /**
* Test of getLayers method, of class GeoServerRESTReader. * 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 // 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.getChildren("layer").size());
System.out.println("Layers:" + result.size()); LOGGER.debug("Layers: " + result.size());
System.out.print("Layers:" ); // LOGGER.debug("Layers:" );
for (NameLinkElem shlayer : result) { for (NameLinkElem shlayer : result) {
assertNotNull(shlayer.getName()); assertNotNull(shlayer.getName());
System.out.print(shlayer.getName() + " "); LOGGER.debug(shlayer.getName() + " ");
} }
// for (Element layer : (List<Element>)result.getChildren("layer")) { // for (Element layer : (List<Element>)result.getChildren("layer")) {
// System.out.print(layer.getChildText("name") + " "); // System.out.print(layer.getChildText("name") + " ");
// } // }
System.out.println(); LOGGER.debug("");
} }
/** /**
@ -79,25 +84,25 @@ public class GeoserverRESTReaderTest extends GeoserverRESTTest {
assertNotNull(wslist); assertNotNull(wslist);
// assertEquals(7, wslist.size()); // value in default gs installation // assertEquals(7, wslist.size()); // value in default gs installation
System.out.println("Workspaces: " + wslist.size()); LOGGER.debug("Workspaces: " + wslist.size());
int dsnum = 0; int dsnum = 0;
for (RESTWorkspaceList.RESTShortWorkspace ws : wslist) { 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()); RESTDataStoreList result = reader.getDatastores(ws.getName());
assertNotNull(result); assertNotNull(result);
dsnum += result.size(); dsnum += result.size();
for (NameLinkElem ds : result) { for (NameLinkElem ds : result) {
assertNotNull(ds.getName()); assertNotNull(ds.getName());
System.out.print(ds.getName() + " " ); LOGGER.debug(ds.getName() + " " );
RESTDataStore datastore = reader.getDatastore(ws.getName(), ds.getName()); RESTDataStore datastore = reader.getDatastore(ws.getName(), ds.getName());
assertNotNull(datastore); assertNotNull(datastore);
assertEquals(ds.getName(), datastore.getName()); assertEquals(ds.getName(), datastore.getName());
assertEquals(ws.getName(), datastore.getWorkspaceName()); assertEquals(ws.getName(), datastore.getWorkspaceName());
} }
System.out.println(); LOGGER.debug("");
} }
System.out.println(); LOGGER.debug("");
System.out.println("Datastores:" + dsnum); // value in default gs installation LOGGER.debug("Datastores:" + dsnum); // value in default gs installation
// assertEquals(4, 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); assertNotNull(names);
assertEquals(names.size(), result.size()); // value in default gs installation assertEquals(names.size(), result.size()); // value in default gs installation
System.out.println("Namespaces:" + result.size()); LOGGER.debug("Namespaces:" + result.size());
System.out.print("Namespaces:" ); LOGGER.debug("Namespaces:" );
int namesIdx = 0; int namesIdx = 0;
for (RESTNamespaceList.RESTShortNamespace ns : result) { for (RESTNamespaceList.RESTShortNamespace ns : result) {
assertEquals("namespace mismatch", names.get(namesIdx++), ns.getName()); 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); assertNotNull(names);
// assertEquals(7, names.size()); // value in default gs installation // assertEquals(7, names.size()); // value in default gs installation
System.out.println("Namespaces:" + names.size()); LOGGER.debug("Namespaces:" + names.size());
System.out.print("Namespaces:"); LOGGER.debug("Namespaces:");
for (String name : names) { 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); assertNotNull(wslist);
// assertEquals(7, wslist.size()); // value in default gs installation // assertEquals(7, wslist.size()); // value in default gs installation
System.out.println("Workspaces:" + wslist.size()); LOGGER.debug("Workspaces:" + wslist.size());
System.out.print("Workspaces:"); LOGGER.debug("Workspaces:");
for (RESTWorkspaceList.RESTShortWorkspace ws : wslist) { 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()); assertEquals(wslist.size(), reader.getWorkspaceNames().size());
} }
@ -217,12 +222,12 @@ public class GeoserverRESTReaderTest extends GeoserverRESTTest {
assertNotNull(names); assertNotNull(names);
// assertEquals(7, names.size()); // value in default gs installation // assertEquals(7, names.size()); // value in default gs installation
System.out.println("Workspaces:" + names.size()); LOGGER.debug("Workspaces:" + names.size());
System.out.print("Workspaces:"); LOGGER.debug("Workspaces:");
for (String name : names) { 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); + RESTURL);
} }
} else if (existgs == false){ } else if (existgs == false){
System.out.println("Failing tests : geoserver not found"); LOGGER.debug("Failing tests : geoserver not found");
fail("GeoServer not found"); fail("GeoServer not found");
} }
GSVersionDecoder v=reader.getGeoserverVersion(); GSVersionDecoder v=reader.getGeoserverVersion();
if (v.compareTo(VERSION.getVersion(GS_VERSION))!=0){ 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+")"); fail("GeoServer version ("+v.getVersion()+") does not match the desired one ("+GS_VERSION+")");
} }
} else { } else {
System.out.println("Skipping tests "); LOGGER.debug("Skipping tests ");
LOGGER.warn("Tests are disabled. Please read the documentation to enable them."); 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.File;
import java.io.IOException; import java.io.IOException;
import org.junit.Test; import org.junit.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import static org.junit.Assert.*; import static org.junit.Assert.*;
import org.springframework.core.io.ClassPathResource; import org.springframework.core.io.ClassPathResource;
@ -38,6 +41,8 @@ import org.springframework.core.io.ClassPathResource;
*/ */
public class UtilTest extends GeoserverRESTTest { public class UtilTest extends GeoserverRESTTest {
private final static Logger LOGGER = LoggerFactory.getLogger(UtilTest.class);
@Test @Test
public void testSearchStyle() throws IOException { public void testSearchStyle() throws IOException {
if (!enabled()) { if (!enabled()) {
@ -75,7 +80,7 @@ public class UtilTest extends GeoserverRESTTest {
for(RESTStyle style : Util.searchStyles(reader, STYLENAME)) 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 // there's a bug in geoserver here: the global style will include workspace info