Skip to content

Commit e50fecf

Browse files
committed
Bump baseline java version to Java 11
1 parent 01b351a commit e50fecf

File tree

46 files changed

+351
-163
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

46 files changed

+351
-163
lines changed

.github/workflows/maven.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ jobs:
1515
runs-on: ubuntu-latest
1616
strategy:
1717
matrix:
18-
java-version: [ 8, 11 ]
18+
java-version: [ 11, 17 ]
1919

2020
steps:
2121
- uses: actions/checkout@v2
@@ -46,11 +46,11 @@ jobs:
4646
needs: build
4747
steps:
4848
- uses: actions/checkout@v2
49-
- name: Set up Java 8
49+
- name: Set up Java 11
5050
uses: actions/setup-java@v3
5151
with:
5252
distribution: 'zulu'
53-
java-version: 8
53+
java-version: 11
5454
server-id: sonatype-nexus-snapshots
5555
server-username: MAVEN_USERNAME
5656
server-password: MAVEN_PASSWORD

embedded-ldap-core/pom.xml

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<project xmlns="http://maven.apache.org/POM/4.0.0"
3+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
5+
<parent>
6+
<groupId>org.zapodot</groupId>
7+
<artifactId>embedded-ldap-junit-parent</artifactId>
8+
<version>0.9.1-SNAPSHOT</version>
9+
</parent>
10+
<modelVersion>4.0.0</modelVersion>
11+
12+
<artifactId>embedded-ldap-core</artifactId>
13+
14+
<dependencies>
15+
<dependency>
16+
<groupId>com.unboundid</groupId>
17+
<artifactId>unboundid-ldapsdk</artifactId>
18+
</dependency>
19+
<dependency>
20+
<groupId>net.bytebuddy</groupId>
21+
<artifactId>byte-buddy</artifactId>
22+
</dependency>
23+
<dependency>
24+
<groupId>com.google.guava</groupId>
25+
<artifactId>guava</artifactId>
26+
</dependency>
27+
<dependency>
28+
<groupId>org.slf4j</groupId>
29+
<artifactId>slf4j-api</artifactId>
30+
</dependency>
31+
</dependencies>
32+
33+
</project>

src/main/java/org/zapodot/junit/ldap/EmbeddedLdapRuleBuilder.java renamed to embedded-ldap-core/src/main/java/org/zapodot/junit/ldap/AbstractEmbeddedLdapSupportBuilder.java

Lines changed: 36 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
import com.unboundid.ldap.sdk.schema.Schema;
1010
import com.unboundid.ldif.LDIFException;
1111
import org.zapodot.junit.ldap.internal.AuthenticationConfiguration;
12-
import org.zapodot.junit.ldap.internal.EmbeddedLdapRuleImpl;
1312

1413
import javax.net.ssl.SSLSocketFactory;
1514
import java.io.File;
@@ -22,61 +21,46 @@
2221
import java.util.List;
2322
import java.util.Objects;
2423

25-
/**
26-
* A builder providing a fluent way of defining EmbeddedLdapRule instances
27-
*/
28-
public class EmbeddedLdapRuleBuilder {
29-
24+
public abstract class AbstractEmbeddedLdapSupportBuilder<T> {
3025
public static final String DEFAULT_DOMAIN = "dc=example,dc=com";
3126
public static final String DEFAULT_BIND_DSN = "cn=Directory manager";
3227
public static final String DEFAULT_BIND_CREDENTIALS = "password";
3328
public static final String LDAP_SERVER_LISTENER_NAME = "test-listener";
3429
public static final int MIN_PORT_EXCLUSIVE = 0;
3530
public static final int MAX_PORT_EXCLUSIVE = 65535;
36-
private List<String> domainDsn = new LinkedList<>();
37-
38-
private String bindDSN = DEFAULT_BIND_DSN;
31+
protected List<String> domainDsn = new LinkedList<>();
3932

40-
private String bindCredentials = DEFAULT_BIND_CREDENTIALS;
33+
protected String bindDSN = DEFAULT_BIND_DSN;
4134

42-
private List<String> ldifsToImport = new LinkedList<>();
35+
protected String bindCredentials = DEFAULT_BIND_CREDENTIALS;
4336

44-
private List<String> schemaLdifs = new LinkedList<>();
37+
protected List<String> ldifsToImport = new LinkedList<>();
4538

46-
private boolean addDefaultSchema = true;
39+
protected List<String> schemaLdifs = new LinkedList<>();
4740

48-
private Integer bindPort = 0;
41+
protected boolean addDefaultSchema = true;
4942

50-
private InetAddress bindAddress = InetAddress.getLoopbackAddress();
43+
protected Integer bindPort = 0;
5144

52-
private AuthenticationConfiguration authenticationConfiguration;
45+
protected InetAddress bindAddress = InetAddress.getLoopbackAddress();
5346

54-
private InMemoryListenerConfig listenerConfig = null;
47+
protected AuthenticationConfiguration authenticationConfiguration;
5548

56-
private boolean useTls = false;
57-
private SSLSocketFactory socketFactory = null;
49+
protected InMemoryListenerConfig listenerConfig = null;
5850

59-
private Integer maxSizeLimit = null;
51+
protected boolean useTls = false;
52+
protected SSLSocketFactory socketFactory = null;
6053

61-
public EmbeddedLdapRuleBuilder() {
62-
}
54+
protected Integer maxSizeLimit = null;
6355

64-
/**
65-
* Creates a new builder
66-
*
67-
* @return a new EmbeddedLdapRuleBuilder instance
68-
*/
69-
public static EmbeddedLdapRuleBuilder newInstance() {
70-
return new EmbeddedLdapRuleBuilder();
71-
}
7256

7357
/**
7458
* Sets a domainDsn to be used. May be multiple values. If not set, it will default to the value of the {@link #DEFAULT_DOMAIN DEFAULT_DOMAIN} field
7559
*
7660
* @param domainDsn a valid DSN string
7761
* @return same EmbeddedLdapRuleBuilder instance with the domainDsn field set
7862
*/
79-
public EmbeddedLdapRuleBuilder usingDomainDsn(final String domainDsn) {
63+
public AbstractEmbeddedLdapSupportBuilder<T> usingDomainDsn(final String domainDsn) {
8064
this.domainDsn.add(domainDsn);
8165
return this;
8266
}
@@ -87,7 +71,7 @@ public EmbeddedLdapRuleBuilder usingDomainDsn(final String domainDsn) {
8771
* @param bindDSN a valid DSN string
8872
* @return same EmbeddedLdapRuleBuilder instance with the bindDSN field set
8973
*/
90-
public EmbeddedLdapRuleBuilder usingBindDSN(final String bindDSN) {
74+
public AbstractEmbeddedLdapSupportBuilder<T> usingBindDSN(final String bindDSN) {
9175
this.bindDSN = bindDSN;
9276
return this;
9377
}
@@ -98,7 +82,7 @@ public EmbeddedLdapRuleBuilder usingBindDSN(final String bindDSN) {
9882
* @param bindCredentials a password string
9983
* @return same EmbeddedLdapRuleBuilder instance with the bindCredentials field set
10084
*/
101-
public EmbeddedLdapRuleBuilder usingBindCredentials(final String bindCredentials) {
85+
public AbstractEmbeddedLdapSupportBuilder<T> usingBindCredentials(final String bindCredentials) {
10286
this.bindCredentials = bindCredentials;
10387
return this;
10488
}
@@ -111,7 +95,7 @@ public EmbeddedLdapRuleBuilder usingBindCredentials(final String bindCredentials
11195
* @throws IllegalArgumentException if the provided value for port is not between @{link MIN_PORT_EXCLUSIVE}
11296
* and @{MAX_PORT_EXCLUSIVE} (exclusive)
11397
*/
114-
public EmbeddedLdapRuleBuilder bindingToPort(final int port) {
98+
public AbstractEmbeddedLdapSupportBuilder<T> bindingToPort(final int port) {
11599
if ((port < MIN_PORT_EXCLUSIVE) || (port > MAX_PORT_EXCLUSIVE)) {
116100
throw new IllegalArgumentException(String.format("Value \"%s\" is not a valid port number", port));
117101
}
@@ -126,7 +110,7 @@ public EmbeddedLdapRuleBuilder bindingToPort(final int port) {
126110
* @return same EmbeddedLdapRuleBuilder instance with the bindAddress field set
127111
* @throws IllegalArgumentException if the value provided for \"address\" is invalid
128112
*/
129-
public EmbeddedLdapRuleBuilder bindingToAddress(final String address) {
113+
public AbstractEmbeddedLdapSupportBuilder<T> bindingToAddress(final String address) {
130114
Objects.requireNonNull(address);
131115
try {
132116
final InetAddress addressByName = InetAddress.getByName(address);
@@ -137,7 +121,7 @@ public EmbeddedLdapRuleBuilder bindingToAddress(final String address) {
137121
return this;
138122
}
139123

140-
public EmbeddedLdapRuleBuilder withMaxSizeLimit(final int maxSizeLimit) {
124+
public AbstractEmbeddedLdapSupportBuilder<T> withMaxSizeLimit(final int maxSizeLimit) {
141125
this.maxSizeLimit = Integer.valueOf(maxSizeLimit);
142126
return this;
143127
}
@@ -147,7 +131,7 @@ public EmbeddedLdapRuleBuilder withMaxSizeLimit(final int maxSizeLimit) {
147131
*
148132
* @return same EmbeddedLdapRuleBuilder instance with the withoutDefaultSchema field set to FALSE
149133
*/
150-
public EmbeddedLdapRuleBuilder withoutDefaultSchema() {
134+
public AbstractEmbeddedLdapSupportBuilder<T> withoutDefaultSchema() {
151135
this.addDefaultSchema = false;
152136
return this;
153137
}
@@ -158,7 +142,7 @@ public EmbeddedLdapRuleBuilder withoutDefaultSchema() {
158142
* @param ldifSchemaFiles LDIF-files containing schema element definitions
159143
* @return same EmbeddedLdapRuleBuilder with the given LDIF-files added to the internal schema file collection.
160144
*/
161-
public EmbeddedLdapRuleBuilder withSchema(final String... ldifSchemaFiles) {
145+
public AbstractEmbeddedLdapSupportBuilder<T> withSchema(final String... ldifSchemaFiles) {
162146
this.schemaLdifs.addAll(Arrays.asList(ldifSchemaFiles));
163147
return this;
164148
}
@@ -169,19 +153,19 @@ public EmbeddedLdapRuleBuilder withSchema(final String... ldifSchemaFiles) {
169153
* @param ldifFiles LDIF-files to import
170154
* @return same EmbeddedLdapRuleBuilder instance with the provided ldifFiles added to the list of LDIF files to import
171155
*/
172-
public EmbeddedLdapRuleBuilder importingLdifs(final String... ldifFiles) {
156+
public AbstractEmbeddedLdapSupportBuilder<T> importingLdifs(final String... ldifFiles) {
173157
if (ldifFiles != null) {
174158
ldifsToImport.addAll(Arrays.asList(ldifFiles));
175159
}
176160
return this;
177161
}
178162

179-
public EmbeddedLdapRuleBuilder withListener(InMemoryListenerConfig listenerConfig) {
163+
public AbstractEmbeddedLdapSupportBuilder<T> withListener(InMemoryListenerConfig listenerConfig) {
180164
this.listenerConfig = listenerConfig;
181165
return this;
182166
}
183167

184-
public EmbeddedLdapRuleBuilder useTls(boolean useTls) {
168+
public AbstractEmbeddedLdapSupportBuilder<T> useTls(boolean useTls) {
185169
this.useTls = useTls;
186170
return this;
187171
}
@@ -191,14 +175,10 @@ public EmbeddedLdapRuleBuilder useTls(boolean useTls) {
191175
*
192176
* @return a new EmbeddedLdapRule instance
193177
*/
194-
public EmbeddedLdapRule build() {
195-
Objects.requireNonNull(bindDSN, "\"bindDSN\" can not be null");
196-
return EmbeddedLdapRuleImpl.createForConfiguration(createInMemoryServerConfiguration(),
197-
authenticationConfiguration,
198-
ldifsToImport, useTls, socketFactory);
199-
}
178+
abstract public T build();
200179

201-
private InMemoryDirectoryServerConfig createInMemoryServerConfiguration() {
180+
181+
protected InMemoryDirectoryServerConfig createInMemoryServerConfiguration() {
202182
try {
203183
final InMemoryDirectoryServerConfig inMemoryDirectoryServerConfig =
204184
new InMemoryDirectoryServerConfig(domainDsnArray());
@@ -210,10 +190,10 @@ private InMemoryDirectoryServerConfig createInMemoryServerConfiguration() {
210190

211191
if (listenerConfig == null) {
212192
listenerConfig = InMemoryListenerConfig.createLDAPConfig(
213-
LDAP_SERVER_LISTENER_NAME,
214-
bindAddress,
215-
bindPort,
216-
null);
193+
LDAP_SERVER_LISTENER_NAME,
194+
bindAddress,
195+
bindPort,
196+
null);
217197
}
218198
inMemoryDirectoryServerConfig.setListenerConfigs(listenerConfig);
219199
inMemoryDirectoryServerConfig.setSchema(customSchema());
@@ -243,8 +223,8 @@ private Schema customSchema() {
243223
final Schema initialSchema = (addDefaultSchema ? Schema.getDefaultStandardSchema() : null);
244224
if (!schemaFiles.isEmpty()) {
245225
final Schema customSchema = initialSchema == null
246-
? Schema.getSchema(schemaFiles)
247-
: Schema.mergeSchemas(initialSchema, Schema.getSchema(schemaFiles));
226+
? Schema.getSchema(schemaFiles)
227+
: Schema.mergeSchemas(initialSchema, Schema.getSchema(schemaFiles));
248228
return customSchema;
249229
} else {
250230
return null;
@@ -278,8 +258,9 @@ public File apply(final String input) {
278258
}));
279259
}
280260

281-
public EmbeddedLdapRuleBuilder withSocketFactory(SSLSocketFactory socketFactory) {
261+
public AbstractEmbeddedLdapSupportBuilder<T> withSocketFactory(SSLSocketFactory socketFactory) {
282262
this.socketFactory = socketFactory;
283263
return this;
284264
}
265+
285266
}

src/main/java/org/zapodot/junit/ldap/internal/AuthenticationConfiguration.java renamed to embedded-ldap-core/src/main/java/org/zapodot/junit/ldap/internal/AuthenticationConfiguration.java

File renamed without changes.

src/main/java/org/zapodot/junit/ldap/internal/jndi/ContextInterceptor.java renamed to embedded-ldap-core/src/main/java/org/zapodot/junit/ldap/internal/jndi/ContextInterceptor.java

File renamed without changes.

src/main/java/org/zapodot/junit/ldap/internal/jndi/ContextProxy.java renamed to embedded-ldap-core/src/main/java/org/zapodot/junit/ldap/internal/jndi/ContextProxy.java

File renamed without changes.

src/main/java/org/zapodot/junit/ldap/internal/jndi/ContextProxyFactory.java renamed to embedded-ldap-core/src/main/java/org/zapodot/junit/ldap/internal/jndi/ContextProxyFactory.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -98,10 +98,10 @@ private static Constructor<? extends Context> getDeclaredConstructor() {
9898

9999
public static DirContext asDelegatingDirContext(final InitialDirContext initialDirContext) {
100100
try {
101-
final DirContext dirContext = DIR_CONTEXT_PROXY_TYPE.newInstance();
101+
final DirContext dirContext = DIR_CONTEXT_PROXY_TYPE.getDeclaredConstructor().newInstance();
102102
((DirContextProxy) dirContext).setDelegatedDirContext(initialDirContext);
103103
return dirContext;
104-
} catch (InstantiationException | IllegalAccessException e) {
104+
} catch (InstantiationException | IllegalAccessException | NoSuchMethodException | InvocationTargetException e) {
105105
throw new IllegalStateException("Could not wrap DirContext", e);
106106
}
107107
}

src/main/java/org/zapodot/junit/ldap/internal/jndi/DirContextProxy.java renamed to embedded-ldap-core/src/main/java/org/zapodot/junit/ldap/internal/jndi/DirContextProxy.java

File renamed without changes.

src/main/java/org/zapodot/junit/ldap/internal/package-info.java renamed to embedded-ldap-core/src/main/java/org/zapodot/junit/ldap/internal/package-info.java

File renamed without changes.

src/main/java/org/zapodot/junit/ldap/internal/unboundid/LDAPConnectionProxy.java renamed to embedded-ldap-core/src/main/java/org/zapodot/junit/ldap/internal/unboundid/LDAPConnectionProxy.java

File renamed without changes.

0 commit comments

Comments
 (0)