Skip to content

Commit eb472b7

Browse files
committed
swap Assert imports
Issue #1058 Signed-off-by: etrandafir93 <[email protected]>
1 parent 8da35be commit eb472b7

File tree

2 files changed

+21
-14
lines changed

2 files changed

+21
-14
lines changed

test-support/src/main/java/org/springframework/ldap/test/AttributeCheckAttributesMapper.java

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,8 @@
2222
import javax.naming.directory.Attribute;
2323
import javax.naming.directory.Attributes;
2424

25-
import junit.framework.Assert;
26-
2725
import org.springframework.ldap.core.AttributesMapper;
26+
import org.springframework.util.Assert;
2827

2928
/**
3029
* Dummy AttributesMapper for testing purposes to check that the received Attributes are
@@ -41,16 +40,21 @@ public class AttributeCheckAttributesMapper implements AttributesMapper<Object>
4140
private String[] absentAttributes = new String[0];
4241

4342
public Object mapFromAttributes(Attributes attributes) throws NamingException {
44-
Assert.assertEquals("Values and attributes need to have the same length ", this.expectedAttributes.length,
45-
this.expectedValues.length);
43+
Assert.isTrue(this.expectedAttributes.length == this.expectedValues.length,
44+
"Values and attributes need to have the same length " + this.expectedAttributes.length + "!="
45+
+ this.expectedValues.length);
46+
4647
for (int i = 0; i < this.expectedAttributes.length; i++) {
4748
Attribute attribute = attributes.get(this.expectedAttributes[i]);
48-
Assert.assertNotNull("Attribute " + this.expectedAttributes[i] + " was not present", attribute);
49-
Assert.assertEquals(this.expectedValues[i], attribute.get());
49+
50+
Assert.notNull(attribute, "Attribute " + this.expectedAttributes[i] + " was not present");
51+
52+
Assert.isTrue(attribute.get().equals(this.expectedValues[i]), "Attribute " + this.expectedAttributes[i]
53+
+ " had value " + attribute.get() + " instead of " + this.expectedValues[i]);
5054
}
5155

5256
for (String absentAttribute : this.absentAttributes) {
53-
Assert.assertNull(attributes.get(absentAttribute));
57+
Assert.isNull(attributes.get(absentAttribute), "Attribute " + absentAttribute + " was present");
5458
}
5559

5660
return new Object();

test-support/src/main/java/org/springframework/ldap/test/AttributeCheckContextMapper.java

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,9 @@
1818

1919
import java.util.Arrays;
2020

21-
import junit.framework.Assert;
22-
2321
import org.springframework.ldap.core.ContextMapper;
2422
import org.springframework.ldap.core.DirContextAdapter;
23+
import org.springframework.util.Assert;
2524

2625
/**
2726
* Dummy ContextMapper for testing purposes to check that the received Attributes are the
@@ -39,16 +38,20 @@ public class AttributeCheckContextMapper implements ContextMapper<DirContextAdap
3938

4039
public DirContextAdapter mapFromContext(Object ctx) {
4140
DirContextAdapter adapter = (DirContextAdapter) ctx;
42-
Assert.assertEquals("Values and attributes need to have the same length ", this.expectedAttributes.length,
43-
this.expectedValues.length);
41+
Assert.isTrue(this.expectedAttributes.length == this.expectedValues.length,
42+
"Values and attributes need to have the same length " + this.expectedAttributes.length + "!="
43+
+ this.expectedValues.length);
4444
for (int i = 0; i < this.expectedAttributes.length; i++) {
4545
String attributeValue = adapter.getStringAttribute(this.expectedAttributes[i]);
46-
Assert.assertNotNull("Attribute " + this.expectedAttributes[i] + " was not present", attributeValue);
47-
Assert.assertEquals(this.expectedValues[i], attributeValue);
46+
Assert.notNull(attributeValue, "Attribute " + this.expectedAttributes[i] + " was not present");
47+
48+
Assert.isTrue(attributeValue.equals(this.expectedValues[i]), "Attribute " + this.expectedAttributes[i]
49+
+ " had value " + attributeValue + " instead of " + this.expectedValues[i]);
4850
}
4951

5052
for (String absentAttribute : this.absentAttributes) {
51-
Assert.assertNull(adapter.getStringAttribute(absentAttribute));
53+
Assert.notNull(adapter.getStringAttribute(absentAttribute),
54+
"Attribute " + absentAttribute + " was present");
5255
}
5356

5457
return adapter;

0 commit comments

Comments
 (0)