Skip to content

Commit

Permalink
ARTEMIS-4353 clean up Maven dependencies
Browse files Browse the repository at this point in the history
This commit contains the following changes:
 - eliminate used, undeclared dependencies
 - eliminate unused, declared dependencies
 - fix scope for test dependencies
 - eliminate org.hamcrest completely as its use involved deprecated code
   as well as dependencies from multiple versions
  • Loading branch information
jbertram authored and gemmellr committed Jul 14, 2023
1 parent 68e400b commit cce565e
Show file tree
Hide file tree
Showing 50 changed files with 748 additions and 574 deletions.
8 changes: 0 additions & 8 deletions artemis-boot/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,4 @@
<activemq.basedir>${project.basedir}/..</activemq.basedir>
</properties>

<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<scope>test</scope>
</dependency>
</dependencies>

</project>
10 changes: 8 additions & 2 deletions artemis-cdi-client/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@
</dependency>
<dependency>
<groupId>org.apache.activemq</groupId>
<artifactId>artemis-jms-server</artifactId>
<artifactId>artemis-commons</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
Expand Down Expand Up @@ -99,16 +99,22 @@
<groupId>org.jboss.shrinkwrap</groupId>
<artifactId>shrinkwrap-api</artifactId>
<version>1.2.6</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.jboss.arquillian.junit</groupId>
<artifactId>arquillian-junit-container</artifactId>
</dependency>
<dependency>
<groupId>org.jboss.arquillian.container</groupId>
<artifactId>arquillian-container-test-api</artifactId>
<version>${arquillian.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.activemq</groupId>
<artifactId>artemis-unit-test-support</artifactId>
<version>${project.version}</version>
<scope>test</scope>
</dependency>

<!-- The johnzon-core and json-api contents are repackaged in -commons,
Expand Down
27 changes: 26 additions & 1 deletion artemis-cli/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,10 @@
</properties>

<dependencies>
<dependency>
<groupId>jakarta.jms</groupId>
<artifactId>jakarta.jms-api</artifactId>
</dependency>
<dependency>
<groupId>org.apache.activemq</groupId>
<artifactId>artemis-jms-client</artifactId>
Expand All @@ -58,6 +62,11 @@
<artifactId>activemq-artemis-native</artifactId>
<version>${activemq-artemis-native-version}</version>
</dependency>
<dependency>
<groupId>org.apache.activemq</groupId>
<artifactId>artemis-quorum-api</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.apache.activemq</groupId>
<artifactId>artemis-server</artifactId>
Expand Down Expand Up @@ -98,6 +107,23 @@
<artifactId>log4j-slf4j-impl</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>io.netty</groupId>
<artifactId>netty-common</artifactId>
</dependency>
<dependency>
<groupId>io.netty</groupId>
<artifactId>netty-buffer</artifactId>
</dependency>
<dependency>
<groupId>io.netty</groupId>
<artifactId>netty-transport</artifactId>
</dependency>
<dependency>
<groupId>jakarta.xml.bind</groupId>
<artifactId>jakarta.xml.bind-api</artifactId>
<version>${jakarta.xml.bind-api.version}</version>
</dependency>

<dependency>
<groupId>com.github.rvesse</groupId>
Expand Down Expand Up @@ -179,7 +205,6 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<version>2.2</version>
<executions>
<execution>
<id>unpack</id>
Expand Down
12 changes: 1 addition & 11 deletions artemis-commons/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -77,11 +77,7 @@
</dependency>
<dependency>
<groupId>io.netty</groupId>
<artifactId>netty-transport</artifactId>
</dependency>
<dependency>
<groupId>io.netty</groupId>
<artifactId>netty-handler</artifactId>
<artifactId>netty-common</artifactId>
</dependency>
<dependency>
<groupId>commons-beanutils</groupId>
Expand All @@ -92,12 +88,6 @@
<artifactId>junit</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.hamcrest</groupId>
<artifactId>hamcrest</artifactId>
<version>${hamcrest.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.activemq</groupId>
<artifactId>artemis-unit-test-support</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,7 @@
*/
package org.apache.activemq.artemis.utils;

import static org.hamcrest.CoreMatchers.is;
import static org.junit.Assert.assertThat;

import org.junit.Assert;
import org.junit.Test;

import static org.apache.activemq.artemis.utils.PowerOf2Util.align;
Expand All @@ -28,17 +26,17 @@ public class PowerOf2UtilTest {
@Test
public void shouldAlignToNextMultipleOfAlignment() {
final int alignment = 512;
assertThat(align(0, alignment), is(0));
assertThat(align(1, alignment), is(alignment));
assertThat(align(alignment, alignment), is(alignment));
assertThat(align(alignment + 1, alignment), is(alignment * 2));
Assert.assertEquals(0, align(0, alignment));
Assert.assertEquals(alignment, align(1, alignment));
Assert.assertEquals(alignment, align(alignment, alignment));
Assert.assertEquals(alignment * 2, align(alignment + 1, alignment));

final int remainder = Integer.MAX_VALUE % alignment;
final int alignedMax = Integer.MAX_VALUE - remainder;
assertThat(align(alignedMax, alignment), is(alignedMax));
Assert.assertEquals(alignedMax, align(alignedMax, alignment));
//given that Integer.MAX_VALUE is the max value that can be represented with int
//the aligned value would be > 2^32, but (int)(2^32) = Integer.MIN_VALUE due to the sign bit
assertThat(align(Integer.MAX_VALUE, alignment), is(Integer.MIN_VALUE));
Assert.assertEquals(Integer.MIN_VALUE, align(Integer.MAX_VALUE, alignment));
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.concurrent.atomic.AtomicLong;

import io.netty.buffer.ByteBuf;
import io.netty.buffer.Unpooled;
import org.apache.activemq.artemis.api.core.ActiveMQBuffer;
import org.apache.activemq.artemis.api.core.ActiveMQBuffers;
import org.apache.activemq.artemis.api.core.SimpleString;
Expand All @@ -28,11 +30,7 @@
import org.junit.Before;
import org.junit.Test;

import io.netty.buffer.ByteBuf;
import io.netty.buffer.Unpooled;

import static org.apache.activemq.artemis.utils.collections.TypedProperties.searchProperty;
import static org.hamcrest.Matchers.greaterThan;

public class TypedPropertiesTest {

Expand Down Expand Up @@ -95,7 +93,7 @@ public void testClear() throws Exception {
Assert.assertTrue(props.containsProperty(key));
Assert.assertNotNull(props.getProperty(key));

Assert.assertThat(props.getEncodeSize(), greaterThan(0));
Assert.assertTrue("encodeSize <= " + 0, props.getEncodeSize() > 0);

props.clear();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
*/
package org.apache.activemq.artemis.utils.collections;

import java.util.Arrays;
import java.util.Collection;
import java.util.HashSet;
import java.util.Iterator;
Expand All @@ -26,14 +27,6 @@
import org.junit.Assert;
import org.junit.Test;

import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.arrayContainingInAnyOrder;
import static org.hamcrest.Matchers.contains;
import static org.hamcrest.Matchers.containsInAnyOrder;
import static org.hamcrest.Matchers.hasSize;
import static org.hamcrest.Matchers.is;
import static org.hamcrest.core.IsEqual.equalTo;

/**
* These tests are based on <a href="https://github.com/real-logic/agrona/blob/master/agrona/src/test/java/org/agrona/collections/IntHashSetTest.java">Agrona IntHashSetTest</a>
* to guarantee a similar coverage to what's provided for a similar collection.
Expand Down Expand Up @@ -297,8 +290,9 @@ public void chainCompactionShouldNotCauseElementsToBeMovedBeforeTheirHash() {

Assert.assertTrue("Failed to remove 8", requiredFields.remove(8L));
Assert.assertTrue("Failed to remove 9", requiredFields.remove(9L));

assertThat(requiredFields, containsInAnyOrder(35L, 49L, 56L));
Assert.assertTrue("requiredFields does not contain " + 35, requiredFields.contains(35L));
Assert.assertTrue("requiredFields does not contain " + 49, requiredFields.contains(49L));
Assert.assertTrue("requiredFields does not contain " + 56, requiredFields.contains(56L));
}

@Test
Expand Down Expand Up @@ -543,8 +537,8 @@ public void removeElementsFromIterator() {
}
}

assertThat(testSet, contains(1001L));
assertThat(testSet, hasSize(1));
Assert.assertTrue("testSet does not contain 1001", testSet.contains(1001L));
Assert.assertEquals(1, testSet.size());
}

@Test
Expand Down Expand Up @@ -588,7 +582,9 @@ public void toArrayCopiesElementsIntoNewArrayIncludingMissingValue() {

final Long[] result = testSet.toArray(new Long[testSet.size()]);

assertThat(result, arrayContainingInAnyOrder(1L, 1001L, LongHashSet.MISSING_VALUE));
Assert.assertTrue(Arrays.asList(result).contains(1L));
Assert.assertTrue(Arrays.asList(result).contains(1001L));
Assert.assertTrue(Arrays.asList(result).contains(LongHashSet.MISSING_VALUE));
}

@Test
Expand All @@ -599,7 +595,9 @@ public void toObjectArrayCopiesElementsIntoNewArrayIncludingMissingValue() {

final Object[] result = testSet.toArray();

assertThat(result, arrayContainingInAnyOrder(1L, 1001L, LongHashSet.MISSING_VALUE));
Assert.assertTrue(Arrays.asList(result).contains(1L));
Assert.assertTrue(Arrays.asList(result).contains(1001L));
Assert.assertTrue(Arrays.asList(result).contains(LongHashSet.MISSING_VALUE));
}

@Test
Expand All @@ -626,14 +624,14 @@ public void consecutiveValuesShouldBeCorrectlyStored() {
testSet.add(i);
}

assertThat(testSet, hasSize(10_000));
Assert.assertEquals(10_000, testSet.size());

int distinctElements = 0;
for (final long ignore : testSet) {
distinctElements++;
}

assertThat(distinctElements, is(10_000));
Assert.assertEquals(10_000, distinctElements);
}

@Test
Expand Down Expand Up @@ -694,7 +692,7 @@ public void shouldGenerateStringRepresentation() {
}

final String mapAsAString = "{1, 19, 11, 7, 3, 12, -2}";
assertThat(testSet.toString(), equalTo(mapAsAString));
Assert.assertEquals(testSet.toString(), mapAsAString);
}

@Test
Expand Down Expand Up @@ -763,11 +761,13 @@ private void assertIteratorHasElementsWithoutHasNext() {
}

private static void assertArrayContainingElements(final Long[] result) {
assertThat(result, arrayContainingInAnyOrder(1L, 1001L));
Assert.assertTrue(Arrays.asList(result).contains(1L));
Assert.assertTrue(Arrays.asList(result).contains(1001L));
}

private static void assertContainsElements(final Set<Long> other) {
assertThat(other, containsInAnyOrder(1L, 1001L));
Assert.assertTrue(other.contains(1L));
Assert.assertTrue(other.contains(1001L));
}

private void exhaustIterator() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,6 @@
import org.junit.Assert;
import org.junit.Test;

import static org.hamcrest.core.Is.is;

public class SparseArrayLinkedListTest {

private static final int SPARSE_ARRAY_CAPACITY = 4;
Expand Down Expand Up @@ -74,7 +72,7 @@ public void shouldClearConsumeElementsInOrder() {
Assert.assertEquals(elements, list.clear(removed::add));
Assert.assertEquals(1, list.sparseArraysCount());
Assert.assertEquals(0, list.size());
Assert.assertThat(removed, is(expected));
Assert.assertEquals(expected, removed);
}

@Test
Expand Down
18 changes: 12 additions & 6 deletions artemis-core-client/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -70,22 +70,24 @@
<artifactId>junit</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.hamcrest</groupId>
<artifactId>hamcrest</artifactId>
<version>${hamcrest.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>io.netty</groupId>
<artifactId>netty-transport-native-epoll</artifactId>
<classifier>${netty-transport-native-epoll-classifier}</classifier>
</dependency>
<dependency>
<groupId>io.netty</groupId>
<artifactId>netty-transport-classes-epoll</artifactId>
</dependency>
<dependency>
<groupId>io.netty</groupId>
<artifactId>netty-transport-native-kqueue</artifactId>
<classifier>${netty-transport-native-kqueue-classifier}</classifier>
</dependency>
<dependency>
<groupId>io.netty</groupId>
<artifactId>netty-transport-classes-kqueue</artifactId>
</dependency>
<dependency>
<groupId>io.netty</groupId>
<artifactId>netty-codec-http</artifactId>
Expand Down Expand Up @@ -118,6 +120,10 @@
<groupId>io.netty</groupId>
<artifactId>netty-common</artifactId>
</dependency>
<dependency>
<groupId>io.netty</groupId>
<artifactId>netty-resolver</artifactId>
</dependency>

<!-- The johnzon-core and json-api contents are repackaged in -commons,
However maven can still need them during tests, which run against
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,6 @@
import org.junit.Assert;
import org.junit.Test;

import static org.hamcrest.CoreMatchers.containsString;
import static org.hamcrest.CoreMatchers.not;
import static org.hamcrest.MatcherAssert.assertThat;

public class TransportConfigurationTest {

@Test
Expand Down Expand Up @@ -95,7 +91,7 @@ public void testToStringObfuscatesPasswords() {

TransportConfiguration configuration = new TransportConfiguration("SomeClass", params, null);

assertThat(configuration.toString(), not(containsString("secret_password")));
Assert.assertFalse("configuration contains secret_password", configuration.toString().contains("secret_password"));
}

@Test
Expand Down

0 comments on commit cce565e

Please sign in to comment.