Add test/integration-tests to build

Issue gh-610
This commit is contained in:
Josh Cummings
2022-01-12 10:11:46 -07:00
parent 943231ed08
commit c162fc9685
6 changed files with 207 additions and 19 deletions

View File

@@ -59,8 +59,8 @@ dependencies {
api "org.apache.directory.server:apacheds-server-jndi:1.5.5"
api "org.apache.directory.shared:shared-ldap:0.9.15"
api "org.apache.httpcomponents:httpclient:4.5.13"
api "org.aspectj:aspectjrt"
api "org.aspectj:aspectjweaver"
api "org.aspectj:aspectjrt:1.9.7"
api "org.aspectj:aspectjweaver:1.9.7"
api "org.assertj:assertj-core:3.21.0"
api "org.bouncycastle:bcpkix-jdk15on:1.69"
api "org.bouncycastle:bcprov-jdk15on:1.69"
@@ -89,6 +89,10 @@ dependencies {
api "org.slf4j:jcl-over-slf4j:1.7.32"
api "org.slf4j:log4j-over-slf4j:1.7.32"
api "org.slf4j:slf4j-api:1.7.32"
api "org.slf4j:slf4j-log4j12:1.7.32"
api "org.springframework.security:spring-security-config:6.0.0-SNAPSHOT"
api "org.springframework.security:spring-security-core:6.0.0-SNAPSHOT"
api "org.springframework.security:spring-security-ldap:6.0.0-SNAPSHOT"
api "org.springframework.ldap:spring-ldap-core:2.3.4.RELEASE"
api "org.synchronoss.cloud:nio-multipart-parser:1.1.0"
}

View File

@@ -29,7 +29,7 @@ include 'test-support'
include 'ldif/ldif-core'
include 'odm'
////include 'sandbox'
//include 'test/integration-tests'
include 'test/integration-tests'
//include 'test/integration-tests-spring20'
//include 'test/integration-tests-spring25'
//include 'test/integration-tests-spring30'

View File

@@ -16,6 +16,7 @@ sourceSets {
}
dependencies {
management platform(project(":spring-ldap-dependencies"))
implementation project(":spring-ldap-test"),
project(":spring-ldap-core-tiger")
@@ -35,22 +36,32 @@ dependencies {
exclude group: "org.springframework", module: "spring-aop"
}
provided "commons-pool:commons-pool",
"org.springframework:spring-jdbc",
"org.springframework:spring-orm"
provided "commons-pool:commons-pool"
provided "org.springframework:spring-jdbc"
provided "org.springframework:spring-orm"
testImplementation "org.springframework:spring-test",
"org.springframework:spring-aop",
"org.springframework:spring-expression",
"org.hibernate:hibernate-core",
"aspectj:aspectjrt:1.5.4",
"aspectj:aspectjweaver:1.5.4",
"hsqldb:hsqldb:1.8.0.7",
"junit:junit",
"org.springframework.security:spring-security-config",
"org.slf4j:slf4j-log4j12",
"org.assertj:assertj-core"
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"
testImplementation "org.springframework:spring-test"
testImplementation "org.springframework:spring-aop"
testImplementation "org.springframework:spring-expression"
testImplementation "org.hibernate:hibernate-core-jakarta"
testImplementation "org.aspectj:aspectjrt"
testImplementation "org.aspectj:aspectjweaver"
testImplementation "org.hsqldb:hsqldb"
testImplementation "junit:junit"
testImplementation "org.springframework.security:spring-security-config"
testImplementation "org.slf4j:slf4j-log4j12"
testImplementation "org.assertj:assertj-core"
testImplementation platform('org.junit:junit-bom')
testImplementation "org.junit.vintage:junit-vintage-engine"
testImplementation("org.springframework.security:spring-security-ldap") {
exclude group: "org.springframework.ldap", module: "spring-ldap-core"

View File

@@ -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 <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
* @version $Rev$, $Date$
*/
@SuppressWarnings("unchecked")
public class ArrayMarshaller<E> implements Marshaller<ArrayTree<E>> {
/** 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<E> keyMarshaller;
/** key Comparator for the AvlTree */
private Comparator<E> 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<E> comparator, Marshaller<E> 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<E> 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<E> 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<E> 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<E> tree = new ArrayTree<E>(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<E> arrayTree = new ArrayTree<E>(this.comparator, nodes);
return arrayTree;
}
catch (NullPointerException npe) {
System.out.println("Bad tree : [" + StringTools.dumpBytes(data) + "]");
throw npe;
}
}
}

View File

@@ -69,7 +69,7 @@ public class ContextSourceAndDataSourceTransactionManagerIntegrationTest extends
}
jdbcTemplate.execute("drop table PERSON if exists");
jdbcTemplate.execute("create table PERSON(fullname VARCHAR, lastname VARCHAR, description VARCHAR)");
jdbcTemplate.execute("create table PERSON(fullname VARCHAR(256), lastname VARCHAR(256), description VARCHAR(256))");
jdbcTemplate.update("insert into PERSON values(?, ?, ?)", new Object[] { "Some Person", "Person",
"Sweden, Company1, Some Person" });
}

View File

@@ -71,7 +71,7 @@ public class ContextSourceAndDataSourceTransactionManagerNamespaceITest extends
}
jdbcTemplate.execute("drop table PERSON if exists");
jdbcTemplate.execute("create table PERSON(fullname VARCHAR, lastname VARCHAR, description VARCHAR)");
jdbcTemplate.execute("create table PERSON(fullname VARCHAR(256), lastname VARCHAR(256), description VARCHAR(256))");
jdbcTemplate.update("insert into PERSON values(?, ?, ?)", new Object[] { "Some Person", "Person",
"Sweden, Company1, Some Person" });
}