[BAEL-3936] Merged with upstream and fixed conflicts
This commit is contained in:
@@ -139,7 +139,7 @@
|
||||
|
||||
<properties>
|
||||
<hibernate.version>5.4.14.Final</hibernate.version>
|
||||
<eclipselink.version>2.7.4-RC1</eclipselink.version>
|
||||
<eclipselink.version>2.7.4</eclipselink.version>
|
||||
<postgres.version>42.2.5</postgres.version>
|
||||
<javax.persistence-api.version>2.2</javax.persistence-api.version>
|
||||
<assertj.version>3.11.1</assertj.version>
|
||||
|
||||
@@ -106,7 +106,7 @@
|
||||
|
||||
<properties>
|
||||
<hibernate.version>5.4.0.Final</hibernate.version>
|
||||
<eclipselink.version>2.7.4-RC1</eclipselink.version>
|
||||
<eclipselink.version>2.7.4</eclipselink.version>
|
||||
<postgres.version>42.2.5</postgres.version>
|
||||
<javax.persistence-api.version>2.2</javax.persistence-api.version>
|
||||
<maven-processor-plugin.version>3.3.3</maven-processor-plugin.version>
|
||||
|
||||
@@ -9,9 +9,9 @@
|
||||
|
||||
<parent>
|
||||
<groupId>com.baeldung</groupId>
|
||||
<artifactId>parent-boot-1</artifactId>
|
||||
<artifactId>parent-boot-2</artifactId>
|
||||
<version>0.0.1-SNAPSHOT</version>
|
||||
<relativePath>../../parent-boot-1</relativePath>
|
||||
<relativePath>../../parent-boot-2</relativePath>
|
||||
</parent>
|
||||
|
||||
<dependencyManagement>
|
||||
@@ -19,7 +19,7 @@
|
||||
<dependency>
|
||||
<groupId>org.springframework.data</groupId>
|
||||
<artifactId>spring-data-releasetrain</artifactId>
|
||||
<version>Hopper-SR10</version>
|
||||
<version>Lovelace-SR16</version>
|
||||
<type>pom</type>
|
||||
<scope>import</scope>
|
||||
</dependency>
|
||||
@@ -174,7 +174,7 @@
|
||||
<start-class>com.baeldung.Application</start-class>
|
||||
<spring.version>4.3.4.RELEASE</spring.version>
|
||||
<httpclient.version>4.5.2</httpclient.version>
|
||||
<spring-data-dynamodb.version>4.4.1</spring-data-dynamodb.version>
|
||||
<spring-data-dynamodb.version>5.1.0</spring-data-dynamodb.version>
|
||||
<aws-java-sdk-dynamodb.version>1.11.64</aws-java-sdk-dynamodb.version>
|
||||
<bootstrap.version>3.3.7-1</bootstrap.version>
|
||||
<sqlite4java.version>1.0.392</sqlite4java.version>
|
||||
|
||||
+2
-2
@@ -44,8 +44,8 @@ public class DynamoDBConfig {
|
||||
return new BasicAWSCredentials(amazonAWSAccessKey, amazonAWSSecretKey);
|
||||
}
|
||||
|
||||
@Bean(name = "mvcHandlerMappingIntrospector")
|
||||
public HandlerMappingIntrospector mvcHandlerMappingIntrospector() {
|
||||
@Bean(name = "mvcHandlerMappingIntrospectorCustom")
|
||||
public HandlerMappingIntrospector mvcHandlerMappingIntrospectorCustom() {
|
||||
return new HandlerMappingIntrospector(context);
|
||||
}
|
||||
}
|
||||
|
||||
+4
-3
@@ -1,12 +1,13 @@
|
||||
package com.baeldung.spring.data.dynamodb.repositories;
|
||||
|
||||
import com.baeldung.spring.data.dynamodb.model.ProductInfo;
|
||||
import java.util.Optional;
|
||||
|
||||
import org.socialsignin.spring.data.dynamodb.repository.EnableScan;
|
||||
import org.springframework.data.repository.CrudRepository;
|
||||
|
||||
import java.util.List;
|
||||
import com.baeldung.spring.data.dynamodb.model.ProductInfo;
|
||||
|
||||
@EnableScan
|
||||
public interface ProductInfoRepository extends CrudRepository<ProductInfo, String> {
|
||||
List<ProductInfo> findById(String id);
|
||||
Optional<ProductInfo> findById(String id);
|
||||
}
|
||||
|
||||
@@ -13,3 +13,12 @@
|
||||
- [Spring Data Annotations](http://www.baeldung.com/spring-data-annotations)
|
||||
- [Spring Data MongoDB Transactions](https://www.baeldung.com/spring-data-mongodb-transactions )
|
||||
- [ZonedDateTime with Spring Data MongoDB](https://www.baeldung.com/spring-data-mongodb-zoneddatetime)
|
||||
|
||||
|
||||
## Spring Data MongoDB Live Testing
|
||||
|
||||
|
||||
There are 3 scripts to simplify running live tests:
|
||||
1. [`live-test-setup.sh`](src/live-test/resources/live-test-setup.sh) builds a docker image with the necessary setup and runs it. The environment is ready, when the log stops - it takes approximately 30 seconds.
|
||||
2. [`live-test.sh`](src/live-test/resources/live-test.sh) runs the live tests (but no other tests).
|
||||
3. [`live-test-teardown.sh`](src/live-test/resources/live-test-teardown.sh) stops and removes the docker image.
|
||||
|
||||
@@ -0,0 +1,8 @@
|
||||
FROM mongo:4.2.1
|
||||
|
||||
COPY init-session.js /docker-entrypoint-initdb.d/
|
||||
|
||||
EXPOSE 27017
|
||||
|
||||
HEALTHCHECK --interval=5s --timeout=3s --start-period=10s CMD mongo db.stats()
|
||||
CMD ["mongod", "--replSet", "rs0"]
|
||||
@@ -0,0 +1 @@
|
||||
rs.initiate();
|
||||
@@ -0,0 +1,5 @@
|
||||
#!/bin/bash
|
||||
|
||||
docker image build -t spring-data-mongodb:live-test .
|
||||
|
||||
docker run -p 27017:27017 --name spring-data-mongodb-live-test spring-data-mongodb:live-test
|
||||
@@ -0,0 +1,4 @@
|
||||
#!/bin/bash
|
||||
|
||||
docker stop spring-data-mongodb-live-test
|
||||
docker rm spring-data-mongodb-live-test
|
||||
@@ -0,0 +1,3 @@
|
||||
#!/bin/bash
|
||||
|
||||
mvn clean compile test -P live-all -f ../../../pom.xml
|
||||
-18
@@ -62,24 +62,6 @@ public class MongoTransactionalLiveTest {
|
||||
}
|
||||
}
|
||||
|
||||
@Test(expected = MongoCommandException.class)
|
||||
@Transactional
|
||||
public void whenCountDuringMongoTransaction_thenException() {
|
||||
userRepository.save(new User("John", 30));
|
||||
userRepository.save(new User("Ringo", 35));
|
||||
userRepository.count();
|
||||
}
|
||||
|
||||
@Test
|
||||
@Transactional
|
||||
public void whenQueryDuringMongoTransaction_thenSuccess() {
|
||||
userRepository.save(new User("Jane", 20));
|
||||
userRepository.save(new User("Nick", 33));
|
||||
List<User> users = mongoTemplate.find(new Query(), User.class);
|
||||
|
||||
assertTrue(users.size() > 1);
|
||||
}
|
||||
|
||||
// ==== Using test instead of before and after due to @transactional doesn't allow list collection
|
||||
|
||||
@Test
|
||||
|
||||
Reference in New Issue
Block a user