From 6689211b5d6218befc3484356b0eeabb023ee754 Mon Sep 17 00:00:00 2001 From: eblondel Date: Mon, 21 Oct 2013 11:28:29 +0200 Subject: [PATCH] #102 master - fix tests --- .../encoder/feature/GSFeatureEncoderTest.java | 152 ++++++------------ 1 file changed, 46 insertions(+), 106 deletions(-) diff --git a/src/test/java/it/geosolutions/geoserver/rest/encoder/feature/GSFeatureEncoderTest.java b/src/test/java/it/geosolutions/geoserver/rest/encoder/feature/GSFeatureEncoderTest.java index a10f77f..d67fd69 100644 --- a/src/test/java/it/geosolutions/geoserver/rest/encoder/feature/GSFeatureEncoderTest.java +++ b/src/test/java/it/geosolutions/geoserver/rest/encoder/feature/GSFeatureEncoderTest.java @@ -95,116 +95,56 @@ public class GSFeatureEncoderTest extends GeoserverRESTTest { if (!GSVersionDecoder.VERSION.getVersion(VERSION).equals( GSVersionDecoder.VERSION.UNRECOGNIZED)) { layerEncoder = new GSLayerEncoder(); - layerEncoder = new GSLayerEncoder(); - layerEncoder.setEnabled(true); - layerEncoder.setQueryable(true); - layerEncoder.setAdvertised(true); - - layerEncoder.setDefaultStyle("point"); - layerEncoder.addStyle("point2"); - layerEncoder.addStyle("point3"); - - // authorityURL - GSAuthorityURLInfoEncoder authorityURL = new GSAuthorityURLInfoEncoder( - "authority1", "http://www.authority1.org"); - layerEncoder.addAuthorityURL(authorityURL); - - // identifier - GSIdentifierInfoEncoder identifier = new GSIdentifierInfoEncoder( - "authority1", "identifier1"); - layerEncoder.addIdentifier(identifier); - - publisher.createWorkspace(DEFAULT_WS); - - File zipFile = new ClassPathResource("testdata/resttestshp.zip") - .getFile(); - - // test insert - boolean published = publisher.publishShp(DEFAULT_WS, storeName, - layerName, zipFile); - assertTrue("publish() failed", published); - assertTrue(existsLayer(layerName)); - - publisher.publishStyle(new File(new ClassPathResource("testdata") - .getFile(), "default_point.sld")); - - // optionally select the attributes to publish - RESTLayer layer = reader.getLayer(layerName); - RESTResource resource = reader.getResource(layer); - List attrs = resource.getEncodedAttributeList(); - assertNotNull(attrs); - for (GSAttributeEncoder enc : attrs) { - fte.setAttribute(enc); - } - - assertTrue(publisher.publishDBLayer(DEFAULT_WS, storeName, fte, - layerEncoder)); - } - - } - - - @Test - public void testIntegration1() throws IOException { - - if (!enabled()) - return; - deleteAll(); - - GeoServerRESTPublisher publisher = new GeoServerRESTPublisher(RESTURL, RESTUSER, RESTPW); - - String storeName = "resttestshp"; - String layerName = "cities"; - - GSFeatureTypeEncoder fte = new GSFeatureTypeEncoder(); - fte.setNativeName(layerName); - fte.setName(layerName + "_NEW2"); - fte.setTitle("title"); - fte.setNativeCRS("EPSG:4326"); - fte.setDescription("desc"); - fte.setEnabled(true); - - //metadataLink - GSMetadataLinkInfoEncoder metadatalink = new GSMetadataLinkInfoEncoder( - "text/xml", "ISO19115:2003", - "http://www.organization.org/metadata1"); - fte.addMetadataLinkInfo(metadatalink); - - //use of GSLayerEncoder for GS 2.1 & before - GSLayerEncoder21 layerEncoder = null; - if (GSVersionDecoder.VERSION.getVersion(VERSION).equals( + } else if (GSVersionDecoder.VERSION.getVersion(VERSION).equals( GSVersionDecoder.VERSION.UNRECOGNIZED)) { layerEncoder = new GSLayerEncoder21(); - layerEncoder.setEnabled(true); - layerEncoder.setQueryable(true); - layerEncoder.setAdvertised(true); - - layerEncoder.setDefaultStyle("point"); - layerEncoder.addStyle("point2"); - layerEncoder.addStyle("point3"); - - // authorityURL - GSAuthorityURLInfoEncoder authorityURL = new GSAuthorityURLInfoEncoder( - "authority1", "http://www.authority1.org"); - GSAuthorityURLInfoEncoder authorityURL2 = new GSAuthorityURLInfoEncoder( - "authority2", "http://www.authority2.org"); - layerEncoder.addAuthorityURL(authorityURL); - layerEncoder.addAuthorityURL(authorityURL2); - - // identifier - GSIdentifierInfoEncoder identifier = new GSIdentifierInfoEncoder( - "authority1", "identifier1"); - GSIdentifierInfoEncoder identifier2 = new GSIdentifierInfoEncoder( - "authority2", "identifier2"); - layerEncoder.addIdentifier(identifier); - layerEncoder.addIdentifier(identifier2); - - publisher.createWorkspace(DEFAULT_WS); - assertTrue(publisher.publishDBLayer(DEFAULT_WS, storeName, fte, - layerEncoder)); } + layerEncoder.setEnabled(true); + layerEncoder.setQueryable(true); + layerEncoder.setAdvertised(true); + + layerEncoder.setDefaultStyle("point"); + layerEncoder.addStyle("point2"); + layerEncoder.addStyle("point3"); + + // authorityURL + GSAuthorityURLInfoEncoder authorityURL = new GSAuthorityURLInfoEncoder( + "authority1", "http://www.authority1.org"); + layerEncoder.addAuthorityURL(authorityURL); + + // identifier + GSIdentifierInfoEncoder identifier = new GSIdentifierInfoEncoder( + "authority1", "identifier1"); + layerEncoder.addIdentifier(identifier); + + publisher.createWorkspace(DEFAULT_WS); + + File zipFile = new ClassPathResource("testdata/resttestshp.zip") + .getFile(); + + // test insert + boolean published = publisher.publishShp(DEFAULT_WS, storeName, + layerName, zipFile); + assertTrue("publish() failed", published); + assertTrue(existsLayer(layerName)); + + publisher.publishStyle(new File(new ClassPathResource("testdata") + .getFile(), "default_point.sld")); + + // optionally select the attributes to publish + RESTLayer layer = reader.getLayer(layerName); + RESTResource resource = reader.getResource(layer); + List attrs = resource.getEncodedAttributeList(); + assertNotNull(attrs); + for (GSAttributeEncoder enc : attrs) { + fte.setAttribute(enc); + } + + assertTrue(publisher.publishDBLayer(DEFAULT_WS, storeName, fte, + layerEncoder)); + } - + @Test public void testFeatureTypeEncoder() {