GSDirectoryOfShapefilesDatastoreEncoder create = new GSDirectoryOfShapefilesDatastoreEncoder(
DS_NAME, LOCATION_1);
assertTrue(manager.getStoreManager().create(WS_NAME, create));
// Read the store from server; check all parameter values
RESTDataStore read = reader.getDatastore(WS_NAME, DS_NAME);
assertEquals(read.getName(), DS_NAME);
assertEquals(read.getWorkspaceName(), WS_NAME);
assertEquals(read.isEnabled(), true);
Map<String, String> connParams = read.getConnectionParameters();
assertEquals(connParams.get("url"), LOCATION_1.toString());
assertEquals(connParams.get("charset"), "ISO-8859-1");
assertEquals(connParams.get("create spatial index"), "true");
assertEquals(connParams.get("memory mapped buffer"), "false");
assertEquals(connParams.get("cache and reuse memory maps"), "true");
// Change all parameter to non-default values
GSDirectoryOfShapefilesDatastoreEncoder update = new GSDirectoryOfShapefilesDatastoreEncoder(
read);
update.setDescription(DS_DESCRIPTION);
update.setEnabled(false);
update.setUrl(LOCATION_2);
update.setCharset(Charset.forName("UTF-8"));
update.setCreateSpatialIndex(false);
update.setMemoryMappedBuffer(true);
update.setCacheAndReuseMemoryMaps(false);
// update the store
assertTrue(manager.getStoreManager().update(WS_NAME, update));
// Read again, check that all parameters have changed
read = reader.getDatastore(WS_NAME, DS_NAME);
assertEquals(read.getWorkspaceName(), WS_NAME);
assertEquals(read.isEnabled(), false);
connParams = read.getConnectionParameters();
assertEquals(connParams.get("url"), LOCATION_2.toString());
assertEquals(connParams.get("charset"), "UTF-8");
assertEquals(connParams.get("create spatial index"), "false");
assertEquals(connParams.get("memory mapped buffer"), "true");
assertEquals(connParams.get("cache and reuse memory maps"), "false");