Merge pull request #187 from chrismayer/tests-code-optimization
Code optimizations for test sources
This commit is contained in:
commit
baf27a6ed7
@ -1,6 +1,5 @@
|
||||
package it.geosolutions.geoserver.decoder;
|
||||
|
||||
import it.geosolutions.geoserver.rest.decoder.RESTLayer;
|
||||
import it.geosolutions.geoserver.rest.decoder.RESTLayer21;
|
||||
import it.geosolutions.geoserver.rest.encoder.authorityurl.GSAuthorityURLInfoEncoder;
|
||||
import it.geosolutions.geoserver.rest.encoder.identifier.GSIdentifierInfoEncoder;
|
||||
@ -14,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;
|
||||
|
||||
/**
|
||||
@ -25,6 +26,8 @@ import org.springframework.core.io.ClassPathResource;
|
||||
*/
|
||||
public class LayerDecoder21Test{
|
||||
|
||||
private final static Logger LOGGER = LoggerFactory.getLogger(LayerDecoder21Test.class);
|
||||
|
||||
RESTLayer21 layer;
|
||||
|
||||
@Before
|
||||
@ -43,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());
|
||||
|
||||
@ -23,7 +23,6 @@ package it.geosolutions.geoserver.decoder;
|
||||
|
||||
import it.geosolutions.geoserver.rest.decoder.RESTCoverage;
|
||||
import it.geosolutions.geoserver.rest.decoder.RESTDimensionInfo;
|
||||
import it.geosolutions.geoserver.rest.encoder.metadatalink.GSMetadataLinkInfoEncoder;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
|
||||
@ -21,11 +21,8 @@
|
||||
*/
|
||||
package it.geosolutions.geoserver.decoder;
|
||||
|
||||
import it.geosolutions.geoserver.rest.GeoServerRESTPublisher;
|
||||
import it.geosolutions.geoserver.rest.GeoServerRESTReader;
|
||||
import it.geosolutions.geoserver.rest.GeoserverRESTTest;
|
||||
import it.geosolutions.geoserver.rest.decoder.about.GSVersionDecoder;
|
||||
import it.geosolutions.geoserver.rest.decoder.about.GSVersionDecoder.VERSION;
|
||||
import junit.framework.Assert;
|
||||
|
||||
import org.jdom.Element;
|
||||
|
||||
@ -25,12 +25,10 @@
|
||||
package it.geosolutions.geoserver.rest;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import it.geosolutions.geoserver.rest.decoder.RESTLayerGroup;
|
||||
import it.geosolutions.geoserver.rest.decoder.utils.NameLinkElem;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.slf4j.Logger;
|
||||
|
||||
@ -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
|
||||
|
||||
}
|
||||
@ -116,7 +121,6 @@ public class GeoserverRESTReaderTest extends GeoserverRESTTest {
|
||||
// assertEquals(7, wsnames.size()); // value in default gs installation
|
||||
|
||||
// System.out.println("Workspaces: " + wslist.size());
|
||||
int dsnum = 0;
|
||||
int wscnt = 0;
|
||||
for (RESTWorkspaceList.RESTShortWorkspace ws : wslist) {
|
||||
String wsname = wsnames.get(wscnt++);
|
||||
@ -158,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("");
|
||||
}
|
||||
|
||||
/**
|
||||
@ -179,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("");
|
||||
}
|
||||
|
||||
/**
|
||||
@ -198,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());
|
||||
}
|
||||
@ -218,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("");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -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.");
|
||||
}
|
||||
}
|
||||
|
||||
@ -24,16 +24,15 @@
|
||||
*/
|
||||
package it.geosolutions.geoserver.rest;
|
||||
|
||||
import static it.geosolutions.geoserver.rest.GeoserverRESTTest.publisher;
|
||||
import static it.geosolutions.geoserver.rest.GeoserverRESTTest.reader;
|
||||
import it.geosolutions.geoserver.rest.decoder.RESTStyle;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import org.junit.Test;
|
||||
import static org.junit.Assert.*;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
import org.springframework.core.io.ClassPathResource;
|
||||
|
||||
/**
|
||||
@ -81,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
|
||||
|
||||
@ -19,8 +19,6 @@
|
||||
*/
|
||||
package it.geosolutions.geoserver.rest.encoder.coverage;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
import it.geosolutions.geoserver.rest.encoder.GSResourceEncoder;
|
||||
import it.geosolutions.geoserver.rest.encoder.GSResourceEncoder.ProjectionPolicy;
|
||||
import it.geosolutions.geoserver.rest.encoder.dimensions.GSCoverageDimensionEncoder;
|
||||
|
||||
@ -19,12 +19,6 @@
|
||||
*/
|
||||
package it.geosolutions.geoserver.rest.encoder.dimensions;
|
||||
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import it.geosolutions.geoserver.rest.encoder.feature.GSFeatureTypeEncoder;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import junit.framework.Assert;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
@ -23,14 +23,11 @@ import it.geosolutions.geoserver.rest.GeoServerRESTPublisher;
|
||||
import it.geosolutions.geoserver.rest.GeoserverRESTTest;
|
||||
import it.geosolutions.geoserver.rest.decoder.RESTFeatureType;
|
||||
import it.geosolutions.geoserver.rest.decoder.RESTLayer;
|
||||
import it.geosolutions.geoserver.rest.decoder.RESTResource;
|
||||
import it.geosolutions.geoserver.rest.decoder.about.GSVersionDecoder;
|
||||
import it.geosolutions.geoserver.rest.decoder.about.GSVersionDecoder.VERSION;
|
||||
import it.geosolutions.geoserver.rest.encoder.GSLayerEncoder;
|
||||
import it.geosolutions.geoserver.rest.encoder.GSLayerEncoder21;
|
||||
import it.geosolutions.geoserver.rest.encoder.GSResourceEncoder;
|
||||
import it.geosolutions.geoserver.rest.encoder.authorityurl.GSAuthorityURLInfoEncoder;
|
||||
import it.geosolutions.geoserver.rest.encoder.dimensions.GSCoverageDimensionEncoder;
|
||||
import it.geosolutions.geoserver.rest.encoder.identifier.GSIdentifierInfoEncoder;
|
||||
import it.geosolutions.geoserver.rest.encoder.metadata.GSDimensionInfoEncoder;
|
||||
import it.geosolutions.geoserver.rest.encoder.metadata.GSDimensionInfoEncoder.Presentation;
|
||||
|
||||
@ -26,8 +26,6 @@
|
||||
package it.geosolutions.geoserver.rest.publisher;
|
||||
|
||||
import it.geosolutions.geoserver.rest.GeoserverRESTTest;
|
||||
import static it.geosolutions.geoserver.rest.GeoserverRESTTest.publisher;
|
||||
import static it.geosolutions.geoserver.rest.GeoserverRESTTest.reader;
|
||||
import it.geosolutions.geoserver.rest.decoder.RESTLayer;
|
||||
import it.geosolutions.geoserver.rest.decoder.RESTStyle;
|
||||
import it.geosolutions.geoserver.rest.decoder.utils.JDOMBuilder;
|
||||
|
||||
@ -33,8 +33,6 @@ import java.io.IOException;
|
||||
|
||||
import org.junit.Test;
|
||||
import static org.junit.Assert.*;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.core.io.ClassPathResource;
|
||||
|
||||
/**
|
||||
@ -47,8 +45,6 @@ import org.springframework.core.io.ClassPathResource;
|
||||
*/
|
||||
public class GeoserverRESTWorkspaceTest extends GeoserverRESTTest {
|
||||
|
||||
private final static Logger LOGGER = LoggerFactory.getLogger(GeoserverRESTWorkspaceTest.class);
|
||||
|
||||
@Test
|
||||
public void testWorkspaces() {
|
||||
if (!enabled()) return;
|
||||
|
||||
@ -35,8 +35,6 @@ import org.apache.commons.httpclient.NameValuePair;
|
||||
import org.junit.Test;
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.core.io.ClassPathResource;
|
||||
|
||||
/**
|
||||
@ -48,8 +46,6 @@ import org.springframework.core.io.ClassPathResource;
|
||||
*/
|
||||
public class GeoserverRESTWorldImageTest extends GeoserverRESTTest {
|
||||
|
||||
private final static Logger LOGGER = LoggerFactory.getLogger(GeoserverRESTWorldImageTest.class);
|
||||
|
||||
@Test
|
||||
public void testPublishWorldImage() throws IOException {
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user