public void testRemoveTypeThatDoesntExistsGracefulWithoutIOException() throws IOException { // two featureTypes should be in List<Name> names = data.getNames(); assertNotNull(names); assertEquals(2, names.size()); try { data.removeSchema("typeThatDoesntExists"); } catch (IOException e) { fail("remove Schema should act gracfully if it has never been created for that type"); } // still the same size and no IOException List<Name> namesAfterRemove = data.getNames(); assertNotNull(namesAfterRemove); assertEquals(2, namesAfterRemove.size()); }
public void testGetFeatureWriter() throws NoSuchElementException, IOException { FeatureWriter<SimpleFeatureType, SimpleFeature> writer = data.getFeatureWriter("road", Transaction.AUTO_COMMIT); assertEquals(roadFeatures.length, count(writer)); assertFalse(writer.hasNext()); try { writer.next(); fail("Should not be able to use a closed writer"); } catch (IOException expected) { } }
public void testUnLockFeatures() throws IOException { FeatureLock lock = new FeatureLock("test", 3600); @SuppressWarnings("unchecked") FeatureLocking<SimpleFeatureType, SimpleFeature> road = (FeatureLocking<SimpleFeatureType, SimpleFeature>) data.getFeatureSource("road"); road.setFeatureLock(lock); road.lockFeatures(); try { road.unLockFeatures(); fail("unlock should fail due on AUTO_COMMIT"); } catch (IOException expected) { } Transaction t = new DefaultTransaction(); road.setTransaction(t); try { road.unLockFeatures(); fail("unlock should fail due lack of authorization"); } catch (IOException expected) { } t.addAuthorization(lock.getAuthorization()); road.unLockFeatures(); t.close(); }
public void testGetFeatureReaderMutability() throws IOException { FeatureReader<SimpleFeatureType, SimpleFeature> reader = data.getFeatureSource("road").getReader(); SimpleFeature feature; while (reader.hasNext()) { feature = (SimpleFeature) reader.next(); feature.setAttribute("name", null); } reader.close(); reader = data.getFeatureSource("road").getReader(); while (reader.hasNext()) { feature = (SimpleFeature) reader.next(); assertNotNull(feature.getAttribute("name")); } reader.close(); try { reader.next(); fail("next should fail with an IOException"); } catch (IOException expected) { } }