36
36
import com .unboundid .ldap .listener .InMemoryListenerConfig ;
37
37
import com .unboundid .ldap .sdk .Attribute ;
38
38
import com .unboundid .ldap .sdk .LDAPException ;
39
+ import com .unboundid .ldap .sdk .schema .Schema ;
39
40
import com .unboundid .ldif .LDIFException ;
40
41
41
42
public class LdapServerExternalResource extends ExternalResource {
@@ -52,7 +53,7 @@ public class LdapServerExternalResource extends ExternalResource {
52
53
*/
53
54
@ SuppressWarnings ("serial" )
54
55
public static LdapServerExternalResource createDefaultInstance (){
55
- return new LdapServerExternalResource (new LinkedHashMap <String , Attribute []>(){{
56
+ return new LdapServerExternalResource (null , new LinkedHashMap <String , Attribute []>(){{
56
57
put ("dc=com" , new Attribute []{
57
58
new Attribute ("objectClass" , "top" ),
58
59
new Attribute ("objectClass" , "domain" ),
@@ -86,12 +87,14 @@ public static LdapServerExternalResource createDefaultInstance(){
86
87
private InMemoryDirectoryServer server = null ;
87
88
private InMemoryLdapServer imlsAnnotation = null ;
88
89
private final LinkedHashMap <String , Attribute []> preloadDnData ;
90
+ private final Schema schema ;
89
91
90
92
public LdapServerExternalResource (){
91
- this . preloadDnData = null ;
93
+ this ( null , null ) ;
92
94
}
93
95
94
- public LdapServerExternalResource (LinkedHashMap <String , Attribute []> preload ){
96
+ public LdapServerExternalResource (Schema schema , LinkedHashMap <String , Attribute []> preload ){
97
+ this .schema = schema ;
95
98
this .preloadDnData = preload ;
96
99
}
97
100
@@ -120,7 +123,7 @@ protected void before() throws Throwable {
120
123
InMemoryListenerConfig listenerConfig = new InMemoryListenerConfig (
121
124
imlsAnnotation .name (), null , imlsAnnotation .port (), null , null , null );
122
125
config .setListenerConfigs (listenerConfig );
123
- config .setSchema (null ); // do not check (attribute) schema
126
+ config .setSchema (schema ); // do not check (attribute) schema
124
127
125
128
server = new InMemoryDirectoryServer (config );
126
129
server .startListening ();
0 commit comments