46.3.19 자동 구성된 Data LDAP 테스트들

@DataLdapTest를 사용하여 LDAP 응용 프로그램을 테스트 할 수 있습니다. 기본적으로 인 메모리 내장 LDAP (사용 가능한 경우)를 구성하고, LdapTemplate을 구성하고, @Entry 클래스를 스캔하고, Spring 데이터 LDAP 저장소를 구성합니다. 일반 @Component 빈은 ApplicationContext로 로드되지 않습니다. (스프링 부트와 함께 LDAP를 사용하는 것에 대한 더 자세한 내용은이 장 앞부분의 "Section 32.9, LDAP"절을 참조하십시오.)

LADP (Light Directory Access Protocol)

  • LADP의 요청 처리 : 사용자 혹은 응용 프로그램에서 요청을 보내면 LDAP을 통해 LADP 서버에 전달이 된다. 서버는 요청을 처리 후 다시 LDAP을 통해 요청자에게 결과를 전송한다. TCP/IP 상에서 운영.

@DataLdapTest에 의해 활성화되는 자동 구성 설정 목록은 부록에서 찾을 수 있습니다.

다음 예제는 사용중인 @DataLdapTest 어노테이션을 보여줍니다.

import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.autoconfigure.data.ldap.DataLdapTest;
import org.springframework.ldap.core.LdapTemplate;
import org.springframework.test.context.junit4.SpringRunner;

@RunWith(SpringRunner.class)
@DataLdapTest
public class ExampleDataLdapTests {

	@Autowired
	private LdapTemplate ldapTemplate;

	//
}

인 메모리 내장 LDAP는 일반적으로 테스트에 적합합니다. 빠르고 개발자 설치가 필요하지 않기 때문입니다. 그러나 실제 LDAP 서버에 대해 테스트를 실행하려면 다음 예와 같이 내장 LDAP 자동 구성을 제외해야합니다.

import org.junit.runner.RunWith;
import org.springframework.boot.autoconfigure.ldap.embedded.EmbeddedLdapAutoConfiguration;
import org.springframework.boot.test.autoconfigure.data.ldap.DataLdapTest;
import org.springframework.test.context.junit4.SpringRunner;

@RunWith(SpringRunner.class)
@DataLdapTest(excludeAutoConfiguration = EmbeddedLdapAutoConfiguration.class)
public class ExampleDataLdapNonEmbeddedTests {

}

Last updated