1
0
mirror of synced 2026-05-22 21:33:16 +00:00

Replace expected @Test attributes with AssertJ

Replace JUnit expected @Test attributes with AssertJ calls.
This commit is contained in:
Phillip Webb
2020-09-10 21:33:16 -07:00
committed by Josh Cummings
parent 20baa7d409
commit c502312719
243 changed files with 2115 additions and 1591 deletions
@@ -27,6 +27,7 @@ import org.junit.Before;
import org.junit.Test;
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.BDDMockito.given;
import static org.mockito.Mockito.mock;
@@ -60,11 +61,12 @@ public class JndiDnsResolverTests {
assertThat(ipAddress).isEqualTo("63.246.7.80");
}
@Test(expected = DnsEntryNotFoundException.class)
@Test
public void testResolveIpAddressNotExisting() throws Exception {
given(this.context.getAttributes(any(String.class), any(String[].class)))
.willThrow(new NameNotFoundException("not found"));
this.dnsResolver.resolveIpAddress("notexisting.ansdansdugiuzgguzgioansdiandwq.foo");
assertThatExceptionOfType(DnsEntryNotFoundException.class)
.isThrownBy(() -> this.dnsResolver.resolveIpAddress("notexisting.ansdansdugiuzgguzgioansdiandwq.foo"));
}
@Test
@@ -75,11 +77,12 @@ public class JndiDnsResolverTests {
assertThat(hostname).isEqualTo("kdc.springsource.com");
}
@Test(expected = DnsEntryNotFoundException.class)
@Test
public void testResolveServiceEntryNotExisting() throws Exception {
given(this.context.getAttributes(any(String.class), any(String[].class)))
.willThrow(new NameNotFoundException("not found"));
this.dnsResolver.resolveServiceEntry("wrong", "secpod.de");
assertThatExceptionOfType(DnsEntryNotFoundException.class)
.isThrownBy(() -> this.dnsResolver.resolveServiceEntry("wrong", "secpod.de"));
}
@Test
@@ -92,11 +95,11 @@ public class JndiDnsResolverTests {
assertThat(ipAddress).isEqualTo("63.246.7.80");
}
@Test(expected = DnsLookupException.class)
@Test
public void testUnknowError() throws Exception {
given(this.context.getAttributes(any(String.class), any(String[].class)))
.willThrow(new NamingException("error"));
this.dnsResolver.resolveIpAddress("");
assertThatExceptionOfType(DnsLookupException.class).isThrownBy(() -> this.dnsResolver.resolveIpAddress(""));
}
private BasicAttributes createSrvRecords() {