@Test public void testExceptionInAddListenerNotRolledBack() throws Exception { BlobStoreConfigurationListener listener = EasyMock.createMock("listener", BlobStoreConfigurationListener.class); BlobStoreInfo goodInfo = this.getGoodInfo("test", 1); this.config.addBlobStoreListener(listener); listener.handleAddBlobStore(goodInfo); GeoWebCacheException ex = new GeoWebCacheException("TEST"); EasyMock.expectLastCall().andThrow(ex); EasyMock.replay(listener); try { this.addInfo(this.config, goodInfo); } catch (ConfigurationPersistenceException ex2) { // Do Nothing } assertThat(this.getInfo(config, "test"), isPresent(equalTo(goodInfo))); }
@Test public void testExceptionInRemoveListenerNotRolledBack() throws Exception { BlobStoreConfigurationListener listener = EasyMock.createMock("listener", BlobStoreConfigurationListener.class); BlobStoreInfo goodInfo = prepForRemove(); this.config.addBlobStoreListener(listener); GeoWebCacheException ex = new GeoWebCacheException("TEST"); listener.handleRemoveBlobStore(goodInfo); EasyMock.expectLastCall().andThrow(ex); EasyMock.replay(listener); try { this.removeInfo(this.config, "test"); } catch (ConfigurationPersistenceException ex2) { // Do Nothing } assertThat(this.getInfo(config, "test"), notPresent()); }
@Test public void testExceptionInModifyListenerNotRolledBack() throws Exception { BlobStoreConfigurationListener listener = EasyMock.createMock("listener", BlobStoreConfigurationListener.class); BlobStoreInfo goodInfo = prepForModify(); this.config.addBlobStoreListener(listener); GeoWebCacheException ex = new GeoWebCacheException("TEST"); listener.handleModifyBlobStore(goodInfo); EasyMock.expectLastCall().andThrow(ex); EasyMock.replay(listener); try { this.modifyInfo(this.config, goodInfo); } catch (ConfigurationPersistenceException ex2) { // Do Nothing } assertThat(this.getInfo(config, "test"), isPresent(infoEquals(2))); }
@Test public void testExceptionInRenameListenerNotRolledBack() throws Exception { BlobStoreConfigurationListener listener = EasyMock.createMock("listener", BlobStoreConfigurationListener.class); BlobStoreInfo goodInfo = prepForRename(); this.config.addBlobStoreListener(listener); GeoWebCacheException ex = new GeoWebCacheException("TEST"); listener.handleRenameBlobStore("test", goodInfo); EasyMock.expectLastCall().andThrow(ex); EasyMock.replay(listener); try { this.renameInfo(this.config, "test", "test2"); } catch (ConfigurationPersistenceException ex2) { // Do Nothing } assertThat(this.getInfo(config, "test2"), isPresent(infoEquals(goodInfo))); }