diff --git a/dependencies/build.gradle b/dependencies/build.gradle
index 724e097f..42224dd8 100644
--- a/dependencies/build.gradle
+++ b/dependencies/build.gradle
@@ -26,6 +26,7 @@ dependencies {
api "commons-pool:commons-pool:1.6"
api "org.apache.commons:commons-pool2:2.4.2"
api "ch.qos.logback:logback-classic:1.2.6"
+ api "com.google.code.typica:typica:1.3"
api "com.google.inject:guice:3.0"
api "com.nimbusds:nimbus-jose-jwt:9.14"
api "com.nimbusds:oauth2-oidc-sdk:9.18"
@@ -45,6 +46,7 @@ dependencies {
api "jakarta.servlet:jakarta.servlet-api:5.0.0"
api "jakarta.xml.bind:jakarta.xml.bind-api:3.0.1"
api "jakarta.persistence:jakarta.persistence-api:3.0.0"
+ api "javax.activation:activation:1.1"
api "ldapsdk:ldapsdk:4.1"
api "net.sourceforge.htmlunit:htmlunit:2.54.0"
api "net.sourceforge.nekohtml:nekohtml:1.9.22"
diff --git a/settings.gradle b/settings.gradle
index 669ba3f3..76c78b14 100644
--- a/settings.gradle
+++ b/settings.gradle
@@ -25,7 +25,7 @@ rootProject.name = 'spring-ldap'
include 'core'
include 'core-tiger'
include 'dependencies'
-//include 'test-support'
+include 'test-support'
include 'ldif/ldif-core'
//include 'odm'
////include 'sandbox'
@@ -50,4 +50,4 @@ rootProject.children.each { p->
p.name = "spring-ldap-" + name
}
-//findProject(":spring-ldap-test-support").name = "spring-ldap-test"
\ No newline at end of file
+findProject(":spring-ldap-test-support").name = "spring-ldap-test"
\ No newline at end of file
diff --git a/test-support/build.gradle b/test-support/build.gradle
index aff8c613..dd6acbff 100644
--- a/test-support/build.gradle
+++ b/test-support/build.gradle
@@ -3,19 +3,28 @@ plugins {
}
dependencies {
+ management platform(project(":spring-ldap-dependencies"))
implementation project(":spring-ldap-core"),
project(":spring-ldap-ldif-core"),
- "com.google.code.typica:typica:1.3",
+ "com.google.code.typica:typica",
"commons-io:commons-io",
- "javax.activation:activation:1.1",
+ "javax.activation:activation",
"org.springframework:spring-core",
"org.springframework:spring-beans",
"org.springframework:spring-context",
"org.springframework:spring-test"
- optional apachedsDependencies
+ optional "org.apache.directory.server:apacheds-core-entry"
+ optional "org.apache.directory.server:apacheds-core"
+ optional "org.apache.directory.server:apacheds-protocol-ldap"
+ optional "org.apache.directory.server:apacheds-protocol-shared"
+ optional "org.apache.directory.server:apacheds-server-jndi"
+ optional "org.apache.directory.shared:shared-ldap"
optional "com.unboundid:unboundid-ldapsdk"
provided "junit:junit"
+ testImplementation platform('org.junit:junit-bom')
+ testImplementation "org.junit.vintage:junit-vintage-engine"
+ testImplementation "org.assertj:assertj-core"
}
diff --git a/test-support/src/test/java/org/apache/directory/server/core/avltree/ArrayMarshaller.java b/test-support/src/test/java/org/apache/directory/server/core/avltree/ArrayMarshaller.java
new file mode 100644
index 00000000..f322c879
--- /dev/null
+++ b/test-support/src/test/java/org/apache/directory/server/core/avltree/ArrayMarshaller.java
@@ -0,0 +1,173 @@
+/*
+ * Copyright 2002-2021 the original author or authors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * https://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.directory.server.core.avltree;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.DataInputStream;
+import java.io.DataOutputStream;
+import java.io.IOException;
+import java.util.Comparator;
+
+import org.apache.directory.shared.ldap.util.StringTools;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * Class to serialize the Array data.
+ *
+ * @author Apache Directory Project
+ * @version $Rev$, $Date$
+ */
+@SuppressWarnings("unchecked")
+public class ArrayMarshaller implements Marshaller> {
+
+ /** static logger */
+ private static final Logger LOG = LoggerFactory.getLogger(ArrayMarshaller.class);
+
+ /** used for serialized form of an empty AvlTree */
+ private static final byte[] EMPTY_TREE = new byte[1];
+
+ /** marshaller to be used for marshalling the keys */
+ private Marshaller keyMarshaller;
+
+ /** key Comparator for the AvlTree */
+ private Comparator comparator;
+
+ /**
+ * Creates a new instance of AvlTreeMarshaller with a custom key Marshaller.
+ * @param comparator Comparator to be used for key comparision
+ * @param keyMarshaller marshaller for keys
+ */
+ public ArrayMarshaller(Comparator comparator, Marshaller keyMarshaller) {
+ this.comparator = comparator;
+ this.keyMarshaller = keyMarshaller;
+ }
+
+ /**
+ * Creates a new instance of AvlTreeMarshaller with the default key Marshaller which
+ * uses Java Serialization.
+ * @param comparator Comparator to be used for key comparision
+ */
+ public ArrayMarshaller(Comparator comparator) {
+ this.comparator = comparator;
+ this.keyMarshaller = DefaultMarshaller.INSTANCE;
+ }
+
+ /**
+ * Marshals the given tree to bytes
+ * @param tree the tree to be marshalled
+ */
+ public byte[] serialize(ArrayTree tree) {
+ if ((tree == null) || (tree.size() == 0)) {
+ return EMPTY_TREE;
+ }
+
+ ByteArrayOutputStream byteStream = new ByteArrayOutputStream();
+ DataOutputStream out = new DataOutputStream(byteStream);
+ byte[] data = null;
+
+ try {
+ out.writeByte(0); // represents the start of an Array byte stream
+ out.writeInt(tree.size());
+
+ for (int position = 0; position < tree.size(); position++) {
+ E value = tree.get(position);
+ byte[] bytes = this.keyMarshaller.serialize(value);
+
+ // Write the key length
+ out.writeInt(bytes.length);
+
+ // Write the key if its length is not null
+ if (bytes.length != 0) {
+ out.write(bytes);
+ }
+ }
+
+ out.flush();
+ data = byteStream.toByteArray();
+
+ // Try to deserialize, just to see
+ try {
+ deserialize(data);
+ }
+ catch (NullPointerException npe) {
+ System.out.println("Bad serialization, tree : [" + StringTools.dumpBytes(data) + "]");
+ throw npe;
+ }
+
+ out.close();
+ }
+ catch (IOException ex) {
+ ex.printStackTrace();
+ }
+
+ return data;
+ }
+
+ /**
+ * Creates an Array from given bytes of data.
+ * @param data byte array to be converted into an array
+ */
+ public ArrayTree deserialize(byte[] data) throws IOException {
+ try {
+ if ((data == null) || (data.length == 0)) {
+ throw new IOException("Null or empty data array is invalid.");
+ }
+
+ if ((data.length == 1) && (data[0] == 0)) {
+ E[] array = (E[]) new Object[] {};
+ ArrayTree tree = new ArrayTree(this.comparator, array);
+ return tree;
+ }
+
+ ByteArrayInputStream bin = new ByteArrayInputStream(data);
+ DataInputStream din = new DataInputStream(bin);
+
+ byte startByte = din.readByte();
+
+ if (startByte != 0) {
+ throw new IOException("wrong array serialized data format");
+ }
+
+ int size = din.readInt();
+ E[] nodes = (E[]) new Object[size];
+
+ for (int i = 0; i < size; i++) {
+ // Read the object's size
+ int dataSize = din.readInt();
+
+ if (dataSize != 0) {
+ byte[] bytes = new byte[dataSize];
+
+ din.read(bytes);
+ E key = this.keyMarshaller.deserialize(bytes);
+ nodes[i] = key;
+ }
+ }
+
+ ArrayTree arrayTree = new ArrayTree(this.comparator, nodes);
+
+ return arrayTree;
+ }
+ catch (NullPointerException npe) {
+ System.out.println("Bad tree : [" + StringTools.dumpBytes(data) + "]");
+ throw npe;
+ }
+ }
+
+}