Merge remote-tracking branch 'eugenp/master'

This commit is contained in:
DOHA 2018-10-01 00:54:06 +03:00
commit faae433c40
326 changed files with 5939 additions and 1638 deletions

View File

@ -24,3 +24,7 @@
- [Practical Java Examples of the Big O Notation](http://www.baeldung.com/java-algorithm-complexity)
- [Find the Middle Element of a Linked List](http://www.baeldung.com/java-linked-list-middle-element)
- [An Introduction to the Theory of Big-O Notation](http://www.baeldung.com/big-o-notation)
- [Check If Two Rectangles Overlap In Java](https://www.baeldung.com/java-check-if-two-rectangles-overlap)
- [Calculate the Distance Between Two Points in Java](https://www.baeldung.com/java-distance-between-two-points)
- [Find the Intersection of Two Lines in Java](https://www.baeldung.com/java-intersection-of-two-lines)
- [Check If a String Contains All The Letters of The Alphabet](https://www.baeldung.com/java-string-contains-all-letters)

View File

@ -0,0 +1,50 @@
package com.baeldung.algorithms.mergesort;
public class MergeSort {
public static void main(String[] args) {
int[] a = { 5, 1, 6, 2, 3, 4 };
mergeSort(a, a.length);
for (int i = 0; i < a.length; i++)
System.out.println(a[i]);
}
public static void mergeSort(int[] a, int n) {
if (n < 2)
return;
int mid = n / 2;
int[] l = new int[mid];
int[] r = new int[n - mid];
for (int i = 0; i < mid; i++) {
l[i] = a[i];
}
for (int i = mid; i < n; i++) {
r[i - mid] = a[i];
}
mergeSort(l, mid);
mergeSort(r, n - mid);
merge(a, l, r, mid, n - mid);
}
public static void merge(int[] a, int[] l, int[] r, int left, int right) {
int i = 0, j = 0, k = 0;
while (i < left && j < right) {
if (l[i] < r[j])
a[k++] = l[i++];
else
a[k++] = r[j++];
}
while (i < left)
a[k++] = l[i++];
while (j < right)
a[k++] = r[j++];
}
}

View File

@ -0,0 +1,17 @@
package com.baeldung.algorithms.mergesort;
import org.junit.Assert;
import org.junit.Test;
public class MergeSortUnitTest {
@Test
public void positiveTest() {
int[] actual = { 5, 1, 6, 2, 3, 4 };
int[] expected = { 1, 2, 3, 4, 5, 6 };
MergeSort.mergeSort(actual, actual.length);
Assert.assertArrayEquals(expected, actual);
}
}

View File

@ -7,7 +7,7 @@ import junit.framework.TestSuite;
/**
* Unit test for simple App.
*/
public class AppTest
public class AppUnitTest
extends TestCase
{
/**
@ -15,7 +15,7 @@ public class AppTest
*
* @param testName name of the test case
*/
public AppTest( String testName )
public AppUnitTest( String testName )
{
super( testName );
}
@ -25,7 +25,7 @@ public class AppTest
*/
public static Test suite()
{
return new TestSuite( AppTest.class );
return new TestSuite( AppUnitTest.class );
}
/**

View File

@ -6,7 +6,7 @@
<groupId>com.baeldung</groupId>
<artifactId>apache-avro</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>Apache Avro</version>
<name>Apache Avro</name>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>

View File

@ -13,7 +13,7 @@ import java.util.Objects;
import static org.junit.Assert.*;
public class AvroSerealizerDeSerealizerTest {
public class AvroSerealizerDeSerealizerUnitTest {
AvroSerealizer serealizer;
AvroDeSerealizer deSerealizer;

View File

@ -1,5 +1,4 @@
### Relevant articles
- [Introduction to Asciidoctor](http://www.baeldung.com/introduction-to-asciidoctor)
- [Generating a Book with Asciidoctor](http://www.baeldung.com/asciidoctor-book)
- [Introduction to Asciidoctor in Java](http://www.baeldung.com/asciidoctor)

View File

@ -61,9 +61,10 @@
</build>
<properties>
<asciidoctor-maven-plugin.version>1.5.5</asciidoctor-maven-plugin.version>
<asciidoctorj.version>1.5.4</asciidoctorj.version>
<asciidoctorj-pdf.src.version>1.5.0-alpha.11</asciidoctorj-pdf.src.version>
<asciidoctor-maven-plugin.version>1.5.6</asciidoctor-maven-plugin.version>
<asciidoctorj.version>1.5.6</asciidoctorj.version>
<asciidoctorj-pdf.version>1.5.0-alpha.15</asciidoctorj-pdf.version>
<asciidoctorj-pdf.plugin.version>1.5.0-alpha.15</asciidoctorj-pdf.plugin.version>
</properties>

View File

@ -3,7 +3,7 @@ package com.baeldung.asciidoctor;
import org.junit.Assert;
import org.junit.Test;
public class AsciidoctorDemoTest {
public class AsciidoctorDemoIntegrationTest {
@Test
public void givenString_whenConverting_thenResultingHTMLCode() {

View File

@ -0,0 +1,38 @@
<?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>
<artifactId>flyway-cdi</artifactId>
<parent>
<groupId>com.baeldung</groupId>
<artifactId>cdi-portable-extension</artifactId>
<version>1.0-SNAPSHOT</version>
</parent>
<dependencies>
<dependency>
<groupId>javax.enterprise</groupId>
<artifactId>cdi-api</artifactId>
<version>2.0.SP1</version>
</dependency>
<dependency>
<groupId>org.flywaydb</groupId>
<artifactId>flyway-core</artifactId>
<version>5.1.4</version>
</dependency>
<dependency>
<groupId>org.apache.tomcat</groupId>
<artifactId>tomcat-jdbc</artifactId>
<version>8.5.33</version>
</dependency>
<dependency>
<groupId>javax.annotation</groupId>
<artifactId>javax.annotation-api</artifactId>
<version>1.3.2</version>
</dependency>
</dependencies>
</project>

View File

@ -0,0 +1,74 @@
package com.baeldung.cdi.extension;
import org.apache.tomcat.jdbc.pool.DataSource;
import org.flywaydb.core.Flyway;
import javax.annotation.sql.DataSourceDefinition;
import javax.enterprise.context.ApplicationScoped;
import javax.enterprise.event.Observes;
import javax.enterprise.inject.Any;
import javax.enterprise.inject.Default;
import javax.enterprise.inject.literal.InjectLiteral;
import javax.enterprise.inject.spi.*;
import javax.enterprise.util.AnnotationLiteral;
/**
* Flyway is now under CDI container like:
*
* @ApplicationScoped
* @FlywayType public class Flyway{
* @Inject setDataSource(DataSource dataSource){
* //...
* }
* }
*/
public class FlywayExtension implements Extension {
DataSourceDefinition dataSourceDefinition = null;
public void registerFlywayType(@Observes BeforeBeanDiscovery bbdEvent) {
bbdEvent.addAnnotatedType(Flyway.class, Flyway.class.getName());
}
public void detectDataSourceDefinition(@Observes @WithAnnotations(DataSourceDefinition.class) ProcessAnnotatedType<?> patEvent) {
AnnotatedType at = patEvent.getAnnotatedType();
dataSourceDefinition = at.getAnnotation(DataSourceDefinition.class);
}
public void processAnnotatedType(@Observes ProcessAnnotatedType<Flyway> patEvent) {
patEvent.configureAnnotatedType()
//Add Scope
.add(ApplicationScoped.Literal.INSTANCE)
//Add Qualifier
.add(new AnnotationLiteral<FlywayType>() {
})
//Decorate setDataSource(DataSource dataSource){} with @Inject
.filterMethods(annotatedMethod -> {
return annotatedMethod.getParameters().size() == 1 &&
annotatedMethod.getParameters().get(0).getBaseType().equals(javax.sql.DataSource.class);
})
.findFirst().get().add(InjectLiteral.INSTANCE);
}
void afterBeanDiscovery(@Observes AfterBeanDiscovery abdEvent, BeanManager bm) {
abdEvent.addBean()
.types(javax.sql.DataSource.class, DataSource.class)
.qualifiers(new AnnotationLiteral<Default>() {}, new AnnotationLiteral<Any>() {})
.scope(ApplicationScoped.class)
.name(DataSource.class.getName())
.beanClass(DataSource.class)
.createWith(creationalContext -> {
DataSource instance = new DataSource();
instance.setUrl(dataSourceDefinition.url());
instance.setDriverClassName(dataSourceDefinition.className());
return instance;
});
}
void runFlywayMigration(@Observes AfterDeploymentValidation adv, BeanManager manager) {
Flyway flyway = manager.createInstance().select(Flyway.class, new AnnotationLiteral<FlywayType>() {}).get();
flyway.migrate();
}
}

View File

@ -0,0 +1,14 @@
package com.baeldung.cdi.extension;
import javax.inject.Qualifier;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
import static java.lang.annotation.ElementType.*;
@Retention(RetentionPolicy.RUNTIME)
@Target({FIELD, METHOD, PARAMETER, TYPE})
@Qualifier
public @interface FlywayType {
}

View File

@ -0,0 +1,6 @@
<beans version="2.0" xmlns="http://xmlns.jcp.org/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee
http://xmlns.jcp.org/xml/ns/javaee/beans_2_0.xsd"
bean-discovery-mode="annotated">
</beans>

View File

@ -0,0 +1,2 @@
com.baeldung.cdi.extension.FlywayExtension

View File

@ -0,0 +1,52 @@
<?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>
<artifactId>main-app</artifactId>
<packaging>jar</packaging>
<parent>
<groupId>com.baeldung</groupId>
<artifactId>cdi-portable-extension</artifactId>
<version>1.0-SNAPSHOT</version>
</parent>
<dependencies>
<dependency>
<groupId>javax.enterprise</groupId>
<artifactId>cdi-api</artifactId>
<version>2.0.SP1</version>
</dependency>
<dependency>
<groupId>org.jboss.weld.se</groupId>
<artifactId>weld-se-core</artifactId>
<version>3.0.5.Final</version>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>com.baeldung</groupId>
<artifactId>flyway-cdi</artifactId>
<version>1.0-SNAPSHOT</version>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>com.h2database</groupId>
<artifactId>h2</artifactId>
<version>1.4.197</version>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>javax.annotation</groupId>
<artifactId>javax.annotation-api</artifactId>
<version>1.3.2</version>
</dependency>
</dependencies>
</project>

View File

@ -0,0 +1,16 @@
package com.baeldung.cdi.extension;
import javax.annotation.sql.DataSourceDefinition;
import javax.enterprise.context.ApplicationScoped;
import javax.enterprise.inject.se.SeContainer;
import javax.enterprise.inject.se.SeContainerInitializer;
@ApplicationScoped
@DataSourceDefinition(name = "ds", className = "org.h2.Driver", url = "jdbc:h2:mem:testdb")
public class MainApp {
public static void main(String[] args) {
SeContainerInitializer initializer = SeContainerInitializer.newInstance();
try (SeContainer container = initializer.initialize()) {
}
}
}

View File

@ -0,0 +1,6 @@
<beans version="2.0" xmlns="http://xmlns.jcp.org/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee
http://xmlns.jcp.org/xml/ns/javaee/beans_2_0.xsd"
bean-discovery-mode="annotated">
</beans>

View File

@ -0,0 +1,4 @@
create table PERSON (
ID int not null,
NAME varchar(100) not null
);

View File

@ -0,0 +1,3 @@
insert into PERSON (ID, NAME) values (1, 'Axel');
insert into PERSON (ID, NAME) values (2, 'Mr. Foo');
insert into PERSON (ID, NAME) values (3, 'Ms. Bar');

View File

@ -0,0 +1,30 @@
<?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</groupId>
<artifactId>cdi-portable-extension</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>pom</packaging>
<properties>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
</properties>
<modules>
<module>main-app</module>
<module>flyway-cdi</module>
</modules>
<dependencies>
<dependency>
<groupId>javax.enterprise</groupId>
<artifactId>cdi-api</artifactId>
<version>2.0.SP1</version>
</dependency>
</dependencies>
</project>

View File

@ -48,4 +48,6 @@
- [Thread Safe LIFO Data Structure Implementations](https://www.baeldung.com/java-lifo-thread-safe)
- [Collections.emptyList() vs. New List Instance](https://www.baeldung.com/java-collections-emptylist-new-list)
- [Initialize a HashMap in Java](https://www.baeldung.com/java-initialize-hashmap)
- [](https://www.baeldung.com/java-hashset-arraylist-contains-performance)
- [Performance of contains() in a HashSet vs ArrayList](https://www.baeldung.com/java-hashset-arraylist-contains-performance)
- [Get the Key for a Value from a Java Map](https://www.baeldung.com/java-map-key-from-value)
- [Time Complexity of Java Collections](https://www.baeldung.com/java-collections-complexity)

View File

@ -0,0 +1,96 @@
package com.baeldung.map.util;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Optional;
public class MapMax {
public <K, V extends Comparable<V>> V maxUsingIteration(Map<K, V> map) {
Map.Entry<K, V> maxEntry = null;
for (Map.Entry<K, V> entry : map.entrySet()) {
if (maxEntry == null || entry.getValue()
.compareTo(maxEntry.getValue()) > 0) {
maxEntry = entry;
}
}
return maxEntry.getValue();
}
public <K, V extends Comparable<V>> V maxUsingCollectionsMax(Map<K, V> map) {
Entry<K, V> maxEntry = Collections.max(map.entrySet(), new Comparator<Entry<K, V>>() {
public int compare(Entry<K, V> e1, Entry<K, V> e2) {
return e1.getValue()
.compareTo(e2.getValue());
}
});
return maxEntry.getValue();
}
public <K, V extends Comparable<V>> V maxUsingCollectionsMaxAndLambda(Map<K, V> map) {
Entry<K, V> maxEntry = Collections.max(map.entrySet(), (Entry<K, V> e1, Entry<K, V> e2) -> e1.getValue()
.compareTo(e2.getValue()));
return maxEntry.getValue();
}
public <K, V extends Comparable<V>> V maxUsingCollectionsMaxAndMethodReference(Map<K, V> map) {
Entry<K, V> maxEntry = Collections.max(map.entrySet(), Comparator.comparing(Map.Entry::getValue));
return maxEntry.getValue();
}
public <K, V extends Comparable<V>> V maxUsingStreamAndLambda(Map<K, V> map) {
Optional<Entry<K, V>> maxEntry = map.entrySet()
.stream()
.max((Entry<K, V> e1, Entry<K, V> e2) -> e1.getValue()
.compareTo(e2.getValue()));
return maxEntry.get()
.getValue();
}
public <K, V extends Comparable<V>> V maxUsingStreamAndMethodReference(Map<K, V> map) {
Optional<Entry<K, V>> maxEntry = map.entrySet()
.stream()
.max(Comparator.comparing(Map.Entry::getValue));
return maxEntry.get()
.getValue();
}
public static void main(String[] args) {
Map<Integer, Integer> map = new HashMap<Integer, Integer>();
map.put(1, 3);
map.put(2, 4);
map.put(3, 5);
map.put(4, 6);
map.put(5, 7);
MapMax mapMax = new MapMax();
System.out.println(mapMax.maxUsingIteration(map));
System.out.println(mapMax.maxUsingCollectionsMax(map));
System.out.println(mapMax.maxUsingCollectionsMaxAndLambda(map));
System.out.println(mapMax.maxUsingCollectionsMaxAndMethodReference(map));
System.out.println(mapMax.maxUsingStreamAndLambda(map));
System.out.println(mapMax.maxUsingStreamAndMethodReference(map));
}
}

View File

@ -0,0 +1,59 @@
package com.baeldung.map.util;
import static org.junit.Assert.assertEquals;
import java.util.HashMap;
import java.util.Map;
import org.junit.Before;
import org.junit.Test;
public class MapMaxUnitTest {
Map<Integer, Integer> map = null;
MapMax mapMax = null;
@Before
public void setupTestData() {
map = new HashMap<Integer, Integer>();
map.put(23, 12);
map.put(46, 24);
map.put(27, 38);
mapMax = new MapMax();
}
@Test
public void givenMap_whenIterated_thenReturnMaxValue() {
assertEquals(new Integer(38), mapMax.maxUsingIteration(map));
}
@Test
public void givenMap_whenUsingCollectionsMax_thenReturnMaxValue() {
assertEquals(new Integer(38), mapMax.maxUsingCollectionsMax(map));
}
@Test
public void givenMap_whenUsingCollectionsMaxAndLambda_thenReturnMaxValue() {
assertEquals(new Integer(38), mapMax.maxUsingCollectionsMaxAndLambda(map));
}
@Test
public void givenMap_whenUsingCollectionsMaxAndMethodReference_thenReturnMaxValue() {
assertEquals(new Integer(38), mapMax.maxUsingCollectionsMaxAndMethodReference(map));
}
@Test
public void givenMap_whenUsingStreamAndLambda_thenReturnMaxValue() {
assertEquals(new Integer(38), mapMax.maxUsingStreamAndLambda(map));
}
@Test
public void givenMap_whenUsingStreamAndMethodReference_thenReturnMaxValue() {
assertEquals(new Integer(38), mapMax.maxUsingStreamAndMethodReference (map));
}
}

View File

@ -31,3 +31,4 @@
- [Create a Symbolic Link with Java](http://www.baeldung.com/java-symlink)
- [Quick Use of FilenameFilter](http://www.baeldung.com/java-filename-filter)
- [Initialize a HashMap in Java](https://www.baeldung.com/java-initialize-hashmap)
- [ Read a File into an ArrayList](https://www.baeldung.com/java-file-to-arraylist)

View File

@ -18,6 +18,7 @@ import java.net.URLConnection;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.stream.Collectors;
import java.util.stream.Stream;
import static org.junit.Assert.assertEquals;
@ -50,7 +51,7 @@ public class FileOperationsManualTest {
@Test
public void givenFileName_whenUsingJarFile_thenFileData() throws IOException {
String expectedData = "BSD License";
String expectedData = "MIT License";
Class clazz = Matchers.class;
InputStream inputStream = clazz.getResourceAsStream("/LICENSE.txt");
@ -79,7 +80,7 @@ public class FileOperationsManualTest {
ClassLoader classLoader = getClass().getClassLoader();
File file = new File(classLoader.getResource("fileTest.txt").getFile());
String data = FileUtils.readFileToString(file);
String data = FileUtils.readFileToString(file, "UTF-8");
assertEquals(expectedData, data.trim());
}
@ -102,12 +103,11 @@ public class FileOperationsManualTest {
Path path = Paths.get(getClass().getClassLoader().getResource("fileTest.txt").toURI());
StringBuilder data = new StringBuilder();
Stream<String> lines = Files.lines(path);
lines.forEach(line -> data.append(line).append("\n"));
String data = lines.collect(Collectors.joining("\n"));
lines.close();
assertEquals(expectedData, data.toString().trim());
assertEquals(expectedData, data.trim());
}
private String readFromInputStream(InputStream inputStream) throws IOException {

View File

@ -0,0 +1 @@
Hello World from fileTest.txt!!!

View File

@ -151,3 +151,4 @@
- [ClassCastException: Arrays$ArrayList cannot be cast to ArrayList](https://www.baeldung.com/java-classcastexception-arrays-arraylist)
- [Throw Exception in Optional in Java 8](https://www.baeldung.com/java-optional-throw-exception)
- [Add a Character to a String at a Given Position](https://www.baeldung.com/java-add-character-to-string)
- [Synthetic Constructs in Java](https://www.baeldung.com/java-synthetic)

View File

@ -0,0 +1,43 @@
package com.baeldung.ternaryoperator;
import static org.assertj.core.api.Assertions.assertThat;
import org.junit.Test;
public class TernaryOperatorUnitTest {
@Test
public void givenACondition_whenUsingTernaryOperator_thenItEvaluatesConditionAndReturnsAValue() {
int number = 10;
String msg = number > 10 ? "Number is greater than 10" : "Number is less than or equal to 10";
assertThat(msg).isEqualTo("Number is less than or equal to 10");
}
@Test
public void givenATrueCondition_whenUsingTernaryOperator_thenOnlyExpression1IsEvaluated() {
int exp1 = 0, exp2 = 0;
int result = 12 > 10 ? ++exp1 : ++exp2;
assertThat(exp1).isEqualTo(1);
assertThat(exp2).isEqualTo(0);
assertThat(result).isEqualTo(1);
}
@Test
public void givenAFalseCondition_whenUsingTernaryOperator_thenOnlyExpression2IsEvaluated() {
int exp1 = 0, exp2 = 0;
int result = 8 > 10 ? ++exp1 : ++exp2;
assertThat(exp1).isEqualTo(0);
assertThat(exp2).isEqualTo(1);
assertThat(result).isEqualTo(1);
}
@Test
public void givenANestedCondition_whenUsingTernaryOperator_thenCorrectValueIsReturned() {
int number = 6;
String msg = number > 10 ? "Number is greater than 10" : number > 5 ? "Number is greater than 5" : "Number is less than or equal to 5";
assertThat(msg).isEqualTo("Number is greater than 5");
}
}

View File

@ -34,3 +34,6 @@
- [Kotlin Constructors](https://www.baeldung.com/kotlin-constructors)
- [Creational Design Patterns in Kotlin: Builder](https://www.baeldung.com/kotlin-builder-pattern)
- [Kotlin Nested and Inner Classes](https://www.baeldung.com/kotlin-inner-classes)
- [Kotlin with Ktor](https://www.baeldung.com/kotlin-ktor)
- [Fuel HTTP Library with Kotlin](https://www.baeldung.com/kotlin-fuel)
- [Introduction to Kovenant Library for Kotlin](https://www.baeldung.com/kotlin-kovenant)

View File

@ -15,7 +15,6 @@
<dependency>
<groupId>javax</groupId>
<artifactId>javaee-api</artifactId>
<version>${javaee-api.version}</version>
<scope>provided</scope>
</dependency>
</dependencies>

View File

@ -24,7 +24,6 @@
<dependency>
<groupId>javax</groupId>
<artifactId>javaee-api</artifactId>
<version>${javaee-api.version}</version>
<scope>provided</scope>
</dependency>
<dependency>

View File

@ -65,6 +65,7 @@
<properties>
<flyway-core.version>5.0.2</flyway-core.version>
<flyway-maven-plugin.version>5.0.2</flyway-maven-plugin.version>
<h2.version>1.4.195</h2.version>
</properties>
</project>

View File

@ -16,7 +16,7 @@ import org.springframework.test.context.junit4.SpringRunner;
@RunWith(SpringRunner.class)
@DirtiesContext(classMode = ClassMode.AFTER_EACH_TEST_METHOD)
@ContextConfiguration(classes = FlywayCallbackTestConfig.class)
public class FlywayApplicationTest {
public class FlywayApplicationUnitTest {
private Log log = LogFactory.getLog(getClass());

View File

@ -18,9 +18,9 @@ import org.junit.Test;
import com.stackify.models.User;
import com.stackify.services.MyService;
public class MyServiceTest {
public class MyServiceUnitTest {
private static final Logger logger = LogManager.getLogger(MyServiceTest.class);
private static final Logger logger = LogManager.getLogger(MyServiceUnitTest.class);
@Test
public void testService() {

View File

@ -9,7 +9,7 @@ import com.stackify.models.Employee;
import ch.qos.logback.classic.Level;
public class EmployeeServiceTest {
public class EmployeeServiceUnitTest {
private static final Logger logger = LoggerFactory.getLogger(Logger.ROOT_LOGGER_NAME);
private EmployeeService employeeService = new EmployeeService();

View File

@ -12,7 +12,7 @@
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.0.0.M5</version>
<version>2.0.0.RELEASE</version>
<relativePath /> <!-- lookup parent from repository -->
</parent>

View File

@ -11,7 +11,7 @@
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.0.0.M6</version>
<version>2.0.0.RELEASE</version>
<relativePath />
</parent>

View File

@ -6,7 +6,7 @@ import io.restassured.RestAssured;
import static io.restassured.RestAssured.*;
import static org.hamcrest.CoreMatchers.*;
public class UserServiceTest {
public class UserServiceLiveTest {
@Test
public void whenAddUser_thenGetUserOk() {
RestAssured.baseURI = "http://localhost:8080/rest-server";

View File

@ -14,3 +14,4 @@
- [Bootstrapping JPA Programmatically in Java](http://www.baeldung.com/java-bootstrap-jpa)
- [Optimistic Locking in JPA](http://www.baeldung.com/jpa-optimistic-locking)
- [Hibernate Entity Lifecycle](https://www.baeldung.com/hibernate-entity-lifecycle)
- [@JoinColumn Annotation Explained](https://www.baeldung.com/jpa-join-column)

View File

@ -0,0 +1,32 @@
package com.baeldung.date;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.time.LocalDate;
import java.time.Period;
import java.util.Date;
import org.joda.time.Years;
public class AgeCalculator {
public int calculateAge(LocalDate birthDate, LocalDate currentDate) {
// validate inputs ...
return Period.between(birthDate, currentDate)
.getYears();
}
public int calculateAgeWithJodaTime(org.joda.time.LocalDate birthDate, org.joda.time.LocalDate currentDate) {
// validate inputs ...
Years age = Years.yearsBetween(birthDate, currentDate);
return age.getYears();
}
public int calculateAgeWithJava7(Date birthDate, Date currentDate) {
// validate inputs ...
DateFormat formatter = new SimpleDateFormat("yyyyMMdd");
int d1 = Integer.parseInt(formatter.format(birthDate));
int d2 = Integer.parseInt(formatter.format(currentDate));
int age = (d2 - d1) / 10000;
return age;
}
}

View File

@ -0,0 +1,31 @@
package com.baeldung.date;
import static org.junit.Assert.assertEquals;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.time.LocalDate;
import java.util.Date;
import org.junit.jupiter.api.Test;
public class AgeCalculatorUnitTest {
AgeCalculator ageCalculator = new AgeCalculator();
@Test
public void givenLocalDate_whenCalculateAge_thenOk() {
assertEquals(10, ageCalculator.calculateAge(LocalDate.of(2008, 5, 20), LocalDate.of(2018, 9, 20)));
}
@Test
public void givenJodaTime_whenCalculateAge_thenOk() {
assertEquals(10, ageCalculator.calculateAgeWithJodaTime(new org.joda.time.LocalDate(2008, 5, 20), new org.joda.time.LocalDate(2018, 9, 20)));
}
@Test
public void givenDate_whenCalculateAge_thenOk() throws ParseException {
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-mm-dd");
Date birthDate = sdf.parse("2008-05-20");
Date currentDate = sdf.parse("2018-09-20");
assertEquals(10, ageCalculator.calculateAgeWithJava7(birthDate, currentDate));
}
}

View File

@ -14,7 +14,7 @@ import java.util.concurrent.TimeUnit;
import static org.junit.Assert.assertEquals;
public class DateDiffTest {
public class DateDiffUnitTest {
@Test
public void givenTwoDatesBeforeJava8_whenDifferentiating_thenWeGetSix() throws ParseException {
SimpleDateFormat sdf = new SimpleDateFormat("MM/dd/yyyy", Locale.ENGLISH);

View File

@ -3,11 +3,16 @@
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</groupId>
<artifactId>java-ee-8-security-api</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>pom</packaging>
<parent>
<groupId>com.baeldung</groupId>
<artifactId>parent-modules</artifactId>
<version>1.0.0-SNAPSHOT</version>
</parent>
<dependencies>
<dependency>
@ -53,10 +58,6 @@
</build>
<properties>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<defaultHttpPort>9080</defaultHttpPort>
<defaultHttpsPort>9443</defaultHttpsPort>

View File

@ -0,0 +1,21 @@
package com.baeldung.percentage;
import java.util.Scanner;
public class PercentageCalculator {
public double calculatePercentage(double obtained,double total){
return obtained*100/total;
}
public static void main(String[] args) {
PercentageCalculator pc = new PercentageCalculator();
Scanner in = new Scanner(System.in);
System.out.println("Enter obtained marks:");
double obtained = in.nextDouble();
System.out.println("Enter total marks:");
double total =in.nextDouble();
System.out.println("Percentage obtained :"+pc.calculatePercentage(obtained,total));
}
}

View File

@ -0,0 +1,33 @@
package com.baeldung.percentage;
import org.junit.Assert;
import org.junit.Test;
public class PercentageCalculatorUnitTest {
private PercentageCalculator pc = new PercentageCalculator();
@Test
public void whenPass2Integers_thenShouldCalculatePercentage(){
Assert.assertEquals("Result not as expected",
50.0,pc.calculatePercentage(50,100),0.1);
}
@Test
public void whenPassObtainedMarksAsDouble_thenShouldCalculatePercentage(){
Assert.assertEquals("Result not as expected",5.05,
pc.calculatePercentage(50.5,1000),0.1);
}
@Test
public void whenPassTotalMarksAsDouble_thenShouldCalculatePercentage(){
Assert.assertEquals("Result not as expected",19.6,
pc.calculatePercentage(5,25.5),0.1);
}
@Test
public void whenPass2DoubleNumbers_thenShouldCalculatePercentage(){
Assert.assertEquals("Result not as expected",20,
pc.calculatePercentage(5.5,27.5),0.1);
}
}

View File

@ -1,4 +1,4 @@
package com.baeldung.collection;
package com.baeldung.stream;
import java.util.ArrayList;
import java.util.List;

View File

@ -27,3 +27,6 @@
- [Compact Strings in Java 9](http://www.baeldung.com/java-9-compact-string)
- [Java Check a String for Lowercase/Uppercase Letter, Special Character and Digit](https://www.baeldung.com/java-lowercase-uppercase-special-character-digit-regex)
- [Convert java.util.Date to String](https://www.baeldung.com/java-util-date-to-string)
- [Converting a Stack Trace to a String in Java](https://www.baeldung.com/java-stacktrace-to-string)
- [Sorting a String Alphabetically in Java](https://www.baeldung.com/java-sort-string-alphabetically)
- [Remove Emojis from a Java String](https://www.baeldung.com/java-string-remove-emojis)

View File

@ -1,23 +1,43 @@
package com.baeldung.string;
import com.google.common.base.Splitter;
import org.apache.commons.lang3.StringUtils;
import org.openjdk.jmh.annotations.*;
import org.openjdk.jmh.runner.Runner;
import org.openjdk.jmh.runner.options.Options;
import org.openjdk.jmh.runner.options.OptionsBuilder;
import java.util.ArrayList;
import java.util.List;
import java.util.StringTokenizer;
import java.util.concurrent.TimeUnit;
import java.util.regex.Pattern;
@BenchmarkMode(Mode.SingleShotTime)
@OutputTimeUnit(TimeUnit.MILLISECONDS)
@Measurement(batchSize = 10000, iterations = 10)
@Warmup(batchSize = 10000, iterations = 10)
public class StringPerformance extends StringPerformanceHints {
@Measurement(batchSize = 100000, iterations = 10)
@Warmup(batchSize = 100000, iterations = 10)
@State(Scope.Thread)
public class StringPerformance {
protected String baeldung = "baeldung";
protected String longString = "Hello baeldung, I am a bit longer than other Strings";
protected String formatString = "hello %s, nice to meet you";
protected String formatDigit = "%d";
protected String emptyString = " ";
protected String result = "";
protected int sampleNumber = 100;
protected Pattern spacePattern = Pattern.compile(emptyString);
protected Pattern longPattern = Pattern.compile(longString);
protected List<String> stringSplit = new ArrayList<>();
protected List<String> stringTokenizer = new ArrayList<>();
@Benchmark
public String benchmarkStringDynamicConcat() {
return dynamicConcat();
result += baeldung;
return result;
}
@Benchmark
@ -36,27 +56,30 @@ public class StringPerformance extends StringPerformanceHints {
@Benchmark
public String benchmarkStringConstructor() {
return stringConstructor();
String result = new String("baeldung");
return result;
}
@Benchmark
public String benchmarkStringLiteral() {
return stringLiteral();
String result = "baeldung";
return result;
}
@Benchmark
public String benchmarkStringFormat_s() {
return stringFormat_s();
return String.format(formatString, baeldung);
}
@Benchmark
public String benchmarkStringConcat() {
return stringConcat();
result = result.concat(baeldung);
return result;
}
@Benchmark
public String benchmarkStringIntern() {
return stringIntern();
return baeldung.intern();
}
@Benchmark
@ -71,85 +94,95 @@ public class StringPerformance extends StringPerformanceHints {
@Benchmark
public List<String> benchmarkGuavaSplitter() {
return guavaSplitter();
return Splitter.on(" ").trimResults()
.omitEmptyStrings()
.splitToList(longString);
}
@Benchmark
public String [] benchmarkStringSplit() {
return stringSplit();
return longString.split(emptyString);
}
@Benchmark
public String [] benchmarkStringSplitPattern() {
return stringSplitPattern();
return spacePattern.split(longString, 0);
}
@Benchmark
public List benchmarkStringTokenizer() {
return stringTokenizer();
StringTokenizer st = new StringTokenizer(longString);
while (st.hasMoreTokens()) {
stringTokenizer.add(st.nextToken());
}
return stringTokenizer;
}
@Benchmark
public List benchmarkStringIndexOf() {
return stringIndexOf();
int pos = 0, end;
while ((end = longString.indexOf(' ', pos)) >= 0) {
stringSplit.add(longString.substring(pos, end));
pos = end + 1;
}
return stringSplit;
}
@Benchmark
public String benchmarkIntegerToString() {
return stringIntegerToString();
return Integer.toString(sampleNumber);
}
@Benchmark
public String benchmarkStringValueOf() {
return stringValueOf();
return String.valueOf(sampleNumber);
}
@Benchmark
public String benchmarkStringConvertPlus() {
return stringConvertPlus();
return sampleNumber + "";
}
@Benchmark
public String benchmarkStringFormat_d() {
return stringFormat_d();
return String.format(formatDigit, sampleNumber);
}
@Benchmark
public boolean benchmarkStringEquals() {
return stringEquals();
return longString.equals(baeldung);
}
@Benchmark
public boolean benchmarkStringEqualsIgnoreCase() {
return stringEqualsIgnoreCase();
return longString.equalsIgnoreCase(baeldung);
}
@Benchmark
public boolean benchmarkStringMatches() {
return stringIsMatch();
return longString.matches(baeldung);
}
@Benchmark
public boolean benchmarkPrecompiledMatches() {
return precompiledMatches();
return longPattern.matcher(baeldung).matches();
}
@Benchmark
public int benchmarkStringCompareTo() {
return stringCompareTo();
return longString.compareTo(baeldung);
}
@Benchmark
public boolean benchmarkStringIsEmpty() {
return stringIsEmpty();
return longString.isEmpty();
}
@Benchmark
public boolean benchmarkStringLengthZero() {
return stringLengthZero();
return longString.length() == 0;
}
public static void main(String[] args) throws Exception {

View File

@ -1,133 +0,0 @@
package com.baeldung.string;
import com.google.common.base.Splitter;
import org.openjdk.jmh.annotations.Scope;
import org.openjdk.jmh.annotations.State;
import java.util.ArrayList;
import java.util.List;
import java.util.StringTokenizer;
import java.util.regex.Pattern;
@State(Scope.Thread)
public class StringPerformanceHints {
protected String baeldung = "baeldung";
protected String longString = "Hello baeldung, I am a bit longer than other Strings";
protected String formatString = "hello %s, nice to meet you";
protected String formatDigit = "%d";
protected String emptyString = " ";
protected String result = "";
protected int sampleNumber = 100;
protected Pattern spacePattern = Pattern.compile(emptyString);
protected Pattern longPattern = Pattern.compile(longString);
protected List<String> stringSplit = new ArrayList<>();
protected List<String> stringTokenizer = new ArrayList<>();
protected String dynamicConcat() {
result += baeldung;
return result;
}
protected String stringConstructor() {
return new String(baeldung);
}
protected String stringLiteral() {
result = baeldung;
return result;
}
protected String stringFormat_s() {
return String.format(formatString, baeldung);
}
protected String stringFormat_d() {
return String.format(formatDigit, sampleNumber);
}
protected String stringConcat() {
result = result.concat(baeldung);
return result;
}
protected List stringTokenizer() {
StringTokenizer st = new StringTokenizer(longString);
while (st.hasMoreTokens()) {
stringTokenizer.add(st.nextToken());
}
return stringTokenizer;
}
protected List stringIndexOf() {
int pos = 0, end;
while ((end = longString.indexOf(' ', pos)) >= 0) {
stringSplit.add(longString.substring(pos, end));
pos = end + 1;
}
return stringSplit;
}
protected String stringIntegerToString() {
return Integer.toString(sampleNumber);
}
protected String stringValueOf() {
return String.valueOf(sampleNumber);
}
protected String stringConvertPlus() {
return sampleNumber + "";
}
protected boolean stringEquals() {
return longString.equals(baeldung);
}
protected boolean stringEqualsIgnoreCase() {
return longString.equalsIgnoreCase(baeldung);
}
protected boolean stringIsMatch() {
return longString.matches(baeldung);
}
protected boolean precompiledMatches() {
return longPattern.matcher(baeldung).matches();
}
protected int stringCompareTo() {
return longString.compareTo(baeldung);
}
protected boolean stringIsEmpty() {
return longString.isEmpty();
}
protected boolean stringLengthZero() {
return longString.length() == 0;
}
protected String [] stringSplitPattern() {
return spacePattern.split(longString, 0);
}
protected String [] stringSplit() {
return longString.split(emptyString);
}
protected List<String> guavaSplitter() {
return Splitter.on(" ").trimResults()
.omitEmptyStrings()
.splitToList(longString);
}
protected String stringIntern() {
return baeldung.intern();
}
}

View File

@ -12,6 +12,11 @@
</parent>
<dependencies>
<dependency>
<groupId>javax.validation</groupId>
<artifactId>validation-api</artifactId>
<version>${validation-api.version}</version>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-validator</artifactId>
@ -42,6 +47,18 @@
<artifactId>spring-test</artifactId>
<version>${org.springframework.version}</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>${junit.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.assertj</groupId>
<artifactId>assertj-core</artifactId>
<version>${assertj.version}</version>
<scope>test</scope>
</dependency>
</dependencies>
<properties>
@ -50,6 +67,7 @@
<javax.el-api.version>3.0.0</javax.el-api.version>
<javax.el.version>2.2.6</javax.el.version>
<org.springframework.version>5.0.2.RELEASE</org.springframework.version>
<junit.version>4.12</junit.version>
<assertj.version>3.11.1</assertj.version>
</properties>
</project>

View File

@ -0,0 +1,14 @@
package org.baeldung.javabeanconstraints.appplication;
import javax.validation.Validation;
import javax.validation.Validator;
import org.baeldung.javabeanconstraints.entities.UserNotBlank;
public class Application {
public static void main(String[] args) throws Exception {
Validator validator = Validation.buildDefaultValidatorFactory().getValidator();
UserNotBlank user = new UserNotBlank(" ");
validator.validate(user).stream().forEach(violation -> System.out.println(violation.getMessage()));
}
}

View File

@ -0,0 +1,22 @@
package org.baeldung.javabeanconstraints.entities;
import javax.validation.constraints.NotBlank;
public class UserNotBlank {
@NotBlank(message = "Name is mandatory")
private final String name;
public UserNotBlank(String name) {
this.name = name;
}
public String getName() {
return name;
}
@Override
public String toString() {
return "User{" + "name=" + name + "}";
}
}

View File

@ -0,0 +1,22 @@
package org.baeldung.javabeanconstraints.entities;
import javax.validation.constraints.NotEmpty;
public class UserNotEmpty {
@NotEmpty(message = "Name is mandatory")
private final String name;
public UserNotEmpty(String name) {
this.name = name;
}
public String getName() {
return name;
}
@Override
public String toString() {
return "User{" + "name=" + name + "}";
}
}

View File

@ -0,0 +1,22 @@
package org.baeldung.javabeanconstraints.entities;
import javax.validation.constraints.NotNull;
public class UserNotNull {
@NotNull(message = "Name is mandatory")
private final String name;
public UserNotNull(String name) {
this.name = name;
}
public String getName() {
return name;
}
@Override
public String toString() {
return "User{" + "name=" + name + "}";
}
}

View File

@ -0,0 +1,63 @@
package org.baeldung.javabeanconstraints.test;
import java.util.Set;
import javax.validation.ConstraintViolation;
import javax.validation.Validation;
import javax.validation.Validator;
import static org.assertj.core.api.Assertions.assertThat;
import org.baeldung.javabeanconstraints.entities.UserNotBlank;
import org.junit.BeforeClass;
import org.junit.Test;
public class UserNotBlankUnitTest {
private static Validator validator;
@BeforeClass
public static void setupValidatorInstance() {
validator = Validation.buildDefaultValidatorFactory().getValidator();
}
@Test
public void whenNotBlankName_thenNoConstraintViolations() {
UserNotBlank user = new UserNotBlank("John");
Set<ConstraintViolation<UserNotBlank>> violations = validator.validate(user);
assertThat(violations.size()).isEqualTo(0);
}
@Test
public void whenBlankName_thenOneConstraintViolation() {
UserNotBlank user = new UserNotBlank(" ");
Set<ConstraintViolation<UserNotBlank>> violations = validator.validate(user);
assertThat(violations.size()).isEqualTo(1);
}
@Test
public void whenEmptyName_thenOneConstraintViolation() {
UserNotBlank user = new UserNotBlank("");
Set<ConstraintViolation<UserNotBlank>> violations = validator.validate(user);
assertThat(violations.size()).isEqualTo(1);
}
@Test
public void whenNullName_thenOneConstraintViolation() {
UserNotBlank user = new UserNotBlank(null);
Set<ConstraintViolation<UserNotBlank>> violations = validator.validate(user);
assertThat(violations.size()).isEqualTo(1);
}
@Test
public void whenToString_thenCorrect() {
UserNotBlank user = new UserNotBlank("John");
assertThat(user.toString()).isEqualTo("User{name=John}");
}
}

View File

@ -0,0 +1,54 @@
package org.baeldung.javabeanconstraints.test;
import java.util.Set;
import javax.validation.ConstraintViolation;
import javax.validation.Validation;
import javax.validation.Validator;
import static org.assertj.core.api.Assertions.assertThat;
import org.baeldung.javabeanconstraints.entities.UserNotEmpty;
import org.junit.BeforeClass;
import org.junit.Test;
public class UserNotEmptyUnitTest {
private static Validator validator;
@BeforeClass
public static void setupValidatorInstance() {
validator = Validation.buildDefaultValidatorFactory().getValidator();
}
@Test
public void whenNotEmptyName_thenNoConstraintViolations() {
UserNotEmpty user = new UserNotEmpty("John");
Set<ConstraintViolation<UserNotEmpty>> violations = validator.validate(user);
assertThat(violations.size()).isEqualTo(0);
}
@Test
public void whenEmptyName_thenOneConstraintViolation() {
UserNotEmpty user = new UserNotEmpty("");
Set<ConstraintViolation<UserNotEmpty>> violations = validator.validate(user);
assertThat(violations.size()).isEqualTo(1);
}
@Test
public void whenNullName_thenOneConstraintViolation() {
UserNotEmpty user = new UserNotEmpty(null);
Set<ConstraintViolation<UserNotEmpty>> violations = validator.validate(user);
assertThat(violations.size()).isEqualTo(1);
}
@Test
public void whenToString_thenCorrect() {
UserNotEmpty user = new UserNotEmpty("John");
assertThat(user.toString()).isEqualTo("User{name=John}");
}
}

View File

@ -0,0 +1,54 @@
package org.baeldung.javabeanconstraints.test;
import java.util.Set;
import javax.validation.ConstraintViolation;
import javax.validation.Validation;
import javax.validation.Validator;
import static org.assertj.core.api.Assertions.assertThat;
import org.baeldung.javabeanconstraints.entities.UserNotNull;
import org.junit.BeforeClass;
import org.junit.Test;
public class UserNotNullUnitTest {
private static Validator validator;
@BeforeClass
public static void setupValidatorInstance() {
validator = Validation.buildDefaultValidatorFactory().getValidator();
}
@Test
public void whenNotNullName_thenNoConstraintViolations() {
UserNotNull user = new UserNotNull("John");
Set<ConstraintViolation<UserNotNull>> violations = validator.validate(user);
assertThat(violations.size()).isEqualTo(0);
}
@Test
public void whenNullName_thenOneConstraintViolation() {
UserNotNull user = new UserNotNull(null);
Set<ConstraintViolation<UserNotNull>> violations = validator.validate(user);
assertThat(violations.size()).isEqualTo(1);
}
@Test
public void whenEmptyName_thenNoConstraintViolations() {
UserNotNull user = new UserNotNull("");
Set<ConstraintViolation<UserNotNull>> violations = validator.validate(user);
assertThat(violations.size()).isEqualTo(0);
}
@Test
public void whenToString_thenCorrect() {
UserNotNull user = new UserNotNull("John");
assertThat(user.toString()).isEqualTo("User{name=John}");
}
}

View File

@ -2,7 +2,6 @@
<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</groupId>
<artifactId>jee-7</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>war</packaging>

View File

@ -7,13 +7,6 @@
<packaging>hpi</packaging>
<name>Hello World Plugin</name>
<description>A sample Jenkins Hello World plugin</description>
<url>https://wiki.jenkins-ci.org/display/JENKINS/TODO+Plugin</url>
<licenses>
<license>
<name>MIT License</name>
<url>http://opensource.org/licenses/MIT</url>
</license>
</licenses>
<parent>
<groupId>org.jenkins-ci.plugins</groupId>

View File

@ -1,2 +1,3 @@
- [Jersey Filters and Interceptors](http://www.baeldung.com/jersey-filters-interceptors)
- [Jersey MVC Support](https://www.baeldung.com/jersey-mvc)
- [Set a Response Body in JAX-RS](https://www.baeldung.com/jax-rs-response)

View File

@ -1,17 +1,15 @@
<?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/maven-v4_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/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<artifactId>parent-boot-1</artifactId>
<groupId>com.baeldung</groupId>
<version>0.0.1-SNAPSHOT</version>
<relativePath>../../../parent-boot-1</relativePath>
<artifactId>jhipster-microservice</artifactId>
<groupId>com.baeldung.jhipster</groupId>
<version>1.0.0-SNAPSHOT</version>
</parent>
<groupId>com.car.app</groupId>
<artifactId>car-app</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>war</packaging>
<name>car-app</name>
@ -37,9 +35,11 @@
<jjwt.version>0.7.0</jjwt.version>
<liquibase-hibernate5.version>3.6</liquibase-hibernate5.version>
<liquibase-slf4j.version>2.0.0</liquibase-slf4j.version>
<liquibase.version>3.6.2</liquibase.version>
<logstash-logback-encoder.version>4.8</logstash-logback-encoder.version>
<m2e.apt.activation>jdt_apt</m2e.apt.activation>
<mapstruct.version>1.1.0.Final</mapstruct.version>
<maven-eclipse-plugin.version>2.10</maven-eclipse-plugin.version>
<maven-enforcer-plugin.version>1.4.1</maven-enforcer-plugin.version>
<maven-resources-plugin.version>3.0.1</maven-resources-plugin.version>
<maven.build.timestamp.format>yyyyMMddHHmmss</maven.build.timestamp.format>
@ -186,12 +186,10 @@
<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
<version>${commons-io.version}</version>
</dependency>
<dependency>
<groupId>io.dropwizard.metrics</groupId>
<artifactId>metrics-annotation</artifactId>
<version>${dropwizard-metrics.version}</version>
</dependency>
<dependency>
<groupId>io.dropwizard.metrics</groupId>
@ -200,17 +198,14 @@
<dependency>
<groupId>io.dropwizard.metrics</groupId>
<artifactId>metrics-json</artifactId>
<version>${dropwizard-metrics.version}</version>
</dependency>
<dependency>
<groupId>io.dropwizard.metrics</groupId>
<artifactId>metrics-jvm</artifactId>
<version>${dropwizard-metrics.version}</version>
</dependency>
<dependency>
<groupId>io.dropwizard.metrics</groupId>
<artifactId>metrics-servlet</artifactId>
<version>${dropwizard-metrics.version}</version>
</dependency>
<dependency>
<groupId>io.dropwizard.metrics</groupId>
@ -505,8 +500,6 @@
<artifactId>maven-compiler-plugin</artifactId>
<version>${maven-compiler-plugin.version}</version>
<configuration>
<source>${maven.compiler.source}</source>
<target>${maven.compiler.target}</target>
<annotationProcessorPaths>
<path>
<groupId>org.mapstruct</groupId>
@ -519,6 +512,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-eclipse-plugin</artifactId>
<version>${maven-eclipse-plugin.version}</version>
<configuration>
<downloadSources>true</downloadSources>
<downloadJavadocs>true</downloadJavadocs>

View File

@ -1,54 +1,113 @@
<?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/maven-v4_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/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<artifactId>jhipster-microservice</artifactId>
<groupId>com.baeldung.jhipster</groupId>
<version>1.0.0-SNAPSHOT</version>
</parent>
<groupId>com.dealer.app</groupId>
<artifactId>dealer-app</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>war</packaging>
<name>dealer-app</name>
<parent>
<artifactId>parent-boot-1</artifactId>
<groupId>com.baeldung</groupId>
<version>0.0.1-SNAPSHOT</version>
<relativePath>../../../parent-boot-1</relativePath>
</parent>
<prerequisites>
<maven>${maven.version}</maven>
</prerequisites>
<properties>
<argLine>-Djava.security.egd=file:/dev/./urandom -Xmx256m</argLine>
<assertj.version>3.6.2</assertj.version>
<awaitility.version>2.0.0</awaitility.version>
<commons-io.version>2.5</commons-io.version>
<commons-lang.version>3.5</commons-lang.version>
<docker-maven-plugin.version>0.4.13</docker-maven-plugin.version>
<hazelcast-hibernate52.version>1.2</hazelcast-hibernate52.version>
<hibernate.version>5.2.8.Final</hibernate.version>
<hikaricp.version>2.6.0</hikaricp.version>
<jacoco-maven-plugin.version>0.7.9</jacoco-maven-plugin.version>
<javassist.version>3.21.0-GA</javassist.version>
<jcache.version>1.0.0</jcache.version>
<jhipster.server.version>1.1.0</jhipster.server.version>
<jjwt.version>0.7.0</jjwt.version>
<liquibase-hibernate5.version>3.6</liquibase-hibernate5.version>
<liquibase-slf4j.version>2.0.0</liquibase-slf4j.version>
<liquibase.version>3.6.2</liquibase.version>
<logstash-logback-encoder.version>4.8</logstash-logback-encoder.version>
<m2e.apt.activation>jdt_apt</m2e.apt.activation>
<mapstruct.version>1.1.0.Final</mapstruct.version>
<maven-eclipse-plugin.version>2.10</maven-eclipse-plugin.version>
<maven-enforcer-plugin.version>1.4.1</maven-enforcer-plugin.version>
<maven-resources-plugin.version>3.0.1</maven-resources-plugin.version>
<maven.build.timestamp.format>yyyyMMddHHmmss</maven.build.timestamp.format>
<maven.version>3.0.0</maven.version>
<metrics-spring.version>3.1.3</metrics-spring.version>
<node.version>v6.10.0</node.version>
<!-- These remain empty unless the corresponding profile is active -->
<profile.no-liquibase />
<profile.swagger />
<!-- Sonar properties -->
<project.testresult.directory>${project.build.directory}/test-results</project.testresult.directory>
<prometheus-simpleclient.version>0.0.20</prometheus-simpleclient.version>
<run.addResources>false</run.addResources>
<scala-maven-plugin.version>3.2.2</scala-maven-plugin.version>
<scala.version>2.12.1</scala.version>
<sonar-maven-plugin.version>3.2</sonar-maven-plugin.version>
<sonar.exclusions>src/main/webapp/content/**/*.*, src/main/webapp/bower_components/**/*.*, src/main/webapp/i18n/*.js, target/www/**/*.*</sonar.exclusions>
<sonar.issue.ignore.multicriteria>S3437,UndocumentedApi,BoldAndItalicTagsCheck</sonar.issue.ignore.multicriteria>
<!-- Rule https://sonarqube.com/coding_rules#rule_key=Web%3ABoldAndItalicTagsCheck is ignored. Even if we agree that using the "i" tag is an awful practice, this is what is
recommended by http://fontawesome.io/examples/ -->
<sonar.issue.ignore.multicriteria.BoldAndItalicTagsCheck.resourceKey>src/main/webapp/app/**/*.*</sonar.issue.ignore.multicriteria.BoldAndItalicTagsCheck.resourceKey>
<sonar.issue.ignore.multicriteria.BoldAndItalicTagsCheck.ruleKey>Web:BoldAndItalicTagsCheck</sonar.issue.ignore.multicriteria.BoldAndItalicTagsCheck.ruleKey>
<!-- Rule https://sonarqube.com/coding_rules#rule_key=squid%3AS3437 is ignored, as a JPA-managed field cannot be transient -->
<sonar.issue.ignore.multicriteria.S3437.resourceKey>src/main/java/**/*</sonar.issue.ignore.multicriteria.S3437.resourceKey>
<sonar.issue.ignore.multicriteria.S3437.ruleKey>squid:S3437</sonar.issue.ignore.multicriteria.S3437.ruleKey>
<!-- Rule http://sonarqube.com/coding_rules#rule_key=squid%3AUndocumentedApi is ignored, as we want to follow "clean code" guidelines and classes, methods and arguments names
should be self-explanatory -->
<sonar.issue.ignore.multicriteria.UndocumentedApi.resourceKey>src/main/java/**/*</sonar.issue.ignore.multicriteria.UndocumentedApi.resourceKey>
<sonar.issue.ignore.multicriteria.UndocumentedApi.ruleKey>squid:UndocumentedApi</sonar.issue.ignore.multicriteria.UndocumentedApi.ruleKey>
<sonar.jacoco.itReportPath>${project.testresult.directory}/coverage/jacoco/jacoco-it.exec</sonar.jacoco.itReportPath>
<sonar.jacoco.reportPath>${project.testresult.directory}/coverage/jacoco/jacoco.exec</sonar.jacoco.reportPath>
<sonar.java.codeCoveragePlugin>jacoco</sonar.java.codeCoveragePlugin>
<sonar.javascript.jstestdriver.reportsPath>${project.testresult.directory}/karma</sonar.javascript.jstestdriver.reportsPath>
<!-- For Sonar < 6.2 -->
<sonar.javascript.lcov.reportPath>${project.testresult.directory}/coverage/report-lcov/lcov.info</sonar.javascript.lcov.reportPath>
<!-- For Sonar >= 6.2 -->
<sonar.javascript.lcov.reportPaths>${project.testresult.directory}/coverage/report-lcov/lcov.info</sonar.javascript.lcov.reportPaths>
<sonar.sources>${project.basedir}/src/main/</sonar.sources>
<sonar.surefire.reportsPath>${project.testresult.directory}/surefire-reports</sonar.surefire.reportsPath>
<sonar.tests>${project.basedir}/src/test/</sonar.tests>
<sortpom-maven-plugin.version>2.5.0</sortpom-maven-plugin.version>
<!-- Spring properties -->
<spring-cloud.version>Camden.SR5</spring-cloud.version>
<springfox.version>2.6.1</springfox.version>
<undertow.version>1.4.10.Final</undertow.version>
<validation-api.version>1.1.0.Final</validation-api.version>
<yarn.version>v0.21.3</yarn.version>
</properties>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>io.github.jhipster</groupId>
<artifactId>jhipster</artifactId>
<version>${jhipster.server.version}</version>
</dependency>
<dependency>
<groupId>io.dropwizard.metrics</groupId>
<artifactId>metrics-core</artifactId>
</dependency>
<dependency>
<groupId>io.dropwizard.metrics</groupId>
<artifactId>metrics-annotation</artifactId>
<version>${dropwizard-metrics.version}</version>
</dependency>
<dependency>
<groupId>io.dropwizard.metrics</groupId>
<artifactId>metrics-json</artifactId>
<version>${dropwizard-metrics.version}</version>
</dependency>
<dependency>
<groupId>io.dropwizard.metrics</groupId>
<artifactId>metrics-jvm</artifactId>
<version>${dropwizard-metrics.version}</version>
</dependency>
<dependency>
<groupId>io.dropwizard.metrics</groupId>
<artifactId>metrics-servlet</artifactId>
<version>${dropwizard-metrics.version}</version>
</dependency>
<dependency>
<groupId>io.dropwizard.metrics</groupId>
<artifactId>metrics-servlets</artifactId>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-dependencies</artifactId>
<version>${spring-cloud.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
<dependencies>
<dependency>
<groupId>com.fasterxml.jackson.datatype</groupId>
<artifactId>jackson-datatype-hibernate5</artifactId>
@ -59,11 +118,11 @@
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.datatype</groupId>
<artifactId>jackson-datatype-jsr310</artifactId>
<artifactId>jackson-datatype-json-org</artifactId>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.datatype</groupId>
<artifactId>jackson-datatype-json-org</artifactId>
<artifactId>jackson-datatype-jsr310</artifactId>
</dependency>
<dependency>
<groupId>com.h2database</groupId>
@ -82,34 +141,12 @@
<groupId>com.hazelcast</groupId>
<artifactId>hazelcast-spring</artifactId>
</dependency>
<dependency>
<groupId>org.awaitility</groupId>
<artifactId>awaitility</artifactId>
<version>${awaitility.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.jayway.jsonpath</groupId>
<artifactId>json-path</artifactId>
<scope>test</scope>
<!-- parent POM declares this dependency in default (compile) scope -->
</dependency>
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger2</artifactId>
<version>${springfox.version}</version>
<exclusions>
<exclusion>
<groupId>org.mapstruct</groupId>
<artifactId>mapstruct</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-bean-validators</artifactId>
<version>${springfox.version}</version>
</dependency>
<dependency>
<groupId>com.mattbertolini</groupId>
<artifactId>liquibase-slf4j</artifactId>
@ -121,16 +158,16 @@
<version>${metrics-spring.version}</version>
<exclusions>
<exclusion>
<groupId>com.codahale.metrics</groupId>
<artifactId>metrics-annotation</artifactId>
<groupId>com.codahale.metrics</groupId>
</exclusion>
<exclusion>
<groupId>com.codahale.metrics</groupId>
<artifactId>metrics-core</artifactId>
<groupId>com.codahale.metrics</groupId>
</exclusion>
<exclusion>
<groupId>com.codahale.metrics</groupId>
<artifactId>metrics-healthchecks</artifactId>
<groupId>com.codahale.metrics</groupId>
</exclusion>
</exclusions>
</dependency>
@ -148,12 +185,56 @@
<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
<version>${commons-io.version}</version>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
<version>${commons-lang.version}</version>
<groupId>io.dropwizard.metrics</groupId>
<artifactId>metrics-annotation</artifactId>
</dependency>
<dependency>
<groupId>io.dropwizard.metrics</groupId>
<artifactId>metrics-core</artifactId>
</dependency>
<dependency>
<groupId>io.dropwizard.metrics</groupId>
<artifactId>metrics-json</artifactId>
</dependency>
<dependency>
<groupId>io.dropwizard.metrics</groupId>
<artifactId>metrics-jvm</artifactId>
</dependency>
<dependency>
<groupId>io.dropwizard.metrics</groupId>
<artifactId>metrics-servlet</artifactId>
</dependency>
<dependency>
<groupId>io.dropwizard.metrics</groupId>
<artifactId>metrics-servlets</artifactId>
</dependency>
<dependency>
<groupId>io.github.jhipster</groupId>
<artifactId>jhipster</artifactId>
<version>${jhipster.server.version}</version>
</dependency>
<dependency>
<groupId>io.jsonwebtoken</groupId>
<artifactId>jjwt</artifactId>
<version>${jjwt.version}</version>
</dependency>
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-bean-validators</artifactId>
<version>${springfox.version}</version>
</dependency>
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger2</artifactId>
<version>${springfox.version}</version>
<exclusions>
<exclusion>
<artifactId>mapstruct</artifactId>
<groupId>org.mapstruct</groupId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>javax.cache</groupId>
@ -163,11 +244,41 @@
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
</dependency>
<dependency>
<groupId>net.logstash.logback</groupId>
<artifactId>logstash-logback-encoder</artifactId>
<version>${logstash-logback-encoder.version}</version>
<exclusions>
<exclusion>
<artifactId>logback-core</artifactId>
<groupId>ch.qos.logback</groupId>
</exclusion>
<exclusion>
<artifactId>logback-classic</artifactId>
<groupId>ch.qos.logback</groupId>
</exclusion>
<exclusion>
<artifactId>logback-access</artifactId>
<groupId>ch.qos.logback</groupId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
<version>${commons-lang.version}</version>
</dependency>
<dependency>
<groupId>org.assertj</groupId>
<artifactId>assertj-core</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.awaitility</groupId>
<artifactId>awaitility</artifactId>
<version>${awaitility.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-envers</artifactId>
@ -216,6 +327,10 @@
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-aop</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-cloud-connectors</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
@ -232,16 +347,6 @@
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-security</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-thymeleaf</artifactId>
@ -251,15 +356,15 @@
<artifactId>spring-boot-starter-web</artifactId>
<exclusions>
<exclusion>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-tomcat</artifactId>
<groupId>org.springframework.boot</groupId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>io.jsonwebtoken</groupId>
<artifactId>jjwt</artifactId>
<version>${jjwt.version}</version>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-test</artifactId>
<scope>test</scope>
</dependency>
<!-- Spring Cloud -->
<dependency>
@ -268,19 +373,31 @@
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-ribbon</artifactId>
<!-- netty's native is pulled, but is useless unless you explicitly add the native binary dependency. Having it in the classpath without the binary can cause warnings -->
<exclusions>
<exclusion>
<groupId>io.netty</groupId>
<artifactId>netty-transport-native-epoll</artifactId>
</exclusion>
</exclusions>
<artifactId>spring-cloud-starter-config</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-eureka</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-feign</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-hystrix</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-ribbon</artifactId>
<!-- netty's native is pulled, but is useless unless you explicitly add the native binary dependency. Having it in the classpath without the binary can cause warnings -->
<exclusions>
<exclusion>
<artifactId>netty-transport-native-epoll</artifactId>
<groupId>io.netty</groupId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-spectator</artifactId>
@ -289,51 +406,51 @@
<groupId>org.springframework.retry</groupId>
<artifactId>spring-retry</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-eureka</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-config</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-feign</artifactId>
</dependency>
<dependency>
<groupId>net.logstash.logback</groupId>
<artifactId>logstash-logback-encoder</artifactId>
<version>${logstash-logback-encoder.version}</version>
<exclusions>
<exclusion>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-core</artifactId>
</exclusion>
<exclusion>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
</exclusion>
<exclusion>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-access</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-cloud-connectors</artifactId>
</dependency>
<!-- security -->
<dependency>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-data</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-test</artifactId>
<scope>test</scope>
</dependency>
<!-- jhipster-needle-maven-add-dependency -->
</dependencies>
<build>
<defaultGoal>spring-boot:run</defaultGoal>
<pluginManagement>
<plugins>
<!-- This plugin's configuration is used to store Eclipse m2e settings only. It has no influence on the Maven build itself. Remove when the m2e plugin can correctly
bind to Maven lifecycle -->
<plugin>
<groupId>org.eclipse.m2e</groupId>
<artifactId>lifecycle-mapping</artifactId>
<version>1.0.0</version>
<configuration>
<lifecycleMappingMetadata>
<pluginExecutions>
<pluginExecution>
<pluginExecutionFilter>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<versionRange>${jacoco-maven-plugin.version}</versionRange>
<goals>
<goal>prepare-agent</goal>
</goals>
</pluginExecutionFilter>
<action>
<ignore />
</action>
</pluginExecution>
</pluginExecutions>
</lifecycleMappingMetadata>
</configuration>
</plugin>
</plugins>
</pluginManagement>
<plugins>
<plugin>
<groupId>com.github.ekryd.sortpom</groupId>
@ -356,6 +473,22 @@
<expandEmptyElements>false</expandEmptyElements>
</configuration>
</plugin>
<plugin>
<groupId>com.spotify</groupId>
<artifactId>docker-maven-plugin</artifactId>
<version>${docker-maven-plugin.version}</version>
<configuration>
<imageName>dealerapp</imageName>
<dockerDirectory>src/main/docker</dockerDirectory>
<resources>
<resource>
<targetPath>/</targetPath>
<directory>${project.build.directory}</directory>
<include>${project.build.finalName}.war</include>
</resource>
</resources>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
@ -373,6 +506,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-eclipse-plugin</artifactId>
<version>${maven-eclipse-plugin.version}</version>
<configuration>
<downloadSources>true</downloadSources>
<downloadJavadocs>true</downloadJavadocs>
@ -479,28 +613,16 @@
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.sonarsource.scanner.maven</groupId>
<artifactId>sonar-maven-plugin</artifactId>
<version>${sonar-maven-plugin.version}</version>
</plugin>
<plugin>
<groupId>org.liquibase</groupId>
<artifactId>liquibase-maven-plugin</artifactId>
<version>${liquibase.version}</version>
<configuration>
<changeLogFile>src/main/resources/config/liquibase/master.xml</changeLogFile>
<diffChangeLogFile>src/main/resources/config/liquibase/changelog/${maven.build.timestamp}_changelog.xml</diffChangeLogFile>
<driver>org.h2.Driver</driver>
<url>jdbc:h2:file:./target/h2db/db/dealerapp</url>
<defaultSchemaName></defaultSchemaName>
<username>dealerapp</username>
<password></password>
<referenceUrl>hibernate:spring:com.dealer.app.domain?dialect=org.hibernate.dialect.H2Dialect&amp;hibernate.physical_naming_strategy=org.springframework.boot.orm.jpa.hibernate.SpringPhysicalNamingStrategy&amp;hibernate.implicit_naming_strategy=org.springframework.boot.orm.jpa.hibernate.SpringImplicitNamingStrategy</referenceUrl>
<verbose>true</verbose>
<logging>debug</logging>
</configuration>
<dependencies>
<dependency>
<groupId>javax.validation</groupId>
<artifactId>validation-api</artifactId>
<version>${validation-api.version}</version>
</dependency>
<dependency>
<groupId>org.javassist</groupId>
<artifactId>javassist</artifactId>
@ -516,12 +638,24 @@
<artifactId>spring-boot-starter-data-jpa</artifactId>
<version>${project.parent.version}</version>
</dependency>
<dependency>
<groupId>javax.validation</groupId>
<artifactId>validation-api</artifactId>
<version>${validation-api.version}</version>
</dependency>
</dependencies>
<configuration>
<changeLogFile>src/main/resources/config/liquibase/master.xml</changeLogFile>
<diffChangeLogFile>src/main/resources/config/liquibase/changelog/${maven.build.timestamp}_changelog.xml</diffChangeLogFile>
<driver>org.h2.Driver</driver>
<url>jdbc:h2:file:./target/h2db/db/dealerapp</url>
<defaultSchemaName />
<username>dealerapp</username>
<password />
<referenceUrl>hibernate:spring:com.dealer.app.domain?dialect=org.hibernate.dialect.H2Dialect&amp;hibernate.physical_naming_strategy=org.springframework.boot.orm.jpa.hibernate.SpringPhysicalNamingStrategy&amp;hibernate.implicit_naming_strategy=org.springframework.boot.orm.jpa.hibernate.SpringImplicitNamingStrategy</referenceUrl>
<verbose>true</verbose>
<logging>debug</logging>
</configuration>
</plugin>
<plugin>
<groupId>org.sonarsource.scanner.maven</groupId>
<artifactId>sonar-maven-plugin</artifactId>
<version>${sonar-maven-plugin.version}</version>
</plugin>
<plugin>
<groupId>org.springframework.boot</groupId>
@ -532,58 +666,8 @@
<!-- Enable the line below to have remote debugging of your application on port 5005 <jvmArguments>-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=5005</jvmArguments> -->
</configuration>
</plugin>
<plugin>
<groupId>com.spotify</groupId>
<artifactId>docker-maven-plugin</artifactId>
<version>${docker-maven-plugin.version}</version>
<configuration>
<imageName>dealerapp</imageName>
<dockerDirectory>src/main/docker</dockerDirectory>
<resources>
<resource>
<targetPath>/</targetPath>
<directory>${project.build.directory}</directory>
<include>${project.build.finalName}.war</include>
</resource>
</resources>
</configuration>
</plugin>
<!-- jhipster-needle-maven-add-plugin -->
</plugins>
<pluginManagement>
<plugins>
<!-- This plugin's configuration is used to store Eclipse m2e settings only. It has no influence on the Maven build itself. Remove when the m2e plugin can correctly
bind to Maven lifecycle -->
<plugin>
<groupId>org.eclipse.m2e</groupId>
<artifactId>lifecycle-mapping</artifactId>
<version>1.0.0</version>
<configuration>
<lifecycleMappingMetadata>
<pluginExecutions>
<pluginExecution>
<pluginExecutionFilter>
<groupId>org.jacoco</groupId>
<artifactId>
jacoco-maven-plugin
</artifactId>
<versionRange>
${jacoco-maven-plugin.version}
</versionRange>
<goals>
<goal>prepare-agent</goal>
</goals>
</pluginExecutionFilter>
<action>
<ignore />
</action>
</pluginExecution>
</pluginExecutions>
</lifecycleMappingMetadata>
</configuration>
</plugin>
</plugins>
</pluginManagement>
</build>
<profiles>
@ -604,24 +688,12 @@
<activation>
<activeByDefault>true</activeByDefault>
</activation>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-undertow</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
<optional>true</optional>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<configuration>
</configuration>
<configuration />
</plugin>
</plugins>
</build>
@ -631,15 +703,20 @@
<!-- default Spring profiles -->
<spring.profiles.active>dev${profile.no-liquibase}</spring.profiles.active>
</properties>
</profile>
<profile>
<id>prod</id>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-undertow</artifactId>
</dependency>
</dependencies>
</profile>
<profile>
<id>prod</id>
<build>
<plugins>
<plugin>
@ -655,15 +732,11 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<configuration>
</configuration>
<configuration />
</plugin>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<executable>true</executable>
</configuration>
<executions>
<execution>
<goals>
@ -671,6 +744,9 @@
</goals>
</execution>
</executions>
<configuration>
<executable>true</executable>
</configuration>
</plugin>
</plugins>
</build>
@ -680,56 +756,20 @@
<!-- default Spring profiles -->
<spring.profiles.active>prod${profile.swagger}${profile.no-liquibase}</spring.profiles.active>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-undertow</artifactId>
</dependency>
</dependencies>
</profile>
<profile>
<!-- Profile for doing "continuous compilation" with the Scala Maven plugin. It allows automatic compilation of Java classes as soon as they are saved. To use it, run in
3 terminals: - './mvnw -Pcc scala:cc' for continous compilation of your classes - './mvnw -Pcc' for hot reload of Spring boot - 'gulp' for hot reload of the HTML/JavaScript assets Everything
should hot reload automatically! -->
<id>cc</id>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-undertow</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
<optional>true</optional>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<configuration>
<warSourceDirectory>src/main/webapp/</warSourceDirectory>
</configuration>
</plugin>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<executable>true</executable>
<fork>true</fork>
<addResources>true</addResources>
<!-- Enable the line below to have remote debugging of your application on port 5005 <jvmArguments>-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=5005</jvmArguments> -->
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<executions>
<execution>
<id>default-compile</id>
<phase>none</phase>
</execution>
<execution>
<id>default-testCompile</id>
<phase>none</phase>
</execution>
</executions>
</plugin>
<plugin>
<groupId>net.alchim31.maven</groupId>
<artifactId>scala-maven-plugin</artifactId>
@ -758,6 +798,37 @@
<scalaVersion>${scala.version}</scalaVersion>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<executions>
<execution>
<id>default-compile</id>
<phase>none</phase>
</execution>
<execution>
<id>default-testCompile</id>
<phase>none</phase>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<configuration>
<warSourceDirectory>src/main/webapp/</warSourceDirectory>
</configuration>
</plugin>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<executable>true</executable>
<fork>true</fork>
<addResources>true</addResources>
<!-- Enable the line below to have remote debugging of your application on port 5005 <jvmArguments>-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=5005</jvmArguments> -->
</configuration>
</plugin>
</plugins>
</build>
<properties>
@ -766,6 +837,17 @@
<!-- default Spring profiles -->
<spring.profiles.active>dev,swagger</spring.profiles.active>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-undertow</artifactId>
</dependency>
</dependencies>
</profile>
<profile>
<!-- Profile for monitoring the application with Graphite. -->
@ -788,12 +870,12 @@
</dependency>
<dependency>
<groupId>io.prometheus</groupId>
<artifactId>simpleclient_servlet</artifactId>
<artifactId>simpleclient_dropwizard</artifactId>
<version>${prometheus-simpleclient.version}</version>
</dependency>
<dependency>
<groupId>io.prometheus</groupId>
<artifactId>simpleclient_dropwizard</artifactId>
<artifactId>simpleclient_servlet</artifactId>
<version>${prometheus-simpleclient.version}</version>
</dependency>
</dependencies>
@ -811,96 +893,4 @@
</profile>
</profiles>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-dependencies</artifactId>
<version>${spring-cloud.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
<prerequisites>
<maven>${maven.version}</maven>
</prerequisites>
<properties>
<argLine>-Djava.security.egd=file:/dev/./urandom -Xmx256m</argLine>
<assertj.version>3.6.2</assertj.version>
<awaitility.version>2.0.0</awaitility.version>
<commons-io.version>2.5</commons-io.version>
<commons-lang.version>3.5</commons-lang.version>
<docker-maven-plugin.version>0.4.13</docker-maven-plugin.version>
<hazelcast-hibernate52.version>1.2</hazelcast-hibernate52.version>
<hibernate.version>5.2.8.Final</hibernate.version>
<hikaricp.version>2.6.0</hikaricp.version>
<jacoco-maven-plugin.version>0.7.9</jacoco-maven-plugin.version>
<javassist.version>3.21.0-GA</javassist.version>
<jcache.version>1.0.0</jcache.version>
<jhipster.server.version>1.1.0</jhipster.server.version>
<jjwt.version>0.7.0</jjwt.version>
<liquibase-hibernate5.version>3.6</liquibase-hibernate5.version>
<liquibase-slf4j.version>2.0.0</liquibase-slf4j.version>
<logstash-logback-encoder.version>4.8</logstash-logback-encoder.version>
<m2e.apt.activation>jdt_apt</m2e.apt.activation>
<mapstruct.version>1.1.0.Final</mapstruct.version>
<maven-enforcer-plugin.version>1.4.1</maven-enforcer-plugin.version>
<maven-resources-plugin.version>3.0.1</maven-resources-plugin.version>
<maven.build.timestamp.format>yyyyMMddHHmmss</maven.build.timestamp.format>
<maven.version>3.0.0</maven.version>
<metrics-spring.version>3.1.3</metrics-spring.version>
<node.version>v6.10.0</node.version>
<!-- These remain empty unless the corresponding profile is active -->
<profile.no-liquibase />
<profile.swagger />
<prometheus-simpleclient.version>0.0.20</prometheus-simpleclient.version>
<!-- Sonar properties -->
<project.testresult.directory>${project.build.directory}/test-results</project.testresult.directory>
<run.addResources>false</run.addResources>
<scala-maven-plugin.version>3.2.2</scala-maven-plugin.version>
<scala.version>2.12.1</scala.version>
<sonar-maven-plugin.version>3.2</sonar-maven-plugin.version>
<sonar.exclusions>src/main/webapp/content/**/*.*, src/main/webapp/bower_components/**/*.*, src/main/webapp/i18n/*.js, target/www/**/*.*</sonar.exclusions>
<sonar.issue.ignore.multicriteria>S3437,UndocumentedApi,BoldAndItalicTagsCheck</sonar.issue.ignore.multicriteria>
<!-- Rule https://sonarqube.com/coding_rules#rule_key=Web%3ABoldAndItalicTagsCheck is ignored. Even if we agree that using the "i" tag is an awful practice, this is what is
recommended by http://fontawesome.io/examples/ -->
<sonar.issue.ignore.multicriteria.BoldAndItalicTagsCheck.resourceKey>src/main/webapp/app/**/*.*</sonar.issue.ignore.multicriteria.BoldAndItalicTagsCheck.resourceKey>
<sonar.issue.ignore.multicriteria.BoldAndItalicTagsCheck.ruleKey>Web:BoldAndItalicTagsCheck</sonar.issue.ignore.multicriteria.BoldAndItalicTagsCheck.ruleKey>
<!-- Rule https://sonarqube.com/coding_rules#rule_key=squid%3AS3437 is ignored, as a JPA-managed field cannot be transient -->
<sonar.issue.ignore.multicriteria.S3437.resourceKey>src/main/java/**/*</sonar.issue.ignore.multicriteria.S3437.resourceKey>
<sonar.issue.ignore.multicriteria.S3437.ruleKey>squid:S3437</sonar.issue.ignore.multicriteria.S3437.ruleKey>
<!-- Rule http://sonarqube.com/coding_rules#rule_key=squid%3AUndocumentedApi is ignored, as we want to follow "clean code" guidelines and classes, methods and arguments names
should be self-explanatory -->
<sonar.issue.ignore.multicriteria.UndocumentedApi.resourceKey>src/main/java/**/*</sonar.issue.ignore.multicriteria.UndocumentedApi.resourceKey>
<sonar.issue.ignore.multicriteria.UndocumentedApi.ruleKey>squid:UndocumentedApi</sonar.issue.ignore.multicriteria.UndocumentedApi.ruleKey>
<sonar.jacoco.itReportPath>${project.testresult.directory}/coverage/jacoco/jacoco-it.exec</sonar.jacoco.itReportPath>
<sonar.jacoco.reportPath>${project.testresult.directory}/coverage/jacoco/jacoco.exec</sonar.jacoco.reportPath>
<sonar.java.codeCoveragePlugin>jacoco</sonar.java.codeCoveragePlugin>
<sonar.javascript.jstestdriver.reportsPath>${project.testresult.directory}/karma</sonar.javascript.jstestdriver.reportsPath>
<!-- For Sonar < 6.2 -->
<sonar.javascript.lcov.reportPath>${project.testresult.directory}/coverage/report-lcov/lcov.info</sonar.javascript.lcov.reportPath>
<!-- For Sonar >= 6.2 -->
<sonar.javascript.lcov.reportPaths>${project.testresult.directory}/coverage/report-lcov/lcov.info</sonar.javascript.lcov.reportPaths>
<sonar.sources>${project.basedir}/src/main/</sonar.sources>
<sonar.surefire.reportsPath>${project.testresult.directory}/surefire-reports</sonar.surefire.reportsPath>
<sonar.tests>${project.basedir}/src/test/</sonar.tests>
<sortpom-maven-plugin.version>2.5.0</sortpom-maven-plugin.version>
<!-- Spring properties -->
<spring-cloud.version>Camden.SR5</spring-cloud.version>
<springfox.version>2.6.1</springfox.version>
<undertow.version>1.4.10.Final</undertow.version>
<validation-api.version>1.1.0.Final</validation-api.version>
<yarn.version>v0.21.3</yarn.version>
</properties>
</project>

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,20 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://maven.apache.org/POM/4.0.0"
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>
<artifactId>jhipster-microservice</artifactId>
<packaging>pom</packaging>
<name>JHipster Microservice</name>
<parent>
<artifactId>jhipster</artifactId>
<groupId>com.baeldung.jhipster</groupId>
<version>1.0.0-SNAPSHOT</version>
</parent>
<modules>
<module>car-app</module>
<module>dealer-app</module>
<module>gateway-app</module>
</modules>
</project>

View File

@ -6,10 +6,9 @@
<description>JHipster Monolithic Application</description>
<parent>
<artifactId>parent-boot-1</artifactId>
<groupId>com.baeldung</groupId>
<version>0.0.1-SNAPSHOT</version>
<relativePath>../../parent-boot-1</relativePath>
<artifactId>jhipster</artifactId>
<groupId>com.baeldung.jhipster</groupId>
<version>1.0.0-SNAPSHOT</version>
</parent>
<dependencies>

23
jhipster/pom.xml Normal file
View File

@ -0,0 +1,23 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://maven.apache.org/POM/4.0.0"
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.jhipster</groupId>
<artifactId>jhipster</artifactId>
<version>1.0.0-SNAPSHOT</version>
<packaging>pom</packaging>
<name>JHipster</name>
<parent>
<artifactId>parent-boot-1</artifactId>
<groupId>com.baeldung</groupId>
<version>0.0.1-SNAPSHOT</version>
<relativePath>../parent-boot-1</relativePath>
</parent>
<modules>
<module>jhipster-monolithic</module>
<module>jhipster-microservice</module>
</modules>
</project>

View File

@ -1,21 +1,12 @@
<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</groupId>
<artifactId>jni</artifactId>
<version>0.0.1-SNAPSHOT</version>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>${junit.version}</version>
<scope>test</scope>
</dependency>
</dependencies>
<properties>
<junit.version>4.8.1</junit.version>
</properties>
<parent>
<groupId>com.baeldung</groupId>
<artifactId>parent-modules</artifactId>
<version>1.0.0-SNAPSHOT</version>
</parent>
</project>

View File

@ -7,7 +7,7 @@ import static org.junit.Assert.assertTrue;
import org.junit.Before;
import org.junit.Test;
public class JNINativeTests {
public class JNINativeManualTest {
@Before
public void setup() {

View File

@ -8,34 +8,38 @@
<name>jooby</name>
<parent>
<groupId>com.baeldung</groupId>
<artifactId>parent-modules</artifactId>
<version>1.0.0-SNAPSHOT</version>
</parent>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.jooby</groupId>
<artifactId>modules</artifactId>
<version>1.1.3</version>
</parent>
<version>${jooby.version}</version>
<type>pom</type>
</dependency>
</dependencies>
</dependencyManagement>
<dependencies>
<dependency>
<groupId>org.jooby</groupId>
<artifactId>jooby-netty</artifactId>
<version>${jooby.version}</version>
</dependency>
<dependency>
<groupId>org.jooby</groupId>
<artifactId>jooby-jedis</artifactId>
<version>${jooby-jedis.version}</version>
</dependency>
<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<scope>test</scope>
<version>${jooby.version}</version>
</dependency>
<dependency>
<groupId>io.rest-assured</groupId>
<artifactId>rest-assured</artifactId>
<scope>test</scope>
<version>${rest-assured.version}</version>
</dependency>
</dependencies>
@ -51,9 +55,8 @@
<properties>
<jooby.version>1.1.3</jooby.version>
<rest-assured.version>3.1.1</rest-assured.version>
<application.class>com.baeldung.jooby.App</application.class>
<jooby-jedis.version>1.1.3</jooby-jedis.version>
<maven-shade-plugin.version>2.4.3</maven-shade-plugin.version>
</properties>

View File

@ -9,7 +9,7 @@ import org.jooby.test.MockRouter;
import org.junit.ClassRule;
import org.junit.Test;
public class AppTest {
public class AppUnitTest {
@ClassRule
public static JoobyRule app = new JoobyRule(new App());

2
jta/README.md Normal file
View File

@ -0,0 +1,2 @@
### Relevant Articles:
- [Guide to Java EE JTA](https://www.baeldung.com/jee-jta)

View File

@ -38,6 +38,16 @@
<version>${junit.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.passay</groupId>
<artifactId>passay</artifactId>
<version>1.3.1</version>
</dependency>
<dependency>
<groupId>org.cryptacular</groupId>
<artifactId>cryptacular</artifactId>
<version>1.2.2</version>
</dependency>
</dependencies>

View File

@ -0,0 +1,149 @@
package com.baeldung.passay;
import org.cryptacular.bean.EncodingHashBean;
import org.cryptacular.spec.CodecSpec;
import org.cryptacular.spec.DigestSpec;
import org.junit.Assert;
import org.junit.Test;
import org.passay.DictionaryRule;
import org.passay.DictionarySubstringRule;
import org.passay.DigestHistoryRule;
import org.passay.EnglishSequenceData;
import org.passay.HistoryRule;
import org.passay.IllegalCharacterRule;
import org.passay.IllegalRegexRule;
import org.passay.IllegalSequenceRule;
import org.passay.NumberRangeRule;
import org.passay.PasswordData;
import org.passay.PasswordValidator;
import org.passay.RepeatCharacterRegexRule;
import org.passay.RuleResult;
import org.passay.SourceRule;
import org.passay.UsernameRule;
import org.passay.WhitespaceRule;
import org.passay.dictionary.ArrayWordList;
import org.passay.dictionary.WordListDictionary;
import java.util.Arrays;
import java.util.List;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
public class NegativeMatchingRulesUnitTest {
@Test
public void givenDictionaryRules_whenValidatePassword_thenFoundIllegalWordsFromDictionary() {
ArrayWordList arrayWordList = new ArrayWordList(new String[] { "bar", "foobar" });
WordListDictionary wordListDictionary = new WordListDictionary(arrayWordList);
DictionaryRule dictionaryRule = new DictionaryRule(wordListDictionary);
DictionarySubstringRule dictionarySubstringRule = new DictionarySubstringRule(wordListDictionary);
PasswordValidator passwordValidator = new PasswordValidator(dictionaryRule, dictionarySubstringRule);
RuleResult validate = passwordValidator.validate(new PasswordData("foobar"));
assertFalse(validate.isValid());
assertEquals("ILLEGAL_WORD:{matchingWord=foobar}", getDetail(validate, 0));
assertEquals("ILLEGAL_WORD:{matchingWord=bar}", getDetail(validate, 1));
}
@Test
public void givenHistoryRule_whenValidatePassword_thenFoundIllegalWordsFromHistory() {
HistoryRule historyRule = new HistoryRule();
PasswordData passwordData = new PasswordData("123");
passwordData.setPasswordReferences(new PasswordData.HistoricalReference("12345"), new PasswordData.HistoricalReference("1234"), new PasswordData.HistoricalReference("123"));
PasswordValidator passwordValidator = new PasswordValidator(historyRule);
RuleResult validate = passwordValidator.validate(passwordData);
assertFalse(validate.isValid());
assertEquals("HISTORY_VIOLATION:{historySize=3}", getDetail(validate, 0));
}
@Test
public void givenSeveralIllegalRules_whenValidatePassword_thenFoundSeveralIllegalPatterns() {
IllegalCharacterRule illegalCharacterRule = new IllegalCharacterRule(new char[] { 'a' });
IllegalRegexRule illegalRegexRule = new IllegalRegexRule("\\w{2}\\d{2}");
IllegalSequenceRule illegalSequenceRule = new IllegalSequenceRule(EnglishSequenceData.Alphabetical, 3, true);
NumberRangeRule numberRangeRule = new NumberRangeRule(1, 10);
WhitespaceRule whitespaceRule = new WhitespaceRule();
PasswordValidator passwordValidator = new PasswordValidator(illegalCharacterRule, illegalRegexRule, illegalSequenceRule, numberRangeRule, whitespaceRule);
RuleResult validate = passwordValidator.validate(new PasswordData("abcd22 "));
assertFalse(validate.isValid());
assertEquals("ILLEGAL_CHAR:{illegalCharacter=a, matchBehavior=contains}", getDetail(validate, 0));
assertEquals("ILLEGAL_MATCH:{match=cd22, pattern=\\w{2}\\d{2}}", getDetail(validate, 1));
assertEquals("ILLEGAL_ALPHABETICAL_SEQUENCE:{sequence=abc}", getDetail(validate, 2));
assertEquals("ILLEGAL_ALPHABETICAL_SEQUENCE:{sequence=bcd}", getDetail(validate, 3));
assertEquals("ILLEGAL_NUMBER_RANGE:{number=2, matchBehavior=contains}", getDetail(validate, 4));
assertEquals("ILLEGAL_WHITESPACE:{whitespaceCharacter= , matchBehavior=contains}", getDetail(validate, 5));
}
@Test
public void givenSourceRule_whenValidatePassword_thenFoundIllegalWordsFromSource() {
SourceRule sourceRule = new SourceRule();
PasswordData passwordData = new PasswordData("password");
passwordData.setPasswordReferences(new PasswordData.SourceReference("source", "password"));
PasswordValidator passwordValidator = new PasswordValidator(sourceRule);
RuleResult validate = passwordValidator.validate(passwordData);
assertFalse(validate.isValid());
assertEquals("SOURCE_VIOLATION:{source=source}", getDetail(validate, 0));
}
@Test
public void givenRepeatCharacterRegexRuleRule_whenValidatePassword_thenFoundIllegalPatternMatches() {
RepeatCharacterRegexRule repeatCharacterRegexRule = new RepeatCharacterRegexRule(3);
PasswordValidator passwordValidator = new PasswordValidator(repeatCharacterRegexRule);
RuleResult validate = passwordValidator.validate(new PasswordData("aaabbb"));
assertFalse(validate.isValid());
assertEquals("ILLEGAL_MATCH:{match=aaa, pattern=([^\\x00-\\x1F])\\1{2}}", getDetail(validate, 0));
assertEquals("ILLEGAL_MATCH:{match=bbb, pattern=([^\\x00-\\x1F])\\1{2}}", getDetail(validate, 1));
}
@Test
public void givenUserNameRule_whenValidatePassword_thenFoundUserNameInPassword() {
PasswordValidator passwordValidator = new PasswordValidator(new UsernameRule());
PasswordData passwordData = new PasswordData("testuser1234");
passwordData.setUsername("testuser");
RuleResult validate = passwordValidator.validate(passwordData);
assertFalse(validate.isValid());
assertEquals("ILLEGAL_USERNAME:{username=testuser, matchBehavior=contains}", getDetail(validate, 0));
}
@Test
public void givenPasswordAndHashBeanAndEncryptedReferences_whenValidate_thenPasswordValidationShouldPass() {
List<PasswordData.Reference> historicalReferences = Arrays.asList(new PasswordData.HistoricalReference("SHA256", "2e4551de804e27aacf20f9df5be3e8cd384ed64488b21ab079fb58e8c90068ab"));
PasswordData passwordData = new PasswordData("example!");
passwordData.setPasswordReferences(historicalReferences);
EncodingHashBean encodingHashBean = new EncodingHashBean(new CodecSpec("Base64"), new DigestSpec("SHA256"), 1, false);
PasswordValidator passwordValidator = new PasswordValidator(new DigestHistoryRule(encodingHashBean));
RuleResult validate = passwordValidator.validate(passwordData);
Assert.assertTrue(validate.isValid());
}
private String getDetail(RuleResult validate, int i) {
return validate.getDetails()
.get(i)
.toString();
}
}

View File

@ -0,0 +1,50 @@
package com.baeldung.passay;
import org.junit.Assert;
import org.junit.Test;
import org.passay.CharacterData;
import org.passay.CharacterRule;
import org.passay.EnglishCharacterData;
import org.passay.PasswordGenerator;
import java.util.stream.Stream;
public class PasswordGeneratorUnitTest {
@Test
public void givenDigitsGenerator_whenGeneratingPassword_thenPasswordContainsDigitsHasLength10() {
CharacterRule digits = new CharacterRule(EnglishCharacterData.Digit);
PasswordGenerator passwordGenerator = new PasswordGenerator();
String password = passwordGenerator.generatePassword(10, digits);
Assert.assertTrue(password.length() == 10);
Assert.assertTrue(containsOnlyCharactersFromSet(password, "0123456789"));
}
@Test
public void givenCustomizedRule_whenGenerating_thenGeneratedPasswordContainsCustomizedCharacters() {
CharacterRule specialCharacterRule = new CharacterRule(new CharacterData() {
@Override
public String getErrorCode() {
return "SAMPLE_ERROR_CODE";
}
@Override
public String getCharacters() {
return "ABCxyz123!@#";
}
});
PasswordGenerator passwordGenerator = new PasswordGenerator();
String password = passwordGenerator.generatePassword(10, specialCharacterRule);
Assert.assertTrue(containsOnlyCharactersFromSet(password, "ABCxyz123!@#"));
}
private boolean containsOnlyCharactersFromSet(String password, String setOfCharacters) {
return Stream.of(password.split(""))
.allMatch(it -> setOfCharacters.contains(it));
}
}

View File

@ -0,0 +1,81 @@
package com.baeldung.passay;
import org.junit.Assert;
import org.junit.Test;
import org.passay.LengthRule;
import org.passay.MessageResolver;
import org.passay.PasswordData;
import org.passay.PasswordValidator;
import org.passay.PropertiesMessageResolver;
import org.passay.RuleResult;
import org.passay.RuleResultDetail;
import org.passay.RuleResultMetadata;
import org.passay.WhitespaceRule;
import java.io.FileInputStream;
import java.io.IOException;
import java.net.URL;
import java.util.Properties;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
public class PasswordValidatorUnitTest {
@Test
public void givenPasswordValidatorWithLengthRule_whenValidation_thenTooShortPassword() {
PasswordData passwordData = new PasswordData("1234");
PasswordValidator passwordValidator = new PasswordValidator(new LengthRule(5));
RuleResult validate = passwordValidator.validate(passwordData);
assertEquals(false, validate.isValid());
RuleResultDetail ruleResultDetail = validate.getDetails()
.get(0);
assertEquals("TOO_SHORT", ruleResultDetail.getErrorCode());
assertEquals(5, ruleResultDetail.getParameters()
.get("minimumLength"));
assertEquals(5, ruleResultDetail.getParameters()
.get("maximumLength"));
Integer lengthCount = validate.getMetadata()
.getCounts()
.get(RuleResultMetadata.CountCategory.Length);
assertEquals(Integer.valueOf(4), lengthCount);
}
@Test
public void givenPasswordValidatorWithLengthRule_whenValidation_thenTooLongPassword() {
PasswordData passwordData = new PasswordData("123456");
PasswordValidator passwordValidator = new PasswordValidator(new LengthRule(5));
RuleResult validate = passwordValidator.validate(passwordData);
assertFalse(validate.isValid());
Assert.assertEquals("TOO_LONG", validate.getDetails()
.get(0)
.getErrorCode());
}
@Test
public void givenPasswordValidatorWithLengthRule_whenValidation_thenCustomizedMeesagesAvailable() throws IOException {
URL resource = this.getClass()
.getClassLoader()
.getResource("messages.properties");
Properties props = new Properties();
props.load(new FileInputStream(resource.getPath()));
MessageResolver resolver = new PropertiesMessageResolver(props);
PasswordValidator validator = new PasswordValidator(resolver, new LengthRule(8, 16), new WhitespaceRule());
RuleResult tooShort = validator.validate(new PasswordData("XXXX"));
RuleResult tooLong = validator.validate(new PasswordData("ZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZ"));
assertEquals("Password must not contain less characters than 16.", validator.getMessages(tooShort)
.get(0));
assertEquals("Password must not have more characters than 16.", validator.getMessages(tooLong)
.get(0));
}
}

View File

@ -0,0 +1,76 @@
package com.baeldung.passay;
import org.junit.Test;
import org.passay.AllowedCharacterRule;
import org.passay.AllowedRegexRule;
import org.passay.CharacterCharacteristicsRule;
import org.passay.CharacterRule;
import org.passay.EnglishCharacterData;
import org.passay.LengthComplexityRule;
import org.passay.LengthRule;
import org.passay.PasswordData;
import org.passay.PasswordValidator;
import org.passay.RuleResult;
import static org.junit.Assert.*;
public class PositiveMatchingRulesUnitTest {
@Test
public void givenPasswordValidationRules_whenValidatingPassword_thenPosswordIsNotValidWithSeveralErrors() {
PasswordValidator passwordValidator = new PasswordValidator(new AllowedCharacterRule(new char[] { 'a', 'b', 'c' }), new AllowedRegexRule("\\d{2}\\w{10}"), new CharacterRule(EnglishCharacterData.LowerCase, 5), new LengthRule(8, 10));
RuleResult validate = passwordValidator.validate(new PasswordData("12abc"));
assertFalse(validate.isValid());
assertEquals("ALLOWED_CHAR:{illegalCharacter=1, matchBehavior=contains}", getDetail(validate, 0));
assertEquals("ALLOWED_CHAR:{illegalCharacter=2, matchBehavior=contains}", getDetail(validate, 1));
assertEquals("ALLOWED_MATCH:{pattern=\\d{2}\\w{10}}", getDetail(validate, 2));
assertEquals("INSUFFICIENT_LOWERCASE:{" + "minimumRequired=5, matchingCharacterCount=3, " + "validCharacters=abcdefghijklmnopqrstuvwxyz, " + "matchingCharacters=abc}", getDetail(validate, 3));
assertEquals("TOO_SHORT:{minimumLength=8, maximumLength=10}", getDetail(validate, 4));
}
@Test
public void givenRulesForDifferentPasswordLength_whenValidatingTwoDifferentPassword_thenBothOfThemAreInvalid() {
PasswordData shortPassword = new PasswordData("12ab");
PasswordData longPassword = new PasswordData("1234abcde");
LengthComplexityRule lengthComplexityRule = new LengthComplexityRule();
lengthComplexityRule.addRules("[1,5]", new CharacterRule(EnglishCharacterData.LowerCase, 5));
lengthComplexityRule.addRules("[6,10]", new AllowedCharacterRule(new char[] { 'a', 'b', 'c', 'd' }));
PasswordValidator passwordValidator = new PasswordValidator(lengthComplexityRule);
RuleResult validateShort = passwordValidator.validate(shortPassword);
RuleResult validateLong = passwordValidator.validate(longPassword);
assertFalse(validateShort.isValid());
assertFalse(validateLong.isValid());
assertEquals("INSUFFICIENT_LOWERCASE:{" + "minimumRequired=5, " + "matchingCharacterCount=2, " + "validCharacters=abcdefghijklmnopqrstuvwxyz, " + "matchingCharacters=ab}", getDetail(validateShort, 0));
assertEquals("ALLOWED_CHAR:{illegalCharacter=1, matchBehavior=contains}", getDetail(validateLong, 0));
}
@Test
public void givenCharacterCharacteristicsRule_whenValidatingPassword_thenItIsInvalidAsItBreaksToManyRules() {
PasswordData shortPassword = new PasswordData();
shortPassword.setPassword("12345abcde!");
CharacterCharacteristicsRule characterCharacteristicsRule = new CharacterCharacteristicsRule(4, new CharacterRule(EnglishCharacterData.LowerCase, 5), new CharacterRule(EnglishCharacterData.UpperCase, 5), new CharacterRule(EnglishCharacterData.Digit),
new CharacterRule(EnglishCharacterData.Special));
PasswordValidator passwordValidator = new PasswordValidator(characterCharacteristicsRule);
RuleResult validate = passwordValidator.validate(shortPassword);
assertFalse(validate.isValid());
assertEquals("INSUFFICIENT_UPPERCASE:{" + "minimumRequired=5, " + "matchingCharacterCount=0, " + "validCharacters=ABCDEFGHIJKLMNOPQRSTUVWXYZ, " + "matchingCharacters=}", getDetail(validate, 0));
assertEquals("INSUFFICIENT_CHARACTERISTICS:{" + "successCount=3, " + "minimumRequired=4, " + "ruleCount=4}", getDetail(validate, 1));
}
private String getDetail(RuleResult validate, int i) {
return validate.getDetails()
.get(i)
.toString();
}
}

View File

@ -0,0 +1,2 @@
TOO_LONG=Password must not have more characters than %2$s.
TOO_SHORT=Password must not contain less characters than %2$s.

View File

@ -1,3 +1,5 @@
## Relevant Articles:
- [Introduction to Project Lombok](http://www.baeldung.com/intro-to-project-lombok)
- [Using Lomboks @Builder Annotation](http://www.baeldung.com/lombok-builder)
- [Using Lomboks @Getter for Boolean Fields](https://www.baeldung.com/lombok-getter-boolean)
- [Lombok @Builder with Inheritance](https://www.baeldung.com/lombok-builder-inheritance)

View File

@ -3,7 +3,6 @@
<modelVersion>4.0.0</modelVersion>
<artifactId>mustache</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>jar</packaging>
<name>mustache</name>
@ -24,10 +23,8 @@
<dependency>
<groupId>org.assertj</groupId>
<artifactId>assertj-core</artifactId>
<version>${assertj.version}</version>
</dependency>
<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
@ -55,13 +52,6 @@
<version>${datafactory.version}</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>${junit.version}</version>
<scope>test</scope>
</dependency>
</dependencies>
<build>
@ -73,90 +63,13 @@
</plugins>
</build>
<profiles>
<profile>
<id>integration</id>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<executions>
<execution>
<phase>integration-test</phase>
<goals>
<goal>test</goal>
</goals>
<configuration>
<excludes>
<exclude>**/*LiveTest.java</exclude>
<exclude>**/AutoconfigurationTest.java</exclude>
</excludes>
<includes>
<include>**/*IntegrationTest.java</include>
<include>**/*IntTest.java</include>
</includes>
</configuration>
</execution>
</executions>
<configuration>
<systemPropertyVariables>
<test.mime>json</test.mime>
</systemPropertyVariables>
</configuration>
</plugin>
</plugins>
</build>
</profile>
<profile>
<id>autoconfiguration</id>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<executions>
<execution>
<phase>integration-test</phase>
<goals>
<goal>test</goal>
</goals>
<configuration>
<excludes>
<exclude>**/*LiveTest.java</exclude>
<exclude>**/*IntegrationTest.java</exclude>
<exclude>**/*IntTest.java</exclude>
</excludes>
<includes>
<include>**/AutoconfigurationTest.java</include>
</includes>
</configuration>
</execution>
</executions>
<configuration>
<systemPropertyVariables>
<test.mime>json</test.mime>
</systemPropertyVariables>
</configuration>
</plugin>
</plugins>
</build>
</profile>
</profiles>
<properties>
<mustache.compiler.api.version>0.9.2</mustache.compiler.api.version>
<assertj.version>3.7.0</assertj.version>
<log4j.version>1.2.16</log4j.version>
<junit.version>4.12</junit.version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<!-- maven plugins -->
<maven-compiler-plugin.version>3.7.0</maven-compiler-plugin.version>
<maven-surefire-plugin.version>2.21.0</maven-surefire-plugin.version>
<datafactory.version>0.8</datafactory.version>
<webjars.bootstrap.version>3.3.7</webjars.bootstrap.version>
<java.version>1.8</java.version>
</properties>
</project>

View File

@ -1,3 +1,3 @@
### Relevant articles
- [Guide to OptaPlanner](https://www.baeldung.com/opta-planner)
- [A Guide to OptaPlanner](https://www.baeldung.com/opta-planner)

View File

@ -0,0 +1,67 @@
package org.baeldung;
import java.io.IOException;
import java.util.HashMap;
import org.apache.cassandra.exceptions.ConfigurationException;
import org.apache.thrift.transport.TTransportException;
import org.baeldung.spring.data.cassandra.config.CassandraConfig;
import org.baeldung.spring.data.cassandra.model.Book;
import org.cassandraunit.utils.EmbeddedCassandraServerHelper;
import org.junit.After;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cassandra.core.cql.CqlIdentifier;
import org.springframework.data.cassandra.core.CassandraAdminOperations;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import com.datastax.driver.core.Cluster;
import com.datastax.driver.core.Session;
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(classes = CassandraConfig.class)
public class SpringContextIntegrationTest {
public static final String KEYSPACE_CREATION_QUERY = "CREATE KEYSPACE IF NOT EXISTS testKeySpace " + "WITH replication = { 'class': 'SimpleStrategy', 'replication_factor': '3' };";
public static final String KEYSPACE_ACTIVATE_QUERY = "USE testKeySpace;";
public static final String DATA_TABLE_NAME = "book";
@Autowired
private CassandraAdminOperations adminTemplate;
@BeforeClass
public static void startCassandraEmbedded() throws InterruptedException, TTransportException, ConfigurationException, IOException {
EmbeddedCassandraServerHelper.startEmbeddedCassandra();
final Cluster cluster = Cluster.builder().addContactPoints("127.0.0.1").withPort(9142).build();
final Session session = cluster.connect();
session.execute(KEYSPACE_CREATION_QUERY);
session.execute(KEYSPACE_ACTIVATE_QUERY);
Thread.sleep(5000);
}
@Before
public void createTable() throws InterruptedException, TTransportException, ConfigurationException, IOException {
adminTemplate.createTable(true, CqlIdentifier.cqlId(DATA_TABLE_NAME), Book.class, new HashMap<String, Object>());
}
@Test
public void whenSpringContextIsBootstrapped_thenNoExceptions() {
}
@After
public void dropTable() {
adminTemplate.dropTable(CqlIdentifier.cqlId(DATA_TABLE_NAME));
}
@AfterClass
public static void stopCassandraEmbedded() {
EmbeddedCassandraServerHelper.cleanEmbeddedCassandra();
}
}

View File

@ -0,0 +1,17 @@
package org.baeldung;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;
import com.baeldung.Application;
@RunWith(SpringRunner.class)
@SpringBootTest(classes = Application.class)
public class SpringContextIntegrationTest {
@Test
public void whenSpringContextIsBootstrapped_thenNoExceptions() {
}
}

View File

@ -0,0 +1,17 @@
package org.baeldung;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;
import com.baeldung.eclipselink.springdata.EclipselinkSpringDataApplication;
@RunWith(SpringRunner.class)
@SpringBootTest(classes = EclipselinkSpringDataApplication.class)
public class SpringContextIntegrationTest {
@Test
public void whenSpringContextIsBootstrapped_thenNoExceptions() {
}
}

View File

@ -0,0 +1,18 @@
package org.baeldung;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import org.springframework.test.context.support.AnnotationConfigContextLoader;
import com.baeldung.spring.data.gemfire.function.GemfireConfiguration;
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(classes=GemfireConfiguration.class, loader=AnnotationConfigContextLoader.class)
public class SpringContextIntegrationTest {
@Test
public void whenSpringContextIsBootstrapped_thenNoExceptions() {
}
}

View File

@ -0,0 +1,19 @@
package org.baeldung;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.test.context.ActiveProfiles;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import com.baeldung.spring.data.neo4j.config.MovieDatabaseNeo4jTestConfiguration;
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(classes = MovieDatabaseNeo4jTestConfiguration.class)
@ActiveProfiles(profiles = "test")
public class SpringContextIntegrationTest {
@Test
public void whenSpringContextIsBootstrapped_thenNoExceptions() {
}
}

View File

@ -0,0 +1,17 @@
package org.baeldung;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import com.baeldung.spring.data.redis.config.RedisConfig;
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(classes = RedisConfig.class)
public class SpringContextIntegrationTest {
@Test
public void whenSpringContextIsBootstrapped_thenNoExceptions() {
}
}

View File

@ -0,0 +1,17 @@
package org.baeldung;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import com.baeldung.spring.data.solr.config.SolrConfig;
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(classes = SolrConfig.class)
public class SpringContextIntegrationTest {
@Test
public void whenSpringContextIsBootstrapped_thenNoExceptions() {
}
}

View File

@ -0,0 +1,17 @@
package org.baeldung;
import org.baeldung.spring.PersistenceConfig;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import org.springframework.test.context.support.AnnotationConfigContextLoader;
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(classes = { PersistenceConfig.class }, loader = AnnotationConfigContextLoader.class)
public class SpringContextIntegrationTest {
@Test
public void whenSpringContextIsBootstrapped_thenNoExceptions() {
}
}

View File

@ -0,0 +1,18 @@
package org.baeldung;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import org.springframework.test.context.support.AnnotationConfigContextLoader;
import com.baeldung.spring.PersistenceConfig;
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(classes = { PersistenceConfig.class }, loader = AnnotationConfigContextLoader.class)
public class SpringContextIntegrationTest {
@Test
public void whenSpringContextIsBootstrapped_thenNoExceptions() {
}
}

230
pom.xml
View File

@ -398,7 +398,7 @@
<module>javafx</module>
<module>jgroups</module>
<module>jee-7</module>
<module>jhipster/jhipster-monolithic</module>
<module>jhipster</module>
<module>jjwt</module>
<module>jsf</module>
<module>json-path</module>
@ -475,6 +475,7 @@
<module>spring-boot-logging-log4j2</module>
<module>spring-cloud-data-flow</module>
<module>spring-cloud</module>
<module>spring-cloud-bus</module>
<module>spring-core</module>
<module>spring-cucumber</module>
<module>spring-ejb</module>
@ -604,16 +605,17 @@
<module>spring-reactive-kotlin</module>
<module>jnosql</module>
<module>spring-boot-angular-ecommerce</module>
<module>cdi-portable-extension</module>
<module>jta</module>
<!--<module>java-dates</module> --> <!-- Commented because we have still not upgraded to java 9 -->
<module>java-websocket</module>
<module>activejdbc</module>
<!-- <module>animal-sniffer-mvn-plugin</module> --><!-- PMD voilation -->
<!-- <module>apache-avro</module> --><!-- Malformed POM -->
<module>animal-sniffer-mvn-plugin</module>
<module>apache-avro</module>
<module>apache-bval</module>
<module>apache-shiro</module>
<module>apache-spark</module>
<!-- <module>asciidoctor</module> --><!-- Malformed POM -->
<module>asciidoctor</module>
<module>checker-plugin</module>
<!-- <module>core-java-10</module> --><!-- Not upgraded to java 10 -->
<!-- <module>core-java-11</module> --><!-- Not upgraded to java 11 -->
@ -622,9 +624,9 @@
<module>dagger</module>
<module>data-structures</module>
<module>dubbo</module>
<!-- <module>flyway</module> --><!-- Malformed POM -->
<module>flyway</module>
<!-- <module>grpc</module> --><!-- protobuf-maven-plugin filecopy failure -->
<!-- <module>java-difference-date</module> --><!-- PMD voilation -->
<module>java-difference-date</module>
<!-- <module>JGit</module> --><!-- Unit test failure -->
<module>jni</module>
<module>jooby</module>
@ -632,24 +634,24 @@
<!-- <module>microprofile</module> --><!-- Takes too much time : Downloads 93 MBs zip and .. -->
<!-- <module>muleesb</module> --><!-- load main class org.mule.munit.remote.RemoteRunner -->
<module>ratpack</module>
<!-- <module>rest-with-spark-java</module> --><!-- PMD voilation -->
<module>rest-with-spark-java</module>
<module>spring-boot-autoconfiguration</module>
<module>spring-boot-custom-starter</module>
<module>spring-boot-jasypt</module>
<!-- <module>spring-custom-aop</module> --><!-- Malformed POM -->
<module>spring-custom-aop</module>
<module>spring-data-rest-querydsl</module>
<!-- <module>spring-groovy</module> --><!-- PMD voilation -->
<module>spring-groovy</module>
<module>spring-mobile</module>
<!-- <module>spring-mustache</module> --><!-- PMD voilation -->
<module>spring-mustache</module>
<module>spring-mvc-simple</module>
<!-- <module>spring-mybatis</module> --><!-- Compilation failure -->
<module>spring-mybatis</module>
<module>spring-rest-hal-browser</module>
<module>spring-rest-shell</module>
<module>spring-rest-template</module>
<module>spring-roo</module>
<module>spring-security-stormpath</module>
<module>sse-jaxrs</module>
<!-- <module>static-analysis</module> --><!-- PMD voilation -->
<module>static-analysis</module>
<module>stripe</module>
<!-- <module>structurizr</module> --><!-- Artiifact not found -->
<module>Twitter4J</module>
@ -660,13 +662,13 @@
<!-- <module>graphql/graphql-java</module> --><!-- Wrong parent -->
<!-- <module>guest/deep-jsf</module> --><!-- guest post on different site -->
<!-- <module>guest/junit5-example</module> --><!-- guest post on different site - Compilation failure -->
<!-- <module>guest/log4j2-example</module> --><!-- PMD voilation -->
<!-- <module>guest/logback-example</module> --><!-- PMD voilation -->
<!-- <module>guest/log4j2-example</module> --><!-- guest post on different site -->
<!-- <module>guest/logback-example</module> --><!-- guest post on different site -->
<!-- <module>guest/memory-leaks</module> --><!-- guest post on different site -->
<!-- <module>guest/remote-debugging</module> --><!-- guest post on different site -->
<!-- <module>guest/spring-boot-app</module> --><!-- guest post on different site -->
<!-- <module>guest/spring-mvc</module> --><!-- Malformed POM -->
<!-- <module>guest/spring-security</module> --><!-- Malformed POM -->
<!-- <module>guest/spring-mvc</module> --><!-- guest post on different site -->
<!-- <module>guest/spring-security</module> --><!-- guest post on different site -->
<!-- <module>guest/thread-pools</module> --><!-- guest post on different site -->
<!-- <module>guest/tomcat-app</module> --><!-- guest post on different site -->
<module>jenkins/hello-world</module>
@ -677,12 +679,166 @@
<module>spring-boot-h2/spring-boot-h2-database</module>
<!--module>spring-boot-h2/spring-boot-h2-remote-app</module-->
<!-- <module>guest\webservices\rest-client</module> --><!-- guest post on different site -->
<!-- <module>guest\webservices\rest-server</module> --><!-- PMD voilation -->
<!-- <module>guest\webservices\rest-server</module> --><!-- guest post on different site -->
<!-- <module>guest\webservices\spring-rest-service</module> --><!-- guest post on different site -->
</modules>
</profile>
<profile>
<id>spring-context</id>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>${maven-surefire-plugin.version}</version>
<configuration>
<forkCount>3</forkCount>
<reuseForks>true</reuseForks>
<includes>
<include>**/*SpringContextIntegrationTest.java</include>
</includes>
</configuration>
</plugin>
</plugins>
</build>
<modules>
<module>spring-5</module>
<module>spring-5-data-reactive</module>
<module>spring-5-reactive</module>
<module>spring-5-reactive-client</module>
<module>spring-5-reactive-security</module>
<module>spring-5-security</module>
<module>spring-activiti</module>
<module>spring-akka</module>
<module>spring-all</module>
<module>spring-aop</module>
<module>spring-apache-camel</module>
<module>spring-batch</module>
<module>spring-bom</module>
<module>spring-boot-admin/spring-boot-admin-client</module>
<module>spring-boot-admin/spring-boot-admin-server</module>
<module>spring-boot-bootstrap</module>
<module>spring-boot-bootstrap</module>
<module>spring-boot-camel</module>
<module>spring-boot-client</module>
<module>spring-boot-custom-starter</module>
<module>greeter-spring-boot-autoconfigure</module>
<module>greeter-spring-boot-sample-app</module>
<module>spring-boot-h2/spring-boot-h2-database</module>
<module>spring-boot-jasypt</module>
<module>spring-boot-keycloak</module>
<module>spring-boot-mvc</module>
<module>spring-boot-property-exp/property-exp-custom-config</module>
<module>spring-boot-property-exp/property-exp-default-config</module>
<module>spring-boot-vue</module>
<module>spring-cloud</module>
<module>spring-cloud/spring-cloud-archaius/basic-config</module>
<module>spring-cloud/spring-cloud-archaius/extra-configs</module>
<module>spring-cloud/spring-cloud-bootstrap/config</module>
<module>spring-cloud/spring-cloud-contract/spring-cloud-contract-consumer</module>
<module>spring-cloud/spring-cloud-contract/spring-cloud-contract-producer</module>
<module>spring-cloud/spring-cloud-gateway</module>
<module>spring-cloud/spring-cloud-kubernetes/demo-backend</module>
<module>spring-cloud/spring-cloud-rest/spring-cloud-rest-config-server</module>
<module>spring-cloud/spring-cloud-ribbon-client </module>
<module>spring-cloud/spring-cloud-security/auth-client</module>
<module>spring-cloud/spring-cloud-security/auth-resource</module>
<module>spring-cloud/spring-cloud-security/auth-server</module>
<module>spring-cloud/spring-cloud-stream/spring-cloud-stream-rabbit</module>
<module>spring-cloud/spring-cloud-task/springcloudtasksink</module>
<module>spring-cloud/spring-cloud-zookeeper </module>
<module>spring-cloud/spring-cloud-bus/spring-cloud-config-server</module>
<module>spring-cloud/spring-cloud-data-flow/log-sink</module>
<module>spring-cloud/spring-cloud-data-flow/time-processor</module>
<module>spring-cloud/spring-cloud-data-flow/time-source</module>
<module>spring-cucumber</module>
<module>spring-data-keyvalue</module>
<module>spring-data-rest</module>
<module>spring-dispatcher-servlet</module>
<module>spring-drools</module>
<module>spring-freemarker</module>
<module>spring-hibernate-3</module>
<module>spring-hibernate4</module>
<module>spring-integration</module>
<module>spring-jenkins-pipeline</module>
<module>spring-jersey</module>
<module>spring-jinq</module>
<module>spring-jms</module>
<module>spring-kafka</module>
<module>spring-katharsis</module>
<module>spring-ldap</module>
<module>spring-mobile</module>
<module>spring-mockito</module>
<module>spring-mvc-forms-thymeleaf</module>
<module>spring-mvc-java</module>
<module>spring-mvc-velocity</module>
<module>spring-mvc-webflow</module>
<module>spring-protobuf</module>
<module>spring-quartz</module>
<module>remoting-hessian-burlap/spring-remoting-hessian-burlap-client</module>
<module>remoting-hessian-burlap/remoting-hessian-burlap-server</module>
<module>spring-reactor</module>
<module>spring-remoting/</module>
<module>spring-remoting/remoting-http/remoting-http-server</module>
<module>spring-remoting/remoting-jms/remoting-jms-client</module>
<module>spring-remoting/remoting-rmi/remoting-rmi-server</module>
<module>spring-rest</module>
<module>spring-rest-angular</module>
<module>spring-rest-embedded-tomcat</module>
<module>spring-rest-full</module>
<module>spring-rest-simple</module>
<module>spring-resttemplate</module>
<module>spring-security-acl</module>
<module>spring-security-angular</module>
<module>spring-security-cache-control</module>
<module>spring-security-client/spring-security-jsp-authentication</module>
<module>spring-security-client/spring-security-jsp-authorize</module>
<module>spring-security-client/spring-security-jsp-config</module>
<module>spring-security-client/spring-security-mvc</module>
<module>spring-security-client/spring-security-thymeleaf-authentication</module>
<module>spring-security-client/spring-security-thymeleaf-authorize</module>
<module>spring-security-client/spring-security-thymeleaf-config</module>
<module>spring-security-core</module>
<module>spring-security-mvc-boot</module>
<module>spring-security-mvc-custom</module>
<module>spring-security-mvc-digest-auth</module>
<module>spring-security-mvc-ldap</module>
<module>spring-security-mvc-persisted-remember-me</module>
<module>spring-security-mvc-session</module>
<module>spring-security-mvc-socket</module>
<module>spring-security-rest</module>
<module>spring-security-sso/spring-security-sso-auth-server</module>
<module>spring-security-sso/spring-security-sso-ui</module>
<module>spring-security-sso/spring-security-sso-ui-2</module>
<module>spring-security-thymeleaf/spring-security-thymeleaf-authentication</module>
<module>spring-security-thymeleaf/spring-security-thymeleaf-authorize</module>
<module>spring-security-thymeleaf/spring-security-thymeleaf-config</module>
<module>spring-security-x509/spring-security-x509-basic-auth</module>
<module>spring-security-x509/spring-security-x509-client-auth</module>
<module>spring-session/spring-session-jdbc</module>
<module>spring-sleuth</module>
<module>spring-social-login</module>
<module>spring-spel</module>
<module>spring-state-machine</module>
<module>spring-swagger-codegen/spring-swagger-codegen-app</module>
<module>spring-thymeleaf</module>
<module>spring-userservice</module>
<module>spring-vault </module>
<module>spring-vertx</module>
<module>spring-zuul/spring-zuul-foos-resource</module>
<module>persistence-modules/spring-data-dynamodb</module>
<module>persistence-modules/spring-data-eclipselink</module>
<module>persistence-modules/spring-data-solr</module>
<module>persistence-modules/spring-hibernate-5</module>
</modules>
</profile>
<profile>
<id>integration</id>
<build>
@ -822,6 +978,7 @@
<module>spring-boot-logging-log4j2</module>
<module>spring-cloud-data-flow</module>
<module>spring-cloud</module>
<module>spring-cloud-bus</module>
<module>spring-core</module>
<module>spring-cucumber</module>
<module>spring-ejb</module>
@ -924,13 +1081,13 @@
<!-- <module>libraries</module> <module>jmeter</module> -->
<!--<module>java-dates</module> --> <!-- Commented because we have still not upgraded to java 9 -->
<module>java-websocket</module>
<!-- <module>activejdbc</module> --><!-- PMD voilation -->
<!-- <module>animal-sniffer-mvn-plugin</module> --><!-- PMD voilation -->
<!-- <module>apache-avro</module> --><!-- Malformed POM -->
<module>activejdbc</module>
<module>animal-sniffer-mvn-plugin</module>
<module>apache-avro</module>
<module>apache-bval</module>
<module>apache-shiro</module>
<module>apache-spark</module>
<!-- <module>asciidoctor</module> --><!-- Malformed POM -->
<module>asciidoctor</module>
<module>checker-plugin</module>
<!-- <module>core-java-10</module> --><!-- Not upgraded to java 10 -->
<!-- <module>core-java-11</module> --><!-- Not upgraded to java 11 -->
@ -939,9 +1096,9 @@
<module>dagger</module>
<module>data-structures</module>
<module>dubbo</module>
<!-- <module>flyway</module> --><!-- Malformed POM -->
<module>flyway</module>
<!-- <module>grpc</module> --><!-- protobuf-maven-plugin filecopy failure -->
<!-- <module>java-difference-date</module> --><!-- PMD voilation -->
<module>java-difference-date</module>
<!-- <module>JGit</module> --><!-- Unit test failure -->
<module>jni</module>
<module>jooby</module>
@ -949,24 +1106,24 @@
<!-- <module>microprofile</module> --><!-- Takes too much time : Downloads 93 MBs zip and .. -->
<!-- <module>muleesb</module> --><!-- load main class org.mule.munit.remote.RemoteRunner -->
<module>ratpack</module>
<!-- <module>rest-with-spark-java</module> --><!-- PMD voilation -->
<module>rest-with-spark-java</module>
<module>spring-boot-autoconfiguration</module>
<module>spring-boot-custom-starter</module>
<!-- <module>spring-boot-jasypt</module> --><!-- PMD voilation -->
<!-- <module>spring-custom-aop</module> --><!-- Malformed POM -->
<module>spring-boot-jasypt</module>
<module>spring-custom-aop</module>
<module>spring-data-rest-querydsl</module>
<!-- <module>spring-groovy</module> --><!-- PMD voilation -->
<module>spring-groovy</module>
<module>spring-mobile</module>
<!-- <module>spring-mustache</module> --><!-- PMD voilation -->
<module>spring-mustache</module>
<module>spring-mvc-simple</module>
<!-- <module>spring-mybatis</module> --><!-- Compilation failure -->
<module>spring-mybatis</module>
<module>spring-rest-hal-browser</module>
<module>spring-rest-shell</module>
<module>spring-rest-template</module>
<module>spring-roo</module>
<module>spring-security-stormpath</module>
<module>sse-jaxrs</module>
<!-- <module>static-analysis</module> --><!-- PMD voilation -->
<module>static-analysis</module>
<module>stripe</module>
<!-- <module>structurizr</module> --><!-- Artiifact not found -->
<!-- <module>Twitter4J</module> --><!-- Test failure -->
@ -977,13 +1134,13 @@
<!-- <module>graphql/graphql-java</module> --><!-- Wrong parent -->
<!-- <module>guest/deep-jsf</module> --><!-- guest post on different site -->
<!-- <module>guest/junit5-example</module> --><!-- guest post on different site - Compilation failure -->
<!-- <module>guest/log4j2-example</module> --><!-- PMD voilation -->
<!-- <module>guest/logback-example</module> --><!-- PMD voilation -->
<!-- <module>guest/log4j2-example</module> --><!-- guest post on different site -->
<!-- <module>guest/logback-example</module> --><!-- guest post on different site -->
<!-- <module>guest/memory-leaks</module> --><!-- guest post on different site -->
<!-- <module>guest/remote-debugging</module> --><!-- guest post on different site -->
<!-- <module>guest/spring-boot-app</module> --><!-- guest post on different site -->
<!-- <module>guest/spring-mvc</module> --><!-- Malformed POM -->
<!-- <module>guest/spring-security</module> --><!-- Malformed POM -->
<!-- <module>guest/spring-mvc</module> --><!-- guest post on different site -->
<!-- <module>guest/spring-security</module> --><!-- guest post on different site -->
<!-- <module>guest/thread-pools</module> --><!-- guest post on different site -->
<!-- <module>guest/tomcat-app</module> --><!-- guest post on different site -->
<module>jenkins/hello-world</module>
@ -994,7 +1151,7 @@
<module>spring-boot-h2/spring-boot-h2-database</module>
<!--module>spring-boot-h2/spring-boot-h2-remote-app</module-->
<!-- <module>guest\webservices\rest-client</module> --><!-- guest post on different site -->
<!-- <module>guest\webservices\rest-server</module> --><!-- PMD voilation -->
<!-- <module>guest\webservices\rest-server</module> --><!-- guest post on different site -->
<!-- <module>guest\webservices\spring-rest-service</module> --><!-- guest post on different site -->
</modules>
@ -1176,6 +1333,7 @@
<module>spring-boot-logging-log4j2</module>
<module>spring-cloud-data-flow</module>
<module>spring-cloud</module>
<module>spring-cloud-bus</module>
<module>spring-core</module>
<module>spring-cucumber</module>
<module>spring-ejb</module>
@ -1383,7 +1541,7 @@
<module>parent-kotlin</module>
<module>libraries</module>
<module>geotools</module>
<module>jhipster/jhipster-monolithic</module>
<module>jhipster</module>
<module>testing-modules/gatling</module>
<module>spring-boot</module>
<module>spring-boot-ops</module>

View File

@ -4,4 +4,4 @@
- [Ratpack Google Guice Integration](http://www.baeldung.com/ratpack-google-guice)
- [Ratpack Integration with Spring Boot](http://www.baeldung.com/ratpack-spring-boot)
- [Ratpack with Hystrix](http://www.baeldung.com/ratpack-hystrix)
- [Ratpack HTTP Client](https://www.baeldung.com/ratpack-http-client)

View File

@ -16,16 +16,16 @@ import junit.framework.Test;
import junit.framework.TestCase;
import junit.framework.TestSuite;
public class AppTest extends TestCase {
public class AppLiveTest extends TestCase {
ObjectMapper mapper = new ObjectMapper();
public AppTest( String testName ) {
public AppLiveTest( String testName ) {
super( testName );
}
public static Test suite() {
return new TestSuite( AppTest.class );
return new TestSuite( AppLiveTest.class );
}
public void testApp() throws IOException, ClassNotFoundException {

View File

@ -2,5 +2,6 @@
- [RxJava and Error Handling](http://www.baeldung.com/rxjava-error-handling)
- [RxJava 2 Flowable](http://www.baeldung.com/rxjava-2-flowable)
- [RxJava 2 - Completable](http://www.baeldung.com/rxjava-completable)
- [RxJava Maybe](http://www.baeldung.com/rxjava-maybe)
- [Introduction to RxRelay for RxJava](http://www.baeldung.com/rx-relay)

View File

@ -38,9 +38,8 @@
<properties>
<assertj.version>3.8.0</assertj.version>
<rx.java2.version>2.1.3</rx.java2.version>
<rx.java2.version>2.2.2</rx.java2.version>
<awaitility.version>1.7.0</awaitility.version>
<rxrelay.version>2.0.0</rxrelay.version>
</properties>
</project>

View File

@ -0,0 +1,112 @@
package com.baeldung.rxjava;
import io.reactivex.Completable;
import io.reactivex.Flowable;
import io.reactivex.Single;
import io.reactivex.observers.DisposableCompletableObserver;
import org.junit.Before;
import org.junit.Test;
public class CompletableUnitTest {
Completable first;
Completable second;
Completable error;
Throwable throwable = new RuntimeException();
@Before
public void setUpCompletables() {
first = Completable.fromSingle(Single.just(1));
second = Completable.fromRunnable(() -> {});
error = Single.error(throwable)
.ignoreElement();
}
@Test
public void whenCompletableConstructed_thenCompletedSuccessfully() {
Completable completed = Completable.complete();
completed.subscribe(new DisposableCompletableObserver() {
@Override
public void onComplete() {
System.out.println("Completed!");
}
@Override
public void onError(Throwable e) {
e.printStackTrace();
}
});
Flowable<String> flowable = Flowable.just("request received", "user logged in");
Completable flowableCompletable = Completable.fromPublisher(flowable);
Completable singleCompletable = Single.just(1)
.ignoreElement();
completed.andThen(flowableCompletable)
.andThen(singleCompletable)
.test()
.assertComplete();
}
@Test
public void whenCombiningCompletables_thenCompletedSuccessfully() {
first.andThen(second)
.test()
.assertComplete();
}
@Test
public void whenCombinedWithError_thenCompletedWithError() {
first.andThen(second)
.andThen(error)
.test()
.assertError(throwable);
}
@Test
public void whenCombinedWithNever_thenDoesNotComplete() {
first.andThen(second)
.andThen(Completable.never())
.test()
.assertNotComplete();
}
@Test
public void whenMergedCompletables_thenCompletedSuccessfully() {
Completable.mergeArray(first, second)
.test()
.assertComplete();
}
@Test
public void whenMergedWithError_thenCompletedWithError() {
Completable.mergeArray(first, second, error)
.test()
.assertError(throwable);
}
@Test
public void whenFlatMaped_thenCompletedSuccessfully() {
Completable allElementsCompletable = Flowable.just("request received", "user logged in")
.flatMapCompletable(message -> Completable
.fromRunnable(() -> System.out.println(message))
);
allElementsCompletable
.test()
.assertComplete();
}
@Test
public void whenAmbWithNever_thenCompletedSuccessfully() {
Completable.ambArray(first, Completable.never(), second)
.test()
.assertComplete();
}
@Test
public void whenAmbWithError_thenCompletedWithError() {
Completable.ambArray(error, first, second)
.test()
.assertError(throwable);
}
}

View File

@ -0,0 +1,17 @@
package org.baeldung;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;
import com.baeldung.flips.ApplicationConfig;
@RunWith(SpringRunner.class)
@SpringBootTest(classes = ApplicationConfig.class)
public class SpringContextIntegrationTest {
@Test
public void whenSpringContextIsBootstrapped_thenNoExceptions() {
}
}

View File

@ -62,28 +62,6 @@
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-api</artifactId>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-engine</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.platform</groupId>
<artifactId>junit-platform-surefire-provider</artifactId>
<version>${junit.platform.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.platform</groupId>
<artifactId>junit-platform-runner</artifactId>
<version>${junit.platform.version}</version>
<scope>test</scope>
</dependency>
</dependencies>
<build>
@ -175,32 +153,13 @@
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<forkCount>3</forkCount>
<reuseForks>true</reuseForks>
<parallel>methods</parallel>
<useUnlimitedThreads>true</useUnlimitedThreads>
<excludes>
<exclude>**/*IntegrationTest.java</exclude>
<exclude>**/*IntTest.java</exclude>
<exclude>**/*LiveTest.java</exclude>
</excludes>
</configuration>
</plugin>
</plugins>
</build>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<java.version>1.8</java.version>
<kotlin.version>1.2.40</kotlin.version>
<kotlin-maven-plugin.version>1.2.40</kotlin-maven-plugin.version>
<junit.platform.version>1.0.0</junit.platform.version>
<junit.jupiter.version>5.0.2</junit.jupiter.version>
</properties>
</project>

View File

@ -0,0 +1,17 @@
package org.baeldung;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;
import com.baeldung.reactive.Spring5ReactiveApplication;
@RunWith(SpringRunner.class)
@SpringBootTest(classes = Spring5ReactiveApplication.class)
public class SpringContextIntegrationTest {
@Test
public void whenSpringContextIsBootstrapped_thenNoExceptions() {
}
}

View File

@ -0,0 +1,17 @@
package org.baeldung;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;
import com.baeldung.reactive.Spring5ReactiveTestApplication;
@RunWith(SpringRunner.class)
@SpringBootTest(classes = Spring5ReactiveTestApplication.class)
public class SpringContextIntegrationTest {
@Test
public void whenSpringContextIsBootstrapped_thenNoExceptions() {
}
}

View File

@ -0,0 +1,17 @@
package org.baeldung;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;
import com.baeldung.reactive.security.SpringSecurity5Application;
@RunWith(SpringRunner.class)
@SpringBootTest(classes = SpringSecurity5Application.class)
public class SpringContextIntegrationTest {
@Test
public void whenSpringContextIsBootstrapped_thenNoExceptions() {
}
}

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