Update hamcrest to 2.2, Junit to 4.13, mockito to 2.28.2

This commit is contained in:
Artem Krosheninnikov
2020-05-04 23:00:28 +03:00
parent 4d2749b697
commit 3fba3f6217
34 changed files with 189 additions and 62 deletions

View File

@ -64,7 +64,11 @@
<artifactId>saxon</artifactId> <artifactId>saxon</artifactId>
</dependency> </dependency>
<dependency>
<groupId>org.hamcrest</groupId>
<artifactId>hamcrest</artifactId>
<scope>test</scope>
</dependency>
<dependency> <dependency>
<groupId>junit</groupId> <groupId>junit</groupId>
<artifactId>junit</artifactId> <artifactId>junit</artifactId>

View File

@ -4,9 +4,9 @@
package net.sourceforge.pmd.lang.apex.ast; package net.sourceforge.pmd.lang.apex.ast;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.core.IsInstanceOf.instanceOf; import static org.hamcrest.core.IsInstanceOf.instanceOf;
import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertThat;
import static org.junit.Assert.assertTrue; import static org.junit.Assert.assertTrue;
import java.io.File; import java.io.File;

View File

@ -157,13 +157,13 @@
<scope>test</scope> <scope>test</scope>
</dependency> </dependency>
<dependency> <dependency>
<groupId>junit</groupId> <groupId>org.hamcrest</groupId>
<artifactId>junit</artifactId> <artifactId>hamcrest-library</artifactId>
<scope>test</scope> <scope>test</scope>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.hamcrest</groupId> <groupId>junit</groupId>
<artifactId>hamcrest-library</artifactId> <artifactId>junit</artifactId>
<scope>test</scope> <scope>test</scope>
</dependency> </dependency>
<dependency> <dependency>
@ -178,7 +178,7 @@
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.mockito</groupId> <groupId>org.mockito</groupId>
<artifactId>mockito-all</artifactId> <artifactId>mockito-core</artifactId>
<scope>test</scope> <scope>test</scope>
</dependency> </dependency>
<dependency> <dependency>

View File

@ -5,10 +5,10 @@
package net.sourceforge.pmd.properties; package net.sourceforge.pmd.properties;
import static net.sourceforge.pmd.properties.constraints.NumericConstraints.inRange; import static net.sourceforge.pmd.properties.constraints.NumericConstraints.inRange;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.allOf; import static org.hamcrest.Matchers.allOf;
import static org.hamcrest.Matchers.hasItem; import static org.hamcrest.Matchers.hasItem;
import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertThat;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
@ -334,18 +334,12 @@ public class PropertyDescriptorTest {
} }
private static Matcher<String> containsIgnoreCase(final String substring) { private static Matcher<String> containsIgnoreCase(final String substring) {
return new SubstringMatcher(substring) { return new SubstringMatcher("containing (ignoring case)", true, substring) {
@Override @Override
protected boolean evalSubstringOf(String string) { protected boolean evalSubstringOf(String string) {
return StringUtils.indexOfIgnoreCase(string, substring) != -1; return StringUtils.indexOfIgnoreCase(string, substring) != -1;
} }
@Override
protected String relationship() {
return "containing (ignoring case)";
}
}; };
} }

View File

@ -11,6 +11,7 @@ import java.util.Iterator;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import org.hamcrest.MatcherAssert;
import org.hamcrest.Matchers; import org.hamcrest.Matchers;
import org.junit.Assert; import org.junit.Assert;
import org.junit.Rule; import org.junit.Rule;
@ -43,7 +44,7 @@ public class TreeRenderersTest {
PropertySource properties = TreeRenderers.XML.newPropertyBundle(); PropertySource properties = TreeRenderers.XML.newPropertyBundle();
Assert.assertThat(properties.getPropertyDescriptors(), MatcherAssert.assertThat(properties.getPropertyDescriptors(),
Matchers.<PropertyDescriptor<?>>containsInAnyOrder(TreeRenderers.XML_LINE_SEPARATOR, Matchers.<PropertyDescriptor<?>>containsInAnyOrder(TreeRenderers.XML_LINE_SEPARATOR,
TreeRenderers.XML_RENDER_COMMON_ATTRIBUTES, TreeRenderers.XML_RENDER_COMMON_ATTRIBUTES,
TreeRenderers.XML_RENDER_PROLOG, TreeRenderers.XML_RENDER_PROLOG,

View File

@ -73,7 +73,11 @@
<groupId>commons-io</groupId> <groupId>commons-io</groupId>
<artifactId>commons-io</artifactId> <artifactId>commons-io</artifactId>
</dependency> </dependency>
<dependency>
<groupId>org.hamcrest</groupId>
<artifactId>hamcrest</artifactId>
<scope>test</scope>
</dependency>
<dependency> <dependency>
<groupId>junit</groupId> <groupId>junit</groupId>
<artifactId>junit</artifactId> <artifactId>junit</artifactId>

View File

@ -38,7 +38,11 @@
<groupId>commons-io</groupId> <groupId>commons-io</groupId>
<artifactId>commons-io</artifactId> <artifactId>commons-io</artifactId>
</dependency> </dependency>
<dependency>
<groupId>org.hamcrest</groupId>
<artifactId>hamcrest</artifactId>
<scope>test</scope>
</dependency>
<dependency> <dependency>
<groupId>junit</groupId> <groupId>junit</groupId>
<artifactId>junit</artifactId> <artifactId>junit</artifactId>

View File

@ -42,7 +42,11 @@
<groupId>commons-io</groupId> <groupId>commons-io</groupId>
<artifactId>commons-io</artifactId> <artifactId>commons-io</artifactId>
</dependency> </dependency>
<dependency>
<groupId>org.hamcrest</groupId>
<artifactId>hamcrest</artifactId>
<scope>test</scope>
</dependency>
<dependency> <dependency>
<groupId>junit</groupId> <groupId>junit</groupId>
<artifactId>junit</artifactId> <artifactId>junit</artifactId>

View File

@ -228,7 +228,11 @@
<groupId>org.apache.commons</groupId> <groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId> <artifactId>commons-lang3</artifactId>
</dependency> </dependency>
<dependency>
<groupId>org.hamcrest</groupId>
<artifactId>hamcrest</artifactId>
<scope>test</scope>
</dependency>
<dependency> <dependency>
<groupId>junit</groupId> <groupId>junit</groupId>
<artifactId>junit</artifactId> <artifactId>junit</artifactId>

View File

@ -101,7 +101,11 @@
<artifactId>snakeyaml</artifactId> <artifactId>snakeyaml</artifactId>
<version>1.19</version> <version>1.19</version>
</dependency> </dependency>
<dependency>
<groupId>org.hamcrest</groupId>
<artifactId>hamcrest</artifactId>
<scope>test</scope>
</dependency>
<dependency> <dependency>
<groupId>junit</groupId> <groupId>junit</groupId>
<artifactId>junit</artifactId> <artifactId>junit</artifactId>

View File

@ -32,7 +32,11 @@
<groupId>commons-io</groupId> <groupId>commons-io</groupId>
<artifactId>commons-io</artifactId> <artifactId>commons-io</artifactId>
</dependency> </dependency>
<dependency>
<groupId>org.hamcrest</groupId>
<artifactId>hamcrest</artifactId>
<scope>test</scope>
</dependency>
<dependency> <dependency>
<groupId>junit</groupId> <groupId>junit</groupId>
<artifactId>junit</artifactId> <artifactId>junit</artifactId>

View File

@ -38,7 +38,11 @@
<groupId>net.sourceforge.pmd</groupId> <groupId>net.sourceforge.pmd</groupId>
<artifactId>pmd-core</artifactId> <artifactId>pmd-core</artifactId>
</dependency> </dependency>
<dependency>
<groupId>org.hamcrest</groupId>
<artifactId>hamcrest</artifactId>
<scope>test</scope>
</dependency>
<dependency> <dependency>
<groupId>junit</groupId> <groupId>junit</groupId>
<artifactId>junit</artifactId> <artifactId>junit</artifactId>

View File

@ -166,6 +166,11 @@
<version>2.12.1</version> <version>2.12.1</version>
<scope>test</scope> <scope>test</scope>
</dependency> </dependency>
<dependency>
<groupId>org.hamcrest</groupId>
<artifactId>hamcrest</artifactId>
<scope>test</scope>
</dependency>
<dependency> <dependency>
<groupId>junit</groupId> <groupId>junit</groupId>
<artifactId>junit</artifactId> <artifactId>junit</artifactId>

View File

@ -5,11 +5,11 @@
package net.sourceforge.pmd.lang.java.ast; package net.sourceforge.pmd.lang.java.ast;
import static org.hamcrest.CoreMatchers.instanceOf; import static org.hamcrest.Matchers.instanceOf;
import static org.junit.Assert.assertThat;
import java.util.List; import java.util.List;
import org.hamcrest.MatcherAssert;
import org.junit.Assert; import org.junit.Assert;
import org.junit.Test; import org.junit.Test;
@ -109,29 +109,29 @@ public class Java14Test {
Assert.assertEquals(18, stmts.size()); Assert.assertEquals(18, stmts.size());
int i = 0; int i = 0;
assertThat(stmts.get(i++), instanceOf(ASTLocalVariableDeclaration.class)); MatcherAssert.assertThat(stmts.get(i++), instanceOf(ASTLocalVariableDeclaration.class));
assertThat(stmts.get(i++), instanceOf(ASTStatementExpression.class)); MatcherAssert.assertThat(stmts.get(i++), instanceOf(ASTStatementExpression.class));
assertThat(stmts.get(i++), instanceOf(ASTStatementExpression.class)); MatcherAssert.assertThat(stmts.get(i++), instanceOf(ASTStatementExpression.class));
assertThat(stmts.get(i++), instanceOf(ASTStatementExpression.class)); MatcherAssert.assertThat(stmts.get(i++), instanceOf(ASTStatementExpression.class));
assertThat(stmts.get(i++), instanceOf(ASTStatementExpression.class)); MatcherAssert.assertThat(stmts.get(i++), instanceOf(ASTStatementExpression.class));
assertThat(stmts.get(i++), instanceOf(ASTStatementExpression.class)); MatcherAssert.assertThat(stmts.get(i++), instanceOf(ASTStatementExpression.class));
assertThat(stmts.get(i++), instanceOf(ASTStatementExpression.class)); MatcherAssert.assertThat(stmts.get(i++), instanceOf(ASTStatementExpression.class));
assertThat(stmts.get(i++), instanceOf(ASTYieldStatement.class)); MatcherAssert.assertThat(stmts.get(i++), instanceOf(ASTYieldStatement.class));
assertThat(stmts.get(i++), instanceOf(ASTYieldStatement.class)); MatcherAssert.assertThat(stmts.get(i++), instanceOf(ASTYieldStatement.class));
assertThat(stmts.get(i++), instanceOf(ASTYieldStatement.class)); MatcherAssert.assertThat(stmts.get(i++), instanceOf(ASTYieldStatement.class));
assertThat(stmts.get(i++), instanceOf(ASTStatementExpression.class)); MatcherAssert.assertThat(stmts.get(i++), instanceOf(ASTStatementExpression.class));
assertThat(stmts.get(i++), instanceOf(ASTStatementExpression.class)); MatcherAssert.assertThat(stmts.get(i++), instanceOf(ASTStatementExpression.class));
assertThat(stmts.get(i++), instanceOf(ASTIfStatement.class)); MatcherAssert.assertThat(stmts.get(i++), instanceOf(ASTIfStatement.class));
assertThat(stmts.get(i++), instanceOf(ASTStatementExpression.class)); MatcherAssert.assertThat(stmts.get(i++), instanceOf(ASTStatementExpression.class));
assertThat(stmts.get(i++), instanceOf(ASTYieldStatement.class)); MatcherAssert.assertThat(stmts.get(i++), instanceOf(ASTYieldStatement.class));
assertThat(stmts.get(i++), instanceOf(ASTYieldStatement.class)); MatcherAssert.assertThat(stmts.get(i++), instanceOf(ASTYieldStatement.class));
assertThat(stmts.get(i++), instanceOf(ASTStatementExpression.class)); MatcherAssert.assertThat(stmts.get(i++), instanceOf(ASTStatementExpression.class));
assertThat(stmts.get(i++), instanceOf(ASTYieldStatement.class)); MatcherAssert.assertThat(stmts.get(i++), instanceOf(ASTYieldStatement.class));
Assert.assertEquals(i, stmts.size()); Assert.assertEquals(i, stmts.size());
} }

View File

@ -55,7 +55,11 @@
<groupId>net.sourceforge.pmd</groupId> <groupId>net.sourceforge.pmd</groupId>
<artifactId>pmd-core</artifactId> <artifactId>pmd-core</artifactId>
</dependency> </dependency>
<dependency>
<groupId>org.hamcrest</groupId>
<artifactId>hamcrest</artifactId>
<scope>test</scope>
</dependency>
<dependency> <dependency>
<groupId>junit</groupId> <groupId>junit</groupId>
<artifactId>junit</artifactId> <artifactId>junit</artifactId>

View File

@ -86,7 +86,11 @@
<groupId>net.sourceforge.saxon</groupId> <groupId>net.sourceforge.saxon</groupId>
<artifactId>saxon</artifactId> <artifactId>saxon</artifactId>
</dependency> </dependency>
<dependency>
<groupId>org.hamcrest</groupId>
<artifactId>hamcrest</artifactId>
<scope>test</scope>
</dependency>
<dependency> <dependency>
<groupId>junit</groupId> <groupId>junit</groupId>
<artifactId>junit</artifactId> <artifactId>junit</artifactId>

View File

@ -87,7 +87,11 @@
<groupId>net.sourceforge.saxon</groupId> <groupId>net.sourceforge.saxon</groupId>
<artifactId>saxon</artifactId> <artifactId>saxon</artifactId>
</dependency> </dependency>
<dependency>
<groupId>org.hamcrest</groupId>
<artifactId>hamcrest</artifactId>
<scope>test</scope>
</dependency>
<dependency> <dependency>
<groupId>junit</groupId> <groupId>junit</groupId>
<artifactId>junit</artifactId> <artifactId>junit</artifactId>

View File

@ -42,7 +42,11 @@
<groupId>commons-io</groupId> <groupId>commons-io</groupId>
<artifactId>commons-io</artifactId> <artifactId>commons-io</artifactId>
</dependency> </dependency>
<dependency>
<groupId>org.hamcrest</groupId>
<artifactId>hamcrest</artifactId>
<scope>test</scope>
</dependency>
<dependency> <dependency>
<groupId>junit</groupId> <groupId>junit</groupId>
<artifactId>junit</artifactId> <artifactId>junit</artifactId>

View File

@ -93,6 +93,11 @@
so that they are automatically available to users so that they are automatically available to users
of the pmd-lang-test module of the pmd-lang-test module
--> -->
<dependency>
<groupId>org.hamcrest</groupId>
<artifactId>hamcrest</artifactId>
<scope>test</scope>
</dependency>
<dependency> <dependency>
<groupId>junit</groupId> <groupId>junit</groupId>
<artifactId>junit</artifactId> <artifactId>junit</artifactId>

View File

@ -42,7 +42,11 @@
<groupId>commons-io</groupId> <groupId>commons-io</groupId>
<artifactId>commons-io</artifactId> <artifactId>commons-io</artifactId>
</dependency> </dependency>
<dependency>
<groupId>org.hamcrest</groupId>
<artifactId>hamcrest</artifactId>
<scope>test</scope>
</dependency>
<dependency> <dependency>
<groupId>junit</groupId> <groupId>junit</groupId>
<artifactId>junit</artifactId> <artifactId>junit</artifactId>

View File

@ -73,7 +73,11 @@
<groupId>commons-io</groupId> <groupId>commons-io</groupId>
<artifactId>commons-io</artifactId> <artifactId>commons-io</artifactId>
</dependency> </dependency>
<dependency>
<groupId>org.hamcrest</groupId>
<artifactId>hamcrest</artifactId>
<scope>test</scope>
</dependency>
<dependency> <dependency>
<groupId>junit</groupId> <groupId>junit</groupId>
<artifactId>junit</artifactId> <artifactId>junit</artifactId>

View File

@ -74,6 +74,11 @@
<artifactId>commons-io</artifactId> <artifactId>commons-io</artifactId>
</dependency> </dependency>
<dependency>
<groupId>org.hamcrest</groupId>
<artifactId>hamcrest</artifactId>
<scope>test</scope>
</dependency>
<dependency> <dependency>
<groupId>junit</groupId> <groupId>junit</groupId>
<artifactId>junit</artifactId> <artifactId>junit</artifactId>

View File

@ -29,6 +29,11 @@
<artifactId>pmd-core</artifactId> <artifactId>pmd-core</artifactId>
</dependency> </dependency>
<dependency>
<groupId>org.hamcrest</groupId>
<artifactId>hamcrest</artifactId>
<scope>test</scope>
</dependency>
<dependency> <dependency>
<groupId>junit</groupId> <groupId>junit</groupId>
<artifactId>junit</artifactId> <artifactId>junit</artifactId>

View File

@ -96,6 +96,11 @@
<artifactId>saxon</artifactId> <artifactId>saxon</artifactId>
</dependency> </dependency>
<dependency>
<groupId>org.hamcrest</groupId>
<artifactId>hamcrest</artifactId>
<scope>test</scope>
</dependency>
<dependency> <dependency>
<groupId>junit</groupId> <groupId>junit</groupId>
<artifactId>junit</artifactId> <artifactId>junit</artifactId>

View File

@ -74,6 +74,11 @@
<artifactId>commons-io</artifactId> <artifactId>commons-io</artifactId>
</dependency> </dependency>
<dependency>
<groupId>org.hamcrest</groupId>
<artifactId>hamcrest</artifactId>
<scope>test</scope>
</dependency>
<dependency> <dependency>
<groupId>junit</groupId> <groupId>junit</groupId>
<artifactId>junit</artifactId> <artifactId>junit</artifactId>

View File

@ -20,6 +20,11 @@
<artifactId>commons-io</artifactId> <artifactId>commons-io</artifactId>
</dependency> </dependency>
<dependency>
<groupId>org.hamcrest</groupId>
<artifactId>hamcrest</artifactId>
<scope>test</scope>
</dependency>
<dependency> <dependency>
<groupId>junit</groupId> <groupId>junit</groupId>
<artifactId>junit</artifactId> <artifactId>junit</artifactId>

View File

@ -45,6 +45,11 @@
<artifactId>pmd-core</artifactId> <artifactId>pmd-core</artifactId>
</dependency> </dependency>
<dependency>
<groupId>org.hamcrest</groupId>
<artifactId>hamcrest</artifactId>
<scope>test</scope>
</dependency>
<dependency> <dependency>
<groupId>junit</groupId> <groupId>junit</groupId>
<artifactId>junit</artifactId> <artifactId>junit</artifactId>

View File

@ -43,6 +43,11 @@
<artifactId>commons-io</artifactId> <artifactId>commons-io</artifactId>
</dependency> </dependency>
<dependency>
<groupId>org.hamcrest</groupId>
<artifactId>hamcrest</artifactId>
<scope>test</scope>
</dependency>
<dependency> <dependency>
<groupId>junit</groupId> <groupId>junit</groupId>
<artifactId>junit</artifactId> <artifactId>junit</artifactId>

View File

@ -12,6 +12,11 @@
</parent> </parent>
<dependencies> <dependencies>
<dependency>
<groupId>org.hamcrest</groupId>
<artifactId>hamcrest</artifactId>
<scope>compile</scope>
</dependency>
<dependency> <dependency>
<groupId>junit</groupId> <groupId>junit</groupId>
<artifactId>junit</artifactId> <artifactId>junit</artifactId>
@ -38,7 +43,6 @@
<dependency> <dependency>
<groupId>org.mockito</groupId> <groupId>org.mockito</groupId>
<artifactId>mockito-core</artifactId> <artifactId>mockito-core</artifactId>
<version>1.10.19</version>
<scope>test</scope> <scope>test</scope>
</dependency> </dependency>
</dependencies> </dependencies>

View File

@ -4,8 +4,7 @@
package net.sourceforge.pmd.testframework; package net.sourceforge.pmd.testframework;
import static org.mockito.Matchers.any; import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Matchers.anyList;
import static org.mockito.Mockito.mock; import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.times; import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify; import static org.mockito.Mockito.verify;
@ -16,6 +15,7 @@ import java.util.Arrays;
import org.junit.Assert; import org.junit.Assert;
import org.junit.Test; import org.junit.Test;
import org.mockito.ArgumentMatchers;
import org.mockito.Mockito; import org.mockito.Mockito;
import org.mockito.invocation.InvocationOnMock; import org.mockito.invocation.InvocationOnMock;
import org.mockito.stubbing.Answer; import org.mockito.stubbing.Answer;
@ -55,7 +55,7 @@ public class RuleTstTest {
verify(rule, times(2)).isRuleChain(); verify(rule, times(2)).isRuleChain();
verify(rule).getMinimumLanguageVersion(); verify(rule).getMinimumLanguageVersion();
verify(rule).getMaximumLanguageVersion(); verify(rule).getMaximumLanguageVersion();
verify(rule).apply(anyList(), any(RuleContext.class)); verify(rule).apply(ArgumentMatchers.<Node>anyList(), any(RuleContext.class));
verify(rule, times(4)).getName(); verify(rule, times(4)).getName();
verify(rule).getPropertiesByPropertyDescriptor(); verify(rule).getPropertiesByPropertyDescriptor();
verifyNoMoreInteractions(rule); verifyNoMoreInteractions(rule);
@ -76,13 +76,13 @@ public class RuleTstTest {
@Override @Override
public Void answer(InvocationOnMock invocation) throws Throwable { public Void answer(InvocationOnMock invocation) throws Throwable {
RuleContext context = invocation.getArgumentAt(1, RuleContext.class); RuleContext context = invocation.getArgument(1, RuleContext.class);
// the violations are reported out of order // the violations are reported out of order
context.getReport().addRuleViolation(createViolation(context, 15, "first reported violation")); context.getReport().addRuleViolation(createViolation(context, 15, "first reported violation"));
context.getReport().addRuleViolation(createViolation(context, 5, "second reported violation")); context.getReport().addRuleViolation(createViolation(context, 5, "second reported violation"));
return null; return null;
} }
}).when(rule).apply(Mockito.anyList(), Mockito.any(RuleContext.class)); }).when(rule).apply(ArgumentMatchers.<Node>anyList(), Mockito.any(RuleContext.class));
TestDescriptor testDescriptor = new TestDescriptor("the code", "sample test", 2, rule, dummyLanguage); TestDescriptor testDescriptor = new TestDescriptor("the code", "sample test", 2, rule, dummyLanguage);
testDescriptor.setReinitializeRule(false); testDescriptor.setReinitializeRule(false);

Some files were not shown because too many files have changed in this diff Show More