From 21218e2c0a44d47d1f33e5075b6f6a188b165624 Mon Sep 17 00:00:00 2001 From: Oscar Fonts Date: Mon, 21 May 2012 17:53:38 +0200 Subject: [PATCH] ArcSDE & OracleNG datastores from Gianni Barrotta --- .../datastore/GSArcSDEDatastoreEncoder.java | 218 ++++++++++++++++++ .../datastore/GSOracleNGDatastoreEncoder.java | 187 +++++++++++++++ .../GSArcSDEDatastoreEncoderTest.java | 127 ++++++++++ .../GSOracleNGDatastoreEncoderTest.java | 133 +++++++++++ 4 files changed, 665 insertions(+) create mode 100644 src/main/java/it/geosolutions/geoserver/rest/encoder/datastore/GSArcSDEDatastoreEncoder.java create mode 100644 src/main/java/it/geosolutions/geoserver/rest/encoder/datastore/GSOracleNGDatastoreEncoder.java create mode 100644 src/test/java/it/geosolutions/geoserver/rest/datastore/GSArcSDEDatastoreEncoderTest.java create mode 100644 src/test/java/it/geosolutions/geoserver/rest/datastore/GSOracleNGDatastoreEncoderTest.java diff --git a/src/main/java/it/geosolutions/geoserver/rest/encoder/datastore/GSArcSDEDatastoreEncoder.java b/src/main/java/it/geosolutions/geoserver/rest/encoder/datastore/GSArcSDEDatastoreEncoder.java new file mode 100644 index 0000000..3d64a1c --- /dev/null +++ b/src/main/java/it/geosolutions/geoserver/rest/encoder/datastore/GSArcSDEDatastoreEncoder.java @@ -0,0 +1,218 @@ +/* + * GeoServer-Manager - Simple Manager Library for GeoServer + * + * Copyright (C) 2007,2012 GeoSolutions S.A.S. + * http://www.geo-solutions.it + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ +package it.geosolutions.geoserver.rest.encoder.datastore; + +import it.geosolutions.geoserver.rest.decoder.RESTDataStore; +import it.geosolutions.geoserver.rest.encoder.utils.ElementUtils; + +/** + * Encoder for an {@value #TYPE} datastore. + * + * @author Gianni Barrotta + * @author Oscar Fonts + */ +public class GSArcSDEDatastoreEncoder extends GSAbstractDatastoreEncoder { + + static final String TYPE = "ArcSDE"; + + static final String DEFAULT_DB_TYPE = "arcsde"; + static final int DEFAULT_PORT = 5151; + static final int DEFAULT_MIN_CONNECTIONS = 2; + static final int DEFAULT_MAX_CONNECTIONS = 6; + static final int DEFAULT_CONNECTION_TIMEOUT = 500; + static final boolean DEFAULT_ALLOW_NON_SPATIAL_TABLES = false; + + /** + * Create an {@value #TYPE} datastore with default connection parameters, + * given a store name, a server name, and a user name. + * + * The following default connection parameters are set: + * + * + * @param name New datastore name + * @param server New server name + * @param user New user name + */ + public GSArcSDEDatastoreEncoder(String name, String server, String user) { + super(name); + + // Set mandatory parameters + setType(TYPE); + setServer(server); + setUser(user); + + // Set default values + setDbType(DEFAULT_DB_TYPE); + setPort(DEFAULT_PORT); + setMinConnections(DEFAULT_MIN_CONNECTIONS); + setMaxConnections(DEFAULT_MAX_CONNECTIONS); + setConnectionTimeout(DEFAULT_CONNECTION_TIMEOUT); + setAllowNonSpatialTables(DEFAULT_ALLOW_NON_SPATIAL_TABLES); + } + + /** + * Create an {@value #TYPE} datastore encoder from an existing store read from server. + * + * @param store The existing store. + * @throws IllegalArgumentException if store type or mandatory parameters are not valid + */ + public GSArcSDEDatastoreEncoder(RESTDataStore store) { + super(store); + + // Check mandatory parameter validity + ensureValidServer(store.getConnectionParameters().get("server")); + ensureValidUser(store.getConnectionParameters().get("user")); + } + + public void setDbType(String dbtype) { + connectionParameters.set("dbtype", dbtype); + } + + public String getDbType() { + return ElementUtils.contains(connectionParameters.getRoot(), "dbtype").getTextTrim(); + } + + public void setServer(String server) { + ensureValidServer(server); + connectionParameters.set("server", server); + } + + public String getServer() { + return ElementUtils.contains(connectionParameters.getRoot(), "server").getTextTrim(); + } + + public void setPort(int port) { + connectionParameters.set("port", Integer.toString(port)); + } + + public int getPort() { + return Integer.parseInt(ElementUtils.contains(connectionParameters.getRoot(), "port").getTextTrim()); + } + + public void setInstance(String instance) { + connectionParameters.set("instance", instance); + } + + public String getInstance() { + return ElementUtils.contains(connectionParameters.getRoot(), "instance").getTextTrim(); + } + + public void setUser(String user) { + ensureValidUser(user); + connectionParameters.set("user", user); + } + + public String getUser() { + return ElementUtils.contains(connectionParameters.getRoot(), "user").getTextTrim(); + } + + public void setPassword(String password) { + connectionParameters.set("password", password); + } + + public String getPassword() { + return ElementUtils.contains(connectionParameters.getRoot(), "password").getTextTrim(); + } + + public void setNamespace(String namespace) { + connectionParameters.set("namespace", namespace); + } + + public String getNamespace() { + return ElementUtils.contains(connectionParameters.getRoot(), "namespace").getTextTrim(); + } + + public void setMinConnections(int minConnections) { + connectionParameters.set("pool.minConnections", Integer.toString(minConnections)); + } + + public int getMinConnections() { + return Integer.parseInt(ElementUtils.contains(connectionParameters.getRoot(), "pool.minConnections").getTextTrim()); + } + + public void setMaxConnections(int maxConnections) { + connectionParameters.set("pool.maxConnections", Integer.toString(maxConnections)); + } + + public int getMaxConnections() { + return Integer.parseInt(ElementUtils.contains(connectionParameters.getRoot(), "pool.maxConnections").getTextTrim()); + } + + public void setConnectionTimeout(int seconds) { + connectionParameters.set("pool.timeOut", Integer.toString(seconds)); + } + + public int getConnectionTimeout() { + return Integer.parseInt(ElementUtils.contains(connectionParameters.getRoot(), "pool.timeOut").getTextTrim()); + } + + public void setAllowNonSpatialTables(boolean allowNonSpatialTables) { + connectionParameters.set("datastore.allowNonSpatialTables", Boolean.toString(allowNonSpatialTables)); + } + + public boolean getAllowNonSpatialTables() { + return Boolean.parseBoolean(ElementUtils.contains(connectionParameters.getRoot(), "datastore.allowNonSpatialTables").getTextTrim()); + } + + /** + * Check server validity. + * + * @param server the server name + * @throws IllegalArgumentException if server name is null or empty + */ + private static void ensureValidServer(String server) { + if (server == null || server.length() == 0) { + throw new IllegalArgumentException( + "ArcSDE store server name cannot be null or empty"); + } + } + + /** + * Check user validity. + * + * @param user the user name + * @throws IllegalArgumentException if user name is null or empty + */ + private static void ensureValidUser(String user) { + if (user == null || user.length() == 0) { + throw new IllegalArgumentException( + "ArcSDE store user name cannot be null or empty"); + } + } + + /** + * @return {@value #TYPE} + */ + String getValidType() { + return TYPE; + } +} \ No newline at end of file diff --git a/src/main/java/it/geosolutions/geoserver/rest/encoder/datastore/GSOracleNGDatastoreEncoder.java b/src/main/java/it/geosolutions/geoserver/rest/encoder/datastore/GSOracleNGDatastoreEncoder.java new file mode 100644 index 0000000..1368633 --- /dev/null +++ b/src/main/java/it/geosolutions/geoserver/rest/encoder/datastore/GSOracleNGDatastoreEncoder.java @@ -0,0 +1,187 @@ +/* + * GeoServer-Manager - Simple Manager Library for GeoServer + * + * Copyright (C) 2007,2012 GeoSolutions S.A.S. + * http://www.geo-solutions.it + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ +package it.geosolutions.geoserver.rest.encoder.datastore; + +import it.geosolutions.geoserver.rest.decoder.RESTDataStore; + +/** + * Encoder for an {@value #TYPE} datastore. + * + * @author Gianni Barrotta + * @author Oscar Fonts + */ +public class GSOracleNGDatastoreEncoder extends GSAbstractDatastoreEncoder { + + static final String TYPE = "Oracle NG"; + + static final int DEFAULT_MIN_CONNECTIONS = 1; + static final int DEFAULT_MAX_CONNECTIONS = 10; + static final int DEFAULT_FETCH_SIZE = 1000; + static final int DEFAULT_CONNECTION_TIMEOUT = 20; + static final boolean DEFAULT_LOOSE_BBOX = true; + static final boolean DEFAULT_PREPARED_STATEMENTS = true; + static final int DEFAULT_MAX_OPEN_PREPARED_STATEMENTS = 50; + + /** + * Create an {@value #TYPE} datastore with default connection parameters, + * given a store name, and a database name. + * + * The following default connection parameters are set: + * + * + * @param name New datastore name + * @param server New server name + * @param user New user name + */ + public GSOracleNGDatastoreEncoder(String name, String database) { + super(name); + + // Set mandatory parameter + setType(TYPE); + setDatabase(database); + + // Set default values + setMinConnections(DEFAULT_MIN_CONNECTIONS); + setMaxConnections(DEFAULT_MAX_CONNECTIONS); + setFetchSize(DEFAULT_FETCH_SIZE); + setConnectionTimeout(DEFAULT_CONNECTION_TIMEOUT); + setLooseBBox(DEFAULT_LOOSE_BBOX); + setPreparedStatements(DEFAULT_PREPARED_STATEMENTS); + setMaxOpenPreparedStatements(DEFAULT_MAX_OPEN_PREPARED_STATEMENTS); + } + + /** + * Create an {@value #TYPE} datastore encoder from an existing store read from server. + * + * @param store The existing store. + * @throws IllegalArgumentException if store type or mandatory parameters are not valid + */ + public GSOracleNGDatastoreEncoder(RESTDataStore store) { + super(store); + + // Check mandatory parameter validity + ensureValidDatabase(store.getConnectionParameters().get("database")); + } + + public void setHost(String host) { + connectionParameters.set("host", host); + } + + public void setPort(int port) { + connectionParameters.set("port", Integer.toString(port)); + } + + public void setNamespace(String namespace) { + connectionParameters.set("namespace", namespace); + } + + public void setDatabase(String database) { + connectionParameters.set("database", database); + } + + public void setSchema(String schema) { + connectionParameters.set("schema", schema); + } + + public void setUser(String user) { + connectionParameters.set("user", user); + } + + public void setPassword(String password) { + connectionParameters.set("passwd", password); + } + + public void setJndiReferenceName(String jndiReferenceName) { + connectionParameters.set("jndiReferenceName", jndiReferenceName); + } + + public void setExposePrimaryKeys(boolean exposePrimaryKeys) { + connectionParameters.set("Expose primary keys", Boolean.toString(exposePrimaryKeys)); + } + + public void setMaxConnections(int maxConnections) { + connectionParameters.set("max connections", Integer.toString(maxConnections)); + } + + public void setMinConnections(int minConnections) { + connectionParameters.set("min connections", Integer.toString(minConnections)); + } + + public void setFetchSize(int fetchSize) { + connectionParameters.set("fetch size", Integer.toString(fetchSize)); + } + + public void setConnectionTimeout(int seconds) { + connectionParameters.set("Connection timeout", Integer.toString(seconds)); + } + + public void setValidateConnections(boolean validateConnections) { + connectionParameters.set("validate connections", Boolean.toString(validateConnections)); + } + + public void setPrimaryKeyMetadataTable(String primaryKeyMetadataTable) { + connectionParameters.set("Primary key metadata table", primaryKeyMetadataTable); + } + + public void setLooseBBox(boolean looseBBox) { + connectionParameters.set("Loose bbox", Boolean.toString(looseBBox)); + } + + public void setPreparedStatements(boolean preparedStatements) { + connectionParameters.set("preparedStatements", Boolean.toString(preparedStatements)); + } + + public void setMaxOpenPreparedStatements(int maxOpenPreparedStatements) { + connectionParameters.set("Max open prepared statements", Integer.toString(maxOpenPreparedStatements)); + } + + /** + * Check database validity. + * + * @param database the database name + * @throws IllegalArgumentException if database is null or empty + */ + private static void ensureValidDatabase(String database) { + if (database == null || database.length() == 0) { + throw new IllegalArgumentException( + "Oracle store database cannot be null or empty"); + } + } + + /** + * @return {@value #TYPE} + */ + String getValidType() { + return TYPE; + } +} diff --git a/src/test/java/it/geosolutions/geoserver/rest/datastore/GSArcSDEDatastoreEncoderTest.java b/src/test/java/it/geosolutions/geoserver/rest/datastore/GSArcSDEDatastoreEncoderTest.java new file mode 100644 index 0000000..2d3d456 --- /dev/null +++ b/src/test/java/it/geosolutions/geoserver/rest/datastore/GSArcSDEDatastoreEncoderTest.java @@ -0,0 +1,127 @@ +/* + * GeoServer-Manager - Simple Manager Library for GeoServer + * + * Copyright (C) 2007,2012 GeoSolutions S.A.S. + * http://www.geo-solutions.it + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ +package it.geosolutions.geoserver.rest.datastore; + +import it.geosolutions.geoserver.rest.GeoserverRESTTest; +import it.geosolutions.geoserver.rest.decoder.RESTDataStore; +import it.geosolutions.geoserver.rest.encoder.datastore.GSArcSDEDatastoreEncoder; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + * Testcase for creating arcsde-based resources on geoserver. + *

+ * Since these tests require a running arcsde instance, this is more like integration tests.
+ * You may skip them by defining

+ *        -DpgIgnore=true 
+ * When pgIgnore is defined that way, failing tests will not break + * the build: they will be logged as errors instead. + * + *

+ * The target arcsde instance can be customized by defining the following env vars:

+ * + * @author etj + * @author Eric Grosso + * @author Gianni Barrotta + * + * @see GeoserverRESTTest + */ +public class GSArcSDEDatastoreEncoderTest extends GeoserverRESTTest { + + private final static Logger LOGGER = LoggerFactory.getLogger(GSArcSDEDatastoreEncoderTest.class); + private static final String DEFAULT_WS = "it.geosolutions"; + + private final boolean pgIgnore; + private final String pgServer; + private final int pgPort; + private final String pgInstance; + private final String pgUser; + private final String pgPassword; + + public GSArcSDEDatastoreEncoderTest(String testName) { + super(testName); + + pgIgnore = System.getProperty("pgIgnore", "false").equalsIgnoreCase("true"); + pgServer = System.getProperty("pgServer", "localhost"); + pgPort = Integer.parseInt(System.getProperty("pgPort", "5151")); + pgInstance = System.getProperty("pgInstance", "test"); + pgUser = System.getProperty("pgUser", "utest"); + pgPassword = System.getProperty("pgPassword", "ptest"); + } + + public void testCreateDeleteArcSDEDatastore() { + if (!enabled()) { + return; + } + deleteAll(); + + String wsName = DEFAULT_WS; + String datastoreName = "resttestarcsde"; + String description = "description"; + String dsNamespace = "http://www.geo-solutions.it"; + boolean exposePrimaryKeys = true; + boolean validateConnections = false; + String primaryKeyMetadataTable = "test"; + + GSArcSDEDatastoreEncoder datastoreEncoder = new GSArcSDEDatastoreEncoder(datastoreName, pgServer, pgUser); + datastoreEncoder.setDescription(description); + datastoreEncoder.setNamespace(dsNamespace); + datastoreEncoder.setPort(pgPort); + datastoreEncoder.setInstance(pgInstance); + datastoreEncoder.setPassword(pgPassword); + + assertTrue(publisher.createWorkspace(wsName)); + + // creation test + boolean created = publisher.createDatastore(wsName, datastoreEncoder); + + if( ! pgIgnore ) + assertTrue("arcsde datastore not created", created); + else if( ! created) + LOGGER.error("*** Datastore " + datastoreName + " has not been created."); + + + RESTDataStore datastore = reader.getDatastore(wsName, datastoreName); + LOGGER.info("The type of the created datastore is: " + datastore.getType()); + + // removing test + boolean removed = publisher.removeDatastore(wsName, datastoreName); + if( ! pgIgnore ) + assertTrue("arcsde datastore not removed", removed); + else if( ! removed ) + LOGGER.error("*** Datastore " + datastoreName + " has not been removed."); + + assertTrue(publisher.removeWorkspace(wsName)); + } + +} diff --git a/src/test/java/it/geosolutions/geoserver/rest/datastore/GSOracleNGDatastoreEncoderTest.java b/src/test/java/it/geosolutions/geoserver/rest/datastore/GSOracleNGDatastoreEncoderTest.java new file mode 100644 index 0000000..2edb9f9 --- /dev/null +++ b/src/test/java/it/geosolutions/geoserver/rest/datastore/GSOracleNGDatastoreEncoderTest.java @@ -0,0 +1,133 @@ +/* + * GeoServer-Manager - Simple Manager Library for GeoServer + * + * Copyright (C) 2007,2012 GeoSolutions S.A.S. + * http://www.geo-solutions.it + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ +package it.geosolutions.geoserver.rest.datastore; + +import it.geosolutions.geoserver.rest.GeoserverRESTTest; +import it.geosolutions.geoserver.rest.decoder.RESTDataStore; +import it.geosolutions.geoserver.rest.encoder.datastore.GSOracleNGDatastoreEncoder; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + * Testcase for creating OracleNG-based resources on geoserver. + *

+ * Since these tests require a running OracleNG instance, this is more like integration tests.
+ * You may skip them by defining

+ *        -DpgIgnore=true 
+ * When pgIgnore is defined that way, failing tests will not break + * the build: they will be logged as errors instead. + * + *

+ * The target OracleNG instance can be customized by defining the following env vars:

+ * + * @author etj + * @author Eric Grosso + * @author Gianni Barrotta + * + * @see GeoserverRESTTest + */ +public class GSOracleNGDatastoreEncoderTest extends GeoserverRESTTest { + + private final static Logger LOGGER = LoggerFactory.getLogger(GSOracleNGDatastoreEncoderTest.class); + private static final String DEFAULT_WS = "it.geosolutions"; + + private final boolean pgIgnore; + private final String pgHost; + private final int pgPort; + private final String pgDatabase; + private final String pgSchema; + private final String pgUser; + private final String pgPassword; + + public GSOracleNGDatastoreEncoderTest(String testName) { + super(testName); + + pgIgnore = System.getProperty("pgIgnore", "false").equalsIgnoreCase("true"); + pgHost = System.getProperty("pgHost", "localhost"); + pgPort = Integer.parseInt(System.getProperty("pgPort", "5432")); + pgDatabase = System.getProperty("pgDatabase", "test"); + pgSchema = System.getProperty("pgSchema", "public"); + pgUser = System.getProperty("pgUser", "utest"); + pgPassword = System.getProperty("pgPassword", "ptest"); + } + + public void testCreateDeleteOracleNGDatastore() { + if (!enabled()) { + return; + } + deleteAll(); + + String wsName = DEFAULT_WS; + String datastoreName = "resttestOracleNG"; + String description = "description"; + String dsNamespace = "http://www.geo-solutions.it"; + boolean exposePrimaryKeys = true; + boolean validateConnections = false; + String primaryKeyMetadataTable = "test"; + + GSOracleNGDatastoreEncoder datastoreEncoder = new GSOracleNGDatastoreEncoder(datastoreName, pgDatabase); + datastoreEncoder.setDescription(description); + datastoreEncoder.setNamespace(dsNamespace); + datastoreEncoder.setHost(pgHost); + datastoreEncoder.setPort(pgPort); + datastoreEncoder.setSchema(pgSchema); + datastoreEncoder.setUser(pgUser); + datastoreEncoder.setPassword(pgPassword); + datastoreEncoder.setExposePrimaryKeys(exposePrimaryKeys); + datastoreEncoder.setValidateConnections(validateConnections); + datastoreEncoder.setPrimaryKeyMetadataTable(primaryKeyMetadataTable); + + assertTrue(publisher.createWorkspace(wsName)); + + // creation test + boolean created = publisher.createDatastore(wsName, datastoreEncoder); + + if( ! pgIgnore ) + assertTrue("OracleNG datastore not created", created); + else if( ! created) + LOGGER.error("*** Datastore " + datastoreName + " has not been created."); + + + RESTDataStore datastore = reader.getDatastore(wsName, datastoreName); + LOGGER.info("The type of the created datastore is: " + datastore.getType()); + + // removing test + boolean removed = publisher.removeDatastore(wsName, datastoreName); + if( ! pgIgnore ) + assertTrue("OracleNG datastore not removed", removed); + else if( ! removed ) + LOGGER.error("*** Datastore " + datastoreName + " has not been removed."); + + assertTrue(publisher.removeWorkspace(wsName)); + } +}