Skip to content
Closed
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
24 changes: 21 additions & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,23 @@
language: java

jdk:
- oraclejdk8
matrix:
include:
- jdk: oraclejdk8
env: JDK='Oracle JDK 8'
- jdk: oraclejdk9
env: JDK='Oracle JDK 9'
- env:
- JDK='Oracle JDK 10'
- NO_JACOCO='true'
before_install: wget https://github.com/sormuras/bach/raw/master/install-jdk.sh && . ./install-jdk.sh -F 10 -L BCL
- env:
- JDK='Oracle JDK 11'
- NO_JACOCO='true'
before_install: wget https://github.com/sormuras/bach/raw/master/install-jdk.sh && . ./install-jdk.sh -F 11 -L BCL
allow_failures:
- env:
- JDK='Oracle JDK 11'
- NO_JACOCO='true'

addons:
apt:
Expand All @@ -19,4 +35,6 @@ services:

install: true

script: "mvn clean dependency:list test -Pall-dbs -Dsort -U"
script:
- "mvn -version"
- "mvn clean dependency:list test -Pall-dbs${NO_JACOCO:+',no-jacoco'} -Dsort -U"
41 changes: 33 additions & 8 deletions pom.xml
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">

<modelVersion>4.0.0</modelVersion>

<groupId>org.springframework.data</groupId>
<artifactId>spring-data-jdbc</artifactId>
<version>1.0.0.BUILD-SNAPSHOT</version>
<groupId>org.springframework.data</groupId>
<artifactId>spring-data-jdbc</artifactId>
<version>1.0.0.DATAJDBC-246-SNAPSHOT</version>

<name>Spring Data JDBC</name>
<description>Spring Data module for JDBC repositories.</description>
Expand Down Expand Up @@ -78,6 +79,25 @@
</build>
</profile>

<profile>
<id>no-jacoco</id>
<build>
<plugins>
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<executions>
<execution>
<id>jacoco-initialize</id>
<phase>none</phase>
</execution>
</executions>
</plugin>
</plugins>
</build>

</profile>

<profile>
<id>all-dbs</id>
<build>
Expand Down Expand Up @@ -223,10 +243,10 @@
</dependency>

<dependency>
<groupId>org.mariadb.jdbc</groupId>
<artifactId>mariadb-java-client</artifactId>
<version>${mariadb-java-client.version}</version>
<scope>test</scope>
<groupId>org.mariadb.jdbc</groupId>
<artifactId>mariadb-java-client</artifactId>
<version>${mariadb-java-client.version}</version>
<scope>test</scope>
</dependency>

<dependency>
Expand Down Expand Up @@ -273,6 +293,11 @@
<artifactId>maven-surefire-plugin</artifactId>
<version>2.12</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<version>3.1.0</version>
</plugin>
</plugins>
</pluginManagement>
<plugins>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Primary;
import org.springframework.context.annotation.Profile;
import org.springframework.data.annotation.CreatedBy;
import org.springframework.data.annotation.CreatedDate;
import org.springframework.data.annotation.Id;
Expand Down Expand Up @@ -70,13 +69,19 @@ public void auditForAnnotatedEntity() {

AuditingAnnotatedDummyEntity entity = repository.save(new AuditingAnnotatedDummyEntity());

softly.assertThat(entity.id).isNotNull();
softly.assertThat(entity.getCreatedBy()).isEqualTo("user01");
softly.assertThat(entity.getCreatedDate()).isAfter(now);
softly.assertThat(entity.getLastModifiedBy()).isEqualTo("user01");
softly.assertThat(entity.getLastModifiedDate()).isAfterOrEqualTo(entity.getCreatedDate());
softly.assertThat(entity.getLastModifiedDate()).isAfter(now);
softly.assertThat(repository.findById(entity.id).get()).isEqualTo(entity);
softly.assertThat(entity.id).as("id not null").isNotNull();
softly.assertThat(entity.getCreatedBy()).as("created by set").isEqualTo("user01");
softly.assertThat(entity.getCreatedDate()).as("created date set").isAfter(now);
softly.assertThat(entity.getLastModifiedBy()).as("modified by set").isEqualTo("user01");
softly.assertThat(entity.getLastModifiedDate()).as("modified date set").isAfterOrEqualTo(entity.getCreatedDate());
softly.assertThat(entity.getLastModifiedDate()).as("modified date after instance creation").isAfter(now);

AuditingAnnotatedDummyEntity reloaded = repository.findById(entity.id).get();

softly.assertThat(reloaded.getCreatedBy()).as("reload created by").isNotNull();
softly.assertThat(reloaded.getCreatedDate()).as("reload created date").isNotNull();
softly.assertThat(reloaded.getLastModifiedBy()).as("reload modified by").isNotNull();
softly.assertThat(reloaded.getLastModifiedDate()).as("reload modified date").isNotNull();

LocalDateTime beforeCreatedDate = entity.getCreatedDate();
LocalDateTime beforeLastModifiedDate = entity.getLastModifiedDate();
Expand All @@ -89,11 +94,19 @@ public void auditForAnnotatedEntity() {

entity = repository.save(entity);

softly.assertThat(entity.getCreatedBy()).isEqualTo("user01");
softly.assertThat(entity.getCreatedDate()).isEqualTo(beforeCreatedDate);
softly.assertThat(entity.getLastModifiedBy()).isEqualTo("user02");
softly.assertThat(entity.getLastModifiedDate()).isAfter(beforeLastModifiedDate);
softly.assertThat(repository.findById(entity.id).get()).isEqualTo(entity);
softly.assertThat(entity.getCreatedBy()).as("created by unchanged").isEqualTo("user01");
softly.assertThat(entity.getCreatedDate()).as("created date unchanged").isEqualTo(beforeCreatedDate);
softly.assertThat(entity.getLastModifiedBy()).as("modified by updated").isEqualTo("user02");
softly.assertThat(entity.getLastModifiedDate()).as("modified date updated").isAfter(beforeLastModifiedDate);

reloaded = repository.findById(entity.id).get();

softly.assertThat(reloaded.getCreatedBy()).as("2. reload created by").isNotNull();
softly.assertThat(reloaded.getCreatedDate()).as("2. reload created date").isNotNull();
softly.assertThat(reloaded.getLastModifiedBy()).as("2. reload modified by").isNotNull();
softly.assertThat(reloaded.getLastModifiedDate()).as("2. reload modified date").isNotNull();

softly.assertAll();
});
}

Expand Down