Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions core/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -38,13 +38,13 @@ dependencies {
exclude group: 'org.assertj'
}
testImplementation platform('org.junit:junit-bom')
testImplementation "org.junit.vintage:junit-vintage-engine"
testImplementation "org.junit.jupiter:junit-jupiter-api"
testImplementation "org.junit.jupiter:junit-jupiter-engine"
testRuntimeOnly("org.junit.platform:junit-platform-launcher")

testImplementation "junit:junit"
testImplementation "commons-lang:commons-lang"
testImplementation "gsbase:gsbase"
testImplementation "org.mockito:mockito-core"
testImplementation "org.mockito:mockito-junit-jupiter:4.11.0"
testImplementation "org.springframework:spring-test"
testImplementation "org.assertj:assertj-core"
testImplementation "com.unboundid:unboundid-ldapsdk"
Expand All @@ -60,6 +60,7 @@ compileTestJava {

test {
jvmArgs '--add-exports', 'java.naming/com.sun.jndi.ldap=ALL-UNNAMED'
useJUnitPlatform()
}

checkFormatMain {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@

import javax.naming.directory.InitialDirContext;

import org.junit.Test;
import org.junit.jupiter.api.Test;

import static org.assertj.core.api.Assertions.assertThat;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@
import javax.naming.ldap.SortResponseControl;
import javax.net.ssl.SSLSocketFactory;

import org.junit.Before;
import org.junit.Test;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;

import org.springframework.aot.hint.MemberCategory;
import org.springframework.aot.hint.RuntimeHints;
Expand All @@ -44,7 +44,7 @@ public class LdapCoreRuntimeHintsTests {

private final RuntimeHints hints = new RuntimeHints();

@Before
@BeforeEach
public void setup() {
SpringFactoriesLoader.forResourceLocation("META-INF/spring/aot.factories")
.load(RuntimeHintsRegistrar.class)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@

package org.springframework.ldap.authentication;

import org.junit.Before;
import org.junit.Test;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;

import org.springframework.ldap.core.AuthenticationSource;

Expand All @@ -36,7 +36,7 @@ public class DefaultValuesAuthenticationSourceDecoratorTests {

private AuthenticationSource authenticationSourceMock;

@Before
@BeforeEach
public void setUp() throws Exception {
this.authenticationSourceMock = mock(AuthenticationSource.class);
this.tested = new DefaultValuesAuthenticationSourceDecorator();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@

import org.apache.commons.pool.impl.GenericKeyedObjectPool;
import org.apache.commons.pool2.impl.GenericKeyedObjectPoolConfig;
import org.junit.Test;
import org.junit.jupiter.api.Test;

import org.springframework.beans.BeansException;
import org.springframework.context.support.ClassPathXmlApplicationContext;
Expand Down Expand Up @@ -97,19 +97,22 @@ public void verifyThatAnonymousReadOnlyContextWillNotBeWrappedInProxy() {
assertThat(Boolean.TRUE).isEqualTo(getInternalState(contextSource, "anonymousReadOnly"));
}

@Test(expected = BeansException.class)
@Test
public void verifyThatAnonymousReadOnlyAndTransactionalThrowsException() {
new ClassPathXmlApplicationContext("/ldap-namespace-config-anonymous-read-only-and-transactions.xml");
assertThatExceptionOfType(BeansException.class).isThrownBy(() -> new ClassPathXmlApplicationContext(
"/ldap-namespace-config-anonymous-read-only-and-transactions.xml"));
}

@Test(expected = BeansException.class)
@Test
public void verifyThatMissingUsernameThrowsException() {
new ClassPathXmlApplicationContext("/ldap-namespace-config-missing-username.xml");
assertThatExceptionOfType(BeansException.class)
.isThrownBy(() -> new ClassPathXmlApplicationContext("/ldap-namespace-config-missing-username.xml"));
}

@Test(expected = BeansException.class)
@Test
public void verifyThatMissingPasswordThrowsException() {
new ClassPathXmlApplicationContext("/ldap-namespace-config-missing-password.xml");
assertThatExceptionOfType(BeansException.class)
.isThrownBy(() -> new ClassPathXmlApplicationContext("/ldap-namespace-config-missing-password.xml"));
}

@Test
Expand Down Expand Up @@ -366,9 +369,10 @@ public void verifyParsePoolingValidationSet() {
assertThat(nonTransientExceptions.contains(CannotProceedException.class)).isTrue();
}

@Test(expected = BeansException.class)
@Test
public void verifyParseWithPoolingAndNativePoolingWillFail() {
new ClassPathXmlApplicationContext("/ldap-namespace-config-pooling-with-native.xml");
assertThatExceptionOfType(BeansException.class)
.isThrownBy(() -> new ClassPathXmlApplicationContext("/ldap-namespace-config-pooling-with-native.xml"));
}

@Test
Expand Down Expand Up @@ -494,14 +498,16 @@ public void verifyParsePool2ValidationSet() {
assertThat(nonTransientExceptions.contains(CannotProceedException.class)).isTrue();
}

@Test(expected = BeansException.class)
@Test
public void verifyParseWithPool2AndNativePoolingWillFail() {
new ClassPathXmlApplicationContext("/ldap-namespace-config-pool2-with-native.xml");
assertThatExceptionOfType(BeansException.class)
.isThrownBy(() -> new ClassPathXmlApplicationContext("/ldap-namespace-config-pool2-with-native.xml"));
}

@Test(expected = BeansException.class)
@Test
public void verifyParseWithPool1AndPool2WillFail() {
new ClassPathXmlApplicationContext("/ldap-namespace-config-pool2-with-pool1.xml");
assertThatExceptionOfType(BeansException.class)
.isThrownBy(() -> new ClassPathXmlApplicationContext("/ldap-namespace-config-pool2-with-pool1.xml"));
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
import javax.naming.ldap.PagedResultsControl;

import com.gargoylesoftware.base.testing.EqualsTester;
import org.junit.Test;
import org.junit.jupiter.api.Test;

/**
* Unit tests for the PagedResult class. {@link PagedResultsControl}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
package org.springframework.ldap.control;

import com.gargoylesoftware.base.testing.EqualsTester;
import org.junit.Test;
import org.junit.jupiter.api.Test;

public class PagedResultsCookieTests {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,9 @@
import com.sun.jndi.ldap.BerDecoder;
import com.sun.jndi.ldap.BerEncoder;
import com.sun.jndi.ldap.ctl.DirSyncResponseControl;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;

import static org.assertj.core.api.Assertions.assertThat;
import static org.mockito.BDDMockito.given;
Expand All @@ -41,7 +41,7 @@ public class PagedResultsDirContextProcessorTests {

private PagedResultsDirContextProcessor tested;

@Before
@BeforeEach
public void setUp() throws Exception {

this.tested = new PagedResultsDirContextProcessor(20);
Expand All @@ -50,7 +50,7 @@ public void setUp() throws Exception {
this.ldapContextMock = mock(LdapContext.class);
}

@After
@AfterEach
public void tearDown() throws Exception {

this.tested = null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,11 @@
import javax.naming.ldap.LdapContext;
import javax.naming.ldap.SortControl;

import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;

import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
import static org.mockito.BDDMockito.given;
import static org.mockito.BDDMockito.mock;
import static org.mockito.BDDMockito.verify;
Expand All @@ -42,7 +43,7 @@ public class RequestControlDirContextProcessorTests {

private DirContext dirContextMock;

@Before
@BeforeEach
public void setUp() throws Exception {
// Create requestControl mock
this.requestControlMock = mock(Control.class);
Expand All @@ -68,7 +69,7 @@ public void postProcess(DirContext ctx) throws NamingException {
};
}

@After
@AfterEach
public void tearDown() throws Exception {
this.requestControlMock = null;
this.requestControl2Mock = null;
Expand Down Expand Up @@ -125,9 +126,10 @@ public void testPreProcessWithNullControlsShouldAdd() throws NamingException {
verify(this.ldapContextMock).setRequestControls(new Control[] { this.requestControlMock });
}

@Test(expected = IllegalArgumentException.class)
public void testPreProcessWhenNotLdapContextShouldFail() throws Exception {
this.tested.preProcess(this.dirContextMock);
@Test
public void testPreProcessWhenNotLdapContextShouldFail() {
assertThatExceptionOfType(IllegalArgumentException.class)
.isThrownBy(() -> this.tested.preProcess(this.dirContextMock));
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@
import com.sun.jndi.ldap.BerDecoder;
import com.sun.jndi.ldap.BerEncoder;
import com.sun.jndi.ldap.ctl.DirSyncResponseControl;
import org.junit.Before;
import org.junit.Test;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;

import static org.assertj.core.api.Assertions.assertThat;
import static org.mockito.BDDMockito.given;
Expand All @@ -45,7 +45,7 @@ public class SortControlDirContextProcessorTests {

private SortControlDirContextProcessor tested;

@Before
@BeforeEach
public void setUp() throws Exception {
this.tested = new SortControlDirContextProcessor("key");

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@
import javax.naming.NameClassPair;
import javax.naming.NamingException;

import org.junit.Before;
import org.junit.Test;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;

import static org.assertj.core.api.Assertions.assertThat;

Expand All @@ -34,7 +34,7 @@ public class CollectingNameClassPairCallbackHandlerTests {

private NameClassPair expectedNameClassPair;

@Before
@BeforeEach
public void setUp() throws Exception {
this.expectedResult = new Object();
this.expectedNameClassPair = new NameClassPair(null, null);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,11 @@
import javax.naming.Binding;
import javax.naming.NamingException;

import org.junit.Before;
import org.junit.Test;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;

import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
import static org.mockito.BDDMockito.given;
import static org.mockito.BDDMockito.mock;

Expand All @@ -32,15 +33,16 @@ public class ContextMapperCallbackHandlerTests {

private ContextMapperCallbackHandler tested;

@Before
@BeforeEach
public void setUp() throws Exception {
this.mapperMock = mock(ContextMapper.class);
this.tested = new ContextMapperCallbackHandler(this.mapperMock);
}

@Test(expected = IllegalArgumentException.class)
@Test
public void testConstructorWithEmptyArgument() {
new ContextMapperCallbackHandler(null);
assertThatExceptionOfType(IllegalArgumentException.class)
.isThrownBy(() -> new ContextMapperCallbackHandler(null));
}

@Test
Expand All @@ -54,10 +56,12 @@ public void testGetObjectFromNameClassPair() throws NamingException {
assertThat(actualResult).isEqualTo(expectedResult);
}

@Test(expected = ObjectRetrievalException.class)
public void testGetObjectFromNameClassPairObjectRetrievalException() throws NamingException {
Binding expectedBinding = new Binding("some name", null);
this.tested.getObjectFromNameClassPair(expectedBinding);
@Test
public void testGetObjectFromNameClassPairObjectRetrievalException() {
assertThatExceptionOfType(ObjectRetrievalException.class).isThrownBy(() -> {
Binding expectedBinding = new Binding("some name", null);
this.tested.getObjectFromNameClassPair(expectedBinding);
});
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@
import javax.naming.directory.DirContext;
import javax.naming.ldap.LdapContext;

import org.junit.Before;
import org.junit.Test;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;

import org.springframework.ldap.LimitExceededException;
import org.springframework.ldap.PartialResultException;
Expand Down Expand Up @@ -64,7 +64,7 @@ public class DefaultLdapClientListTests {

private DefaultLdapClient tested;

@Before
@BeforeEach
public void setUp() throws Exception {
// Setup ContextSource mock
this.contextSourceMock = mock(ContextSource.class);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@
import javax.naming.directory.SearchResult;
import javax.naming.ldap.LdapContext;

import org.junit.Before;
import org.junit.Test;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.mockito.BDDMockito;

import org.springframework.LdapDataEntry;
Expand Down Expand Up @@ -56,7 +56,7 @@ public class DefaultLdapClientLookupTests {

private LdapClient tested;

@Before
@BeforeEach
public void setUp() throws Exception {
this.contextSourceMock = mock(ContextSource.class);
this.dirContextMock = mock(LdapContext.class);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@
import javax.naming.directory.DirContext;
import javax.naming.ldap.LdapContext;

import org.junit.Before;
import org.junit.Test;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;

import org.springframework.ldap.NameAlreadyBoundException;
import org.springframework.ldap.UncategorizedLdapException;
Expand Down Expand Up @@ -51,7 +51,7 @@ public class DefaultLdapClientRenameTests {

private LdapClient tested;

@Before
@BeforeEach
public void setUp() throws Exception {
// Setup ContextSource mock
this.contextSourceMock = mock(ContextSource.class);
Expand Down
Loading