This is an automated email from the ASF dual-hosted git repository.

ggregory pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/commons-bcel.git


The following commit(s) were added to refs/heads/master by this push:
     new 3547f427 Make test more readable and maintainable, and less verbose
3547f427 is described below

commit 3547f42735d2cbf90c61e93cb086624cd953d658
Author: Gary David Gregory (Code signing key) <ggreg...@apache.org>
AuthorDate: Tue Oct 1 08:18:50 2024 -0400

    Make test more readable and maintainable, and less verbose
    
    - Use JUnit 5 APIs
    - Be consistent throughout tests
---
 pom.xml                                                      |  7 -------
 .../bcel/classfile/ConstantPoolModuleAccessTestCase.java     |  5 -----
 .../apache/bcel/verifier/statics/Pass3aVerifierTestCase.java |  8 +++++---
 .../verifier/structurals/InstConstraintVisitorTestCase.java  | 12 ++++++------
 4 files changed, 11 insertions(+), 21 deletions(-)

diff --git a/pom.xml b/pom.xml
index 9999fff7..5f46d255 100644
--- a/pom.xml
+++ b/pom.xml
@@ -65,7 +65,6 @@
     <commons.jira.id>BCEL</commons.jira.id>
     <commons.jira.pid>12314220</commons.jira.pid>
     <mockito.version>4.11.0</mockito.version>
-    <assertj.version>3.26.3</assertj.version>
     <jna.version>5.15.0</jna.version>
     <japicmp.skip>false</japicmp.skip>
     <!-- JaCoCo on Java 8 is different from other versions. On JDK9+ there is 
a profile -->
@@ -354,12 +353,6 @@
       <version>${mockito.version}</version>
       <scope>test</scope>
     </dependency>
-    <dependency>
-      <groupId>org.assertj</groupId>
-      <artifactId>assertj-core</artifactId>
-      <version>${assertj.version}</version>
-      <scope>test</scope>
-    </dependency>
     <dependency>
       <groupId>net.java.dev.jna</groupId>
       <artifactId>jna</artifactId>
diff --git 
a/src/test/java/org/apache/bcel/classfile/ConstantPoolModuleAccessTestCase.java 
b/src/test/java/org/apache/bcel/classfile/ConstantPoolModuleAccessTestCase.java
index 2c4eb290..8cf3799d 100644
--- 
a/src/test/java/org/apache/bcel/classfile/ConstantPoolModuleAccessTestCase.java
+++ 
b/src/test/java/org/apache/bcel/classfile/ConstantPoolModuleAccessTestCase.java
@@ -261,11 +261,6 @@ public final class ConstantPoolModuleAccessTestCase {
                         final List<String> expected = new ArrayList<>();
                         
expected.add("jdk.internal.netscape.javascript.spi.JSObjectProvider");
                         assertEquals(expected, Arrays.asList(usedClassNames));
-                    } else if (urlPath.contains("/org/assertj/assertj-core/")) 
{
-                        final List<String> expected = new ArrayList<>();
-                        
expected.add("org.assertj.core.configuration.Configuration");
-                        
expected.add("org.assertj.core.presentation.Representation");
-                        assertEquals(expected, Arrays.asList(usedClassNames));
                     } else {
                         assertEquals(0, usedClassNames.length, "Found " + 
Arrays.toString(usedClassNames) + " in " + urlPath);
                     }
diff --git 
a/src/test/java/org/apache/bcel/verifier/statics/Pass3aVerifierTestCase.java 
b/src/test/java/org/apache/bcel/verifier/statics/Pass3aVerifierTestCase.java
index c368c392..0421a2a0 100644
--- a/src/test/java/org/apache/bcel/verifier/statics/Pass3aVerifierTestCase.java
+++ b/src/test/java/org/apache/bcel/verifier/statics/Pass3aVerifierTestCase.java
@@ -16,7 +16,9 @@
  */
 package org.apache.bcel.verifier.statics;
 
-import static org.assertj.core.api.Assertions.assertThat;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+
 import static org.mockito.Mockito.doReturn;
 import static org.mockito.Mockito.mock;
 import static org.mockito.Mockito.spy;
@@ -105,8 +107,8 @@ class Pass3aVerifierTestCase {
         final Pass3aVerifier pass3aVerifier = new Pass3aVerifier(verifier, 0);
         final VerificationResult verificationResult = 
pass3aVerifier.do_verify();
 
-        
assertThat(verificationResult.getStatus()).isEqualTo(VerificationResult.VERIFIED_REJECTED);
-        assertThat(verificationResult.getMessage()).startsWith("Instruction 
ldc[18](2) 0 constraint violated: Operand of LDC");
+        assertEquals(VerificationResult.VERIFIED_REJECTED, 
verificationResult.getStatus());
+        assertTrue(verificationResult.getMessage().startsWith("Instruction 
ldc[18](2) 0 constraint violated: Operand of LDC"));
     }
 
     @BeforeEach
diff --git 
a/src/test/java/org/apache/bcel/verifier/structurals/InstConstraintVisitorTestCase.java
 
b/src/test/java/org/apache/bcel/verifier/structurals/InstConstraintVisitorTestCase.java
index 72d4c04b..6a6c8391 100644
--- 
a/src/test/java/org/apache/bcel/verifier/structurals/InstConstraintVisitorTestCase.java
+++ 
b/src/test/java/org/apache/bcel/verifier/structurals/InstConstraintVisitorTestCase.java
@@ -16,33 +16,33 @@
  */
 package org.apache.bcel.verifier.structurals;
 
-import static org.assertj.core.api.Assertions.assertThatCode;
+import static org.junit.jupiter.api.Assertions.assertThrows;
+import static org.junit.jupiter.api.Assertions.assertTrue;
 import static org.mockito.Mockito.mock;
 import static org.mockito.Mockito.when;
 
 import org.apache.bcel.classfile.Constant;
 import org.apache.bcel.generic.ConstantPoolGen;
 import org.apache.bcel.generic.LDC;
+import org.apache.bcel.verifier.exc.CodeConstraintException;
 import org.junit.jupiter.api.BeforeEach;
 import org.junit.jupiter.params.ParameterizedTest;
 import org.junit.jupiter.params.provider.MethodSource;
 
 public class InstConstraintVisitorTestCase {
+
     private ConstantPoolGen cp;
 
     @ParameterizedTest
     
@MethodSource("org.apache.bcel.verifier.statics.Pass3aVerifierTestCase#constantsNotSupportedByLdc")
     public void rejectLdcConstantModule(final Constant constant) {
         final InstConstraintVisitor visitor = new InstConstraintVisitor();
-
         cp = mock(ConstantPoolGen.class);
         when(cp.getConstant(0)).thenReturn(constant);
-
         visitor.setConstantPoolGen(cp);
-
         final LDC ldc = new LDC(0);
-
-        assertThatCode(() -> 
visitor.visitLDC(ldc)).hasMessageStartingWith("Instruction LDC constraint 
violated: Referenced constant should be a");
+        assertTrue(assertThrows(CodeConstraintException.class, () -> 
visitor.visitLDC(ldc)).getMessage()
+                .startsWith("Instruction LDC constraint violated: Referenced 
constant should be a"));
     }
 
     @BeforeEach

Reply via email to