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
2 changes: 0 additions & 2 deletions eng/versioning/external_dependencies.txt
Original file line number Diff line number Diff line change
Expand Up @@ -339,7 +339,6 @@ springboot3_io.projectreactor:reactor-test;3.7.9
springboot3_jakarta.servlet:jakarta.servlet-api;6.0.0
springboot3_jakarta.validation:jakarta.validation-api;3.0.2
springboot3_javax.annotation:javax.annotation-api;1.3.2
springboot3_junit:junit;4.13.2
springboot3_net.bytebuddy:byte-buddy-agent;1.17.7
springboot3_net.bytebuddy:byte-buddy;1.17.7
springboot3_org.apache.commons:commons-lang3;3.17.0
Expand All @@ -355,7 +354,6 @@ springboot3_org.assertj:assertj-core;3.27.4
springboot3_org.hibernate.validator:hibernate-validator;8.0.3.Final
springboot3_org.javatuples:javatuples;1.2
springboot3_org.junit.jupiter:junit-jupiter;5.12.2
springboot3_org.junit.vintage:junit-vintage-engine;5.12.2
springboot3_org.messaginghub:pooled-jms;3.1.7
springboot3_org.mockito:mockito-core;5.17.0
springboot3_org.postgresql:postgresql;42.7.7
Expand Down
18 changes: 0 additions & 18 deletions sdk/spring/azure-spring-data-cosmos/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -154,12 +154,6 @@
<version>1.17.7</version> <!-- {x-version-update;springboot3_net.bytebuddy:byte-buddy-agent;external_dependency} -->
<scope>test</scope>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.13.2</version> <!-- {x-version-update;springboot3_junit:junit;external_dependency} -->
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
Expand Down Expand Up @@ -202,18 +196,6 @@
<artifactId>slf4j-api</artifactId>
<version>2.0.17</version> <!-- {x-version-update;springboot3_org.slf4j:slf4j-api;external_dependency} -->
</dependency>
<dependency>
<groupId>org.junit.vintage</groupId>
<artifactId>junit-vintage-engine</artifactId>
<version>5.12.2</version> <!-- {x-version-update;springboot3_org.junit.vintage:junit-vintage-engine;external_dependency} -->
<scope>test</scope>
<exclusions>
<exclusion>
<groupId>org.hamcrest</groupId>
<artifactId>hamcrest-core</artifactId>
</exclusion>
</exclusions>
</dependency>
</dependencies>

<build>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,6 @@
import com.azure.spring.data.cosmos.core.CosmosTemplate;
import com.azure.spring.data.cosmos.core.ReactiveCosmosTemplate;
import com.azure.spring.data.cosmos.repository.support.CosmosEntityInformation;
import org.junit.rules.TestRule;
import org.junit.runner.Description;
import org.junit.runners.model.Statement;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

Expand All @@ -19,7 +16,7 @@
import java.util.concurrent.ConcurrentMap;

@SuppressWarnings({"rawtypes", "unchecked"})
public abstract class AbstractIntegrationTestCollectionManager<T> implements TestRule {
public abstract class AbstractIntegrationTestCollectionManager<T> {

private static final Logger LOGGER = LoggerFactory.getLogger(AbstractIntegrationTestCollectionManager.class);
private static final Duration LEASE_DURATION = Duration.ofSeconds(5 * 60);
Expand Down Expand Up @@ -115,19 +112,6 @@ private void releaseLocks() {
}
}

@Override
public Statement apply(Statement base, Description description) {
return new Statement() {
public void evaluate() throws Throwable {
try {
base.evaluate();
} finally {
releaseLocks();
}
}
};
}

private static class ContainerRefs {

CosmosEntityInformation cosmosEntityInformation;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,21 +6,21 @@
import com.azure.spring.data.cosmos.domain.Address;
import com.azure.spring.data.cosmos.repository.TestRepositoryConfig;
import com.azure.spring.data.cosmos.repository.support.CosmosEntityInformation;
import org.junit.After;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.springframework.test.context.junit.jupiter.SpringExtension;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;

import java.time.Duration;
import java.time.OffsetDateTime;

import static org.junit.Assert.assertTrue;
import static org.junit.jupiter.api.Assertions.assertTrue;

@RunWith(SpringJUnit4ClassRunner.class)
@ExtendWith(SpringExtension.class)
@ContextConfiguration(classes = TestRepositoryConfig.class)
@SuppressWarnings({"rawtypes", "unchecked"})
public class ContainerLockIT {
Expand All @@ -36,7 +36,7 @@ public class ContainerLockIT {
private ContainerLock lock;
private ContainerLock otherLock;

@Before
@BeforeEach
public void setup() {
staticTemplate = template;
CosmosEntityInformation entityInfo = new CosmosEntityInformation(Address.class);
Expand All @@ -46,7 +46,7 @@ public void setup() {
otherLock = new ContainerLock(reactiveTemplate, entityInfo.getContainerName(), SHORT_LEASE_DURATION);
}

@After
@AfterEach
public void cleanup() {
releaseLockIgnoreException(lock);
releaseLockIgnoreException(otherLock);
Expand Down Expand Up @@ -81,7 +81,7 @@ public void acquireShouldThrowExceptionIfWaitForIsLessThanLeaseDuration() {

try {
otherLock.acquire(SHORT_LEASE_DURATION.minusSeconds(1));
Assert.fail();
Assertions.fail();
} catch (ContainerLock.LockAcquisitionFailedException ex) {
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,17 @@
import com.azure.cosmos.CosmosAsyncClient;
import com.azure.cosmos.CosmosClientBuilder;
import com.azure.spring.data.cosmos.repository.TestRepositoryConfig;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.springframework.test.context.junit.jupiter.SpringExtension;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;

import java.lang.reflect.Field;

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

@RunWith(SpringJUnit4ClassRunner.class)
@ExtendWith(SpringExtension.class)
@ContextConfiguration(classes = TestRepositoryConfig.class)
public class CosmosFactoryTestIT {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@
// Licensed under the MIT License.
package com.azure.spring.data.cosmos.common;

import org.junit.Test;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.config.ConfigurableBeanFactory;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.PropertySource;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNotNull;

public class ExpressionResolverUnitTest {
private static final String LITERAL_EXPRESSION = "literal expression";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,16 @@
// Licensed under the MIT License.
package com.azure.spring.data.cosmos.common;

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

import java.util.HashMap;
import java.util.Map;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.function.Function;
import java.util.stream.IntStream;

import static org.junit.Assert.assertEquals;
import static org.junit.jupiter.api.Assertions.assertEquals;

public class MemoizerUnitTest {

Expand All @@ -20,7 +20,7 @@ public class MemoizerUnitTest {
private static final Function<String, Integer> MEMOIZED_FUNCTION =
Memoizer.memoize(MemoizerUnitTest::incrCount);

@Before
@BeforeEach
public void setUp() {
COUNT_MAP.put(KEY, new AtomicInteger(0));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
import org.springframework.data.domain.Pageable;

import static org.assertj.core.api.Assertions.assertThat;
import static org.junit.Assert.assertTrue;
import static org.junit.jupiter.api.Assertions.assertTrue;

public class PageTestUtils {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,17 @@
// Licensed under the MIT License.
package com.azure.spring.data.cosmos.common;

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

public class PropertyLoaderUnitTest {

@Test
public void testGetProjectVersion() {
final String version = PropertyLoader.getProjectVersion();

Assert.assertNotNull(version);
Assert.assertNotEquals(version, "");
Assert.assertNotEquals(version, "@project.version@");
Assertions.assertNotNull(version);
Assertions.assertNotEquals(version, "");
Assertions.assertNotEquals(version, "@project.version@");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,7 @@
import com.azure.spring.data.cosmos.common.ExpressionResolver;
import com.azure.spring.data.cosmos.common.TestConstants;
import com.fasterxml.jackson.databind.ObjectMapper;
import org.assertj.core.api.Assertions;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.ExpectedException;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.NoSuchBeanDefinitionException;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
Expand All @@ -26,13 +23,13 @@

import java.lang.reflect.Field;

import static org.junit.Assert.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.assertj.core.api.Assertions.assertThat;
import static org.junit.jupiter.api.Assertions.assertThrows;

public class AbstractCosmosConfigurationIT {

@SuppressWarnings("deprecation")
@Rule
public ExpectedException exception = ExpectedException.none();


@Test
public void containsExpressionResolver() {
Expand All @@ -47,24 +44,26 @@ public void containsCosmosFactory() {
final AbstractApplicationContext context = new AnnotationConfigApplicationContext(
TestCosmosConfiguration.class);

Assertions.assertThat(context.getBean(CosmosFactory.class)).isNotNull();
assertThat(context.getBean(CosmosFactory.class)).isNotNull();
}

@Test(expected = NoSuchBeanDefinitionException.class)
@Test
public void defaultObjectMapperBeanNotExists() {
final AbstractApplicationContext context = new AnnotationConfigApplicationContext(
TestCosmosConfiguration.class);
assertThrows(NoSuchBeanDefinitionException.class, () -> {
final AbstractApplicationContext context = new AnnotationConfigApplicationContext(
TestCosmosConfiguration.class);

context.getBean(ObjectMapper.class);
context.getBean(ObjectMapper.class);
});
}

@Test
public void objectMapperIsConfigurable() {
final AbstractApplicationContext context = new AnnotationConfigApplicationContext(
ObjectMapperConfiguration.class);

Assertions.assertThat(context.getBean(ObjectMapper.class)).isNotNull();
Assertions.assertThat(context.getBean(Constants.OBJECT_MAPPER_BEAN_NAME)).isNotNull();
assertThat(context.getBean(ObjectMapper.class)).isNotNull();
assertThat(context.getBean(Constants.OBJECT_MAPPER_BEAN_NAME)).isNotNull();
}

@Test
Expand All @@ -73,16 +72,16 @@ public void testCosmosClientBuilderConfigurable() throws IllegalAccessException,
RequestOptionsConfiguration.class);
final CosmosFactory factory = context.getBean(CosmosFactory.class);

Assertions.assertThat(factory).isNotNull();
assertThat(factory).isNotNull();

final CosmosAsyncClient cosmosAsyncClient = factory.getCosmosAsyncClient();

Assertions.assertThat(cosmosAsyncClient).isNotNull();
assertThat(cosmosAsyncClient).isNotNull();
Field desiredConsistencyLevel = cosmosAsyncClient.getClass().getDeclaredField("desiredConsistencyLevel");
desiredConsistencyLevel.setAccessible(true);
ConsistencyLevel consistencyLevel =
(ConsistencyLevel) desiredConsistencyLevel.get(cosmosAsyncClient);
Assertions.assertThat(consistencyLevel).isEqualTo(ConsistencyLevel.CONSISTENT_PREFIX);
assertThat(consistencyLevel).isEqualTo(ConsistencyLevel.CONSISTENT_PREFIX);
}

@Configuration
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,16 @@
import com.azure.spring.data.cosmos.Constants;
import com.azure.spring.data.cosmos.CosmosFactory;
import com.azure.spring.data.cosmos.common.PropertyLoader;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.junit.MockitoJUnitRunner;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.mockito.junit.jupiter.MockitoExtension;

import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;

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

@RunWith(MockitoJUnitRunner.class)
@ExtendWith(MockitoExtension.class)
public class CosmosFactoryUnitTest {

@Test
Expand Down
Loading
Loading