You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@groovy.apache.org by su...@apache.org on 2022/10/22 17:11:13 UTC
[groovy] branch GROOVY_4_0_X updated: Simplify assertion
This is an automated email from the ASF dual-hosted git repository.
sunlan pushed a commit to branch GROOVY_4_0_X
in repository https://gitbox.apache.org/repos/asf/groovy.git
The following commit(s) were added to refs/heads/GROOVY_4_0_X by this push:
new 3509af910b Simplify assertion
3509af910b is described below
commit 3509af910b28784c0faf6fc0de89c9223441bce7
Author: Daniel Sun <su...@apache.org>
AuthorDate: Sat Oct 22 23:21:02 2022 +0800
Simplify assertion
(cherry picked from commit e7f9896b2987c7f2df639634c0070f263c58f1e4)
---
.../groovy/org/codehaus/groovy/classgen/TestSupport.java | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/src/testFixtures/groovy/org/codehaus/groovy/classgen/TestSupport.java b/src/testFixtures/groovy/org/codehaus/groovy/classgen/TestSupport.java
index 86fbb1fbce..2b11eed1ae 100644
--- a/src/testFixtures/groovy/org/codehaus/groovy/classgen/TestSupport.java
+++ b/src/testFixtures/groovy/org/codehaus/groovy/classgen/TestSupport.java
@@ -76,7 +76,7 @@ public class TestSupport extends GroovyTestCase implements Opcodes {
protected void assertSetProperty(Object bean, String property, Object newValue) throws Exception {
PropertyDescriptor descriptor = getDescriptor(bean, property);
Method method = descriptor.getWriteMethod();
- assertTrue("has setter method", method != null);
+ assertNotNull("has setter method", method);
Object[] args = {newValue};
Object value = invokeMethod(bean, method, args);
assertEquals("should return null", null, value);
@@ -86,7 +86,7 @@ public class TestSupport extends GroovyTestCase implements Opcodes {
protected void assertGetProperty(Object bean, String property, Object expected) throws Exception {
PropertyDescriptor descriptor = getDescriptor(bean, property);
Method method = descriptor.getReadMethod();
- assertTrue("has getter method", method != null);
+ assertNotNull("has getter method", method);
Object[] args = { };
Object value = invokeMethod(bean, method, args);
@@ -118,7 +118,7 @@ public class TestSupport extends GroovyTestCase implements Opcodes {
protected void assertField(Class aClass, String name, int modifiers, ClassNode type) throws Exception {
Field field = aClass.getDeclaredField(name);
- assertTrue("Found field called: " + name, field != null);
+ assertNotNull("Found field called: " + name, field);
assertEquals("Name", name, field.getName());
assertEquals("Type", type.getName(), field.getType().getName());
assertEquals("Modifiers", modifiers, field.getModifiers());
@@ -165,7 +165,7 @@ public class TestSupport extends GroovyTestCase implements Opcodes {
protected GroovyObject compile(String fileName) throws Exception {
Class<?> groovyClass = loader.parseClass(new GroovyCodeSource(new File(fileName)));
GroovyObject object = (GroovyObject) groovyClass.getDeclaredConstructor().newInstance();
- assertTrue(object != null);
+ assertNotNull(object);
return object;
}
}