Skip to content

Commit

Permalink
Fixing deprecated API, work in progress!
Browse files Browse the repository at this point in the history
  • Loading branch information
aaime committed Mar 15, 2021
1 parent 2156410 commit 50b202f
Show file tree
Hide file tree
Showing 51 changed files with 165 additions and 177 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

import static org.geowebcache.util.TestUtils.isPresent;
import static org.hamcrest.Matchers.hasProperty;
import static org.junit.Assert.assertThat;
import static org.hamcrest.MatcherAssert.assertThat;

import java.io.File;
import java.io.IOException;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
package org.geowebcache;

import static org.geowebcache.TestHelpers.hasStatus;
import static org.junit.Assert.assertThat;
import static org.hamcrest.MatcherAssert.assertThat;

import java.util.Collections;
import javax.servlet.http.HttpServletResponse;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@
import static org.easymock.EasyMock.expect;
import static org.easymock.EasyMock.replay;
import static org.easymock.EasyMock.verify;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.is;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertSame;
import static org.junit.Assert.assertThat;
import static org.junit.Assert.assertTrue;

import java.util.HashMap;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@
*/
package org.geowebcache;

import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.contains;
import static org.hamcrest.Matchers.containsInAnyOrder;
import static org.hamcrest.Matchers.equalTo;
import static org.hamcrest.Matchers.sameInstance;
import static org.junit.Assert.assertThat;

import java.util.Collection;
import org.hamcrest.Matchers;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@
*/
package org.geowebcache.blobstore.file;

import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.equalTo;
import static org.hamcrest.Matchers.nullValue;
import static org.junit.Assert.assertThat;

import java.util.concurrent.CountDownLatch;
import java.util.concurrent.ExecutorService;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,14 @@
import static org.easymock.EasyMock.verify;
import static org.geowebcache.util.TestUtils.isPresent;
import static org.geowebcache.util.TestUtils.notPresent;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.allOf;
import static org.hamcrest.Matchers.arrayContainingInAnyOrder;
import static org.hamcrest.Matchers.equalTo;
import static org.hamcrest.Matchers.hasProperty;
import static org.hamcrest.Matchers.instanceOf;
import static org.hamcrest.Matchers.sameInstance;
import static org.junit.Assert.assertThat;
import static org.junit.Assert.assertSame;
import static org.junit.Assert.assertThrows;

import java.io.IOException;
import java.util.Collection;
Expand All @@ -36,6 +37,7 @@
import org.easymock.IMocksControl;
import org.geowebcache.GeoWebCacheException;
import org.geowebcache.storage.UnsuitableStorageException;
import org.hamcrest.CoreMatchers;
import org.junit.Test;

public abstract class BlobStoreConfigurationTest
Expand Down Expand Up @@ -87,10 +89,8 @@ public void testRollBackOnUnsuitableStorageExceptionInAddHandler() throws Except
expectLastCall().andThrow(new UnsuitableStorageException("TEST"));
EasyMock.replay(listener);
config.addBlobStoreListener(listener);
exception.expect(instanceOf(ConfigurationPersistenceException.class));
exception.expectCause(instanceOf(UnsuitableStorageException.class));
try {
config.addBlobStore(info);
assertThrows(ConfigurationPersistenceException.class, () -> config.addBlobStore(info));
} finally {
verify(listener);
assertThat(config.getBlobStore("test"), notPresent());
Expand All @@ -109,10 +109,11 @@ public void testRollBackOnUnsuitableStorageExceptionInModifyHandler() throws Exc
EasyMock.replay(listener);
config.addBlobStoreListener(listener);
config.addBlobStore(info1);
exception.expect(instanceOf(ConfigurationPersistenceException.class));
exception.expectCause(instanceOf(UnsuitableStorageException.class));
try {
config.modifyBlobStore(info2);
} catch (ConfigurationPersistenceException expected) {
assertThat(
expected.getCause(), CoreMatchers.instanceOf(UnsuitableStorageException.class));
} finally {
verify(listener);
assertThat(config.getBlobStore("test"), isPresent(infoEquals(info1)));
Expand Down Expand Up @@ -142,10 +143,10 @@ public void testRollBackOnSupressedUnsuitableStorageExceptionInModifyHandler()
config.addBlobStoreListener(listener1);
config.addBlobStoreListener(listener2);
config.addBlobStore(info1);
exception.expect(instanceOf(ConfigurationPersistenceException.class));
exception.expectCause(instanceOf(IOException.class));
try {
config.modifyBlobStore(info2);
} catch (ConfigurationPersistenceException expected) {
assertThat(expected.getCause(), CoreMatchers.instanceOf(IOException.class));
} finally {
control.verify();
assertThat(config.getBlobStore("test"), isPresent(infoEquals(info1)));
Expand All @@ -168,10 +169,10 @@ public void testRollBackOnSupressedUnsuitableStorageExceptionInAddHandler() thro
control.replay();
config.addBlobStoreListener(listener1);
config.addBlobStoreListener(listener2);
exception.expect(instanceOf(ConfigurationPersistenceException.class));
exception.expectCause(instanceOf(IOException.class));
try {
config.addBlobStore(info1);
} catch (ConfigurationPersistenceException expected) {
assertThat(expected.getCause(), CoreMatchers.instanceOf(IOException.class));
} finally {
control.verify();
assertThat(config.getBlobStore("test"), notPresent());
Expand Down Expand Up @@ -464,12 +465,11 @@ public void testExceptionInAddListenerIsWrapped() throws Exception {
EasyMock.expectLastCall().andThrow(ex);
EasyMock.replay(listener);

exception.expect(
allOf(
instanceOf(ConfigurationPersistenceException.class),
hasProperty("cause", sameInstance(ex))));

this.addInfo(this.config, goodInfo);
try {
this.addInfo(this.config, goodInfo);
} catch (ConfigurationPersistenceException expected) {
assertSame(ex, ex.getCause());
}
}

@Test
Expand Down Expand Up @@ -537,21 +537,22 @@ public void testExceptionInAddListenerRecordsSuppressedExceptions() throws Excep

EasyMock.replay(listener1, listener2);

exception.expect(
allOf(
instanceOf(ConfigurationPersistenceException.class),
hasProperty(
"cause",
allOf(
sameInstance(ex2),
hasProperty(
"suppressed",
arrayContainingInAnyOrder(sameInstance(ex1)))))));

this.addInfo(this.config, goodInfo);
try {
this.addInfo(this.config, goodInfo);
} catch (ConfigurationPersistenceException expected) {
assertThat(
expected,
hasProperty(
"cause",
allOf(
sameInstance(ex2),
hasProperty(
"suppressed",
arrayContainingInAnyOrder(sameInstance(ex1))))));
}
}
// Exceptions during modify handlers

// Exceptions during modify handlers
@Test
public void testExceptionInModifyListenerIsWrapped() throws Exception {
BlobStoreConfigurationListener listener =
Expand All @@ -564,12 +565,11 @@ public void testExceptionInModifyListenerIsWrapped() throws Exception {
EasyMock.expectLastCall().andThrow(ex);
EasyMock.replay(listener);

exception.expect(
allOf(
instanceOf(ConfigurationPersistenceException.class),
hasProperty("cause", sameInstance(ex))));

this.modifyInfo(this.config, goodInfo);
try {
this.modifyInfo(this.config, goodInfo);
} catch (ConfigurationPersistenceException expected) {
assertThat(expected, hasProperty("cause", sameInstance(ex)));
}
}

/**
Expand Down Expand Up @@ -650,18 +650,19 @@ public void testExceptionInModifyListenerRecordsSuppressedExceptions() throws Ex

EasyMock.replay(listener1, listener2);

exception.expect(
allOf(
instanceOf(ConfigurationPersistenceException.class),
hasProperty(
"cause",
allOf(
sameInstance(ex2),
hasProperty(
"suppressed",
arrayContainingInAnyOrder(sameInstance(ex1)))))));

this.modifyInfo(this.config, goodInfo);
try {
this.modifyInfo(this.config, goodInfo);
} catch (ConfigurationPersistenceException expected) {
assertThat(
expected,
hasProperty(
"cause",
allOf(
sameInstance(ex2),
hasProperty(
"suppressed",
arrayContainingInAnyOrder(sameInstance(ex1))))));
}
}

// Exceptions during rename handlers
Expand Down Expand Up @@ -689,12 +690,11 @@ public void testExceptionInRenameListenerIsWrapped() throws Exception {
EasyMock.expectLastCall().andThrow(ex);
EasyMock.replay(listener);

exception.expect(
allOf(
instanceOf(ConfigurationPersistenceException.class),
hasProperty("cause", sameInstance(ex))));

this.renameInfo(this.config, "test", "test2");
try {
this.renameInfo(this.config, "test", "test2");
} catch (ConfigurationPersistenceException expected) {
assertThat(expected, hasProperty("cause", sameInstance(ex)));
}
}

@Test
Expand Down Expand Up @@ -763,18 +763,19 @@ public void testExceptionInRenameListenerRecordsSuppressedExceptions() throws Ex

EasyMock.replay(listener1, listener2);

exception.expect(
allOf(
instanceOf(ConfigurationPersistenceException.class),
hasProperty(
"cause",
allOf(
sameInstance(ex2),
hasProperty(
"suppressed",
arrayContainingInAnyOrder(sameInstance(ex1)))))));

this.renameInfo(this.config, "test", "test2");
try {
this.renameInfo(this.config, "test", "test2");
} catch (ConfigurationPersistenceException expected) {
assertThat(
expected,
hasProperty(
"cause",
allOf(
sameInstance(ex2),
hasProperty(
"suppressed",
arrayContainingInAnyOrder(sameInstance(ex1))))));
}
}

// Exceptions during remove handlers
Expand Down Expand Up @@ -802,12 +803,11 @@ public void testExceptionInRemoveListenerIsWrapped() throws Exception {
EasyMock.expectLastCall().andThrow(ex);
EasyMock.replay(listener);

exception.expect(
allOf(
instanceOf(ConfigurationPersistenceException.class),
hasProperty("cause", sameInstance(ex))));

this.removeInfo(this.config, "test");
try {
this.removeInfo(this.config, "test");
} catch (ConfigurationPersistenceException expected) {
assertThat(expected, hasProperty("cause", sameInstance(ex)));
}
}

@Test
Expand Down Expand Up @@ -876,17 +876,18 @@ public void testExceptionInRemoveListenerRecordsSuppressedExceptions() throws Ex

EasyMock.replay(listener1, listener2);

exception.expect(
allOf(
instanceOf(ConfigurationPersistenceException.class),
hasProperty(
"cause",
allOf(
sameInstance(ex2),
hasProperty(
"suppressed",
arrayContainingInAnyOrder(sameInstance(ex1)))))));

this.removeInfo(this.config, "test");
try {
this.removeInfo(this.config, "test");
} catch (ConfigurationPersistenceException expected) {
assertThat(
expected,
hasProperty(
"cause",
allOf(
sameInstance(ex2),
hasProperty(
"suppressed",
arrayContainingInAnyOrder(sameInstance(ex1))))));
}
}
}
Loading

0 comments on commit 50b202f

Please sign in to comment.