Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- main
- java
- com.test.ldap
- Application.java
- Person.java
- PersonRepository.java
- resources
- application.yml
- schema.ldif
- test
- java
- Tests.java
- resources
- test.yml
- test_schema.ldif
- import com.test.ldap.Person;
- import com.test.ldap.PersonRepository;
- import org.junit.Test;
- import org.junit.runner.RunWith;
- import org.springframework.beans.factory.annotation.Autowired;
- import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
- import org.springframework.boot.test.context.SpringBootTest;
- import org.springframework.test.context.TestPropertySource;
- import org.springframework.test.context.junit4.SpringRunner;
- import java.util.List;
- @RunWith(SpringRunner.class)
- @SpringBootTest(classes = {PersonRepository.class})
- @TestPropertySource(locations = "classpath:test.yml")
- @EnableAutoConfiguration
- public class Tests {
- @Autowired
- private PersonRepository personRepository;
- @Test
- public void testGetPersonByLastName() {
- List<Person> names = personRepository.getPersonNamesByLastName("Bachman");
- assert(names.size() > 0);
- }
- }
- # Spring LDAP Mapping Attributes to POJO with AttributesMapper configuration application.yml
- spring:
- ldap:
- # Spring LDAP
- #
- # In this example we use an embedded ldap server. When using a real one,
- # you can configure the settings here.
- #
- # urls: ldap://localhost:12345
- # base: dc=memorynotfound,dc=com
- # username: uid=admin
- # password: secret
- # Embedded Spring LDAP
- embedded:
- base-dn: dc=test,dc=com
- credential:
- username: uid=admin
- password: secret
- ldif: classpath:test_schema.ldif
- port: 12345
- validation:
- enabled: false
Add Comment
Please, Sign In to add comment