소스 검색

Polish UnboundIdContainerTests

Basic server startup test now asserts a successful server startup
instead of a failed one.

Issue: gh-5920
Josh Cummings 6 년 전
부모
커밋
b9c499d8c8
1개의 변경된 파일7개의 추가작업 그리고 5개의 파일을 삭제
  1. 7 5
      ldap/src/integration-test/java/org/springframework/security/ldap/server/UnboundIdContainerTests.java

+ 7 - 5
ldap/src/integration-test/java/org/springframework/security/ldap/server/UnboundIdContainerTests.java

@@ -22,8 +22,9 @@ import java.util.List;
 
 import org.junit.Test;
 
+import org.springframework.context.support.GenericApplicationContext;
+
 import static org.assertj.core.api.Assertions.assertThat;
-import static org.junit.Assert.fail;
 
 /**
  * @author Eddú Meléndez
@@ -31,17 +32,18 @@ import static org.junit.Assert.fail;
 public class UnboundIdContainerTests {
 
 	@Test
-	public void startLdapServer() throws IOException {
+	public void startLdapServer() throws Exception {
 		UnboundIdContainer server = new UnboundIdContainer("dc=springframework,dc=org",
 				"classpath:test-server.ldif");
+		server.setApplicationContext(new GenericApplicationContext());
 		List<Integer> ports = getDefaultPorts(1);
 		server.setPort(ports.get(0));
 
 		try {
 			server.afterPropertiesSet();
-			fail("Expected a RuntimeException to be thrown.");
-		} catch (Exception ex) {
-			assertThat(ex).hasMessage("Server startup failed");
+			assertThat(server.getPort()).isEqualTo(ports.get(0));
+		} finally {
+			server.destroy();
 		}
 	}