This is an automated email from the ASF dual-hosted git repository. ctubbsii pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/accumulo.git
The following commit(s) were added to refs/heads/master by this push: new 767d637 Update dependency and plugin versions (#1562) 767d637 is described below commit 767d637c97fbcb3d6cb727682fb55fb8d6936af3 Author: Christopher Tubbs <ctubb...@apache.org> AuthorDate: Fri Mar 13 16:35:03 2020 -0400 Update dependency and plugin versions (#1562) Fix warnings due to updated dependencies * Use new vfs2 method instead of deprecated one * Use assertThrows instead of ExpectedException Remove hamcrest dependency, because it's not needed any more Enforce dependency convergence to versions specified in the dependencyManagement section when transitive dependencies from different direct dependencies conflict. Fix vfs test due to change in behavior for class reloading Fix spotbugs and improve CryptoTest --- .../core/clientImpl/lexicoder/ByteUtilsTest.java | 9 +- .../core/conf/AccumuloConfigurationTest.java | 9 +- .../accumulo/core/conf/ClientPropertyTest.java | 10 +- .../apache/accumulo/core/crypto/CryptoTest.java | 49 ++++----- .../accumulo/core/util/PreAllocatedArrayTest.java | 21 ++-- .../core/util/UnsynchronizedBufferTest.java | 11 +- .../org/apache/accumulo/fate/util/RetryTest.java | 36 +++---- .../hadoop/mapred/AccumuloInputFormatTest.java | 8 +- .../hadoop/mapreduce/AccumuloInputFormatTest.java | 9 +- pom.xml | 113 ++++++++++++--------- .../server/fs/PerTableVolumeChooserTest.java | 23 +---- .../server/fs/PreferredVolumeChooserTest.java | 31 ++---- .../accumulo/server/fs/VolumeManagerImplTest.java | 21 +--- .../apache/accumulo/tserver/InMemoryMapTest.java | 11 +- .../tserver/compaction/CompactionPlanTest.java | 16 +-- .../tserver/log/SortedLogRecoveryTest.java | 15 +-- .../vfs/AccumuloReloadingVFSClassLoader.java | 6 +- .../vfs/AccumuloReloadingVFSClassLoaderTest.java | 12 ++- test/pom.xml | 4 - .../accumulo/test/functional/ClassLoaderIT.java | 3 +- .../accumulo/test/functional/ScannerContextIT.java | 3 +- .../apache/accumulo/test/functional/TableIT.java | 3 +- .../apache/accumulo/test/rpc/ThriftBehaviorIT.java | 23 ++--- 23 files changed, 172 insertions(+), 274 deletions(-) diff --git a/core/src/test/java/org/apache/accumulo/core/clientImpl/lexicoder/ByteUtilsTest.java b/core/src/test/java/org/apache/accumulo/core/clientImpl/lexicoder/ByteUtilsTest.java index 6a89f75..629434e 100644 --- a/core/src/test/java/org/apache/accumulo/core/clientImpl/lexicoder/ByteUtilsTest.java +++ b/core/src/test/java/org/apache/accumulo/core/clientImpl/lexicoder/ByteUtilsTest.java @@ -20,16 +20,12 @@ package org.apache.accumulo.core.clientImpl.lexicoder; import static org.junit.Assert.assertArrayEquals; import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertThrows; -import org.junit.Rule; import org.junit.Test; -import org.junit.rules.ExpectedException; public class ByteUtilsTest { - @Rule - public ExpectedException exception = ExpectedException.none(); - private final byte[] empty = new byte[0]; private final byte[] noSplits = "nosplits".getBytes(); private final byte[] splitAt5 = ("1234" + (char) 0x00 + "56789").getBytes(); @@ -93,8 +89,7 @@ public class ByteUtilsTest { @Test public void testIllegalArgument() { // incomplete bytes would cause an ArrayIndexOutOfBounds in the past - exception.expect(IllegalArgumentException.class); byte[] errorBytes = {0x01}; - ByteUtils.unescape(errorBytes); + assertThrows(IllegalArgumentException.class, () -> ByteUtils.unescape(errorBytes)); } } diff --git a/core/src/test/java/org/apache/accumulo/core/conf/AccumuloConfigurationTest.java b/core/src/test/java/org/apache/accumulo/core/conf/AccumuloConfigurationTest.java index a530470..55f0af7 100644 --- a/core/src/test/java/org/apache/accumulo/core/conf/AccumuloConfigurationTest.java +++ b/core/src/test/java/org/apache/accumulo/core/conf/AccumuloConfigurationTest.java @@ -22,6 +22,7 @@ import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertNotSame; import static org.junit.Assert.assertSame; +import static org.junit.Assert.assertThrows; import static org.junit.Assert.assertTrue; import java.util.Collection; @@ -32,15 +33,10 @@ import java.util.function.Predicate; import org.apache.accumulo.core.conf.AccumuloConfiguration.ScanExecutorConfig; import org.apache.accumulo.core.spi.scan.SimpleScanDispatcher; -import org.junit.Rule; import org.junit.Test; -import org.junit.rules.ExpectedException; public class AccumuloConfigurationTest { - @Rule - public ExpectedException thrown = ExpectedException.none(); - @Test public void testGetPropertyByString() { AccumuloConfiguration c = DefaultConfiguration.getInstance(); @@ -196,8 +192,7 @@ public class AccumuloConfigurationTest { expected1.put(Property.TABLE_ARBITRARY_PROP_PREFIX.getKey() + "a2", "asg34"); assertEquals(expected1, pm1); - thrown.expect(UnsupportedOperationException.class); - pm1.put("k9", "v3"); + assertThrows(UnsupportedOperationException.class, () -> pm1.put("k9", "v3")); } @Test diff --git a/core/src/test/java/org/apache/accumulo/core/conf/ClientPropertyTest.java b/core/src/test/java/org/apache/accumulo/core/conf/ClientPropertyTest.java index f5efe5c..6f861f5 100644 --- a/core/src/test/java/org/apache/accumulo/core/conf/ClientPropertyTest.java +++ b/core/src/test/java/org/apache/accumulo/core/conf/ClientPropertyTest.java @@ -19,15 +19,14 @@ package org.apache.accumulo.core.conf; import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertThrows; import static org.junit.Assert.assertTrue; import java.util.Properties; import org.apache.accumulo.core.client.security.tokens.AuthenticationToken; import org.apache.accumulo.core.client.security.tokens.PasswordToken; -import org.junit.Rule; import org.junit.Test; -import org.junit.rules.ExpectedException; public class ClientPropertyTest { @@ -59,9 +58,6 @@ public class ClientPropertyTest { assertEquals("/path/to/keytab", ClientProperty.AUTH_TOKEN.getValue(props)); } - @Rule - public ExpectedException exception = ExpectedException.none(); - @Test public void testTypes() { Properties props = new Properties(); @@ -81,7 +77,7 @@ public class ClientPropertyTest { value = ClientProperty.BATCH_WRITER_LATENCY_MAX.getTimeInMillis(props); assertEquals(1234L, value.longValue()); - exception.expect(IllegalStateException.class); - ClientProperty.BATCH_WRITER_LATENCY_MAX.getBytes(props); + assertThrows(IllegalStateException.class, + () -> ClientProperty.BATCH_WRITER_LATENCY_MAX.getBytes(props)); } } diff --git a/core/src/test/java/org/apache/accumulo/core/crypto/CryptoTest.java b/core/src/test/java/org/apache/accumulo/core/crypto/CryptoTest.java index 9b73c83..cec0986 100644 --- a/core/src/test/java/org/apache/accumulo/core/crypto/CryptoTest.java +++ b/core/src/test/java/org/apache/accumulo/core/crypto/CryptoTest.java @@ -23,7 +23,7 @@ import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertNotEquals; import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.fail; +import static org.junit.Assert.assertThrows; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; @@ -73,9 +73,7 @@ import org.apache.hadoop.fs.FSDataOutputStream; import org.apache.hadoop.fs.FileSystem; import org.apache.hadoop.fs.Path; import org.junit.BeforeClass; -import org.junit.Rule; import org.junit.Test; -import org.junit.rules.ExpectedException; import com.google.common.collect.Iterables; @@ -93,9 +91,6 @@ public class CryptoTest { System.getProperty("user.dir") + "/target/CryptoTest-emptykeyfile"; private static Configuration hadoopConf = new Configuration(); - @Rule - public ExpectedException exception = ExpectedException.none(); - @BeforeClass public static void setupKeyFiles() throws Exception { FileSystem fs = FileSystem.getLocal(hadoopConf); @@ -279,25 +274,31 @@ public class CryptoTest { AccumuloVFSClassLoader.loadClass(configuredClass, CryptoService.class); CryptoService cs = clazz.getDeclaredConstructor().newInstance(); - exception.expect(NullPointerException.class); - cs.init(aconf.getAllPropertiesWithPrefix(Property.TABLE_PREFIX)); assertEquals(AESCryptoService.class, cs.getClass()); + assertThrows(NullPointerException.class, + () -> cs.init(aconf.getAllPropertiesWithPrefix(Property.TABLE_PREFIX))); } - @SuppressFBWarnings(value = "CIPHER_INTEGRITY", justification = "CBC is being tested") @Test public void testAESKeyUtilsGeneratesKey() throws NoSuchAlgorithmException, NoSuchProviderException, NoSuchPaddingException, InvalidKeyException { SecureRandom sr = SecureRandom.getInstance("SHA1PRNG", "SUN"); - java.security.Key key; - key = AESKeyUtils.generateKey(sr, 16); - Cipher.getInstance("AES/CBC/NoPadding").init(Cipher.ENCRYPT_MODE, key); - - key = AESKeyUtils.generateKey(sr, 24); - key = AESKeyUtils.generateKey(sr, 32); - key = AESKeyUtils.generateKey(sr, 11); + // verify valid key sizes (corresponds to 128, 192, and 256 bits) + for (int i : new int[] {16, 24, 32}) { + verifyKeySizeForCBC(sr, i); + } + // verify invalid key sizes + for (int i : new int[] {1, 2, 8, 11, 15, 64, 128}) { + assertThrows(InvalidKeyException.class, () -> verifyKeySizeForCBC(sr, i)); + } + } - exception.expect(InvalidKeyException.class); + // this has to be a separate method, for spotbugs, because spotbugs annotation doesn't seem to + // apply to the lambda inline + @SuppressFBWarnings(value = "CIPHER_INTEGRITY", justification = "CBC is being tested") + private void verifyKeySizeForCBC(SecureRandom sr, int sizeInBytes) + throws InvalidKeyException, NoSuchAlgorithmException, NoSuchPaddingException { + java.security.Key key = AESKeyUtils.generateKey(sr, sizeInBytes); Cipher.getInstance("AES/CBC/NoPadding").init(Cipher.ENCRYPT_MODE, key); } @@ -324,9 +325,7 @@ public class CryptoTest { java.security.Key wrongKek = new SecretKeySpec(wrongBytes, "AES"); byte[] wrapped = AESKeyUtils.wrapKey(fek, kek); - exception.expect(CryptoException.class); - java.security.Key unwrapped = AESKeyUtils.unwrapKey(wrapped, wrongKek); - fail("creation of " + unwrapped + " should fail"); + assertThrows(CryptoException.class, () -> AESKeyUtils.unwrapKey(wrapped, wrongKek)); } @Test @@ -341,17 +340,13 @@ public class CryptoTest { @Test public void testAESKeyUtilsLoadKekFromUriInvalidUri() { - exception.expect(CryptoException.class); - SecretKeySpec fileKey = AESKeyUtils.loadKekFromUri( - System.getProperty("user.dir") + "/target/CryptoTest-testkeyfile-doesnt-exist"); - fail("creation of " + fileKey + " should fail"); + assertThrows(CryptoException.class, () -> AESKeyUtils.loadKekFromUri( + System.getProperty("user.dir") + "/target/CryptoTest-testkeyfile-doesnt-exist")); } @Test public void testAESKeyUtilsLoadKekFromEmptyFile() { - exception.expect(CryptoException.class); - SecretKeySpec fileKey = AESKeyUtils.loadKekFromUri(emptyKeyPath); - fail("creation of " + fileKey + " should fail"); + assertThrows(CryptoException.class, () -> AESKeyUtils.loadKekFromUri(emptyKeyPath)); } private ArrayList<Key> testData() { diff --git a/core/src/test/java/org/apache/accumulo/core/util/PreAllocatedArrayTest.java b/core/src/test/java/org/apache/accumulo/core/util/PreAllocatedArrayTest.java index 037a88e..7c48fbd 100644 --- a/core/src/test/java/org/apache/accumulo/core/util/PreAllocatedArrayTest.java +++ b/core/src/test/java/org/apache/accumulo/core/util/PreAllocatedArrayTest.java @@ -21,18 +21,14 @@ package org.apache.accumulo.core.util; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertNull; +import static org.junit.Assert.assertThrows; import java.util.Iterator; -import org.junit.Rule; import org.junit.Test; -import org.junit.rules.ExpectedException; public class PreAllocatedArrayTest { - @Rule - public ExpectedException exception = ExpectedException.none(); - /** * Test method for {@link org.apache.accumulo.core.util.PreAllocatedArray#PreAllocatedArray(int)}. */ @@ -50,8 +46,7 @@ public class PreAllocatedArrayTest { @Test public void testPreAllocatedArray_Fail() { - exception.expect(IllegalArgumentException.class); - new PreAllocatedArray<String>(-5); + assertThrows(IllegalArgumentException.class, () -> new PreAllocatedArray<String>(-5)); } /** @@ -89,31 +84,27 @@ public class PreAllocatedArrayTest { public void testSetIndexHigh() { PreAllocatedArray<String> strings = new PreAllocatedArray<>(3); strings.set(2, "in bounds"); - exception.expect(IndexOutOfBoundsException.class); - strings.set(3, "out of bounds"); + assertThrows(IndexOutOfBoundsException.class, () -> strings.set(3, "out of bounds")); } @Test public void testSetIndexNegative() { PreAllocatedArray<String> strings = new PreAllocatedArray<>(3); strings.set(0, "in bounds"); - exception.expect(IndexOutOfBoundsException.class); - strings.set(-3, "out of bounds"); + assertThrows(IndexOutOfBoundsException.class, () -> strings.set(-3, "out of bounds")); } @Test public void testGetIndexHigh() { PreAllocatedArray<String> strings = new PreAllocatedArray<>(3); strings.get(2); - exception.expect(IndexOutOfBoundsException.class); - strings.get(3); + assertThrows(IndexOutOfBoundsException.class, () -> strings.get(3)); } @Test public void testGetIndexNegative() { PreAllocatedArray<String> strings = new PreAllocatedArray<>(3); strings.get(0); - exception.expect(IndexOutOfBoundsException.class); - strings.get(-3); + assertThrows(IndexOutOfBoundsException.class, () -> strings.get(-3)); } } diff --git a/core/src/test/java/org/apache/accumulo/core/util/UnsynchronizedBufferTest.java b/core/src/test/java/org/apache/accumulo/core/util/UnsynchronizedBufferTest.java index c9886ae..93c2b89 100644 --- a/core/src/test/java/org/apache/accumulo/core/util/UnsynchronizedBufferTest.java +++ b/core/src/test/java/org/apache/accumulo/core/util/UnsynchronizedBufferTest.java @@ -20,6 +20,7 @@ package org.apache.accumulo.core.util; import static java.nio.charset.StandardCharsets.UTF_8; import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertThrows; import static org.junit.Assert.assertTrue; import java.io.ByteArrayOutputStream; @@ -28,15 +29,10 @@ import java.nio.ByteBuffer; import java.util.Arrays; import org.apache.hadoop.io.WritableUtils; -import org.junit.Rule; import org.junit.Test; -import org.junit.rules.ExpectedException; public class UnsynchronizedBufferTest { - @Rule - public ExpectedException thrown = ExpectedException.none(); - @Test public void testByteBufferConstructor() { byte[] test = "0123456789".getBytes(UTF_8); @@ -57,8 +53,9 @@ public class UnsynchronizedBufferTest { buf = new byte[6]; // the byte buffer has the extra byte, but should not be able to read it... - thrown.expect(ArrayIndexOutOfBoundsException.class); - ub.readBytes(buf); + final UnsynchronizedBuffer.Reader ub2 = ub; + final byte[] buf2 = buf; + assertThrows(ArrayIndexOutOfBoundsException.class, () -> ub2.readBytes(buf2)); } @Test diff --git a/core/src/test/java/org/apache/accumulo/fate/util/RetryTest.java b/core/src/test/java/org/apache/accumulo/fate/util/RetryTest.java index a15f06d..745d268 100644 --- a/core/src/test/java/org/apache/accumulo/fate/util/RetryTest.java +++ b/core/src/test/java/org/apache/accumulo/fate/util/RetryTest.java @@ -25,8 +25,8 @@ import static java.util.concurrent.TimeUnit.MINUTES; import static java.util.concurrent.TimeUnit.NANOSECONDS; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertThrows; import static org.junit.Assert.assertTrue; -import static org.junit.Assert.fail; import java.util.concurrent.TimeUnit; @@ -38,9 +38,7 @@ import org.apache.accumulo.fate.util.Retry.NeedsTimeIncrement; import org.apache.accumulo.fate.util.Retry.RetryFactory; import org.easymock.EasyMock; import org.junit.Before; -import org.junit.Rule; import org.junit.Test; -import org.junit.rules.ExpectedException; import org.slf4j.Logger; public class RetryTest { @@ -54,9 +52,6 @@ public class RetryTest { private Retry unlimitedRetry; private static final TimeUnit MS = MILLISECONDS; - @Rule - public ExpectedException exception = ExpectedException.none(); - @Before public void setup() { retry = Retry.builder().maxRetries(MAX_RETRIES).retryAfter(INITIAL_WAIT, MS) @@ -103,9 +98,7 @@ public class RetryTest { assertFalse(retry.canRetry()); // Calling useRetry when canRetry returns false throws an exception - exception.expect(IllegalStateException.class); - retry.useRetry(); - fail("previous command should have thrown IllegalStateException"); + assertThrows(IllegalStateException.class, () -> retry.useRetry()); } @Test @@ -245,9 +238,8 @@ public class RetryTest { NeedsRetries builder = Retry.builder(); builder.maxRetries(10); builder.maxRetries(0); - exception.expect(IllegalArgumentException.class); - builder.maxRetries(-1); - fail("Should not allow negative retries"); + assertThrows("Should not allow negative retries", IllegalArgumentException.class, + () -> builder.maxRetries(-1)); } @Test @@ -260,9 +252,8 @@ public class RetryTest { builder.retryAfter(0, MILLISECONDS); builder.retryAfter(0, DAYS); - exception.expect(IllegalArgumentException.class); - builder.retryAfter(-1, NANOSECONDS); - fail("Should not allow negative wait times"); + assertThrows("Should not allow negative wait times", IllegalArgumentException.class, + () -> builder.retryAfter(-1, NANOSECONDS)); } @Test @@ -275,9 +266,8 @@ public class RetryTest { builder.incrementBy(0, HOURS); builder.incrementBy(0, NANOSECONDS); - exception.expect(IllegalArgumentException.class); - builder.incrementBy(-1, NANOSECONDS); - fail("Should not allow negative increments"); + assertThrows("Should not allow negative increments", IllegalArgumentException.class, + () -> builder.incrementBy(-1, NANOSECONDS)); } @Test @@ -287,9 +277,8 @@ public class RetryTest { builder.maxWait(15, MILLISECONDS); builder.maxWait(16, MILLISECONDS); - exception.expect(IllegalArgumentException.class); - builder.maxWait(14, MILLISECONDS); - fail("Max wait time should be greater than or equal to initial wait time"); + assertThrows("Max wait time should be greater than or equal to initial wait time", + IllegalArgumentException.class, () -> builder.maxWait(14, MILLISECONDS)); } @Test @@ -303,9 +292,8 @@ public class RetryTest { builder.logInterval(0, HOURS); builder.logInterval(0, NANOSECONDS); - exception.expect(IllegalArgumentException.class); - builder.logInterval(-1, NANOSECONDS); - fail("Log interval must not be negative"); + assertThrows("Log interval must not be negative", IllegalArgumentException.class, + () -> builder.logInterval(-1, NANOSECONDS)); } @Test diff --git a/hadoop-mapreduce/src/test/java/org/apache/accumulo/hadoop/mapred/AccumuloInputFormatTest.java b/hadoop-mapreduce/src/test/java/org/apache/accumulo/hadoop/mapred/AccumuloInputFormatTest.java index 4ae0cde..54e8d5b 100644 --- a/hadoop-mapreduce/src/test/java/org/apache/accumulo/hadoop/mapred/AccumuloInputFormatTest.java +++ b/hadoop-mapreduce/src/test/java/org/apache/accumulo/hadoop/mapred/AccumuloInputFormatTest.java @@ -19,6 +19,7 @@ package org.apache.accumulo.hadoop.mapred; import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertThrows; import static org.junit.Assert.fail; import java.io.ByteArrayOutputStream; @@ -43,7 +44,6 @@ import org.junit.Before; import org.junit.BeforeClass; import org.junit.Rule; import org.junit.Test; -import org.junit.rules.ExpectedException; import org.junit.rules.TestName; public class AccumuloInputFormatTest { @@ -53,8 +53,6 @@ public class AccumuloInputFormatTest { @Rule public TestName test = new TestName(); - @Rule - public ExpectedException exception = ExpectedException.none(); @Before public void createJob() { @@ -71,8 +69,8 @@ public class AccumuloInputFormatTest { public void testMissingTable() throws Exception { Properties clientProps = org.apache.accumulo.hadoop.mapreduce.AccumuloInputFormatTest.setupClientProperties(); - exception.expect(IllegalArgumentException.class); - AccumuloInputFormat.configure().clientProperties(clientProps).store(new JobConf()); + assertThrows(IllegalArgumentException.class, + () -> AccumuloInputFormat.configure().clientProperties(clientProps).store(new JobConf())); } /** diff --git a/hadoop-mapreduce/src/test/java/org/apache/accumulo/hadoop/mapreduce/AccumuloInputFormatTest.java b/hadoop-mapreduce/src/test/java/org/apache/accumulo/hadoop/mapreduce/AccumuloInputFormatTest.java index cf1ea14..ff63f60 100644 --- a/hadoop-mapreduce/src/test/java/org/apache/accumulo/hadoop/mapreduce/AccumuloInputFormatTest.java +++ b/hadoop-mapreduce/src/test/java/org/apache/accumulo/hadoop/mapreduce/AccumuloInputFormatTest.java @@ -19,6 +19,7 @@ package org.apache.accumulo.hadoop.mapreduce; import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertThrows; import static org.junit.Assert.fail; import java.io.ByteArrayOutputStream; @@ -42,13 +43,9 @@ import org.apache.hadoop.conf.Configuration; import org.apache.hadoop.io.Text; import org.apache.hadoop.mapreduce.Job; import org.junit.BeforeClass; -import org.junit.Rule; import org.junit.Test; -import org.junit.rules.ExpectedException; public class AccumuloInputFormatTest { - @Rule - public ExpectedException exception = ExpectedException.none(); static Properties clientProperties; @@ -71,8 +68,8 @@ public class AccumuloInputFormatTest { public void testMissingTable() throws Exception { Properties clientProps = org.apache.accumulo.hadoop.mapreduce.AccumuloInputFormatTest.setupClientProperties(); - exception.expect(IllegalArgumentException.class); - AccumuloInputFormat.configure().clientProperties(clientProps).store(Job.getInstance()); + assertThrows(IllegalArgumentException.class, () -> AccumuloInputFormat.configure() + .clientProperties(clientProps).store(Job.getInstance())); } /** diff --git a/pom.xml b/pom.xml index e4b1d4e..2e4580c 100644 --- a/pom.xml +++ b/pom.xml @@ -115,9 +115,9 @@ <!-- used for filtering the java source with the current version --> <accumulo.release.version>${project.version}</accumulo.release.version> <!-- bouncycastle version for test dependencies --> - <bouncycastle.version>1.62</bouncycastle.version> + <bouncycastle.version>1.64</bouncycastle.version> <!-- Curator version --> - <curator.version>4.2.0</curator.version> + <curator.version>4.3.0</curator.version> <!-- relative path for Eclipse format; should override in child modules if necessary --> <eclipseFormatterStyle>${project.parent.basedir}/contrib/Eclipse-Accumulo-Codestyle.xml</eclipseFormatterStyle> <!-- extra release args for testing --> @@ -126,27 +126,26 @@ <failsafe.groups /> <!-- surefire/failsafe plugin option --> <forkCount>1</forkCount> - <hadoop.version>3.1.2</hadoop.version> - <hk2.version>2.5.0</hk2.version> + <hadoop.version>3.2.1</hadoop.version> + <hk2.version>2.6.1</hk2.version> <htrace.hadoop.version>4.1.0-incubating</htrace.hadoop.version> <htrace.version>3.2.0-incubating</htrace.version> <it.failIfNoSpecifiedTests>false</it.failIfNoSpecifiedTests> - <jackson.version>2.10.0</jackson.version> + <jackson.version>2.10.3</jackson.version> <javax.el.version>3.0.1-b06</javax.el.version> <jaxb.version>2.3.0.1</jaxb.version> - <jersey.version>2.28</jersey.version> - <jetty.version>9.4.19.v20190610</jetty.version> + <jersey.version>2.30.1</jersey.version> + <jetty.version>9.4.27.v20200227</jetty.version> <maven.compiler.release>11</maven.compiler.release> <maven.compiler.source>11</maven.compiler.source> <maven.compiler.target>11</maven.compiler.target> <!-- surefire/failsafe plugin option --> <maven.test.redirectTestOutputToFile>true</maven.test.redirectTestOutputToFile> - <powermock.version>2.0.2</powermock.version> + <powermock.version>2.0.5</powermock.version> <!-- surefire/failsafe plugin option --> <reuseForks>false</reuseForks> - <slf4j.version>1.7.26</slf4j.version> + <slf4j.version>1.7.30</slf4j.version> <sourceReleaseAssemblyDescriptor>source-release-tar</sourceReleaseAssemblyDescriptor> - <spotbugs.version>3.1.12</spotbugs.version> <surefire.excludedGroups /> <surefire.failIfNoSpecifiedTests>false</surefire.failIfNoSpecifiedTests> <surefire.groups /> @@ -162,12 +161,12 @@ <dependency> <groupId>com.beust</groupId> <artifactId>jcommander</artifactId> - <version>1.72</version> + <version>1.78</version> </dependency> <dependency> <groupId>com.fasterxml</groupId> <artifactId>classmate</artifactId> - <version>1.5.0</version> + <version>1.5.1</version> </dependency> <dependency> <groupId>com.fasterxml.jackson.core</groupId> @@ -202,22 +201,27 @@ <dependency> <groupId>com.github.ben-manes.caffeine</groupId> <artifactId>caffeine</artifactId> - <version>2.7.0</version> + <version>2.8.1</version> </dependency> <dependency> <groupId>com.github.spotbugs</groupId> <artifactId>spotbugs-annotations</artifactId> - <version>${spotbugs.version}</version> + <version>4.0.0</version> </dependency> <dependency> <groupId>com.google.auto.service</groupId> <artifactId>auto-service</artifactId> - <version>1.0-rc5</version> + <version>1.0-rc6</version> + </dependency> + <dependency> + <groupId>com.google.code.findbugs</groupId> + <artifactId>jsr305</artifactId> + <version>3.0.2</version> </dependency> <dependency> <groupId>com.google.code.gson</groupId> <artifactId>gson</artifactId> - <version>2.8.5</version> + <version>2.8.6</version> </dependency> <dependency> <!-- this is a runtime dependency of guava, no longer included with guava as of 27.1 --> @@ -228,7 +232,7 @@ <dependency> <groupId>com.google.guava</groupId> <artifactId>guava</artifactId> - <version>28.0-jre</version> + <version>28.2-jre</version> </dependency> <dependency> <groupId>com.google.protobuf</groupId> @@ -248,7 +252,7 @@ <dependency> <groupId>commons-beanutils</groupId> <artifactId>commons-beanutils</artifactId> - <version>1.9.3</version> + <version>1.9.4</version> </dependency> <dependency> <groupId>commons-cli</groupId> @@ -258,7 +262,7 @@ <dependency> <groupId>commons-codec</groupId> <artifactId>commons-codec</artifactId> - <version>1.12</version> + <version>1.14</version> </dependency> <dependency> <groupId>commons-io</groupId> @@ -271,6 +275,11 @@ <version>1.2</version> </dependency> <dependency> + <groupId>jakarta.annotation</groupId> + <artifactId>jakarta.annotation-api</artifactId> + <version>1.3.5</version> + </dependency> + <dependency> <groupId>javax.activation</groupId> <artifactId>javax.activation-api</artifactId> <version>1.2.0</version> @@ -318,7 +327,7 @@ <dependency> <groupId>junit</groupId> <artifactId>junit</artifactId> - <version>4.12</version> + <version>4.13</version> </dependency> <dependency> <groupId>org.apache.accumulo</groupId> @@ -394,12 +403,12 @@ <dependency> <groupId>org.apache.commons</groupId> <artifactId>commons-collections4</artifactId> - <version>4.3</version> + <version>4.4</version> </dependency> <dependency> <groupId>org.apache.commons</groupId> <artifactId>commons-configuration2</artifactId> - <version>2.5</version> + <version>2.7</version> </dependency> <dependency> <groupId>org.apache.commons</groupId> @@ -424,12 +433,18 @@ <dependency> <groupId>org.apache.commons</groupId> <artifactId>commons-text</artifactId> - <version>1.6</version> + <version>1.8</version> </dependency> <dependency> <groupId>org.apache.commons</groupId> <artifactId>commons-vfs2</artifactId> - <version>2.3</version> + <version>2.6.0</version> + <exclusions> + <exclusion> + <groupId>org.apache.hadoop</groupId> + <artifactId>hadoop-hdfs-client</artifactId> + </exclusion> + </exclusions> </dependency> <dependency> <groupId>org.apache.curator</groupId> @@ -552,9 +567,14 @@ <version>${bouncycastle.version}</version> </dependency> <dependency> + <groupId>org.checkerframework</groupId> + <artifactId>checker-qual</artifactId> + <version>3.1.0</version> + </dependency> + <dependency> <groupId>org.easymock</groupId> <artifactId>easymock</artifactId> - <version>4.0.2</version> + <version>4.2</version> </dependency> <dependency> <groupId>org.eclipse.jetty</groupId> @@ -594,7 +614,7 @@ <dependency> <groupId>org.freemarker</groupId> <artifactId>freemarker</artifactId> - <version>2.3.28</version> + <version>2.3.30</version> </dependency> <dependency> <groupId>org.glassfish.hk2</groupId> @@ -722,29 +742,24 @@ <version>2.2.6</version> </dependency> <dependency> - <groupId>org.hamcrest</groupId> - <artifactId>hamcrest</artifactId> - <version>2.1</version> - </dependency> - <dependency> - <groupId>org.hamcrest</groupId> - <artifactId>hamcrest-core</artifactId> - <version>2.1</version> - </dependency> - <dependency> <groupId>org.hibernate.validator</groupId> <artifactId>hibernate-validator</artifactId> - <version>6.1.0.Final</version> + <version>6.1.2.Final</version> </dependency> <dependency> <groupId>org.javassist</groupId> <artifactId>javassist</artifactId> - <version>3.25.0-GA</version> + <version>3.26.0-GA</version> </dependency> <dependency> <groupId>org.jboss.logging</groupId> <artifactId>jboss-logging</artifactId> - <version>3.4.0.Final</version> + <version>3.4.1.Final</version> + </dependency> + <dependency> + <groupId>org.objenesis</groupId> + <artifactId>objenesis</artifactId> + <version>3.1</version> </dependency> <dependency> <groupId>org.powermock</groupId> @@ -774,7 +789,7 @@ <dependency> <groupId>org.apache.logging.log4j</groupId> <artifactId>log4j-bom</artifactId> - <version>2.13.0</version> + <version>2.13.1</version> <type>pom</type> <scope>import</scope> </dependency> @@ -833,7 +848,7 @@ <plugin> <groupId>com.github.spotbugs</groupId> <artifactId>spotbugs-maven-plugin</artifactId> - <version>${spotbugs.version}.1</version> + <version>3.1.12.1</version> <configuration> <xmlOutput>true</xmlOutput> <effort>Max</effort> @@ -913,6 +928,11 @@ </plugin> <plugin> <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-dependency-plugin</artifactId> + <version>3.1.2</version> + </plugin> + <plugin> + <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-jar-plugin</artifactId> <configuration> <archive> @@ -1062,14 +1082,6 @@ <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-dependency-plugin</artifactId> - <dependencies> - <dependency> - <!-- needed for Java 11 until maven-dependency-plugin 3.1.2 is released --> - <groupId>org.apache.maven.shared</groupId> - <artifactId>maven-dependency-analyzer</artifactId> - <version>1.11.1</version> - </dependency> - </dependencies> <executions> <execution> <id>analyze</id> @@ -1169,6 +1181,7 @@ <requireJavaVersion> <version>[11,)</version> </requireJavaVersion> + <dependencyConvergence /> </rules> </configuration> </execution> @@ -1266,7 +1279,7 @@ <dependency> <groupId>com.puppycrawl.tools</groupId> <artifactId>checkstyle</artifactId> - <version>8.29</version> + <version>8.30</version> </dependency> </dependencies> <executions> diff --git a/server/base/src/test/java/org/apache/accumulo/server/fs/PerTableVolumeChooserTest.java b/server/base/src/test/java/org/apache/accumulo/server/fs/PerTableVolumeChooserTest.java index eb1d9a6..518b5e0 100644 --- a/server/base/src/test/java/org/apache/accumulo/server/fs/PerTableVolumeChooserTest.java +++ b/server/base/src/test/java/org/apache/accumulo/server/fs/PerTableVolumeChooserTest.java @@ -24,7 +24,7 @@ import static org.easymock.EasyMock.expect; import static org.easymock.EasyMock.replay; import static org.easymock.EasyMock.verify; import static org.junit.Assert.assertSame; -import static org.junit.Assert.fail; +import static org.junit.Assert.assertThrows; import org.apache.accumulo.core.data.TableId; import org.apache.accumulo.core.spi.common.ServiceEnvironment; @@ -33,9 +33,7 @@ import org.apache.accumulo.server.fs.VolumeChooser.VolumeChooserException; import org.apache.accumulo.server.fs.VolumeChooserEnvironment.ChooserScope; import org.junit.After; import org.junit.Before; -import org.junit.Rule; import org.junit.Test; -import org.junit.rules.ExpectedException; public class PerTableVolumeChooserTest { @@ -54,9 +52,6 @@ public class PerTableVolumeChooserTest { public static class MockChooser2 extends RandomVolumeChooser {} - @Rule - public ExpectedException thrown = ExpectedException.none(); - @Before public void before() { serviceEnv = createStrictMock(ServiceEnvironment.class); @@ -126,9 +121,7 @@ public class PerTableVolumeChooserTest { .once(); replay(serviceEnv, tableConf, systemConf); - thrown.expect(VolumeChooserException.class); - getTableDelegate(); - fail("should not reach"); + assertThrows(VolumeChooserException.class, () -> getTableDelegate()); } @Test @@ -140,9 +133,7 @@ public class PerTableVolumeChooserTest { VolumeChooser.class)).andThrow(new RuntimeException()); replay(serviceEnv, tableConf, systemConf); - thrown.expect(VolumeChooserException.class); - getTableDelegate(); - fail("should not reach"); + assertThrows(VolumeChooserException.class, () -> getTableDelegate()); } @Test @@ -179,9 +170,7 @@ public class PerTableVolumeChooserTest { .once(); replay(serviceEnv, tableConf, systemConf); - thrown.expect(VolumeChooserException.class); - getDelegate(ChooserScope.LOGGER); - fail("should not reach"); + assertThrows(VolumeChooserException.class, () -> getDelegate(ChooserScope.LOGGER)); } @Test @@ -194,9 +183,7 @@ public class PerTableVolumeChooserTest { .andThrow(new RuntimeException()); replay(serviceEnv, tableConf, systemConf); - thrown.expect(VolumeChooserException.class); - getDelegate(ChooserScope.LOGGER); - fail("should not reach"); + assertThrows(VolumeChooserException.class, () -> getDelegate(ChooserScope.LOGGER)); } @Test diff --git a/server/base/src/test/java/org/apache/accumulo/server/fs/PreferredVolumeChooserTest.java b/server/base/src/test/java/org/apache/accumulo/server/fs/PreferredVolumeChooserTest.java index 1167af9..c66c6bc 100644 --- a/server/base/src/test/java/org/apache/accumulo/server/fs/PreferredVolumeChooserTest.java +++ b/server/base/src/test/java/org/apache/accumulo/server/fs/PreferredVolumeChooserTest.java @@ -24,7 +24,7 @@ import static org.easymock.EasyMock.expect; import static org.easymock.EasyMock.replay; import static org.easymock.EasyMock.verify; import static org.junit.Assert.assertEquals; -import static org.junit.Assert.fail; +import static org.junit.Assert.assertThrows; import java.util.Set; @@ -35,9 +35,7 @@ import org.apache.accumulo.server.fs.VolumeChooser.VolumeChooserException; import org.apache.accumulo.server.fs.VolumeChooserEnvironment.ChooserScope; import org.junit.After; import org.junit.Before; -import org.junit.Rule; import org.junit.Test; -import org.junit.rules.ExpectedException; public class PreferredVolumeChooserTest { @@ -54,9 +52,6 @@ public class PreferredVolumeChooserTest { private Configuration systemConf; private PreferredVolumeChooser chooser; - @Rule - public ExpectedException thrown = ExpectedException.none(); - @Before public void before() { serviceEnv = createStrictMock(ServiceEnvironment.class); @@ -118,9 +113,7 @@ public class PreferredVolumeChooserTest { .once(); replay(serviceEnv, tableConf, systemConf); - thrown.expect(VolumeChooserException.class); - chooseForTable(); - fail("should not reach"); + assertThrows(VolumeChooserException.class, () -> chooseForTable()); } @Test @@ -128,9 +121,7 @@ public class PreferredVolumeChooserTest { expect(tableConf.getTableCustom(TABLE_CUSTOM_SUFFIX)).andReturn(",").once(); replay(serviceEnv, tableConf, systemConf); - thrown.expect(VolumeChooserException.class); - chooseForTable(); - fail("should not reach"); + assertThrows(VolumeChooserException.class, () -> chooseForTable()); } @Test @@ -140,9 +131,7 @@ public class PreferredVolumeChooserTest { .once(); replay(serviceEnv, tableConf, systemConf); - thrown.expect(VolumeChooserException.class); - chooseForTable(); - fail("should not reach"); + assertThrows(VolumeChooserException.class, () -> chooseForTable()); } @Test @@ -171,9 +160,7 @@ public class PreferredVolumeChooserTest { .once(); replay(serviceEnv, tableConf, systemConf); - thrown.expect(VolumeChooserException.class); - choose(ChooserScope.LOGGER); - fail("should not reach"); + assertThrows(VolumeChooserException.class, () -> choose(ChooserScope.LOGGER)); } @Test @@ -182,9 +169,7 @@ public class PreferredVolumeChooserTest { .once(); replay(serviceEnv, tableConf, systemConf); - thrown.expect(VolumeChooserException.class); - choose(ChooserScope.LOGGER); - fail("should not reach"); + assertThrows(VolumeChooserException.class, () -> choose(ChooserScope.LOGGER)); } @Test @@ -195,9 +180,7 @@ public class PreferredVolumeChooserTest { .once(); replay(serviceEnv, tableConf, systemConf); - thrown.expect(VolumeChooserException.class); - choose(ChooserScope.LOGGER); - fail("should not reach"); + assertThrows(VolumeChooserException.class, () -> choose(ChooserScope.LOGGER)); } @Test diff --git a/server/base/src/test/java/org/apache/accumulo/server/fs/VolumeManagerImplTest.java b/server/base/src/test/java/org/apache/accumulo/server/fs/VolumeManagerImplTest.java index 1e1d084..c02714c 100644 --- a/server/base/src/test/java/org/apache/accumulo/server/fs/VolumeManagerImplTest.java +++ b/server/base/src/test/java/org/apache/accumulo/server/fs/VolumeManagerImplTest.java @@ -18,7 +18,7 @@ */ package org.apache.accumulo.server.fs; -import static org.junit.Assert.fail; +import static org.junit.Assert.assertThrows; import java.util.Arrays; import java.util.List; @@ -28,17 +28,12 @@ import org.apache.accumulo.core.conf.ConfigurationCopy; import org.apache.accumulo.core.conf.Property; import org.apache.accumulo.core.data.TableId; import org.apache.hadoop.conf.Configuration; -import org.junit.Rule; import org.junit.Test; -import org.junit.rules.ExpectedException; public class VolumeManagerImplTest { private Configuration hadoopConf = new Configuration(); - @Rule - public ExpectedException thrown = ExpectedException.none(); - @Test public void invalidChooserConfigured() throws Exception { List<String> volumes = Arrays.asList("file://one/", "file://two/", "file://three/"); @@ -47,20 +42,14 @@ public class VolumeManagerImplTest { conf.set(Property.INSTANCE_VOLUMES, String.join(",", volumes)); conf.set(Property.GENERAL_VOLUME_CHOOSER, "org.apache.accumulo.server.fs.ChooserThatDoesntExist"); - thrown.expect(RuntimeException.class); - try (var vm = VolumeManagerImpl.get(conf, hadoopConf)) { - fail("shouldn't reach here " + vm); - } + assertThrows(RuntimeException.class, () -> VolumeManagerImpl.get(conf, hadoopConf)); } @Test public void noViewFS() throws Exception { ConfigurationCopy conf = new ConfigurationCopy(); conf.set(Property.INSTANCE_VOLUMES, "viewfs://dummy"); - thrown.expect(IllegalArgumentException.class); - try (var vm = VolumeManagerImpl.get(conf, hadoopConf)) { - fail("shouldn't reach here " + vm); - } + assertThrows(IllegalArgumentException.class, () -> VolumeManagerImpl.get(conf, hadoopConf)); } public static class WrongVolumeChooser implements VolumeChooser { @@ -86,12 +75,10 @@ public class VolumeManagerImplTest { conf.set(INSTANCE_DFS_URI, volumes.iterator().next()); conf.set(Property.INSTANCE_VOLUMES, String.join(",", volumes)); conf.set(Property.GENERAL_VOLUME_CHOOSER, WrongVolumeChooser.class.getName()); - thrown.expect(RuntimeException.class); try (var vm = VolumeManagerImpl.get(conf, hadoopConf)) { VolumeChooserEnvironment chooserEnv = new VolumeChooserEnvironmentImpl(TableId.of("sometable"), null, null); - vm.choose(chooserEnv, volumes); - fail("shouldn't reach here"); + assertThrows(RuntimeException.class, () -> vm.choose(chooserEnv, volumes)); } } } diff --git a/server/tserver/src/test/java/org/apache/accumulo/tserver/InMemoryMapTest.java b/server/tserver/src/test/java/org/apache/accumulo/tserver/InMemoryMapTest.java index fd670ee..bb7bdcd 100644 --- a/server/tserver/src/test/java/org/apache/accumulo/tserver/InMemoryMapTest.java +++ b/server/tserver/src/test/java/org/apache/accumulo/tserver/InMemoryMapTest.java @@ -20,6 +20,7 @@ package org.apache.accumulo.tserver; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertThrows; import static org.junit.Assert.assertTrue; import static org.junit.Assert.fail; @@ -65,7 +66,6 @@ import org.apache.hadoop.io.Text; import org.easymock.EasyMock; import org.junit.Rule; import org.junit.Test; -import org.junit.rules.ExpectedException; import org.junit.rules.TemporaryFolder; import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; @@ -96,9 +96,6 @@ public class InMemoryMapTest { } } - @Rule - public ExpectedException thrown = ExpectedException.none(); - public static ServerContext getServerContext() { Configuration hadoopConf = new Configuration(); ServerContext context = EasyMock.createMock(ServerContext.class); @@ -799,9 +796,9 @@ public class InMemoryMapTest { iter.seek(new Range(), LocalityGroupUtil.EMPTY_CF_SET, false); assertEquals(expectedAll, readAll(iter)); - iter = imm.skvIterator(sampleConfig1); - thrown.expect(SampleNotPresentException.class); - iter.seek(new Range(), LocalityGroupUtil.EMPTY_CF_SET, false); + final MemoryIterator iter2 = imm.skvIterator(sampleConfig1); + assertThrows(SampleNotPresentException.class, + () -> iter2.seek(new Range(), LocalityGroupUtil.EMPTY_CF_SET, false)); } private TreeMap<Key,Value> readAll(SortedKeyValueIterator<Key,Value> iter) throws IOException { diff --git a/server/tserver/src/test/java/org/apache/accumulo/tserver/compaction/CompactionPlanTest.java b/server/tserver/src/test/java/org/apache/accumulo/tserver/compaction/CompactionPlanTest.java index 09619b2..4a7383e 100644 --- a/server/tserver/src/test/java/org/apache/accumulo/tserver/compaction/CompactionPlanTest.java +++ b/server/tserver/src/test/java/org/apache/accumulo/tserver/compaction/CompactionPlanTest.java @@ -18,18 +18,15 @@ */ package org.apache.accumulo.tserver.compaction; +import static org.junit.Assert.assertThrows; + import java.util.Set; import org.apache.accumulo.core.metadata.StoredTabletFile; -import org.junit.Rule; import org.junit.Test; -import org.junit.rules.ExpectedException; public class CompactionPlanTest { - @Rule - public ExpectedException exception = ExpectedException.none(); - @Test public void testOverlappingInputAndDelete() { CompactionPlan cp1 = new CompactionPlan(); @@ -44,8 +41,7 @@ public class CompactionPlanTest { Set<StoredTabletFile> allFiles = Set.of(fr1, fr2); - exception.expect(IllegalStateException.class); - cp1.validate(allFiles); + assertThrows(IllegalStateException.class, () -> cp1.validate(allFiles)); } @Test @@ -62,8 +58,7 @@ public class CompactionPlanTest { Set<StoredTabletFile> allFiles = Set.of(fr1, fr2); - exception.expect(IllegalStateException.class); - cp1.validate(allFiles); + assertThrows(IllegalStateException.class, () -> cp1.validate(allFiles)); } @Test @@ -80,8 +75,7 @@ public class CompactionPlanTest { Set<StoredTabletFile> allFiles = Set.of(fr1, fr2); - exception.expect(IllegalStateException.class); - cp1.validate(allFiles); + assertThrows(IllegalStateException.class, () -> cp1.validate(allFiles)); } } diff --git a/server/tserver/src/test/java/org/apache/accumulo/tserver/log/SortedLogRecoveryTest.java b/server/tserver/src/test/java/org/apache/accumulo/tserver/log/SortedLogRecoveryTest.java index b76f50b..ed7e60a 100644 --- a/server/tserver/src/test/java/org/apache/accumulo/tserver/log/SortedLogRecoveryTest.java +++ b/server/tserver/src/test/java/org/apache/accumulo/tserver/log/SortedLogRecoveryTest.java @@ -24,6 +24,7 @@ import static org.apache.accumulo.tserver.logger.LogEvents.DEFINE_TABLET; import static org.apache.accumulo.tserver.logger.LogEvents.MUTATION; import static org.apache.accumulo.tserver.logger.LogEvents.OPEN; import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertThrows; import static org.junit.Assert.assertTrue; import static org.junit.Assert.fail; @@ -57,7 +58,6 @@ import org.apache.hadoop.io.MapFile.Writer; import org.apache.hadoop.io.Text; import org.junit.Rule; import org.junit.Test; -import org.junit.rules.ExpectedException; import org.junit.rules.TemporaryFolder; import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; @@ -74,9 +74,6 @@ public class SortedLogRecoveryTest { public TemporaryFolder tempFolder = new TemporaryFolder(new File(System.getProperty("user.dir") + "/target")); - @Rule - public ExpectedException thrown = ExpectedException.none(); - static class KeyValue implements Comparable<KeyValue> { public final LogFileKey key; public final LogFileValue value; @@ -874,9 +871,8 @@ public class SortedLogRecoveryTest { Map<String,KeyValue[]> logs = new TreeMap<>(); logs.put("entries1", entries1); - thrown.expect(IllegalStateException.class); - thrown.expectMessage("consecutive " + LogEvents.COMPACTION_FINISH.name()); - recover(logs, extent); + var e = assertThrows(IllegalStateException.class, () -> recover(logs, extent)); + assertTrue(e.getMessage().contains("consecutive " + LogEvents.COMPACTION_FINISH.name())); } @Test @@ -996,8 +992,7 @@ public class SortedLogRecoveryTest { Map<String,KeyValue[]> logs = new TreeMap<>(); logs.put("entries1", entries1); - thrown.expect(IllegalStateException.class); - thrown.expectMessage("not " + LogEvents.OPEN); - recover(logs, extent); + var e = assertThrows(IllegalStateException.class, () -> recover(logs, extent)); + assertTrue(e.getMessage().contains("not " + LogEvents.OPEN)); } } diff --git a/start/src/main/java/org/apache/accumulo/start/classloader/vfs/AccumuloReloadingVFSClassLoader.java b/start/src/main/java/org/apache/accumulo/start/classloader/vfs/AccumuloReloadingVFSClassLoader.java index 0b61f2f..9e52bb2 100644 --- a/start/src/main/java/org/apache/accumulo/start/classloader/vfs/AccumuloReloadingVFSClassLoader.java +++ b/start/src/main/java/org/apache/accumulo/start/classloader/vfs/AccumuloReloadingVFSClassLoader.java @@ -265,21 +265,21 @@ public class AccumuloReloadingVFSClassLoader implements FileListener, ReloadingC @Override public void fileCreated(FileChangeEvent event) throws Exception { if (log.isDebugEnabled()) - log.debug("{} created, recreating classloader", event.getFile().getURL()); + log.debug("{} created, recreating classloader", event.getFileObject().getURL()); scheduleRefresh(); } @Override public void fileDeleted(FileChangeEvent event) throws Exception { if (log.isDebugEnabled()) - log.debug("{} deleted, recreating classloader", event.getFile().getURL()); + log.debug("{} deleted, recreating classloader", event.getFileObject().getURL()); scheduleRefresh(); } @Override public void fileChanged(FileChangeEvent event) throws Exception { if (log.isDebugEnabled()) - log.debug("{} changed, recreating classloader", event.getFile().getURL()); + log.debug("{} changed, recreating classloader", event.getFileObject().getURL()); scheduleRefresh(); } diff --git a/start/src/test/java/org/apache/accumulo/start/classloader/vfs/AccumuloReloadingVFSClassLoaderTest.java b/start/src/test/java/org/apache/accumulo/start/classloader/vfs/AccumuloReloadingVFSClassLoaderTest.java index aaa33f7..4c434b5 100644 --- a/start/src/test/java/org/apache/accumulo/start/classloader/vfs/AccumuloReloadingVFSClassLoaderTest.java +++ b/start/src/test/java/org/apache/accumulo/start/classloader/vfs/AccumuloReloadingVFSClassLoaderTest.java @@ -20,8 +20,8 @@ package org.apache.accumulo.start.classloader.vfs; import static org.junit.Assert.assertArrayEquals; import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertNotEquals; +import static org.junit.Assert.assertNotSame; import static org.junit.Assert.assertTrue; import java.io.File; @@ -171,9 +171,13 @@ public class AccumuloReloadingVFSClassLoaderTest { Object o2 = clazz2.getDeclaredConstructor().newInstance(); assertEquals("Hello World!", o2.toString()); - // This is true because they are loaded by the same classloader due to the new retry - assertTrue(clazz1.equals(clazz2)); - assertFalse(o1.equals(o2)); + // This is false because even though it's the same class, it's loaded from a different jar + // this is a change in behavior from previous versions of vfs2 where it would load the same + // class from different jars as though it was from the first jar + assertNotEquals(clazz1, clazz2); + assertNotSame(o1, o2); + assertEquals(clazz1.getName(), clazz2.getName()); + assertEquals(o1.toString(), o2.toString()); arvcl.close(); } diff --git a/test/pom.xml b/test/pom.xml index eff4814..4923204 100644 --- a/test/pom.xml +++ b/test/pom.xml @@ -175,10 +175,6 @@ <artifactId>easymock</artifactId> </dependency> <dependency> - <groupId>org.hamcrest</groupId> - <artifactId>hamcrest</artifactId> - </dependency> - <dependency> <groupId>org.slf4j</groupId> <artifactId>slf4j-api</artifactId> </dependency> diff --git a/test/src/main/java/org/apache/accumulo/test/functional/ClassLoaderIT.java b/test/src/main/java/org/apache/accumulo/test/functional/ClassLoaderIT.java index bac838b..21b5fda 100644 --- a/test/src/main/java/org/apache/accumulo/test/functional/ClassLoaderIT.java +++ b/test/src/main/java/org/apache/accumulo/test/functional/ClassLoaderIT.java @@ -48,7 +48,6 @@ import org.apache.accumulo.test.categories.MiniClusterOnlyTests; import org.apache.hadoop.fs.FSDataOutputStream; import org.apache.hadoop.fs.FileSystem; import org.apache.hadoop.fs.Path; -import org.hamcrest.CoreMatchers; import org.junit.Assume; import org.junit.Before; import org.junit.Test; @@ -68,7 +67,7 @@ public class ClassLoaderIT extends AccumuloClusterHarness { @Before public void checkCluster() { - Assume.assumeThat(getClusterType(), CoreMatchers.is(ClusterType.MINI)); + Assume.assumeTrue(getClusterType() == ClusterType.MINI); MiniAccumuloClusterImpl mac = (MiniAccumuloClusterImpl) getCluster(); rootPath = mac.getConfig().getDir().getAbsolutePath(); } diff --git a/test/src/main/java/org/apache/accumulo/test/functional/ScannerContextIT.java b/test/src/main/java/org/apache/accumulo/test/functional/ScannerContextIT.java index 017f743..fb41529 100644 --- a/test/src/main/java/org/apache/accumulo/test/functional/ScannerContextIT.java +++ b/test/src/main/java/org/apache/accumulo/test/functional/ScannerContextIT.java @@ -45,7 +45,6 @@ import org.apache.accumulo.harness.AccumuloClusterHarness; import org.apache.accumulo.miniclusterImpl.MiniAccumuloClusterImpl; import org.apache.hadoop.fs.FileSystem; import org.apache.hadoop.fs.Path; -import org.hamcrest.CoreMatchers; import org.junit.Assume; import org.junit.Before; import org.junit.Test; @@ -68,7 +67,7 @@ public class ScannerContextIT extends AccumuloClusterHarness { @Before public void checkCluster() throws Exception { - Assume.assumeThat(getClusterType(), CoreMatchers.is(ClusterType.MINI)); + Assume.assumeTrue(getClusterType() == ClusterType.MINI); MiniAccumuloClusterImpl.class.cast(getCluster()); fs = FileSystem.get(cluster.getServerContext().getHadoopConf()); } diff --git a/test/src/main/java/org/apache/accumulo/test/functional/TableIT.java b/test/src/main/java/org/apache/accumulo/test/functional/TableIT.java index 91f9617..3fd0437 100644 --- a/test/src/main/java/org/apache/accumulo/test/functional/TableIT.java +++ b/test/src/main/java/org/apache/accumulo/test/functional/TableIT.java @@ -42,7 +42,6 @@ import org.apache.accumulo.test.VerifyIngest.VerifyParams; import org.apache.accumulo.test.categories.MiniClusterOnlyTests; import org.apache.hadoop.fs.FileSystem; import org.apache.hadoop.fs.Path; -import org.hamcrest.CoreMatchers; import org.junit.Assume; import org.junit.Test; import org.junit.experimental.categories.Category; @@ -59,7 +58,7 @@ public class TableIT extends AccumuloClusterHarness { @Test public void test() throws Exception { - Assume.assumeThat(getClusterType(), CoreMatchers.is(ClusterType.MINI)); + Assume.assumeTrue(getClusterType() == ClusterType.MINI); AccumuloCluster cluster = getCluster(); MiniAccumuloClusterImpl mac = (MiniAccumuloClusterImpl) cluster; diff --git a/test/src/main/java/org/apache/accumulo/test/rpc/ThriftBehaviorIT.java b/test/src/main/java/org/apache/accumulo/test/rpc/ThriftBehaviorIT.java index 9510c48..2515aa5 100644 --- a/test/src/main/java/org/apache/accumulo/test/rpc/ThriftBehaviorIT.java +++ b/test/src/main/java/org/apache/accumulo/test/rpc/ThriftBehaviorIT.java @@ -19,6 +19,8 @@ package org.apache.accumulo.test.rpc; import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertThrows; +import static org.junit.Assert.assertTrue; import static org.junit.Assert.fail; import java.util.concurrent.TimeUnit; @@ -27,13 +29,11 @@ import org.apache.accumulo.test.categories.SunnyDayTests; import org.apache.accumulo.test.rpc.thrift.SimpleThriftService; import org.apache.thrift.TApplicationException; import org.apache.thrift.TException; -import org.hamcrest.core.IsInstanceOf; import org.junit.After; import org.junit.Before; import org.junit.Rule; import org.junit.Test; import org.junit.experimental.categories.Category; -import org.junit.rules.ExpectedException; import org.junit.rules.TestName; import org.junit.rules.Timeout; @@ -46,9 +46,6 @@ public class ThriftBehaviorIT { @Rule public TestName testName = new TestName(); - @Rule - public ExpectedException exception = ExpectedException.none(); - private SimpleThriftService.Client client; private SimpleThriftServiceHandler handler; private SimpleThriftServiceRunner serviceRunner; @@ -85,9 +82,8 @@ public class ThriftBehaviorIT { @Test public void echoFailHandler() throws TException { - exception.expect(TException.class); - exception.expectCause(IsInstanceOf.instanceOf(UnsupportedOperationException.class)); - handler.echoFail(KITTY_MSG); + var e = assertThrows(TException.class, () -> handler.echoFail(KITTY_MSG)); + assertTrue(e.getCause() instanceof UnsupportedOperationException); } @Test @@ -104,8 +100,7 @@ public class ThriftBehaviorIT { @Test public void echoRuntimeFailHandler() { - exception.expect(UnsupportedOperationException.class); - handler.echoRuntimeFail(KITTY_MSG); + assertThrows(UnsupportedOperationException.class, () -> handler.echoRuntimeFail(KITTY_MSG)); } @Test @@ -132,9 +127,8 @@ public class ThriftBehaviorIT { @Test public void onewayFailHandler() throws TException { - exception.expect(TException.class); - exception.expectCause(IsInstanceOf.instanceOf(UnsupportedOperationException.class)); - handler.onewayFail(KITTY_MSG); + var e = assertThrows(TException.class, () -> handler.onewayFail(KITTY_MSG)); + assertTrue(e.getCause() instanceof UnsupportedOperationException); } @Test @@ -146,8 +140,7 @@ public class ThriftBehaviorIT { @Test public void onewayRuntimeFailHandler() { - exception.expect(UnsupportedOperationException.class); - handler.onewayRuntimeFail(KITTY_MSG); + assertThrows(UnsupportedOperationException.class, () -> handler.onewayRuntimeFail(KITTY_MSG)); } @Test