Merge branch 'master' into BAEL-4183-dependency-management-in-gradle

This commit is contained in:
Simone Cusimano 2020-10-20 08:58:08 +02:00
commit b01576bac5
105 changed files with 335 additions and 368 deletions

View File

@ -10,4 +10,4 @@ This module contains articles about algorithms. Some classes of algorithms, e.g.
- [Introduction to Minimax Algorithm](https://www.baeldung.com/java-minimax-algorithm) - [Introduction to Minimax Algorithm](https://www.baeldung.com/java-minimax-algorithm)
- [How to Calculate Levenshtein Distance in Java?](https://www.baeldung.com/java-levenshtein-distance) - [How to Calculate Levenshtein Distance in Java?](https://www.baeldung.com/java-levenshtein-distance)
- [How to Find the Kth Largest Element in Java](https://www.baeldung.com/java-kth-largest-element) - [How to Find the Kth Largest Element in Java](https://www.baeldung.com/java-kth-largest-element)
- More articles: [[next -->]](/../algorithms-miscellaneous-2) - More articles: [[next -->]](/algorithms-miscellaneous-2)

View File

@ -14,4 +14,4 @@ This module contains articles about algorithms. Some classes of algorithms, e.g.
- [Displaying Money Amounts in Words](https://www.baeldung.com/java-money-into-words) - [Displaying Money Amounts in Words](https://www.baeldung.com/java-money-into-words)
- [A Collaborative Filtering Recommendation System in Java](https://www.baeldung.com/java-collaborative-filtering-recommendations) - [A Collaborative Filtering Recommendation System in Java](https://www.baeldung.com/java-collaborative-filtering-recommendations)
- [Implementing A* Pathfinding in Java](https://www.baeldung.com/java-a-star-pathfinding) - [Implementing A* Pathfinding in Java](https://www.baeldung.com/java-a-star-pathfinding)
- More articles: [[<-- prev]](/../algorithms-miscellaneous-1) [[next -->]](/../algorithms-miscellaneous-3) - More articles: [[<-- prev]](/algorithms-miscellaneous-1) [[next -->]](/algorithms-miscellaneous-3)

View File

@ -15,5 +15,5 @@ This module contains articles about algorithms. Some classes of algorithms, e.g.
- [Maximum Subarray Problem](https://www.baeldung.com/java-maximum-subarray) - [Maximum Subarray Problem](https://www.baeldung.com/java-maximum-subarray)
- [How to Merge Two Sorted Arrays](https://www.baeldung.com/java-merge-sorted-arrays) - [How to Merge Two Sorted Arrays](https://www.baeldung.com/java-merge-sorted-arrays)
- [Median of Stream of Integers using Heap](https://www.baeldung.com/java-stream-integers-median-using-heap) - [Median of Stream of Integers using Heap](https://www.baeldung.com/java-stream-integers-median-using-heap)
- More articles: [[<-- prev]](/../algorithms-miscellaneous-4) [[next -->]](/../algorithms-miscellaneous-6) - More articles: [[<-- prev]](/algorithms-miscellaneous-4) [[next -->]](/algorithms-miscellaneous-6)

View File

@ -10,4 +10,4 @@
- [Implementing a 2048 Solver in Java](https://www.baeldung.com/2048-java-solver) - [Implementing a 2048 Solver in Java](https://www.baeldung.com/2048-java-solver)
- [Finding Top K Elements in an Array](https://www.baeldung.com/java-array-top-elements) - [Finding Top K Elements in an Array](https://www.baeldung.com/java-array-top-elements)
- [Reversing a Linked List in Java](https://www.baeldung.com/java-reverse-linked-list) - [Reversing a Linked List in Java](https://www.baeldung.com/java-reverse-linked-list)
- More articles: [[<-- prev]](/../algorithms-miscellaneous-5) - More articles: [[<-- prev]](/algorithms-miscellaneous-5)

View File

@ -19,12 +19,12 @@ public class StudentDbService implements StudentService {
} }
public Student update(Student student) { public Student update(Student student) {
logger.log(Level.INFO, "Updating sutdent in DB..."); logger.log(Level.INFO, "Updating student in DB...");
return student; return student;
} }
public String delete(String registrationId) { public String delete(String registrationId) {
logger.log(Level.INFO, "Deleteing sutdent in DB..."); logger.log(Level.INFO, "Deleting student in DB...");
return registrationId; return registrationId;
} }
} }

View File

@ -33,11 +33,15 @@ public class HashSetBenchmark {
private List<Employee> employeeList1 = new ArrayList<>(); private List<Employee> employeeList1 = new ArrayList<>();
private Set<Employee> employeeSet2 = new HashSet<>(); private Set<Employee> employeeSet2 = new HashSet<>();
private List<Employee> employeeList2 = new ArrayList<>(); private List<Employee> employeeList2 = new ArrayList<>();
private Set<Employee> employeeSet3 = new HashSet<>();
private Set<Employee> employeeSet4 = new HashSet<>();
private long set1Size = 60000; private long set1Size = 60000;
private long list1Size = 50000; private long list1Size = 50000;
private long set2Size = 50000; private long set2Size = 50000;
private long list2Size = 60000; private long list2Size = 60000;
private long set3Size = 50000;
private long set4Size = 60000;
@Setup(Level.Trial) @Setup(Level.Trial)
public void setUp() { public void setUp() {
@ -58,6 +62,14 @@ public class HashSetBenchmark {
employeeList2.add(new Employee(i, RandomStringUtils.random(7, true, false))); employeeList2.add(new Employee(i, RandomStringUtils.random(7, true, false)));
} }
for (long i = 0; i < set3Size; i++) {
employeeSet3.add(new Employee(i, RandomStringUtils.random(7, true, false)));
}
for (long i = 0; i < set4Size; i++) {
employeeSet4.add(new Employee(i, RandomStringUtils.random(7, true, false)));
}
} }
} }
@ -72,6 +84,11 @@ public class HashSetBenchmark {
return state.employeeSet2.removeAll(state.employeeList2); return state.employeeSet2.removeAll(state.employeeList2);
} }
@Benchmark
public boolean given_SizeOfHashsetSmallerThanSizeOfAnotherHashSet_When_RemoveAllFromHashSet_Then_GoodPerformance(MyState state) {
return state.employeeSet3.removeAll(state.employeeSet4);
}
public static void main(String[] args) throws Exception { public static void main(String[] args) throws Exception {
Options options = new OptionsBuilder().include(HashSetBenchmark.class.getSimpleName()) Options options = new OptionsBuilder().include(HashSetBenchmark.class.getSimpleName())
.threads(1) .threads(1)

View File

@ -73,7 +73,7 @@ public class LivelockExample {
public void tryLock(Lock lock, long millis) { public void tryLock(Lock lock, long millis) {
try { try {
lock.tryLock(10, TimeUnit.MILLISECONDS); lock.tryLock(millis, TimeUnit.MILLISECONDS);
} catch (InterruptedException e) { } catch (InterruptedException e) {
e.printStackTrace(); e.printStackTrace();
} }

View File

@ -0,0 +1,37 @@
package com.baeldung.constantspatterns;
public class Calculator {
public static final double PI = 3.14159265359;
private static final double UPPER_LIMIT = 0x1.fffffffffffffP+1023;
public enum Operation {
ADD, SUBTRACT, DIVIDE, MULTIPLY
}
public double operateOnTwoNumbers(double numberOne, double numberTwo, Operation operation) {
if (numberOne > UPPER_LIMIT) {
throw new IllegalArgumentException("'numberOne' is too large");
}
if (numberTwo > UPPER_LIMIT) {
throw new IllegalArgumentException("'numberTwo' is too large");
}
double answer = 0;
switch (operation) {
case ADD:
answer = numberOne + numberTwo;
break;
case SUBTRACT:
answer = numberOne - numberTwo;
break;
case DIVIDE:
answer = numberOne / numberTwo;
break;
case MULTIPLY:
answer = numberOne * numberTwo;
break;
}
return answer;
}
}

View File

@ -0,0 +1,10 @@
package com.baeldung.constantspatterns;
public interface CalculatorConstants {
double PI = 3.14159265359;
double UPPER_LIMIT = 0x1.fffffffffffffP+1023;
enum Operation {
ADD, SUBTRACT, MULTIPLY, DIVIDE
};
}

View File

@ -0,0 +1,32 @@
package com.baeldung.constantspatterns;
public class GeometryCalculator implements CalculatorConstants {
public static final double UPPER_LIMIT = 100000000000000000000.0;
public double operateOnTwoNumbers(double numberOne, double numberTwo, Operation operation) {
if (numberOne > UPPER_LIMIT) {
throw new IllegalArgumentException("'numberOne' is too large");
}
if (numberTwo > UPPER_LIMIT) {
throw new IllegalArgumentException("'numberTwo' is too large");
}
double answer = 0;
switch (operation) {
case ADD:
answer = numberOne + numberTwo;
break;
case SUBTRACT:
answer = numberOne - numberTwo;
break;
case DIVIDE:
answer = numberOne / numberTwo;
break;
case MULTIPLY:
answer = numberOne * numberTwo;
break;
}
return answer;
}
}

View File

@ -0,0 +1,16 @@
package com.baeldung.constantspatterns.calculations;
public final class MathConstants {
public static final double PI = 3.14159265359;
static final double GOLDEN_RATIO = 1.6180;
static final double GRAVITATIONAL_ACCELERATION = 9.8;
static final double EULERS_NUMBER = 2.7182818284590452353602874713527;
public enum Operation {
ADD, SUBTRACT, DIVIDE, MULTIPLY
}
private MathConstants() {
}
}

View File

@ -0,0 +1,23 @@
package com.baeldung.constantspatterns;
import static org.junit.jupiter.api.Assertions.assertEquals;
import org.junit.Test;
public class ConstantPatternUnitTest {
@Test
public void givenTwoNumbersAndAdd_whenCallingCalculatorOperatOneTwoNumbers_thenCorrectAnswerReturned() {
Calculator calculator = new Calculator();
double expected = 4;
double answer = calculator.operateOnTwoNumbers(2, 2, Calculator.Operation.ADD);
assertEquals(expected, answer);
}
@Test
public void givenTwoNumbersAndAdd_whenCallingGeometryCalculatorOperatOneTwoNumbers_thenCorrectAnswerReturned() {
GeometryCalculator calculator = new GeometryCalculator();
double expected = 4;
double answer = calculator.operateOnTwoNumbers(2, 2, GeometryCalculator.Operation.ADD);
assertEquals(expected, answer);
}
}

View File

@ -3,7 +3,7 @@ package com.baeldung.hashing;
class SHACommonUtils { class SHACommonUtils {
public static String bytesToHex(byte[] hash) { public static String bytesToHex(byte[] hash) {
StringBuffer hexString = new StringBuffer(); StringBuilder hexString = new StringBuilder(2 * hash.length);
for (byte h : hash) { for (byte h : hash) {
String hex = Integer.toHexString(0xff & h); String hex = Integer.toHexString(0xff & h);
if (hex.length() == 1) if (hex.length() == 1)

View File

@ -104,16 +104,12 @@
<plugin> <plugin>
<groupId>org.apache.maven.plugins</groupId> <groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId> <artifactId>maven-surefire-plugin</artifactId>
<version>${maven-surefire-plugin.version}</version>
</plugin> </plugin>
</plugins> </plugins>
</build> </build>
<properties> <properties>
<maven-surefire-plugin.version>2.22.2</maven-surefire-plugin.version>
<joda-money.version>1.0.1</joda-money.version> <joda-money.version>1.0.1</joda-money.version>
<junit-jupiter.version>5.6.2</junit-jupiter.version>
</properties> </properties>
</project> </project>

View File

@ -51,4 +51,17 @@
<plexus-container-default.version>1.0-alpha-9</plexus-container-default.version> <plexus-container-default.version>1.0-alpha-9</plexus-container-default.version>
</properties> </properties>
<build>
<plugins>
<plugin>
<artifactId>maven-verifier-plugin</artifactId>
<version>${maven.verifier.version}</version>
<configuration>
<verificationFile>../input-resources/verifications.xml</verificationFile>
<failOnError>false</failOnError>
</configuration>
</plugin>
</plugins>
</build>
</project> </project>

View File

@ -15,7 +15,7 @@
</parent> </parent>
<modules> <modules>
<!--<module>custom-rule</module>--> <!-- Fixing in JAVA-2819 --> <module>custom-rule</module>
<module>maven-enforcer</module> <module>maven-enforcer</module>
</modules> </modules>

View File

@ -0,0 +1,29 @@
<?xml version="1.0" encoding="UTF-8"?>
<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>com.baeldung.core-java-persistence-2</groupId>
<artifactId>core-java-persistence-2</artifactId>
<version>0.1.0-SNAPSHOT</version>
<name>core-java-persistence-2</name>
<packaging>jar</packaging>
<parent>
<groupId>com.baeldung</groupId>
<artifactId>persistence-modules</artifactId>
<version>1.0.0-SNAPSHOT</version>
</parent>
<dependencies>
<dependency>
<groupId>com.h2database</groupId>
<artifactId>h2</artifactId>
<version>${h2.version}</version>
</dependency>
</dependencies>
<properties>
<h2.version>1.4.200</h2.version>
</properties>
</project>

View File

@ -0,0 +1,13 @@
package com.baeldung.getdburl;
import java.sql.Connection;
import java.sql.DriverManager;
public class DBConfiguration {
public static Connection getConnection() throws Exception {
Class.forName("org.h2.Driver");
String url = "jdbc:h2:mem:testdb";
return DriverManager.getConnection(url, "user", "password");
}
}

View File

@ -0,0 +1,18 @@
package com.baeldung.getdburl;
import static org.junit.jupiter.api.Assertions.assertEquals;
import java.sql.Connection;
import org.junit.jupiter.api.Test;
class DBConfigurationUnitTest {
@Test
void givenConnectionObject_whenExtractMetaData_thenGetDbURL() throws Exception {
Connection connection = DBConfiguration.getConnection();
String dbUrl = connection.getMetaData().getURL();
assertEquals("jdbc:h2:mem:testdb", dbUrl);
}
}

View File

@ -76,10 +76,6 @@
<properties> <properties>
<flyway.configFiles>src/main/resources/application-${spring-boot.run.profiles}.properties</flyway.configFiles> <flyway.configFiles>src/main/resources/application-${spring-boot.run.profiles}.properties</flyway.configFiles>
<!-- testing -->
<maven-surefire-plugin.version>2.22.2</maven-surefire-plugin.version>
<junit-jupiter.version>5.6.2</junit-jupiter.version>
<junit.version>4.13</junit.version>
</properties> </properties>
</project> </project>

View File

@ -66,10 +66,6 @@
<flyway-core.version>5.2.3</flyway-core.version> <flyway-core.version>5.2.3</flyway-core.version>
<flyway-maven-plugin.version>5.0.2</flyway-maven-plugin.version> <flyway-maven-plugin.version>5.0.2</flyway-maven-plugin.version>
<!-- testing -->
<maven-surefire-plugin.version>2.22.2</maven-surefire-plugin.version>
<junit-jupiter.version>5.6.2</junit-jupiter.version>
<junit.version>4.13</junit.version>
</properties> </properties>
</project> </project>

View File

@ -17,6 +17,7 @@
<module>apache-bookkeeper</module><!-- BAEL-2322 --> <module>apache-bookkeeper</module><!-- BAEL-2322 -->
<module>apache-cayenne</module> <module>apache-cayenne</module>
<module>core-java-persistence</module> <module>core-java-persistence</module>
<module>core-java-persistence-2</module>
<module>deltaspike</module> <module>deltaspike</module>
<module>elasticsearch</module> <module>elasticsearch</module>
<module>flyway</module> <module>flyway</module>

View File

@ -69,10 +69,6 @@
<r2dbc-h2.version>0.8.1.RELEASE</r2dbc-h2.version> <r2dbc-h2.version>0.8.1.RELEASE</r2dbc-h2.version>
<h2.version>1.4.200</h2.version> <h2.version>1.4.200</h2.version>
<!-- testing -->
<maven-surefire-plugin.version>2.22.2</maven-surefire-plugin.version>
<junit-jupiter.version>5.6.2</junit-jupiter.version>
<junit.version>4.13</junit.version>
</properties> </properties>
</project> </project>

View File

@ -62,10 +62,6 @@
<jedis.version>3.3.0</jedis.version> <jedis.version>3.3.0</jedis.version>
<epoll.version>4.1.50.Final</epoll.version> <epoll.version>4.1.50.Final</epoll.version>
<!-- testing -->
<maven-surefire-plugin.version>2.22.2</maven-surefire-plugin.version>
<junit-jupiter.version>5.6.2</junit-jupiter.version>
<junit.version>4.13</junit.version>
</properties> </properties>
</project> </project>

View File

@ -40,10 +40,6 @@
<properties> <properties>
<mysql-connector-java.version>8.0.12</mysql-connector-java.version> <mysql-connector-java.version>8.0.12</mysql-connector-java.version>
<!-- testing -->
<maven-surefire-plugin.version>2.22.2</maven-surefire-plugin.version>
<junit-jupiter.version>5.6.2</junit-jupiter.version>
<junit.version>4.13</junit.version>
</properties> </properties>
</project> </project>

View File

@ -47,10 +47,6 @@
<start-class>com.baeldung.h2db.demo.server.SpringBootApp</start-class> <start-class>com.baeldung.h2db.demo.server.SpringBootApp</start-class>
<db-util.version>1.0.4</db-util.version> <db-util.version>1.0.4</db-util.version>
<!-- testing -->
<maven-surefire-plugin.version>2.22.2</maven-surefire-plugin.version>
<junit-jupiter.version>5.6.2</junit-jupiter.version>
<junit.version>4.13</junit.version>
</properties> </properties>
</project> </project>

View File

@ -37,9 +37,5 @@
</dependencies> </dependencies>
<properties> <properties>
<!-- testing -->
<maven-surefire-plugin.version>2.22.2</maven-surefire-plugin.version>
<junit-jupiter.version>5.6.2</junit-jupiter.version>
<junit.version>4.13</junit.version>
</properties> </properties>
</project> </project>

View File

@ -76,11 +76,6 @@
<properties> <properties>
<mockito.version>2.23.0</mockito.version> <mockito.version>2.23.0</mockito.version>
<validation-api.version>2.0.1.Final</validation-api.version> <validation-api.version>2.0.1.Final</validation-api.version>
<!-- testing -->
<maven-surefire-plugin.version>2.22.2</maven-surefire-plugin.version>
<junit-jupiter.version>5.6.2</junit-jupiter.version>
<junit.version>4.13</junit.version>
</properties> </properties>
</project> </project>

View File

@ -54,10 +54,6 @@
<spring-boot.version>2.2.6.RELEASE</spring-boot.version> <spring-boot.version>2.2.6.RELEASE</spring-boot.version>
<cassandra-unit-spring.version>3.11.2.0</cassandra-unit-spring.version> <cassandra-unit-spring.version>3.11.2.0</cassandra-unit-spring.version>
<!-- testing -->
<maven-surefire-plugin.version>2.22.2</maven-surefire-plugin.version>
<junit-jupiter.version>5.6.2</junit-jupiter.version>
<junit.version>4.13</junit.version>
</properties> </properties>
</project> </project>

View File

@ -105,10 +105,6 @@
<cassandra-unit-shaded.version>2.1.9.2</cassandra-unit-shaded.version> <cassandra-unit-shaded.version>2.1.9.2</cassandra-unit-shaded.version>
<hector-core.version>2.0-0</hector-core.version> <hector-core.version>2.0-0</hector-core.version>
<!-- testing -->
<maven-surefire-plugin.version>2.22.2</maven-surefire-plugin.version>
<junit-jupiter.version>5.6.2</junit-jupiter.version>
<junit.version>4.13</junit.version>
</properties> </properties>
</project> </project>

View File

@ -17,10 +17,6 @@
<java.version>1.8</java.version> <java.version>1.8</java.version>
<cosmodb.version>2.3.0</cosmodb.version> <cosmodb.version>2.3.0</cosmodb.version>
<!-- testing -->
<maven-surefire-plugin.version>2.22.2</maven-surefire-plugin.version>
<junit-jupiter.version>5.6.2</junit-jupiter.version>
<junit.version>4.13</junit.version>
</properties> </properties>
<dependencies> <dependencies>

View File

@ -182,11 +182,6 @@
<dynamodblocal.version>1.11.86</dynamodblocal.version> <dynamodblocal.version>1.11.86</dynamodblocal.version>
<dynamodblocal.repository.url>https://s3-us-west-2.amazonaws.com/dynamodb-local/release</dynamodblocal.repository.url> <dynamodblocal.repository.url>https://s3-us-west-2.amazonaws.com/dynamodb-local/release</dynamodblocal.repository.url>
<maven-dependency-plugin.version>3.1.1</maven-dependency-plugin.version> <maven-dependency-plugin.version>3.1.1</maven-dependency-plugin.version>
<!-- testing -->
<maven-surefire-plugin.version>2.22.2</maven-surefire-plugin.version>
<junit-jupiter.version>5.6.2</junit-jupiter.version>
<junit.version>4.13</junit.version>
</properties> </properties>
</project> </project>

View File

@ -69,10 +69,5 @@
<fastjson.version>1.2.47</fastjson.version> <fastjson.version>1.2.47</fastjson.version>
<spatial4j.version>0.7</spatial4j.version> <spatial4j.version>0.7</spatial4j.version>
<jts.version>1.15.0</jts.version> <jts.version>1.15.0</jts.version>
<!-- testing -->
<maven-surefire-plugin.version>2.22.2</maven-surefire-plugin.version>
<junit-jupiter.version>5.6.2</junit-jupiter.version>
<junit.version>4.13</junit.version>
</properties> </properties>
</project> </project>

View File

@ -28,9 +28,5 @@
</dependencies> </dependencies>
<properties> <properties>
<!-- testing -->
<maven-surefire-plugin.version>2.22.2</maven-surefire-plugin.version>
<junit-jupiter.version>5.6.2</junit-jupiter.version>
<junit.version>4.13</junit.version>
</properties> </properties>
</project> </project>

View File

@ -73,10 +73,6 @@
<postgresql.version>42.2.5</postgresql.version> <postgresql.version>42.2.5</postgresql.version>
<guava.version>21.0</guava.version> <guava.version>21.0</guava.version>
<!-- testing -->
<maven-surefire-plugin.version>2.22.2</maven-surefire-plugin.version>
<junit-jupiter.version>5.6.2</junit-jupiter.version>
<junit.version>4.13</junit.version>
</properties> </properties>
</project> </project>

View File

@ -16,10 +16,6 @@
<dependencies> <dependencies>
<!-- Prod Dependencies --> <!-- Prod Dependencies -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency> <dependency>
<groupId>org.springframework.boot</groupId> <groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId> <artifactId>spring-boot-starter-data-jpa</artifactId>
@ -66,11 +62,6 @@
<datasource-proxy.version>1.4.1</datasource-proxy.version> <datasource-proxy.version>1.4.1</datasource-proxy.version>
<guava.version>21.0</guava.version> <guava.version>21.0</guava.version>
<testcontainers.version>1.12.2</testcontainers.version> <testcontainers.version>1.12.2</testcontainers.version>
<!-- testing -->
<maven-surefire-plugin.version>2.22.2</maven-surefire-plugin.version>
<junit-jupiter.version>5.6.2</junit-jupiter.version>
<junit.version>4.13</junit.version>
</properties> </properties>
</project> </project>

View File

@ -99,10 +99,6 @@
<guava.version>21.0</guava.version> <guava.version>21.0</guava.version>
<testcontainers.version>1.12.2</testcontainers.version> <testcontainers.version>1.12.2</testcontainers.version>
<!-- testing -->
<maven-surefire-plugin.version>2.22.2</maven-surefire-plugin.version>
<junit-jupiter.version>5.6.2</junit-jupiter.version>
<junit.version>4.13</junit.version>
</properties> </properties>
</project> </project>

View File

@ -73,10 +73,6 @@
<postgresql.version>42.2.5</postgresql.version> <postgresql.version>42.2.5</postgresql.version>
<guava.version>21.0</guava.version> <guava.version>21.0</guava.version>
<!-- testing -->
<maven-surefire-plugin.version>2.22.2</maven-surefire-plugin.version>
<junit-jupiter.version>5.6.2</junit-jupiter.version>
<junit.version>4.13</junit.version>
</properties> </properties>
</project> </project>

View File

@ -84,10 +84,6 @@
</dependencies> </dependencies>
<properties> <properties>
<!-- testing -->
<maven-surefire-plugin.version>2.22.2</maven-surefire-plugin.version>
<junit-jupiter.version>5.6.2</junit-jupiter.version>
<junit.version>4.13</junit.version>
<tomcat-dbcp.version>9.0.0.M26</tomcat-dbcp.version> <tomcat-dbcp.version>9.0.0.M26</tomcat-dbcp.version>
<jta.version>1.1</jta.version> <jta.version>1.1</jta.version>
<guava.version>21.0</guava.version> <guava.version>21.0</guava.version>

View File

@ -44,10 +44,6 @@
<properties> <properties>
<datasource-proxy.version>1.4.1</datasource-proxy.version> <datasource-proxy.version>1.4.1</datasource-proxy.version>
<!-- testing -->
<maven-surefire-plugin.version>2.22.2</maven-surefire-plugin.version>
<junit-jupiter.version>5.6.2</junit-jupiter.version>
<junit.version>4.13</junit.version>
</properties> </properties>
</project> </project>

View File

@ -44,9 +44,5 @@
<properties> <properties>
<guava.version>29.0-jre</guava.version> <guava.version>29.0-jre</guava.version>
<!-- testing -->
<maven-surefire-plugin.version>2.22.2</maven-surefire-plugin.version>
<junit-jupiter.version>5.6.2</junit-jupiter.version>
<junit.version>4.13</junit.version>
</properties> </properties>
</project> </project>

View File

@ -50,9 +50,6 @@
</dependencies> </dependencies>
<properties> <properties>
<!-- testing -->
<maven-surefire-plugin.version>2.22.2</maven-surefire-plugin.version>
<junit-jupiter.version>5.6.2</junit-jupiter.version>
<junit.version>4.13</junit.version>
</properties> </properties>
</project> </project>

View File

@ -29,9 +29,6 @@
</dependencies> </dependencies>
<properties> <properties>
<!-- testing -->
<maven-surefire-plugin.version>2.22.2</maven-surefire-plugin.version>
<junit-jupiter.version>5.6.2</junit-jupiter.version>
<junit.version>4.13</junit.version>
</properties> </properties>
</project> </project>

View File

@ -108,10 +108,6 @@
<projectreactor.version>3.2.0.RELEASE</projectreactor.version> <projectreactor.version>3.2.0.RELEASE</projectreactor.version>
<mongodb-driver.version>4.0.5</mongodb-driver.version> <mongodb-driver.version>4.0.5</mongodb-driver.version>
<!-- testing -->
<maven-surefire-plugin.version>2.22.2</maven-surefire-plugin.version>
<junit-jupiter.version>5.6.2</junit-jupiter.version>
<junit.version>4.13</junit.version>
</properties> </properties>
</project> </project>

View File

@ -98,11 +98,6 @@
<cglib.version>3.2.4</cglib.version> <cglib.version>3.2.4</cglib.version>
<nosqlunit.version>0.10.0</nosqlunit.version> <nosqlunit.version>0.10.0</nosqlunit.version>
<embedded-redis.version>0.6</embedded-redis.version> <embedded-redis.version>0.6</embedded-redis.version>
<!-- testing -->
<maven-surefire-plugin.version>2.22.2</maven-surefire-plugin.version>
<junit-jupiter.version>5.6.2</junit-jupiter.version>
<junit.version>4.13</junit.version>
</properties> </properties>
</project> </project>

View File

@ -5,7 +5,6 @@ import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.PropertySource; import org.springframework.context.annotation.PropertySource;
import org.springframework.data.redis.connection.jedis.JedisConnectionFactory; import org.springframework.data.redis.connection.jedis.JedisConnectionFactory;
import org.springframework.data.redis.connection.lettuce.LettuceConnectionFactory;
import org.springframework.data.redis.core.RedisTemplate; import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.data.redis.listener.ChannelTopic; import org.springframework.data.redis.listener.ChannelTopic;
import org.springframework.data.redis.listener.RedisMessageListenerContainer; import org.springframework.data.redis.listener.RedisMessageListenerContainer;

View File

@ -1,16 +1,32 @@
package com.baeldung; package com.baeldung;
import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.Test; import org.junit.Test;
import org.junit.runner.RunWith; import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.ContextConfiguration; import org.springframework.test.annotation.DirtiesContext;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; import org.springframework.test.annotation.DirtiesContext.ClassMode;
import com.baeldung.spring.data.redis.config.RedisConfig; import com.baeldung.spring.data.redis.SpringRedisApplication;
@RunWith(SpringJUnit4ClassRunner.class) import redis.embedded.RedisServerBuilder;
@ContextConfiguration(classes = RedisConfig.class)
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT, classes = SpringRedisApplication.class)
@DirtiesContext(classMode = ClassMode.BEFORE_CLASS)
public class SpringContextTest { public class SpringContextTest {
private static redis.embedded.RedisServer redisServer;
@BeforeClass
public static void startRedisServer() {
redisServer = new RedisServerBuilder().port(6379).setting("maxmemory 256M").build();
redisServer.start();
}
@AfterClass
public static void stopRedisServer() {
redisServer.stop();
}
@Test @Test
public void whenSpringContextIsBootstrapped_thenNoExceptions() { public void whenSpringContextIsBootstrapped_thenNoExceptions() {
} }

View File

@ -46,10 +46,6 @@
<properties> <properties>
<spring-data-solr.version>2.0.5.RELEASE</spring-data-solr.version> <spring-data-solr.version>2.0.5.RELEASE</spring-data-solr.version>
<!-- testing -->
<maven-surefire-plugin.version>2.22.2</maven-surefire-plugin.version>
<junit-jupiter.version>5.6.2</junit-jupiter.version>
<junit.version>4.13</junit.version>
</properties> </properties>
</project> </project>

View File

@ -18,7 +18,6 @@
<dependency> <dependency>
<groupId>org.springframework.data</groupId> <groupId>org.springframework.data</groupId>
<artifactId>spring-data-jdbc</artifactId> <artifactId>spring-data-jdbc</artifactId>
<version>${spring-data-jdbc.version}</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.springframework.boot</groupId> <groupId>org.springframework.boot</groupId>
@ -36,11 +35,5 @@
</dependencies> </dependencies>
<properties> <properties>
<spring-data-jdbc.version>2.0.3.RELEASE</spring-data-jdbc.version>
<!-- testing -->
<maven-surefire-plugin.version>2.22.2</maven-surefire-plugin.version>
<junit-jupiter.version>5.6.2</junit-jupiter.version>
<junit.version>4.13</junit.version>
</properties> </properties>
</project> </project>

View File

@ -4,11 +4,12 @@
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 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> <modelVersion>4.0.0</modelVersion>
<!-- this module should use the Boot parent directly to avoid inherit the logback dependency from our other parents -->
<parent> <parent>
<groupId>com.baeldung.spring-boot-modules</groupId> <groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-modules</artifactId> <artifactId>spring-boot-starter-parent</artifactId>
<version>1.0.0-SNAPSHOT</version> <version>2.1.1.RELEASE</version>
<relativePath>../</relativePath> <relativePath/> <!-- lookup parent from repository -->
</parent> </parent>
<artifactId>spring-boot-mvc-birt</artifactId> <artifactId>spring-boot-mvc-birt</artifactId>
@ -19,10 +20,6 @@
<description>Module For Spring Boot Integration with BIRT</description> <description>Module For Spring Boot Integration with BIRT</description>
<dependencies> <dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter</artifactId>
</dependency>
<dependency> <dependency>
<groupId>org.springframework.boot</groupId> <groupId>org.springframework.boot</groupId>
@ -51,17 +48,14 @@
<artifactId>org.eclipse.birt.runtime_4.8.0-20180626</artifactId> <artifactId>org.eclipse.birt.runtime_4.8.0-20180626</artifactId>
<version>${eclipse.birt.runtime.version}</version> <version>${eclipse.birt.runtime.version}</version>
</dependency> </dependency>
<!-- https://mvnrepository.com/artifact/log4j/log4j -->
<dependency> <dependency>
<groupId>log4j</groupId> <groupId>log4j</groupId>
<artifactId>log4j</artifactId> <artifactId>log4j</artifactId>
<version>${log4j.version}</version> <version>${log4j.version}</version>
</dependency> </dependency>
<!-- https://mvnrepository.com/artifact/org.projectlombok/lombok -->
<dependency> <dependency>
<groupId>org.projectlombok</groupId> <groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId> <artifactId>lombok</artifactId>
<version>${lombok.version}</version>
<scope>provided</scope> <scope>provided</scope>
</dependency> </dependency>
@ -81,6 +75,7 @@
<maven.compiler.source>1.8</maven.compiler.source> <maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target> <maven.compiler.target>1.8</maven.compiler.target>
<eclipse.birt.runtime.version>4.8.0</eclipse.birt.runtime.version> <eclipse.birt.runtime.version>4.8.0</eclipse.birt.runtime.version>
<log4j.version>1.2.17</log4j.version>
</properties> </properties>
</project> </project>

View File

@ -0,0 +1,9 @@
# Set root logger level to DEBUG and its only appender to A1.
log4j.rootLogger=DEBUG, A1
# A1 is set to be a ConsoleAppender.
log4j.appender.A1=org.apache.log4j.ConsoleAppender
# A1 uses PatternLayout.
log4j.appender.A1.layout=org.apache.log4j.PatternLayout
log4j.appender.A1.layout.ConversionPattern=%-4r [%t] %-5p %c %x - %m%n

View File

@ -0,0 +1,13 @@
package com.baeldung.birt.engine;
import org.junit.Test;
import org.springframework.boot.test.context.SpringBootTest;
@SpringBootTest
public class SpringContextTest {
@Test
public void whenSpringContextIsBootstrapped_thenNoExceptions() {
}
}

View File

@ -52,7 +52,6 @@
<plugin> <plugin>
<groupId>org.springframework.boot</groupId> <groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId> <artifactId>spring-boot-maven-plugin</artifactId>
<version>${spring-boot-maven-plugin.version}</version>
</plugin> </plugin>
</plugins> </plugins>
</pluginManagement> </pluginManagement>
@ -85,13 +84,7 @@
<spring-cloud-starter-feign.version>1.4.7.RELEASE</spring-cloud-starter-feign.version> <spring-cloud-starter-feign.version>1.4.7.RELEASE</spring-cloud-starter-feign.version>
<spring-cloud-starter-hystrix.version>1.4.7.RELEASE</spring-cloud-starter-hystrix.version> <spring-cloud-starter-hystrix.version>1.4.7.RELEASE</spring-cloud-starter-hystrix.version>
<spring-cloud-stream.version>3.0.6.RELEASE</spring-cloud-stream.version> <spring-cloud-stream.version>3.0.6.RELEASE</spring-cloud-stream.version>
<spring-boot-starter-web.version>2.3.1.RELEASE</spring-boot-starter-web.version>
<spring-boot-maven-plugin.version>2.3.1.RELEASE</spring-boot-maven-plugin.version>
<!-- testing -->
<maven-surefire-plugin.version>2.22.2</maven-surefire-plugin.version>
<junit-jupiter.version>5.6.2</junit-jupiter.version>
<junit.version>4.13</junit.version>
</properties> </properties>
</project> </project>

View File

@ -68,10 +68,6 @@
<spring-cloud.version>Dalston.SR4</spring-cloud.version> <spring-cloud.version>Dalston.SR4</spring-cloud.version>
<spring-cloud>2.2.1.RELEASE</spring-cloud> <spring-cloud>2.2.1.RELEASE</spring-cloud>
<!-- testing -->
<maven-surefire-plugin.version>2.22.2</maven-surefire-plugin.version>
<junit-jupiter.version>5.6.2</junit-jupiter.version>
<junit.version>4.13</junit.version>
</properties> </properties>
</project> </project>

View File

@ -30,13 +30,6 @@
<dependencyManagement> <dependencyManagement>
<dependencies> <dependencies>
<dependency>
<groupId>org.junit</groupId>
<artifactId>junit-bom</artifactId>
<version>${junit-jupiter.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
<dependency> <dependency>
<groupId>org.springframework.cloud</groupId> <groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-dependencies</artifactId> <artifactId>spring-cloud-dependencies</artifactId>
@ -50,10 +43,6 @@
<properties> <properties>
<spring-cloud-dependencies.version>Brixton.SR7</spring-cloud-dependencies.version> <spring-cloud-dependencies.version>Brixton.SR7</spring-cloud-dependencies.version>
<!-- testing -->
<maven-surefire-plugin.version>2.22.2</maven-surefire-plugin.version>
<junit-jupiter.version>5.6.2</junit-jupiter.version>
<junit.version>4.13</junit.version>
</properties> </properties>
</project> </project>

View File

@ -17,13 +17,6 @@
</parent> </parent>
<dependencies> <dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-dependencies</artifactId>
<version>${spring-boot.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
<dependency> <dependency>
<groupId>org.springframework.boot</groupId> <groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId> <artifactId>spring-boot-starter-web</artifactId>
@ -78,10 +71,5 @@
<properties> <properties>
<maven.compiler.source>1.8</maven.compiler.source> <maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target> <maven.compiler.target>1.8</maven.compiler.target>
<!-- testing -->
<maven-surefire-plugin.version>2.22.2</maven-surefire-plugin.version>
<junit-jupiter.version>5.6.2</junit-jupiter.version>
<junit.version>4.13</junit.version>
</properties> </properties>
</project> </project>

View File

@ -52,10 +52,6 @@
<properties> <properties>
<spring-cloud-dependencies.version>Edgware.SR5</spring-cloud-dependencies.version> <spring-cloud-dependencies.version>Edgware.SR5</spring-cloud-dependencies.version>
<!-- testing -->
<maven-surefire-plugin.version>2.22.2</maven-surefire-plugin.version>
<junit-jupiter.version>5.6.2</junit-jupiter.version>
<junit.version>4.13</junit.version>
</properties> </properties>
</project> </project>

View File

@ -101,10 +101,6 @@
<properties> <properties>
<spring-cloud-dependencies.version>Dalston.RELEASE</spring-cloud-dependencies.version> <spring-cloud-dependencies.version>Dalston.RELEASE</spring-cloud-dependencies.version>
<!-- testing -->
<maven-surefire-plugin.version>2.22.2</maven-surefire-plugin.version>
<junit-jupiter.version>5.6.2</junit-jupiter.version>
<junit.version>4.13</junit.version>
</properties> </properties>
</project> </project>

View File

@ -23,13 +23,6 @@
<dependencyManagement> <dependencyManagement>
<dependencies> <dependencies>
<dependency>
<groupId>org.junit</groupId>
<artifactId>junit-bom</artifactId>
<version>${junit-jupiter.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
<dependency> <dependency>
<groupId>org.springframework.boot</groupId> <groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-dependencies</artifactId> <artifactId>spring-boot-dependencies</artifactId>
@ -126,9 +119,5 @@
<maven.compiler.target>1.8</maven.compiler.target> <maven.compiler.target>1.8</maven.compiler.target>
<orderservice.mainclass>com.baeldung.orderservice.OrderApplication</orderservice.mainclass> <orderservice.mainclass>com.baeldung.orderservice.OrderApplication</orderservice.mainclass>
<!-- testing -->
<maven-surefire-plugin.version>2.22.2</maven-surefire-plugin.version>
<junit-jupiter.version>5.6.2</junit-jupiter.version>
<junit.version>4.13</junit.version>
</properties> </properties>
</project> </project>

View File

@ -74,10 +74,6 @@
<properties> <properties>
<spring-cloud-dependencies.version>Dalston.RELEASE</spring-cloud-dependencies.version> <spring-cloud-dependencies.version>Dalston.RELEASE</spring-cloud-dependencies.version>
<!-- testing -->
<maven-surefire-plugin.version>2.22.2</maven-surefire-plugin.version>
<junit-jupiter.version>5.6.2</junit-jupiter.version>
<junit.version>4.13</junit.version>
</properties> </properties>
</project> </project>

View File

@ -83,10 +83,6 @@
<properties> <properties>
<spring-cloud-dependencies.version>Dalston.RELEASE</spring-cloud-dependencies.version> <spring-cloud-dependencies.version>Dalston.RELEASE</spring-cloud-dependencies.version>
<!-- testing -->
<maven-surefire-plugin.version>2.22.2</maven-surefire-plugin.version>
<junit-jupiter.version>5.6.2</junit-jupiter.version>
<junit.version>4.13</junit.version>
</properties> </properties>
</project> </project>

View File

@ -38,13 +38,6 @@
<dependencyManagement> <dependencyManagement>
<dependencies> <dependencies>
<dependency>
<groupId>org.junit</groupId>
<artifactId>junit-bom</artifactId>
<version>${junit-jupiter.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
<dependency> <dependency>
<groupId>org.springframework.cloud</groupId> <groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-dependencies</artifactId> <artifactId>spring-cloud-dependencies</artifactId>
@ -58,10 +51,6 @@
<properties> <properties>
<spring-cloud-dependencies.version>Brixton.SR7</spring-cloud-dependencies.version> <spring-cloud-dependencies.version>Brixton.SR7</spring-cloud-dependencies.version>
<!-- testing -->
<maven-surefire-plugin.version>2.22.2</maven-surefire-plugin.version>
<junit-jupiter.version>5.6.2</junit-jupiter.version>
<junit.version>4.13</junit.version>
</properties> </properties>
</project> </project>

View File

@ -22,13 +22,6 @@
<dependencyManagement> <dependencyManagement>
<dependencies> <dependencies>
<dependency>
<groupId>org.junit</groupId>
<artifactId>junit-bom</artifactId>
<version>${junit-jupiter.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
<dependency> <dependency>
<groupId>org.springframework.cloud</groupId> <groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-dependencies</artifactId> <artifactId>spring-cloud-dependencies</artifactId>
@ -42,10 +35,6 @@
<properties> <properties>
<spring-cloud-dependencies.version>Hoxton.SR4</spring-cloud-dependencies.version> <spring-cloud-dependencies.version>Hoxton.SR4</spring-cloud-dependencies.version>
<!-- testing -->
<maven-surefire-plugin.version>2.22.2</maven-surefire-plugin.version>
<junit-jupiter.version>5.6.2</junit-jupiter.version>
<junit.version>4.13</junit.version>
</properties> </properties>
</project> </project>

View File

@ -65,10 +65,6 @@
<postgresql.version>42.2.10</postgresql.version> <postgresql.version>42.2.10</postgresql.version>
<bytebuddy.version>1.10.10</bytebuddy.version> <bytebuddy.version>1.10.10</bytebuddy.version>
<!-- testing -->
<maven-surefire-plugin.version>2.22.2</maven-surefire-plugin.version>
<junit-jupiter.version>5.6.2</junit-jupiter.version>
<junit.version>4.13</junit.version>
</properties> </properties>
</project> </project>

View File

@ -87,10 +87,6 @@
<aws-lambda-java-core.version>1.1.0</aws-lambda-java-core.version> <aws-lambda-java-core.version>1.1.0</aws-lambda-java-core.version>
<spring-boot-thin.version>1.0.10.RELEASE</spring-boot-thin.version> <spring-boot-thin.version>1.0.10.RELEASE</spring-boot-thin.version>
<!-- testing -->
<maven-surefire-plugin.version>2.22.2</maven-surefire-plugin.version>
<junit-jupiter.version>5.6.2</junit-jupiter.version>
<junit.version>4.13</junit.version>
</properties> </properties>
</project> </project>

View File

@ -1,4 +1,4 @@
package com.baeldung.spring.cloudfunction.functions.aws; package com.baeldung.spring.cloudfunction.aws.functions;
import java.util.function.Function; import java.util.function.Function;

View File

@ -1 +1 @@
spring.cloud.function.scan.packages: com.baeldung.spring.cloudfunction.functions.aws spring.cloud.function.scan.packages: com.baeldung.spring.cloudfunction.aws.functions

View File

@ -58,7 +58,6 @@
<dependency> <dependency>
<groupId>org.springframework.boot</groupId> <groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId> <artifactId>spring-boot-starter-web</artifactId>
<version>${spring-boot-starter-web.version}</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.springframework.boot</groupId> <groupId>org.springframework.boot</groupId>

View File

@ -47,24 +47,20 @@
<dependency> <dependency>
<groupId>org.springframework.boot</groupId> <groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId> <artifactId>spring-boot-starter-web</artifactId>
<version>${spring-boot-starter-web.version}</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.springframework.boot</groupId> <groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-thymeleaf</artifactId> <artifactId>spring-boot-starter-thymeleaf</artifactId>
<version>${spring-boot-starter-web.version}</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.springframework.boot</groupId> <groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId> <artifactId>spring-boot-starter-actuator</artifactId>
<version>${spring-boot-starter-web.version}</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.springframework.boot</groupId> <groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId> <artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope> <scope>test</scope>
<version>${spring-boot-starter-web.version}</version>
</dependency> </dependency>
</dependencies> </dependencies>

View File

@ -18,13 +18,11 @@
<dependency> <dependency>
<groupId>org.springframework.boot</groupId> <groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId> <artifactId>spring-boot-starter-web</artifactId>
<version>${spring-boot-starter-web.version}</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.springframework.boot</groupId> <groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId> <artifactId>spring-boot-starter-test</artifactId>
<version>${spring-boot-starter-web.version}</version>
<scope>test</scope> <scope>test</scope>
</dependency> </dependency>
</dependencies> </dependencies>

View File

@ -25,9 +25,5 @@
</modules> </modules>
<properties> <properties>
<!-- testing -->
<maven-surefire-plugin.version>2.22.2</maven-surefire-plugin.version>
<junit-jupiter.version>5.6.2</junit-jupiter.version>
<junit.version>4.13</junit.version>
</properties> </properties>
</project> </project>

View File

@ -2,6 +2,7 @@ package com.baeldung.cloud.openfeign.config;
import feign.Logger; import feign.Logger;
import feign.RequestInterceptor; import feign.RequestInterceptor;
import feign.auth.BasicAuthRequestInterceptor;
import feign.codec.ErrorDecoder; import feign.codec.ErrorDecoder;
import feign.okhttp.OkHttpClient; import feign.okhttp.OkHttpClient;
import org.apache.http.entity.ContentType; import org.apache.http.entity.ContentType;
@ -34,4 +35,9 @@ public class ClientConfiguration {
requestTemplate.header("Accept", ContentType.APPLICATION_JSON.getMimeType()); requestTemplate.header("Accept", ContentType.APPLICATION_JSON.getMimeType());
}; };
} }
// @Bean - uncomment to use this interceptor and remove @Bean from the requestInterceptor()
public BasicAuthRequestInterceptor basicAuthRequestInterceptor() {
return new BasicAuthRequestInterceptor("ajeje", "brazof");
}
} }

View File

@ -75,9 +75,5 @@
</dependencies> </dependencies>
<properties> <properties>
<!-- testing -->
<maven-surefire-plugin.version>2.22.2</maven-surefire-plugin.version>
<junit-jupiter.version>5.6.2</junit-jupiter.version>
<junit.version>4.13</junit.version>
</properties> </properties>
</project> </project>

View File

@ -53,10 +53,6 @@
<properties> <properties>
<spring-cloud.version>Camden.SR4</spring-cloud.version> <spring-cloud.version>Camden.SR4</spring-cloud.version>
<!-- testing -->
<maven-surefire-plugin.version>2.22.2</maven-surefire-plugin.version>
<junit-jupiter.version>5.6.2</junit-jupiter.version>
<junit.version>4.13</junit.version>
</properties> </properties>
</project> </project>

View File

@ -61,10 +61,6 @@
<properties> <properties>
<spring-cloud.version>Edgware.SR4</spring-cloud.version> <spring-cloud.version>Edgware.SR4</spring-cloud.version>
<!-- testing -->
<maven-surefire-plugin.version>2.22.2</maven-surefire-plugin.version>
<junit-jupiter.version>5.6.2</junit-jupiter.version>
<junit.version>4.13</junit.version>
</properties> </properties>
</project> </project>

View File

@ -83,10 +83,6 @@
<rest-assured.version>3.0.1</rest-assured.version> <rest-assured.version>3.0.1</rest-assured.version>
<embedded-redis.version>0.6</embedded-redis.version> <embedded-redis.version>0.6</embedded-redis.version>
<!-- testing -->
<maven-surefire-plugin.version>2.22.2</maven-surefire-plugin.version>
<junit-jupiter.version>5.6.2</junit-jupiter.version>
<junit.version>4.13</junit.version>
</properties> </properties>
</project> </project>

View File

@ -46,11 +46,6 @@
<properties> <properties>
<spring-cloud-dependencies.version>Hoxton.SR4</spring-cloud-dependencies.version> <spring-cloud-dependencies.version>Hoxton.SR4</spring-cloud-dependencies.version>
<!-- testing -->
<maven-surefire-plugin.version>2.22.2</maven-surefire-plugin.version>
<junit-jupiter.version>5.6.2</junit-jupiter.version>
<junit.version>4.13</junit.version>
</properties> </properties>
</project> </project>

View File

@ -56,9 +56,5 @@
<properties> <properties>
<spring-cloud.version>Hoxton.SR3</spring-cloud.version> <spring-cloud.version>Hoxton.SR3</spring-cloud.version>
<!-- testing -->
<maven-surefire-plugin.version>2.22.2</maven-surefire-plugin.version>
<junit-jupiter.version>5.6.2</junit-jupiter.version>
<junit.version>4.13</junit.version>
</properties> </properties>
</project> </project>

View File

@ -21,9 +21,5 @@
</modules> </modules>
<properties> <properties>
<!-- testing -->
<maven-surefire-plugin.version>2.22.2</maven-surefire-plugin.version>
<junit-jupiter.version>5.6.2</junit-jupiter.version>
<junit.version>4.13</junit.version>
</properties> </properties>
</project> </project>

View File

@ -106,10 +106,6 @@
<kafka-avro-serializer.version>4.0.0</kafka-avro-serializer.version> <kafka-avro-serializer.version>4.0.0</kafka-avro-serializer.version>
<avro.version>1.8.2</avro.version> <avro.version>1.8.2</avro.version>
<!-- testing -->
<maven-surefire-plugin.version>2.22.2</maven-surefire-plugin.version>
<junit-jupiter.version>5.6.2</junit-jupiter.version>
<junit.version>4.13</junit.version>
</properties> </properties>
</project> </project>

View File

@ -43,11 +43,6 @@
<aws-sdk.version>1.11.632</aws-sdk.version> <aws-sdk.version>1.11.632</aws-sdk.version>
<spring-cloud-stream-kinesis-binder.version>2.0.2.RELEASE</spring-cloud-stream-kinesis-binder.version> <spring-cloud-stream-kinesis-binder.version>2.0.2.RELEASE</spring-cloud-stream-kinesis-binder.version>
<spring-cloud-stream-test.version>2.2.1.RELEASE</spring-cloud-stream-test.version> <spring-cloud-stream-test.version>2.2.1.RELEASE</spring-cloud-stream-test.version>
<!-- testing -->
<maven-surefire-plugin.version>2.22.2</maven-surefire-plugin.version>
<junit-jupiter.version>5.6.2</junit-jupiter.version>
<junit.version>4.13</junit.version>
</properties> </properties>
</project> </project>

View File

@ -50,10 +50,6 @@
<spring-cloud-dependencies.version>Hoxton.SR4</spring-cloud-dependencies.version> <spring-cloud-dependencies.version>Hoxton.SR4</spring-cloud-dependencies.version>
<spring-cloud-task.version>2.2.3.RELEASE</spring-cloud-task.version> <spring-cloud-task.version>2.2.3.RELEASE</spring-cloud-task.version>
<!-- testing -->
<maven-surefire-plugin.version>2.22.2</maven-surefire-plugin.version>
<junit-jupiter.version>5.6.2</junit-jupiter.version>
<junit.version>4.13</junit.version>
</properties> </properties>
</project> </project>

View File

@ -83,11 +83,6 @@
<properties> <properties>
<spring-cloud.version>Greenwich.RELEASE</spring-cloud.version> <spring-cloud.version>Greenwich.RELEASE</spring-cloud.version>
<!-- testing -->
<maven-surefire-plugin.version>2.22.2</maven-surefire-plugin.version>
<junit-jupiter.version>5.6.2</junit-jupiter.version>
<junit.version>4.13</junit.version>
</properties> </properties>
</project> </project>

View File

@ -35,7 +35,6 @@
<dependency> <dependency>
<groupId>org.springframework.boot</groupId> <groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId> <artifactId>spring-boot-starter-web</artifactId>
<version>${spring-boot-starter-web.version}</version>
</dependency> </dependency>
</dependencies> </dependencies>

View File

@ -35,13 +35,13 @@
<dependency> <dependency>
<groupId>org.springframework.boot</groupId> <groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId> <artifactId>spring-boot-starter-web</artifactId>
<version>${spring-boot-starter-web.version}</version> <version>${spring-boot.version}</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.springframework.boot</groupId> <groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId> <artifactId>spring-boot-starter-test</artifactId>
<version>${spring-boot-starter-web.version}</version> <version>${spring-boot.version}</version>
<scope>test</scope> <scope>test</scope>
</dependency> </dependency>
</dependencies> </dependencies>

View File

@ -41,7 +41,7 @@
<dependency> <dependency>
<groupId>org.springframework.boot</groupId> <groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId> <artifactId>spring-boot-starter-test</artifactId>
<version>${spring-boot-starter-web.version}</version> <version>${spring-boot.version}</version>
<scope>test</scope> <scope>test</scope>
</dependency> </dependency>
</dependencies> </dependencies>

View File

@ -50,7 +50,6 @@
<dependency> <dependency>
<groupId>org.springframework.boot</groupId> <groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId> <artifactId>spring-boot-starter-test</artifactId>
<version>${spring-boot-starter-web.version}</version>
<scope>test</scope> <scope>test</scope>
</dependency> </dependency>
</dependencies> </dependencies>

View File

@ -81,10 +81,6 @@
<properties> <properties>
<spring-cloud.version>Hoxton.SR4</spring-cloud.version> <spring-cloud.version>Hoxton.SR4</spring-cloud.version>
<!-- testing -->
<maven-surefire-plugin.version>2.22.2</maven-surefire-plugin.version>
<junit-jupiter.version>5.6.2</junit-jupiter.version>
<junit.version>4.13</junit.version>
</properties> </properties>
</project> </project>

View File

@ -226,7 +226,7 @@
<httpcore.version>4.4.9</httpcore.version> <httpcore.version>4.4.9</httpcore.version>
<httpclient.version>4.5.5</httpclient.version> <httpclient.version>4.5.5</httpclient.version>
<javax.servlet-api.version>4.0.0</javax.servlet-api.version> <javax.servlet-api.version>4.0.0</javax.servlet-api.version>
<wiremock.version>2.25.1</wiremock.version> <wiremock.version>2.27.2</wiremock.version>
<assertj-core.version>3.10.0</assertj-core.version> <assertj-core.version>3.10.0</assertj-core.version>
<spring-boot.version>1.5.10.RELEASE</spring-boot.version> <spring-boot.version>1.5.10.RELEASE</spring-boot.version>
</properties> </properties>

View File

@ -11,11 +11,7 @@ public class MaxSizeConstraintValidator implements ConstraintValidator<MaxSizeCo
@Override @Override
public boolean isValid(List<Movie> values, ConstraintValidatorContext context) { public boolean isValid(List<Movie> values, ConstraintValidatorContext context) {
boolean isValid = true; return values.size() <= 4;
if (values.size() > 4) {
isValid = false;
}
return isValid;
} }
} }

View File

@ -1,7 +1,6 @@
package com.baeldung.resttemplate; package com.baeldung.resttemplate;
import org.springframework.boot.SpringApplication; import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.boot.autoconfigure.SpringBootApplication;
@SpringBootApplication @SpringBootApplication

View File

@ -1,14 +0,0 @@
package com.baeldung.resttemplate.logging;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.boot.autoconfigure.SpringBootApplication;
@SpringBootApplication
@EnableAutoConfiguration
public class RestTemplateConfigurationApplication {
public static void main(String[] args) {
SpringApplication.run(RestTemplateConfigurationApplication.class, args);
}
}

View File

@ -14,16 +14,18 @@ import org.springframework.http.client.ClientHttpResponse;
public class LoggingInterceptor implements ClientHttpRequestInterceptor { public class LoggingInterceptor implements ClientHttpRequestInterceptor {
final static Logger log = LoggerFactory.getLogger(LoggingInterceptor.class); final static Logger LOGGER = LoggerFactory.getLogger(LoggingInterceptor.class);
@Override @Override
public ClientHttpResponse intercept(HttpRequest req, byte[] reqBody, ClientHttpRequestExecution ex) throws IOException { public ClientHttpResponse intercept(HttpRequest req, byte[] reqBody, ClientHttpRequestExecution ex) throws IOException {
log.debug("Request body: {}", new String(reqBody, StandardCharsets.UTF_8)); LOGGER.debug("Request body: {}", new String(reqBody, StandardCharsets.UTF_8));
ClientHttpResponse response = ex.execute(req, reqBody); ClientHttpResponse response = ex.execute(req, reqBody);
if (LOGGER.isDebugEnabled()) {
InputStreamReader isr = new InputStreamReader(response.getBody(), StandardCharsets.UTF_8); InputStreamReader isr = new InputStreamReader(response.getBody(), StandardCharsets.UTF_8);
String body = new BufferedReader(isr).lines() String body = new BufferedReader(isr).lines()
.collect(Collectors.joining("\n")); .collect(Collectors.joining("\n"));
log.debug("Response body: {}", body); LOGGER.debug("Response body: {}", body);
}
return response; return response;
} }
} }

View File

@ -1,18 +1,21 @@
package com.baeldung.resttemplate.logging; package com.baeldung.resttemplate.logging;
import static org.hamcrest.CoreMatchers.equalTo; import static org.junit.Assert.assertEquals;
import static org.hamcrest.MatcherAssert.assertThat;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import org.junit.Test; import org.junit.Test;
import org.junit.runner.RunWith; import org.junit.runner.RunWith;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.boot.test.context.SpringBootTest; import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.http.HttpStatus; import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity; import org.springframework.http.ResponseEntity;
import org.springframework.http.client.ClientHttpRequestFactory;
import org.springframework.http.client.ClientHttpRequestInterceptor; import org.springframework.http.client.ClientHttpRequestInterceptor;
import org.springframework.http.client.HttpComponentsClientHttpRequestFactory; import org.springframework.http.client.HttpComponentsClientHttpRequestFactory;
import org.springframework.http.client.SimpleClientHttpRequestFactory;
import org.springframework.http.client.BufferingClientHttpRequestFactory;
import org.springframework.test.context.junit4.SpringRunner; import org.springframework.test.context.junit4.SpringRunner;
import org.springframework.util.CollectionUtils; import org.springframework.util.CollectionUtils;
import org.springframework.web.client.RestTemplate; import org.springframework.web.client.RestTemplate;
@ -22,6 +25,7 @@ import org.springframework.web.client.RestTemplate;
public class RestTemplateLoggingLiveTest { public class RestTemplateLoggingLiveTest {
private static final String baseUrl = "http://localhost:8080/spring-rest"; private static final String baseUrl = "http://localhost:8080/spring-rest";
private static final Logger LOGGER = LoggerFactory.getLogger(RestTemplateLoggingLiveTest.class);
@Test @Test
public void givenHttpClientConfiguration_whenSendGetForRequestEntity_thenRequestResponseFullLog() { public void givenHttpClientConfiguration_whenSendGetForRequestEntity_thenRequestResponseFullLog() {
@ -30,13 +34,22 @@ public class RestTemplateLoggingLiveTest {
restTemplate.setRequestFactory(new HttpComponentsClientHttpRequestFactory()); restTemplate.setRequestFactory(new HttpComponentsClientHttpRequestFactory());
final ResponseEntity<String> response = restTemplate.postForEntity(baseUrl + "/persons", "my request body", String.class); final ResponseEntity<String> response = restTemplate.postForEntity(baseUrl + "/persons", "my request body", String.class);
assertThat(response.getStatusCode(), equalTo(HttpStatus.OK)); assertEquals(HttpStatus.OK, response.getStatusCode());
assertEquals("[\"Lucie\",\"Jackie\",\"Danesh\",\"Tao\"]", response.getBody());
} }
@Test @Test
public void givenLoggingInterceptorConfiguration_whenSendGetForRequestEntity_thenRequestResponseCustomLog() { public void givenLoggingInterceptorConfiguration_whenSendGetForRequestEntity_thenRequestResponseCustomLog() {
RestTemplate restTemplate = new RestTemplate(); RestTemplate restTemplate = null;
if (LOGGER.isDebugEnabled()) {
ClientHttpRequestFactory factory = new BufferingClientHttpRequestFactory(
new SimpleClientHttpRequestFactory());
restTemplate = new RestTemplate(factory);
} else {
restTemplate = new RestTemplate();
}
List<ClientHttpRequestInterceptor> interceptors = restTemplate.getInterceptors(); List<ClientHttpRequestInterceptor> interceptors = restTemplate.getInterceptors();
if (CollectionUtils.isEmpty(interceptors)) { if (CollectionUtils.isEmpty(interceptors)) {
interceptors = new ArrayList<>(); interceptors = new ArrayList<>();
@ -45,6 +58,7 @@ public class RestTemplateLoggingLiveTest {
restTemplate.setInterceptors(interceptors); restTemplate.setInterceptors(interceptors);
final ResponseEntity<String> response = restTemplate.postForEntity(baseUrl + "/persons", "my request body", String.class); final ResponseEntity<String> response = restTemplate.postForEntity(baseUrl + "/persons", "my request body", String.class);
assertThat(response.getStatusCode(), equalTo(HttpStatus.OK)); assertEquals(HttpStatus.OK, response.getStatusCode());
assertEquals("[\"Lucie\",\"Jackie\",\"Danesh\",\"Tao\"]", response.getBody());
} }
} }

View File

@ -1,5 +1,5 @@
logging.level.org.springframework.web.client.RestTemplate=DEBUG logging.level.org.springframework.web.client.RestTemplate=DEBUG
logging.level.com.baeldung.resttemplate.logging.LoggingInterceptor=DEBUG logging.level.com.baeldung.resttemplate.logging=DEBUG
logging.level.org.apache.http=DEBUG logging.level.org.apache.http=DEBUG
logging.level.httpclient.wire=DEBUG logging.level.httpclient.wire=DEBUG
logging.pattern.console=%20logger{20} - %msg%n logging.pattern.console=%20logger{20} - %msg%n

View File

@ -46,7 +46,7 @@ public class TestResultLoggerExtension implements TestWatcher, AfterAllCallback
@Override @Override
public void testFailed(ExtensionContext context, Throwable cause) { public void testFailed(ExtensionContext context, Throwable cause) {
LOG.info("Test Aborted for test {}: ", context.getDisplayName()); LOG.info("Test Failed for test {}: ", context.getDisplayName());
testResultsStatus.add(TestResultStatus.FAILED); testResultsStatus.add(TestResultStatus.FAILED);
} }

View File

@ -55,8 +55,8 @@
</dependencies> </dependencies>
<properties> <properties>
<junit.jupiter.version>5.6.2</junit.jupiter.version> <junit.jupiter.version>5.7.0</junit.jupiter.version>
<junit.platform.version>1.6.0</junit.platform.version> <junit.platform.version>1.7.0</junit.platform.version>
<log4j2.version>2.8.2</log4j2.version> <log4j2.version>2.8.2</log4j2.version>
<assertj-core.version>3.11.1</assertj-core.version> <assertj-core.version>3.11.1</assertj-core.version>
</properties> </properties>

View File

@ -37,7 +37,6 @@
<dependency> <dependency>
<groupId>com.fasterxml.jackson.core</groupId> <groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId> <artifactId>jackson-databind</artifactId>
<version>${jackson.version}</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.springframework.boot</groupId> <groupId>org.springframework.boot</groupId>
@ -72,7 +71,6 @@
<plugin> <plugin>
<groupId>org.springframework.boot</groupId> <groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId> <artifactId>spring-boot-maven-plugin</artifactId>
<version>2.0.5.RELEASE</version>
</plugin> </plugin>
<!--<plugin>--> <!--<plugin>-->
<!--<groupId>net.alchim31.maven</groupId>--> <!--<groupId>net.alchim31.maven</groupId>-->
@ -117,10 +115,10 @@
<maven.compiler.source>1.8</maven.compiler.source> <maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target> <maven.compiler.target>1.8</maven.compiler.target>
<encoding>UTF-8</encoding> <encoding>UTF-8</encoding>
<scala.version>2.11.12</scala.version> <!--2.11.12 --> <!--2.12.6 --> <scala.version>2.12.12</scala.version> <!--2.11.12 --> <!--2.12.6 -->
<gatling.version>2.2.5</gatling.version> <!--2.2.5 --> <!--2.3.1 --> <gatling.version>3.4.0</gatling.version> <!--2.2.5 --> <!--2.3.1 -->
<scala-maven-plugin.version>3.2.2</scala-maven-plugin.version> <!--3.2.2 --> <!--3.3.2 --> <scala-maven-plugin.version>4.4.0</scala-maven-plugin.version> <!--3.2.2 --> <!--3.3.2 -->
<gatling-maven-plugin.version>2.2.1</gatling-maven-plugin.version> <!--2.2.1 --> <!--2.2.4 --> <gatling-maven-plugin.version>3.1.0</gatling-maven-plugin.version> <!--2.2.1 --> <!--2.2.4 -->
<jmeter.version>5.0</jmeter.version> <jmeter.version>5.0</jmeter.version>
</properties> </properties>

View File

@ -4,8 +4,11 @@ import javax.persistence.Entity;
import javax.persistence.GeneratedValue; import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType; import javax.persistence.GenerationType;
import javax.persistence.Id; import javax.persistence.Id;
import javax.persistence.Index;
import javax.persistence.Table;
@Entity @Entity
@Table(indexes = {@Index(columnList="customerId")})
public class CustomerRewardsAccount { public class CustomerRewardsAccount {
@Id @Id

Some files were not shown because too many files have changed in this diff Show More