@Test public void testListenerDoesntHearFailureToRemoveDoesntExist() throws Exception { BlobStoreConfigurationListener listener = EasyMock.createMock("listener", BlobStoreConfigurationListener.class); this.config.addBlobStoreListener(listener); EasyMock.replay(listener); try { this.removeInfo(this.config, "test"); } catch (NoSuchElementException ex) { // Do Nothing } EasyMock.verify(listener); }
@Test public void testListenerDoesntHearFailureToRenameDueToBackend() throws Exception { BlobStoreConfigurationListener listener = EasyMock.createMock("listener", BlobStoreConfigurationListener.class); BlobStoreInfo goodInfo = this.getGoodInfo("test", 1); this.addInfo(this.config, goodInfo); this.config.addBlobStoreListener(listener); EasyMock.replay(listener); this.failNextWrite(); try { this.removeInfo(this.config, "test"); } catch (ConfigurationPersistenceException ex) { // Do Nothing } EasyMock.verify(listener); }
@Test public void testListenerDoesntHearFailureToRemoveDueToBackend() throws Exception { BlobStoreConfigurationListener listener = EasyMock.createMock("listener", BlobStoreConfigurationListener.class); BlobStoreInfo goodInfo = this.getGoodInfo("test", 1); this.addInfo(this.config, goodInfo); this.config.addBlobStoreListener(listener); EasyMock.replay(listener); this.failNextWrite(); try { this.removeInfo(this.config, "test"); } catch (ConfigurationPersistenceException ex) { // Do Nothing } EasyMock.verify(listener); }
@Test public void testListenerHearsRemove() throws Exception { BlobStoreInfo goodInfo = this.getGoodInfo("test", 1); this.addInfo(this.config, goodInfo); BlobStoreConfigurationListener listener = EasyMock.createMock("listener", BlobStoreConfigurationListener.class); this.config.addBlobStoreListener(listener); listener.handleRemoveBlobStore(EasyMock.eq(goodInfo)); EasyMock.expectLastCall().once(); EasyMock.replay(listener); this.removeInfo(this.config, "test"); EasyMock.verify(listener); }
@Test public void testExceptionInRemoveListenerIsWrapped() 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); exception.expect( allOf( instanceOf(ConfigurationPersistenceException.class), hasProperty("cause", sameInstance(ex)))); this.removeInfo(this.config, "test"); }
@Test public void testExceptionInRemoveListenerDoesntBlockOtherListeners() throws Exception { BlobStoreConfigurationListener listener1 = EasyMock.createMock("listener", BlobStoreConfigurationListener.class); BlobStoreConfigurationListener listener2 = EasyMock.createMock("listener", BlobStoreConfigurationListener.class); BlobStoreInfo goodInfo = prepForRemove(); this.config.addBlobStoreListener(listener1); this.config.addBlobStoreListener(listener2); GeoWebCacheException ex1 = new GeoWebCacheException("TEST1"); listener1.handleRemoveBlobStore(goodInfo); EasyMock.expectLastCall().andThrow(ex1); listener2.handleRemoveBlobStore(goodInfo); EasyMock.expectLastCall().once(); EasyMock.replay(listener1, listener2); try { this.removeInfo(this.config, "test"); } catch (ConfigurationPersistenceException ex3) { // Do Nothing } EasyMock.verify(listener2); }
@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()); }
arrayContainingInAnyOrder(sameInstance(ex1))))))); this.removeInfo(this.config, "test");