mirror of
https://github.com/spring-projects/spring-security.git
synced 2025-06-24 04:52:16 +00:00
Polish UnboundIdContainerTests
Basic server startup test now asserts a successful server startup instead of a failed one. Issue: gh-5920
This commit is contained in:
parent
22bd8f1c1f
commit
b9c499d8c8
@ -22,8 +22,9 @@ import java.util.List;
|
|||||||
|
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
|
import org.springframework.context.support.GenericApplicationContext;
|
||||||
|
|
||||||
import static org.assertj.core.api.Assertions.assertThat;
|
import static org.assertj.core.api.Assertions.assertThat;
|
||||||
import static org.junit.Assert.fail;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Eddú Meléndez
|
* @author Eddú Meléndez
|
||||||
@ -31,17 +32,18 @@ import static org.junit.Assert.fail;
|
|||||||
public class UnboundIdContainerTests {
|
public class UnboundIdContainerTests {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void startLdapServer() throws IOException {
|
public void startLdapServer() throws Exception {
|
||||||
UnboundIdContainer server = new UnboundIdContainer("dc=springframework,dc=org",
|
UnboundIdContainer server = new UnboundIdContainer("dc=springframework,dc=org",
|
||||||
"classpath:test-server.ldif");
|
"classpath:test-server.ldif");
|
||||||
|
server.setApplicationContext(new GenericApplicationContext());
|
||||||
List<Integer> ports = getDefaultPorts(1);
|
List<Integer> ports = getDefaultPorts(1);
|
||||||
server.setPort(ports.get(0));
|
server.setPort(ports.get(0));
|
||||||
|
|
||||||
try {
|
try {
|
||||||
server.afterPropertiesSet();
|
server.afterPropertiesSet();
|
||||||
fail("Expected a RuntimeException to be thrown.");
|
assertThat(server.getPort()).isEqualTo(ports.get(0));
|
||||||
} catch (Exception ex) {
|
} finally {
|
||||||
assertThat(ex).hasMessage("Server startup failed");
|
server.destroy();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user