Merge branch 'master' of https://github.com/eugenp/tutorials
This commit is contained in:
commit
789505d769
@ -14,18 +14,19 @@
|
|||||||
<dependencies>
|
<dependencies>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.typesafe.akka</groupId>
|
<groupId>com.typesafe.akka</groupId>
|
||||||
<artifactId>akka-stream_2.11</artifactId>
|
<artifactId>akka-stream_${scala.version}</artifactId>
|
||||||
<version>${akkastreams.version}</version>
|
<version>${akkastreams.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.typesafe.akka</groupId>
|
<groupId>com.typesafe.akka</groupId>
|
||||||
<artifactId>akka-stream-testkit_2.11</artifactId>
|
<artifactId>akka-stream-testkit_${scala.version}</artifactId>
|
||||||
<version>${akkastreams.version}</version>
|
<version>${akkastreams.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
<properties>
|
<properties>
|
||||||
<akkastreams.version>2.5.2</akkastreams.version>
|
<akkastreams.version>2.5.2</akkastreams.version>
|
||||||
|
<scala.version>2.11</scala.version>
|
||||||
</properties>
|
</properties>
|
||||||
|
|
||||||
</project>
|
</project>
|
@ -1,42 +1,42 @@
|
|||||||
package com.baeldung.algorithms.reversingtree;
|
package com.baeldung.algorithms.reversingtree;
|
||||||
|
|
||||||
public class TreeNode {
|
public class TreeNode {
|
||||||
|
|
||||||
private int value;
|
private int value;
|
||||||
private TreeNode rightChild;
|
private TreeNode rightChild;
|
||||||
private TreeNode leftChild;
|
private TreeNode leftChild;
|
||||||
|
|
||||||
public int getValue() {
|
public int getValue() {
|
||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setValue(int value) {
|
public void setValue(int value) {
|
||||||
this.value = value;
|
this.value = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
public TreeNode getRightChild() {
|
public TreeNode getRightChild() {
|
||||||
return rightChild;
|
return rightChild;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setRightChild(TreeNode rightChild) {
|
public void setRightChild(TreeNode rightChild) {
|
||||||
this.rightChild = rightChild;
|
this.rightChild = rightChild;
|
||||||
}
|
}
|
||||||
|
|
||||||
public TreeNode getLeftChild() {
|
public TreeNode getLeftChild() {
|
||||||
return leftChild;
|
return leftChild;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setLeftChild(TreeNode leftChild) {
|
public void setLeftChild(TreeNode leftChild) {
|
||||||
this.leftChild = leftChild;
|
this.leftChild = leftChild;
|
||||||
}
|
}
|
||||||
|
|
||||||
public TreeNode(int value, TreeNode rightChild, TreeNode leftChild) {
|
public TreeNode(int value, TreeNode leftChild, TreeNode rightChild) {
|
||||||
this.value = value;
|
this.value = value;
|
||||||
this.rightChild = rightChild;
|
this.rightChild = rightChild;
|
||||||
this.leftChild = leftChild;
|
this.leftChild = leftChild;
|
||||||
}
|
}
|
||||||
|
|
||||||
public TreeNode(int value) {
|
public TreeNode(int value) {
|
||||||
this.value = value;
|
this.value = value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,68 +1,53 @@
|
|||||||
package com.baeldung.algorithms.reversingtree;
|
package com.baeldung.algorithms.reversingtree;
|
||||||
|
|
||||||
import java.util.LinkedList;
|
import java.util.LinkedList;
|
||||||
|
|
||||||
public class TreeReverser {
|
public class TreeReverser {
|
||||||
|
|
||||||
public TreeNode createBinaryTree() {
|
public void reverseRecursive(TreeNode treeNode) {
|
||||||
|
if (treeNode == null) {
|
||||||
TreeNode leaf1 = new TreeNode(3);
|
return;
|
||||||
TreeNode leaf2 = new TreeNode(1);
|
}
|
||||||
TreeNode leaf3 = new TreeNode(9);
|
|
||||||
TreeNode leaf4 = new TreeNode(6);
|
TreeNode temp = treeNode.getLeftChild();
|
||||||
|
treeNode.setLeftChild(treeNode.getRightChild());
|
||||||
TreeNode nodeLeft = new TreeNode(2, leaf1, leaf2);
|
treeNode.setRightChild(temp);
|
||||||
TreeNode nodeRight = new TreeNode(7, leaf3, leaf4);
|
|
||||||
|
reverseRecursive(treeNode.getLeftChild());
|
||||||
TreeNode root = new TreeNode(4, nodeRight, nodeLeft);
|
reverseRecursive(treeNode.getRightChild());
|
||||||
|
}
|
||||||
return root;
|
|
||||||
}
|
public void reverseIterative(TreeNode treeNode) {
|
||||||
|
LinkedList<TreeNode> queue = new LinkedList<TreeNode>();
|
||||||
public void reverseRecursive(TreeNode treeNode) {
|
|
||||||
if (treeNode == null) {
|
if (treeNode != null) {
|
||||||
return;
|
queue.add(treeNode);
|
||||||
}
|
}
|
||||||
|
|
||||||
TreeNode temp = treeNode.getLeftChild();
|
while (!queue.isEmpty()) {
|
||||||
treeNode.setLeftChild(treeNode.getRightChild());
|
|
||||||
treeNode.setRightChild(temp);
|
TreeNode node = queue.poll();
|
||||||
|
if (node.getLeftChild() != null)
|
||||||
reverseRecursive(treeNode.getLeftChild());
|
queue.add(node.getLeftChild());
|
||||||
reverseRecursive(treeNode.getRightChild());
|
if (node.getRightChild() != null)
|
||||||
}
|
queue.add(node.getRightChild());
|
||||||
|
|
||||||
public void reverseIterative(TreeNode treeNode) {
|
TreeNode temp = node.getLeftChild();
|
||||||
LinkedList<TreeNode> queue = new LinkedList<TreeNode>();
|
node.setLeftChild(node.getRightChild());
|
||||||
|
node.setRightChild(temp);
|
||||||
if (treeNode != null) {
|
}
|
||||||
queue.add(treeNode);
|
}
|
||||||
}
|
|
||||||
|
public String toString(TreeNode root) {
|
||||||
while (!queue.isEmpty()) {
|
if (root == null) {
|
||||||
|
return "";
|
||||||
TreeNode node = queue.poll();
|
}
|
||||||
if (node.getLeftChild() != null)
|
|
||||||
queue.add(node.getLeftChild());
|
StringBuffer buffer = new StringBuffer(String.valueOf(root.getValue())).append(" ");
|
||||||
if (node.getRightChild() != null)
|
|
||||||
queue.add(node.getRightChild());
|
buffer.append(toString(root.getLeftChild()));
|
||||||
|
buffer.append(toString(root.getRightChild()));
|
||||||
TreeNode temp = node.getLeftChild();
|
|
||||||
node.setLeftChild(node.getRightChild());
|
return buffer.toString();
|
||||||
node.setRightChild(temp);
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public String toString(TreeNode root) {
|
|
||||||
if (root == null) {
|
|
||||||
return "";
|
|
||||||
}
|
|
||||||
|
|
||||||
StringBuffer buffer = new StringBuffer(String.valueOf(root.getValue())).append(" ");
|
|
||||||
|
|
||||||
buffer.append(toString(root.getLeftChild()));
|
|
||||||
buffer.append(toString(root.getRightChild()));
|
|
||||||
|
|
||||||
return buffer.toString();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
@ -1,33 +1,47 @@
|
|||||||
package com.baeldung.algorithms.reversingtree;
|
package com.baeldung.algorithms.reversingtree;
|
||||||
|
|
||||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||||
|
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
public class TreeReverserUnitTest {
|
public class TreeReverserUnitTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void givenTreeWhenReversingRecursivelyThenReversed() {
|
public void givenTreeWhenReversingRecursivelyThenReversed() {
|
||||||
TreeReverser reverser = new TreeReverser();
|
TreeReverser reverser = new TreeReverser();
|
||||||
|
|
||||||
TreeNode treeNode = reverser.createBinaryTree();
|
TreeNode treeNode = createBinaryTree();
|
||||||
|
|
||||||
reverser.reverseRecursive(treeNode);
|
reverser.reverseRecursive(treeNode);
|
||||||
|
|
||||||
assertEquals("4 7 9 6 2 3 1", reverser.toString(treeNode)
|
assertEquals("4 7 9 6 2 3 1", reverser.toString(treeNode)
|
||||||
.trim());
|
.trim());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void givenTreeWhenReversingIterativelyThenReversed() {
|
public void givenTreeWhenReversingIterativelyThenReversed() {
|
||||||
TreeReverser reverser = new TreeReverser();
|
TreeReverser reverser = new TreeReverser();
|
||||||
|
|
||||||
TreeNode treeNode = reverser.createBinaryTree();
|
TreeNode treeNode = createBinaryTree();
|
||||||
|
|
||||||
reverser.reverseIterative(treeNode);
|
reverser.reverseIterative(treeNode);
|
||||||
|
|
||||||
assertEquals("4 7 9 6 2 3 1", reverser.toString(treeNode)
|
assertEquals("4 7 9 6 2 3 1", reverser.toString(treeNode)
|
||||||
.trim());
|
.trim());
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
private TreeNode createBinaryTree() {
|
||||||
|
|
||||||
|
TreeNode leaf1 = new TreeNode(1);
|
||||||
|
TreeNode leaf2 = new TreeNode(3);
|
||||||
|
TreeNode leaf3 = new TreeNode(6);
|
||||||
|
TreeNode leaf4 = new TreeNode(9);
|
||||||
|
|
||||||
|
TreeNode nodeRight = new TreeNode(7, leaf3, leaf4);
|
||||||
|
TreeNode nodeLeft = new TreeNode(2, leaf1, leaf2);
|
||||||
|
|
||||||
|
TreeNode root = new TreeNode(4, nodeLeft, nodeRight);
|
||||||
|
|
||||||
|
return root;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@ -6,6 +6,12 @@
|
|||||||
<version>0.0.1</version>
|
<version>0.0.1</version>
|
||||||
<name>apache-meecrowave</name>
|
<name>apache-meecrowave</name>
|
||||||
<description>A sample REST API application with Meecrowave</description>
|
<description>A sample REST API application with Meecrowave</description>
|
||||||
|
|
||||||
|
<parent>
|
||||||
|
<groupId>com.baeldung</groupId>
|
||||||
|
<artifactId>parent-modules</artifactId>
|
||||||
|
<version>1.0.0-SNAPSHOT</version>
|
||||||
|
</parent>
|
||||||
|
|
||||||
<dependencies>
|
<dependencies>
|
||||||
<!-- https://mvnrepository.com/artifact/org.apache.meecrowave/meecrowave-core -->
|
<!-- https://mvnrepository.com/artifact/org.apache.meecrowave/meecrowave-core -->
|
||||||
|
@ -17,7 +17,7 @@ import okhttp3.Request;
|
|||||||
import okhttp3.Response;
|
import okhttp3.Response;
|
||||||
|
|
||||||
@RunWith(MonoMeecrowave.Runner.class)
|
@RunWith(MonoMeecrowave.Runner.class)
|
||||||
public class ArticleEndpointsTest {
|
public class ArticleEndpointsUnitTest {
|
||||||
|
|
||||||
@ConfigurationInject
|
@ConfigurationInject
|
||||||
private Meecrowave.Builder config;
|
private Meecrowave.Builder config;
|
@ -14,6 +14,14 @@
|
|||||||
<version>1.0.0-SNAPSHOT</version>
|
<version>1.0.0-SNAPSHOT</version>
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
|
<dependencies>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.google.guava</groupId>
|
||||||
|
<artifactId>guava</artifactId>
|
||||||
|
<version>${guava.version}</version>
|
||||||
|
</dependency>
|
||||||
|
</dependencies>
|
||||||
|
|
||||||
<build>
|
<build>
|
||||||
<plugins>
|
<plugins>
|
||||||
<plugin>
|
<plugin>
|
||||||
@ -31,6 +39,7 @@
|
|||||||
<properties>
|
<properties>
|
||||||
<maven.compiler.source.version>11</maven.compiler.source.version>
|
<maven.compiler.source.version>11</maven.compiler.source.version>
|
||||||
<maven.compiler.target.version>11</maven.compiler.target.version>
|
<maven.compiler.target.version>11</maven.compiler.target.version>
|
||||||
|
<guava.version>27.1-jre</guava.version>
|
||||||
</properties>
|
</properties>
|
||||||
|
|
||||||
</project>
|
</project>
|
||||||
|
@ -0,0 +1,32 @@
|
|||||||
|
package com.baeldung;
|
||||||
|
|
||||||
|
import com.google.common.base.Strings;
|
||||||
|
import org.junit.Assert;
|
||||||
|
import org.junit.Test;
|
||||||
|
|
||||||
|
import java.util.Optional;
|
||||||
|
import java.util.function.Predicate;
|
||||||
|
|
||||||
|
public class EmptyStringToEmptyOptionalUnitTest {
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void givenEmptyString_whenFilteringOnOptional_thenEmptyOptionalIsReturned() {
|
||||||
|
String str = "";
|
||||||
|
Optional<String> opt = Optional.ofNullable(str).filter(s -> !s.isEmpty());
|
||||||
|
Assert.assertFalse(opt.isPresent());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void givenEmptyString_whenFilteringOnOptionalInJava11_thenEmptyOptionalIsReturned() {
|
||||||
|
String str = "";
|
||||||
|
Optional<String> opt = Optional.ofNullable(str).filter(Predicate.not(String::isEmpty));
|
||||||
|
Assert.assertFalse(opt.isPresent());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void givenEmptyString_whenPassingResultOfEmptyToNullToOfNullable_thenEmptyOptionalIsReturned() {
|
||||||
|
String str = "";
|
||||||
|
Optional<String> opt = Optional.ofNullable(Strings.emptyToNull(str));
|
||||||
|
Assert.assertFalse(opt.isPresent());
|
||||||
|
}
|
||||||
|
}
|
@ -34,6 +34,7 @@
|
|||||||
<configuration>
|
<configuration>
|
||||||
<source>${maven.compiler.source.version}</source>
|
<source>${maven.compiler.source.version}</source>
|
||||||
<target>${maven.compiler.target.version}</target>
|
<target>${maven.compiler.target.version}</target>
|
||||||
|
<compilerArgs>--enable-preview</compilerArgs>
|
||||||
</configuration>
|
</configuration>
|
||||||
</plugin>
|
</plugin>
|
||||||
</plugins>
|
</plugins>
|
||||||
|
@ -0,0 +1,37 @@
|
|||||||
|
package com.baeldung.switchExpression;
|
||||||
|
|
||||||
|
import org.junit.Assert;
|
||||||
|
import org.junit.Test;
|
||||||
|
|
||||||
|
public class SwitchUnitTest {
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void switchJava12(){
|
||||||
|
|
||||||
|
var month = Month.AUG;
|
||||||
|
|
||||||
|
var value = switch(month){
|
||||||
|
case JAN,JUN, JUL -> 3;
|
||||||
|
case FEB,SEP, OCT, NOV, DEC -> 1;
|
||||||
|
case MAR,MAY, APR, AUG -> 2;
|
||||||
|
};
|
||||||
|
|
||||||
|
Assert.assertEquals(value, 2);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void switchLocalVariable(){
|
||||||
|
var month = Month.AUG;
|
||||||
|
int i = switch (month){
|
||||||
|
case JAN,JUN, JUL -> 3;
|
||||||
|
case FEB,SEP, OCT, NOV, DEC -> 1;
|
||||||
|
case MAR,MAY, APR, AUG -> {
|
||||||
|
int j = month.toString().length() * 4;
|
||||||
|
break j;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
Assert.assertEquals(12, i);
|
||||||
|
}
|
||||||
|
|
||||||
|
enum Month {JAN, FEB, MAR, APR, MAY, JUN, JUL, AUG, SEP, OCT, NOV, DEC}
|
||||||
|
}
|
4
core-java-lang-oop-2/.gitignore
vendored
Normal file
4
core-java-lang-oop-2/.gitignore
vendored
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
target/
|
||||||
|
.idea/
|
||||||
|
bin/
|
||||||
|
*.iml
|
5
core-java-lang-oop-2/README.md
Normal file
5
core-java-lang-oop-2/README.md
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
=========
|
||||||
|
|
||||||
|
## Core Java Lang OOP 2 Cookbooks and Examples
|
||||||
|
|
||||||
|
### Relevant Articles:
|
27
core-java-lang-oop-2/pom.xml
Normal file
27
core-java-lang-oop-2/pom.xml
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
<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>core-java-lang-oop-2</artifactId>
|
||||||
|
<version>0.1.0-SNAPSHOT</version>
|
||||||
|
<name>core-java-lang-oop-2</name>
|
||||||
|
<packaging>jar</packaging>
|
||||||
|
|
||||||
|
<parent>
|
||||||
|
<groupId>com.baeldung</groupId>
|
||||||
|
<artifactId>parent-java</artifactId>
|
||||||
|
<version>0.0.1-SNAPSHOT</version>
|
||||||
|
<relativePath>../parent-java</relativePath>
|
||||||
|
</parent>
|
||||||
|
|
||||||
|
<build>
|
||||||
|
<finalName>core-java-lang-oop-2</finalName>
|
||||||
|
<resources>
|
||||||
|
<resource>
|
||||||
|
<directory>src/main/resources</directory>
|
||||||
|
<filtering>true</filtering>
|
||||||
|
</resource>
|
||||||
|
</resources>
|
||||||
|
</build>
|
||||||
|
|
||||||
|
</project>
|
@ -0,0 +1,16 @@
|
|||||||
|
package com.baeldung.supertypecompilerexception;
|
||||||
|
|
||||||
|
public class MyClass {
|
||||||
|
|
||||||
|
private int myField1 = 10;
|
||||||
|
private int myField2;
|
||||||
|
|
||||||
|
public MyClass() {
|
||||||
|
//uncomment this to see the supertype compiler error:
|
||||||
|
//this(myField1);
|
||||||
|
}
|
||||||
|
|
||||||
|
public MyClass(int i) {
|
||||||
|
myField2 = i;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,15 @@
|
|||||||
|
package com.baeldung.supertypecompilerexception;
|
||||||
|
|
||||||
|
public class MyClassSolution1 {
|
||||||
|
|
||||||
|
private int myField1 = 10;
|
||||||
|
private int myField2;
|
||||||
|
|
||||||
|
public MyClassSolution1() {
|
||||||
|
myField2 = myField1;
|
||||||
|
}
|
||||||
|
|
||||||
|
public MyClassSolution1(int i) {
|
||||||
|
myField2 = i;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,19 @@
|
|||||||
|
package com.baeldung.supertypecompilerexception;
|
||||||
|
|
||||||
|
public class MyClassSolution2 {
|
||||||
|
|
||||||
|
private int myField1 = 10;
|
||||||
|
private int myField2;
|
||||||
|
|
||||||
|
public MyClassSolution2() {
|
||||||
|
setupMyFields(myField1);
|
||||||
|
}
|
||||||
|
|
||||||
|
public MyClassSolution2(int i) {
|
||||||
|
setupMyFields(i);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void setupMyFields(int i) {
|
||||||
|
myField2 = i;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,15 @@
|
|||||||
|
package com.baeldung.supertypecompilerexception;
|
||||||
|
|
||||||
|
public class MyClassSolution3 {
|
||||||
|
|
||||||
|
private static final int SOME_CONSTANT = 10;
|
||||||
|
private int myField2;
|
||||||
|
|
||||||
|
public MyClassSolution3() {
|
||||||
|
this(SOME_CONSTANT);
|
||||||
|
}
|
||||||
|
|
||||||
|
public MyClassSolution3(int i) {
|
||||||
|
myField2 = i;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,14 @@
|
|||||||
|
package com.baeldung.supertypecompilerexception;
|
||||||
|
|
||||||
|
public class MyException extends RuntimeException {
|
||||||
|
private int errorCode = 0;
|
||||||
|
|
||||||
|
public MyException(String message) {
|
||||||
|
//uncomment this to see the supertype compiler error:
|
||||||
|
//super(message + getErrorCode());
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getErrorCode() {
|
||||||
|
return errorCode;
|
||||||
|
}
|
||||||
|
}
|
43
libraries2/pom.xml
Normal file
43
libraries2/pom.xml
Normal file
@ -0,0 +1,43 @@
|
|||||||
|
<?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>libraries2</artifactId>
|
||||||
|
<name>libraries2</name>
|
||||||
|
|
||||||
|
<parent>
|
||||||
|
<groupId>com.baeldung</groupId>
|
||||||
|
<artifactId>parent-modules</artifactId>
|
||||||
|
<version>1.0.0-SNAPSHOT</version>
|
||||||
|
</parent>
|
||||||
|
|
||||||
|
<properties>
|
||||||
|
<jbpm.version>6.0.0.Final</jbpm.version>
|
||||||
|
</properties>
|
||||||
|
|
||||||
|
<repositories>
|
||||||
|
<repository>
|
||||||
|
<id>jboss-public-repository-group</id>
|
||||||
|
<name>JBoss Public Repository Group</name>
|
||||||
|
<url>http://repository.jboss.org/nexus/content/groups/public/</url>
|
||||||
|
<releases>
|
||||||
|
<enabled>true</enabled>
|
||||||
|
<updatePolicy>never</updatePolicy>
|
||||||
|
</releases>
|
||||||
|
<snapshots>
|
||||||
|
<enabled>true</enabled>
|
||||||
|
<updatePolicy>daily</updatePolicy>
|
||||||
|
</snapshots>
|
||||||
|
</repository>
|
||||||
|
</repositories>
|
||||||
|
|
||||||
|
<dependencies>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.jbpm</groupId>
|
||||||
|
<artifactId>jbpm-test</artifactId>
|
||||||
|
<version>${jbpm.version}</version>
|
||||||
|
</dependency>
|
||||||
|
</dependencies>
|
||||||
|
</project>
|
@ -0,0 +1,19 @@
|
|||||||
|
package com.baeldung.jbpm;
|
||||||
|
|
||||||
|
import org.kie.api.runtime.manager.Context;
|
||||||
|
import org.kie.internal.runtime.manager.context.EmptyContext;
|
||||||
|
|
||||||
|
import com.baeldung.jbpm.engine.WorkflowEngine;
|
||||||
|
import com.baeldung.jbpm.engine.WorkflowEngineImpl;
|
||||||
|
|
||||||
|
public class WorkflowProcessMain {
|
||||||
|
|
||||||
|
public static void main(String[] args) {
|
||||||
|
WorkflowEngine workflowEngine = new WorkflowEngineImpl();
|
||||||
|
String processId = "com.baeldung.bpmn.helloworld";
|
||||||
|
String kbaseId = "kbase";
|
||||||
|
String persistenceUnit = "org.jbpm.persistence.jpa";
|
||||||
|
Context<String> initialContext = EmptyContext.get();
|
||||||
|
workflowEngine.runjBPMEngineForProcess(processId, initialContext, kbaseId, persistenceUnit);
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,10 @@
|
|||||||
|
package com.baeldung.jbpm.engine;
|
||||||
|
|
||||||
|
import org.kie.api.runtime.manager.Context;
|
||||||
|
import org.kie.api.runtime.process.ProcessInstance;
|
||||||
|
|
||||||
|
public interface WorkflowEngine {
|
||||||
|
|
||||||
|
public ProcessInstance runjBPMEngineForProcess(String processId, Context<String> initialContext, String kbaseId, String persistenceUnit);
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,66 @@
|
|||||||
|
package com.baeldung.jbpm.engine;
|
||||||
|
|
||||||
|
import javax.persistence.EntityManagerFactory;
|
||||||
|
import javax.persistence.Persistence;
|
||||||
|
|
||||||
|
import org.jbpm.test.JBPMHelper;
|
||||||
|
import org.kie.api.KieBase;
|
||||||
|
import org.kie.api.KieServices;
|
||||||
|
import org.kie.api.runtime.KieContainer;
|
||||||
|
import org.kie.api.runtime.KieSession;
|
||||||
|
import org.kie.api.runtime.manager.Context;
|
||||||
|
import org.kie.api.runtime.manager.RuntimeEngine;
|
||||||
|
import org.kie.api.runtime.manager.RuntimeEnvironment;
|
||||||
|
import org.kie.api.runtime.manager.RuntimeEnvironmentBuilder;
|
||||||
|
import org.kie.api.runtime.manager.RuntimeManager;
|
||||||
|
import org.kie.api.runtime.manager.RuntimeManagerFactory;
|
||||||
|
import org.kie.api.runtime.process.ProcessInstance;
|
||||||
|
|
||||||
|
public class WorkflowEngineImpl implements WorkflowEngine {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ProcessInstance runjBPMEngineForProcess(String processId, Context<String> initialContext, String kbaseId, String persistenceUnit) {
|
||||||
|
RuntimeManager manager = null;
|
||||||
|
RuntimeEngine engine = null;
|
||||||
|
ProcessInstance pInstance = null;
|
||||||
|
try {
|
||||||
|
KieBase kbase = getKieBase(kbaseId);
|
||||||
|
manager = createJBPMRuntimeManager(kbase, persistenceUnit);
|
||||||
|
engine = manager.getRuntimeEngine(initialContext);
|
||||||
|
pInstance = executeProcessInstance(processId, manager, initialContext, engine);
|
||||||
|
} catch (Exception ex) {
|
||||||
|
ex.printStackTrace();
|
||||||
|
} finally {
|
||||||
|
if (manager != null && engine != null)
|
||||||
|
manager.disposeRuntimeEngine(engine);
|
||||||
|
System.exit(0);
|
||||||
|
}
|
||||||
|
return pInstance;
|
||||||
|
}
|
||||||
|
|
||||||
|
private ProcessInstance executeProcessInstance(String processId, RuntimeManager manager, Context<String> initialContext, RuntimeEngine engine) {
|
||||||
|
KieSession ksession = engine.getKieSession();
|
||||||
|
ProcessInstance pInstance = ksession.startProcess(processId);
|
||||||
|
return pInstance;
|
||||||
|
}
|
||||||
|
|
||||||
|
private KieBase getKieBase(String kbaseId) {
|
||||||
|
KieServices ks = KieServices.Factory.get();
|
||||||
|
KieContainer kContainer = ks.getKieClasspathContainer();
|
||||||
|
KieBase kbase = kContainer.getKieBase(kbaseId);
|
||||||
|
return kbase;
|
||||||
|
}
|
||||||
|
|
||||||
|
private RuntimeManager createJBPMRuntimeManager(KieBase kbase, String persistenceUnit) {
|
||||||
|
JBPMHelper.startH2Server();
|
||||||
|
JBPMHelper.setupDataSource();
|
||||||
|
EntityManagerFactory emf = Persistence.createEntityManagerFactory(persistenceUnit);
|
||||||
|
RuntimeEnvironmentBuilder runtimeEnvironmentBuilder = RuntimeEnvironmentBuilder.Factory.get()
|
||||||
|
.newDefaultBuilder();
|
||||||
|
RuntimeEnvironment runtimeEnvironment = runtimeEnvironmentBuilder.entityManagerFactory(emf)
|
||||||
|
.knowledgeBase(kbase)
|
||||||
|
.get();
|
||||||
|
return RuntimeManagerFactory.Factory.get()
|
||||||
|
.newSingletonRuntimeManager(runtimeEnvironment);
|
||||||
|
}
|
||||||
|
}
|
3
libraries2/src/main/resources/META-INF/kmodule.xml
Normal file
3
libraries2/src/main/resources/META-INF/kmodule.xml
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
<kmodule xmlns="http://jboss.org/kie/6.0.0/kmodule">
|
||||||
|
<kbase name="kbase" packages="com.baeldung.process" />
|
||||||
|
</kmodule>
|
@ -0,0 +1,54 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<definitions id="Definition"
|
||||||
|
targetNamespace="http://www.jboss.org/drools"
|
||||||
|
typeLanguage="http://www.java.com/javaTypes"
|
||||||
|
expressionLanguage="http://www.mvel.org/2.0"
|
||||||
|
xmlns="http://www.omg.org/spec/BPMN/20100524/MODEL"
|
||||||
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
|
xsi:schemaLocation="http://www.omg.org/spec/BPMN/20100524/MODEL BPMN20.xsd"
|
||||||
|
xmlns:g="http://www.jboss.org/drools/flow/gpd"
|
||||||
|
xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI"
|
||||||
|
xmlns:dc="http://www.omg.org/spec/DD/20100524/DC"
|
||||||
|
xmlns:di="http://www.omg.org/spec/DD/20100524/DI"
|
||||||
|
xmlns:tns="http://www.jboss.org/drools">
|
||||||
|
|
||||||
|
<process processType="Private" isExecutable="true" id="com.baeldung.bpmn.helloworld" name="HelloWorld Process" tns:packageName="com.baeldung.bpmn.process" >
|
||||||
|
|
||||||
|
<!-- nodes -->
|
||||||
|
<scriptTask id="_jbpm-unique-1" name="HelloWorld" scriptFormat="http://www.java.com/java" >
|
||||||
|
<script>System.out.println("Hello World");</script>
|
||||||
|
</scriptTask>
|
||||||
|
<endEvent id="_jbpm-unique-2" name="End" >
|
||||||
|
<terminateEventDefinition />
|
||||||
|
</endEvent>
|
||||||
|
<startEvent id="_jbpm-unique-0" name="Start" isInterrupting="false"/>
|
||||||
|
|
||||||
|
<!-- connections -->
|
||||||
|
<sequenceFlow id="_jbpm-unique-0-_jbpm-unique-1" sourceRef="_jbpm-unique-0" targetRef="_jbpm-unique-1" />
|
||||||
|
<sequenceFlow id="_jbpm-unique-1-_jbpm-unique-2" sourceRef="_jbpm-unique-1" targetRef="_jbpm-unique-2" />
|
||||||
|
|
||||||
|
</process>
|
||||||
|
|
||||||
|
<bpmndi:BPMNDiagram>
|
||||||
|
<bpmndi:BPMNPlane bpmnElement="com.baeldung.bpmn.helloworld" >
|
||||||
|
<bpmndi:BPMNShape bpmnElement="_jbpm-unique-1" >
|
||||||
|
<dc:Bounds x="119" y="44" width="111" height="48" />
|
||||||
|
</bpmndi:BPMNShape>
|
||||||
|
<bpmndi:BPMNShape bpmnElement="_jbpm-unique-2" >
|
||||||
|
<dc:Bounds x="272" y="43" width="48" height="48" />
|
||||||
|
</bpmndi:BPMNShape>
|
||||||
|
<bpmndi:BPMNShape bpmnElement="_jbpm-unique-0" >
|
||||||
|
<dc:Bounds x="28" y="44" width="48" height="48" />
|
||||||
|
</bpmndi:BPMNShape>
|
||||||
|
<bpmndi:BPMNEdge bpmnElement="_jbpm-unique-0-_jbpm-unique-1" >
|
||||||
|
<di:waypoint x="52" y="68" />
|
||||||
|
<di:waypoint x="174" y="68" />
|
||||||
|
</bpmndi:BPMNEdge>
|
||||||
|
<bpmndi:BPMNEdge bpmnElement="_jbpm-unique-1-_jbpm-unique-2" >
|
||||||
|
<di:waypoint x="174" y="68" />
|
||||||
|
<di:waypoint x="296" y="67" />
|
||||||
|
</bpmndi:BPMNEdge>
|
||||||
|
</bpmndi:BPMNPlane>
|
||||||
|
</bpmndi:BPMNDiagram>
|
||||||
|
|
||||||
|
</definitions>
|
@ -0,0 +1,52 @@
|
|||||||
|
package com.baeldung.jbpm;
|
||||||
|
|
||||||
|
import org.jbpm.test.JbpmJUnitBaseTestCase;
|
||||||
|
import org.junit.After;
|
||||||
|
import org.junit.Before;
|
||||||
|
import org.junit.Test;
|
||||||
|
import org.kie.api.runtime.KieSession;
|
||||||
|
import org.kie.api.runtime.manager.RuntimeEngine;
|
||||||
|
import org.kie.api.runtime.manager.RuntimeManager;
|
||||||
|
import org.kie.api.runtime.process.ProcessInstance;
|
||||||
|
import org.kie.internal.runtime.manager.context.ProcessInstanceIdContext;
|
||||||
|
|
||||||
|
public class WorkflowEngineIntegrationTest extends JbpmJUnitBaseTestCase {
|
||||||
|
|
||||||
|
private String[] triggeredNodesArray = { "Start", "HelloWorld", "End" };
|
||||||
|
private RuntimeManager manager = null;
|
||||||
|
private RuntimeEngine runtimeEngine = null;
|
||||||
|
private KieSession ksession = null;
|
||||||
|
private ProcessInstance processInstance = null;
|
||||||
|
|
||||||
|
@Before
|
||||||
|
public void setup() {
|
||||||
|
manager = createRuntimeManager(Strategy.SINGLETON, "manager", "com/baeldung/process/helloworld.bpmn");
|
||||||
|
runtimeEngine = getRuntimeEngine(ProcessInstanceIdContext.get());
|
||||||
|
ksession = runtimeEngine.getKieSession();
|
||||||
|
processInstance = ksession.startProcess("com.baeldung.bpmn.helloworld");
|
||||||
|
}
|
||||||
|
|
||||||
|
@After
|
||||||
|
public void cleanup() {
|
||||||
|
manager.disposeRuntimeEngine(runtimeEngine);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void givenProcessInstance_whenExecutionCompleted_thenVerifyNodesExecutionOrder() {
|
||||||
|
assertNodeTriggered(processInstance.getId(), triggeredNodesArray);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void givenProcessInstance_whenExecutionCompleted_thenVerifyKnowledgeSessionId() {
|
||||||
|
int ksessionID = ksession.getId();
|
||||||
|
runtimeEngine = getRuntimeEngine(ProcessInstanceIdContext.get(processInstance.getId()));
|
||||||
|
ksession = runtimeEngine.getKieSession();
|
||||||
|
assertEquals(ksessionID, ksession.getId());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void givenProcessInstance_whenExecutionCompleted_thenVerifyProcessInstanceStatus() {
|
||||||
|
assertProcessInstanceCompleted(processInstance.getId(), ksession);
|
||||||
|
assertTrue("ProcessInstance completed with status 2", processInstance.getState() == 2);
|
||||||
|
}
|
||||||
|
}
|
@ -37,12 +37,29 @@
|
|||||||
<artifactId>jackson-databind</artifactId>
|
<artifactId>jackson-databind</artifactId>
|
||||||
<version>${jackson.version}</version>
|
<version>${jackson.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.docx4j</groupId>
|
||||||
|
<artifactId>docx4j</artifactId>
|
||||||
|
<version>${docx4j.version}</version>
|
||||||
|
<exclusions>
|
||||||
|
<exclusion>
|
||||||
|
<groupId>org.slf4j</groupId>
|
||||||
|
<artifactId>slf4j-log4j12</artifactId>
|
||||||
|
</exclusion>
|
||||||
|
<exclusion>
|
||||||
|
<groupId>log4j</groupId>
|
||||||
|
<artifactId>log4j</artifactId>
|
||||||
|
</exclusion>
|
||||||
|
</exclusions>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
<properties>
|
<properties>
|
||||||
<logback.version>1.2.3</logback.version>
|
<logback.version>1.2.3</logback.version>
|
||||||
<logback.contrib.version>0.1.5</logback.contrib.version>
|
<logback.contrib.version>0.1.5</logback.contrib.version>
|
||||||
<jackson.version>2.9.7</jackson.version>
|
<jackson.version>2.9.7</jackson.version>
|
||||||
|
<docx4j.version>3.3.5</docx4j.version>
|
||||||
</properties>
|
</properties>
|
||||||
|
|
||||||
</project>
|
</project>
|
||||||
|
@ -1,27 +0,0 @@
|
|||||||
<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>
|
|
||||||
<groupId>com.baeldung</groupId>
|
|
||||||
<artifactId>noexception</artifactId>
|
|
||||||
<version>1.0</version>
|
|
||||||
<name>noexception</name>
|
|
||||||
|
|
||||||
<parent>
|
|
||||||
<groupId>com.baeldung</groupId>
|
|
||||||
<artifactId>parent-modules</artifactId>
|
|
||||||
<version>1.0.0-SNAPSHOT</version>
|
|
||||||
</parent>
|
|
||||||
|
|
||||||
<dependencies>
|
|
||||||
<dependency>
|
|
||||||
<groupId>com.machinezoo.noexception</groupId>
|
|
||||||
<artifactId>noexception</artifactId>
|
|
||||||
<version>${noexception.version}</version>
|
|
||||||
</dependency>
|
|
||||||
</dependencies>
|
|
||||||
|
|
||||||
<properties>
|
|
||||||
<noexception.version>1.1.0</noexception.version>
|
|
||||||
</properties>
|
|
||||||
|
|
||||||
</project>
|
|
@ -1,24 +0,0 @@
|
|||||||
package com.baeldung.noexception;
|
|
||||||
|
|
||||||
import com.machinezoo.noexception.ExceptionHandler;
|
|
||||||
import org.slf4j.Logger;
|
|
||||||
import org.slf4j.LoggerFactory;
|
|
||||||
|
|
||||||
public class CustomExceptionHandler extends ExceptionHandler {
|
|
||||||
|
|
||||||
private Logger logger = LoggerFactory.getLogger(CustomExceptionHandler.class);
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean handle(Throwable throwable) {
|
|
||||||
|
|
||||||
if (throwable.getClass()
|
|
||||||
.isAssignableFrom(RuntimeException.class)
|
|
||||||
|| throwable.getClass()
|
|
||||||
.isAssignableFrom(Error.class)) {
|
|
||||||
return false;
|
|
||||||
} else {
|
|
||||||
logger.error("Caught Exception ", throwable);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,13 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<configuration>
|
|
||||||
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
|
|
||||||
<encoder>
|
|
||||||
<pattern>%d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n
|
|
||||||
</pattern>
|
|
||||||
</encoder>
|
|
||||||
</appender>
|
|
||||||
|
|
||||||
<root level="INFO">
|
|
||||||
<appender-ref ref="STDOUT" />
|
|
||||||
</root>
|
|
||||||
</configuration>
|
|
@ -1,63 +0,0 @@
|
|||||||
package com.baeldung.noexception;
|
|
||||||
|
|
||||||
import com.machinezoo.noexception.Exceptions;
|
|
||||||
import org.junit.Test;
|
|
||||||
import org.slf4j.Logger;
|
|
||||||
import org.slf4j.LoggerFactory;
|
|
||||||
|
|
||||||
public class NoExceptionUnitTest {
|
|
||||||
|
|
||||||
private static Logger logger = LoggerFactory.getLogger(NoExceptionUnitTest.class);
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void whenStdExceptionHandling_thenCatchAndLog() {
|
|
||||||
try {
|
|
||||||
System.out.println("Result is " + Integer.parseInt("foobar"));
|
|
||||||
} catch (Throwable exception) {
|
|
||||||
logger.error("Caught exception:", exception);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void whenDefaultNoException_thenCatchAndLog() {
|
|
||||||
|
|
||||||
Exceptions.log().run(() -> System.out.println("Result is " + Integer.parseInt("foobar")));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void givenLogger_whenDefaultNoException_thenCatchAndLogWithClassName() {
|
|
||||||
System.out.println("Result is " + Exceptions.log(logger).get(() -> +Integer.parseInt("foobar")).orElse(-1));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void givenLoggerAndMessage_whenDefaultNoException_thenCatchAndLogWithClassNameAndMessage() {
|
|
||||||
System.out.println("Result is " + Exceptions.log(logger, "Something went wrong:").get(() -> +Integer.parseInt("foobar")).orElse(-1));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void givenDefaultValue_whenDefaultNoException_thenCatchAndLogPrintDefault() {
|
|
||||||
System.out.println("Result is " + Exceptions.log(logger, "Something went wrong:").get(() -> +Integer.parseInt("foobar")).orElse(-1));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test(expected = Error.class)
|
|
||||||
public void givenCustomHandler_whenError_thenRethrowError() {
|
|
||||||
CustomExceptionHandler customExceptionHandler = new CustomExceptionHandler();
|
|
||||||
customExceptionHandler.run(() -> throwError());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void givenCustomHandler_whenException_thenCatchAndLog() {
|
|
||||||
CustomExceptionHandler customExceptionHandler = new CustomExceptionHandler();
|
|
||||||
customExceptionHandler.run(() -> throwException());
|
|
||||||
}
|
|
||||||
|
|
||||||
private static void throwError() {
|
|
||||||
throw new Error("This is very bad.");
|
|
||||||
}
|
|
||||||
|
|
||||||
private static void throwException() {
|
|
||||||
String testString = "foo";
|
|
||||||
testString.charAt(5);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -8,11 +8,7 @@ public class UsingOptional {
|
|||||||
|
|
||||||
String response = doSomething(processed);
|
String response = doSomething(processed);
|
||||||
|
|
||||||
if (response == null) {
|
return Optional.ofNullable(response);
|
||||||
return Optional.empty();
|
|
||||||
}
|
|
||||||
|
|
||||||
return Optional.of(response);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private String doSomething(boolean processed) {
|
private String doSomething(boolean processed) {
|
||||||
|
@ -18,36 +18,36 @@
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.jnosql.diana</groupId>
|
<groupId>org.jnosql.diana</groupId>
|
||||||
<artifactId>diana-document</artifactId>
|
<artifactId>diana-document</artifactId>
|
||||||
<version>0.0.5</version>
|
<version>${jnosql.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.jnosql.diana</groupId>
|
<groupId>org.jnosql.diana</groupId>
|
||||||
<artifactId>mongodb-driver</artifactId>
|
<artifactId>mongodb-driver</artifactId>
|
||||||
<version>0.0.5</version>
|
<version>${jnosql.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<!--NoSQL Column oriented-->
|
<!--NoSQL Column oriented-->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.jnosql.diana</groupId>
|
<groupId>org.jnosql.diana</groupId>
|
||||||
<artifactId>diana-column</artifactId>
|
<artifactId>diana-column</artifactId>
|
||||||
<version>0.0.5</version>
|
<version>${jnosql.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.jnosql.diana</groupId>
|
<groupId>org.jnosql.diana</groupId>
|
||||||
<artifactId>cassandra-driver</artifactId>
|
<artifactId>cassandra-driver</artifactId>
|
||||||
<version>0.0.5</version>
|
<version>${jnosql.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<!--NoSQL Key Value oriented-->
|
<!--NoSQL Key Value oriented-->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.jnosql.diana</groupId>
|
<groupId>org.jnosql.diana</groupId>
|
||||||
<artifactId>diana-key-value</artifactId>
|
<artifactId>diana-key-value</artifactId>
|
||||||
<version>0.0.5</version>
|
<version>${jnosql.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.jnosql.diana</groupId>
|
<groupId>org.jnosql.diana</groupId>
|
||||||
<artifactId>hazelcast-driver</artifactId>
|
<artifactId>hazelcast-driver</artifactId>
|
||||||
<version>0.0.5</version>
|
<version>${jnosql.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
|
@ -21,7 +21,7 @@
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.springframework.data</groupId>
|
<groupId>org.springframework.data</groupId>
|
||||||
<artifactId>spring-data-cassandra</artifactId>
|
<artifactId>spring-data-cassandra</artifactId>
|
||||||
<version>2.1.2.RELEASE</version>
|
<version>${spring-data-cassandra.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>io.projectreactor</groupId>
|
<groupId>io.projectreactor</groupId>
|
||||||
@ -53,6 +53,7 @@
|
|||||||
<project.reporting.outputEncoding>UTF-8
|
<project.reporting.outputEncoding>UTF-8
|
||||||
</project.reporting.outputEncoding>
|
</project.reporting.outputEncoding>
|
||||||
<java.version>1.8</java.version>
|
<java.version>1.8</java.version>
|
||||||
|
<spring-data-cassandra.version>2.1.2.RELEASE</spring-data-cassandra.version>
|
||||||
</properties>
|
</properties>
|
||||||
|
|
||||||
</project>
|
</project>
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
package com.baeldung.domain;
|
package com.baeldung.entity;
|
||||||
|
|
||||||
import javax.persistence.Entity;
|
import javax.persistence.Entity;
|
||||||
import javax.persistence.Id;
|
import javax.persistence.Id;
|
@ -0,0 +1,78 @@
|
|||||||
|
package com.baeldung.entity;
|
||||||
|
|
||||||
|
import javax.persistence.Basic;
|
||||||
|
import javax.persistence.Column;
|
||||||
|
import javax.persistence.Entity;
|
||||||
|
import javax.persistence.GeneratedValue;
|
||||||
|
import javax.persistence.Id;
|
||||||
|
import java.util.Objects;
|
||||||
|
|
||||||
|
@Entity
|
||||||
|
public class Passenger {
|
||||||
|
|
||||||
|
@Id
|
||||||
|
@GeneratedValue
|
||||||
|
@Column(nullable = false)
|
||||||
|
private Long id;
|
||||||
|
|
||||||
|
@Basic(optional = false)
|
||||||
|
@Column(nullable = false)
|
||||||
|
private String firstName;
|
||||||
|
|
||||||
|
@Basic(optional = false)
|
||||||
|
@Column(nullable = false)
|
||||||
|
private String lastName;
|
||||||
|
|
||||||
|
private Passenger(String firstName, String lastName) {
|
||||||
|
this.firstName = firstName;
|
||||||
|
this.lastName = lastName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Passenger from(String firstName, String lastName) {
|
||||||
|
return new Passenger(firstName, lastName);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Long getId() {
|
||||||
|
return id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setId(Long id) {
|
||||||
|
this.id = id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getFirstName() {
|
||||||
|
return firstName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setFirstName(String firstName) {
|
||||||
|
this.firstName = firstName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getLastName() {
|
||||||
|
return lastName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setLastName(String lastName) {
|
||||||
|
this.lastName = lastName;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return "Passenger{" + "id=" + id + ", firstName='" + firstName + '\'' + ", lastName='" + lastName + '\'' + '}';
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean equals(Object o) {
|
||||||
|
if (this == o)
|
||||||
|
return true;
|
||||||
|
if (o == null || getClass() != o.getClass())
|
||||||
|
return false;
|
||||||
|
Passenger passenger = (Passenger) o;
|
||||||
|
return Objects.equals(firstName, passenger.firstName) && Objects.equals(lastName, passenger.lastName);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int hashCode() {
|
||||||
|
return Objects.hash(firstName, lastName);
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,48 @@
|
|||||||
|
package com.baeldung.exists;
|
||||||
|
|
||||||
|
import javax.persistence.Entity;
|
||||||
|
import javax.persistence.GeneratedValue;
|
||||||
|
import javax.persistence.Id;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author paullatzelsperger
|
||||||
|
* @since 2019-03-20
|
||||||
|
*/
|
||||||
|
@Entity
|
||||||
|
public class Car {
|
||||||
|
|
||||||
|
@Id
|
||||||
|
@GeneratedValue
|
||||||
|
private int id;
|
||||||
|
private Integer power;
|
||||||
|
private String model;
|
||||||
|
|
||||||
|
Car() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public Car(int power, String model) {
|
||||||
|
this.power = power;
|
||||||
|
this.model = model;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Integer getPower() {
|
||||||
|
return power;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setPower(Integer power) {
|
||||||
|
this.power = power;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getModel() {
|
||||||
|
return model;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setModel(String model) {
|
||||||
|
this.model = model;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getId() {
|
||||||
|
return id;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,24 @@
|
|||||||
|
package com.baeldung.exists;
|
||||||
|
|
||||||
|
import org.springframework.data.jpa.repository.JpaRepository;
|
||||||
|
import org.springframework.data.jpa.repository.Query;
|
||||||
|
import org.springframework.data.repository.query.Param;
|
||||||
|
import org.springframework.stereotype.Repository;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author paullatzelsperger
|
||||||
|
* @since 2019-03-20
|
||||||
|
*/
|
||||||
|
@Repository
|
||||||
|
public interface CarRepository extends JpaRepository<Car, Integer> {
|
||||||
|
|
||||||
|
boolean existsCarByPower(int power);
|
||||||
|
|
||||||
|
boolean existsCarByModel(String model);
|
||||||
|
|
||||||
|
@Query("select case when count(c)> 0 then true else false end from Car c where c.model = :model")
|
||||||
|
boolean existsCarExactCustomQuery(@Param("model") String model);
|
||||||
|
|
||||||
|
@Query("select case when count(c)> 0 then true else false end from Car c where lower(c.model) like lower(:model)")
|
||||||
|
boolean existsCarLikeCustomQuery(@Param("model") String model);
|
||||||
|
}
|
@ -1,8 +1,8 @@
|
|||||||
package com.baeldung.dao.repositories;
|
package com.baeldung.repository;
|
||||||
|
|
||||||
import org.springframework.data.jpa.repository.JpaRepository;
|
import org.springframework.data.jpa.repository.JpaRepository;
|
||||||
|
|
||||||
import com.baeldung.domain.Employee;
|
import com.baeldung.entity.Employee;
|
||||||
|
|
||||||
public interface EmployeeRepository extends JpaRepository<Employee, Long> {
|
public interface EmployeeRepository extends JpaRepository<Employee, Long> {
|
||||||
|
|
@ -0,0 +1,14 @@
|
|||||||
|
package com.baeldung.repository;
|
||||||
|
|
||||||
|
import com.baeldung.entity.Passenger;
|
||||||
|
import org.springframework.data.jpa.repository.JpaRepository;
|
||||||
|
import org.springframework.stereotype.Repository;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@Repository
|
||||||
|
interface PassengerRepository extends JpaRepository<Passenger, Long> {
|
||||||
|
|
||||||
|
List<Passenger> findByFirstNameIgnoreCase(String firstName);
|
||||||
|
|
||||||
|
}
|
@ -1,8 +1,6 @@
|
|||||||
package com.baeldung.exists;
|
package com.baeldung.exists;
|
||||||
|
|
||||||
import static org.assertj.core.api.Assertions.assertThat;
|
import com.baeldung.Application;
|
||||||
import static org.springframework.data.domain.ExampleMatcher.GenericPropertyMatchers.ignoreCase;
|
|
||||||
|
|
||||||
import org.junit.After;
|
import org.junit.After;
|
||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
@ -13,13 +11,12 @@ import org.springframework.data.domain.Example;
|
|||||||
import org.springframework.data.domain.ExampleMatcher;
|
import org.springframework.data.domain.ExampleMatcher;
|
||||||
import org.springframework.test.context.junit4.SpringRunner;
|
import org.springframework.test.context.junit4.SpringRunner;
|
||||||
|
|
||||||
import com.baeldung.boot.Application;
|
|
||||||
import com.baeldung.boot.domain.Car;
|
|
||||||
import com.baeldung.boot.repository.CarRepository;
|
|
||||||
|
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
import static org.assertj.core.api.Assertions.assertThat;
|
||||||
|
import static org.springframework.data.domain.ExampleMatcher.GenericPropertyMatchers.ignoreCase;
|
||||||
|
|
||||||
@RunWith(SpringRunner.class)
|
@RunWith(SpringRunner.class)
|
||||||
@SpringBootTest(classes = {Application.class})
|
@SpringBootTest(classes = {Application.class})
|
||||||
public class CarRepositoryIntegrationTest {
|
public class CarRepositoryIntegrationTest {
|
@ -1,4 +1,4 @@
|
|||||||
package com.baeldung.dao.repositories;
|
package com.baeldung.repository;
|
||||||
|
|
||||||
import static org.assertj.core.api.AssertionsForClassTypes.assertThat;
|
import static org.assertj.core.api.AssertionsForClassTypes.assertThat;
|
||||||
|
|
||||||
@ -8,7 +8,7 @@ import org.springframework.beans.factory.annotation.Autowired;
|
|||||||
import org.springframework.boot.test.autoconfigure.orm.jpa.DataJpaTest;
|
import org.springframework.boot.test.autoconfigure.orm.jpa.DataJpaTest;
|
||||||
import org.springframework.test.context.junit4.SpringRunner;
|
import org.springframework.test.context.junit4.SpringRunner;
|
||||||
|
|
||||||
import com.baeldung.domain.Employee;
|
import com.baeldung.entity.Employee;
|
||||||
|
|
||||||
@RunWith(SpringRunner.class)
|
@RunWith(SpringRunner.class)
|
||||||
@DataJpaTest
|
@DataJpaTest
|
@ -0,0 +1,54 @@
|
|||||||
|
package com.baeldung.repository;
|
||||||
|
|
||||||
|
import com.baeldung.entity.Passenger;
|
||||||
|
import org.junit.Before;
|
||||||
|
import org.junit.Test;
|
||||||
|
import org.junit.runner.RunWith;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.boot.test.autoconfigure.orm.jpa.DataJpaTest;
|
||||||
|
import org.springframework.test.context.junit4.SpringRunner;
|
||||||
|
|
||||||
|
import javax.persistence.EntityManager;
|
||||||
|
import javax.persistence.PersistenceContext;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import static org.hamcrest.MatcherAssert.assertThat;
|
||||||
|
import static org.hamcrest.Matchers.contains;
|
||||||
|
import static org.hamcrest.core.IsNot.not;
|
||||||
|
|
||||||
|
@DataJpaTest
|
||||||
|
@RunWith(SpringRunner.class)
|
||||||
|
public class PassengerRepositoryIntegrationTest {
|
||||||
|
|
||||||
|
@PersistenceContext
|
||||||
|
private EntityManager entityManager;
|
||||||
|
@Autowired
|
||||||
|
private PassengerRepository repository;
|
||||||
|
|
||||||
|
@Before
|
||||||
|
public void before() {
|
||||||
|
entityManager.persist(Passenger.from("Jill", "Smith"));
|
||||||
|
entityManager.persist(Passenger.from("Eve", "Jackson"));
|
||||||
|
entityManager.persist(Passenger.from("Fred", "Bloggs"));
|
||||||
|
entityManager.persist(Passenger.from("Ricki", "Bobbie"));
|
||||||
|
entityManager.persist(Passenger.from("Siya", "Kolisi"));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void givenPassengers_whenMatchingIgnoreCase_thenExpectedReturned() {
|
||||||
|
Passenger jill = Passenger.from("Jill", "Smith");
|
||||||
|
Passenger eve = Passenger.from("Eve", "Jackson");
|
||||||
|
Passenger fred = Passenger.from("Fred", "Bloggs");
|
||||||
|
Passenger siya = Passenger.from("Siya", "Kolisi");
|
||||||
|
Passenger ricki = Passenger.from("Ricki", "Bobbie");
|
||||||
|
|
||||||
|
List<Passenger> passengers = repository.findByFirstNameIgnoreCase("FRED");
|
||||||
|
|
||||||
|
assertThat(passengers, contains(fred));
|
||||||
|
assertThat(passengers, not(contains(eve)));
|
||||||
|
assertThat(passengers, not(contains(siya)));
|
||||||
|
assertThat(passengers, not(contains(jill)));
|
||||||
|
assertThat(passengers, not(contains(ricki)));
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,37 @@
|
|||||||
|
package com.baeldung.customer;
|
||||||
|
|
||||||
|
import javax.persistence.Entity;
|
||||||
|
import javax.persistence.GeneratedValue;
|
||||||
|
import javax.persistence.Id;
|
||||||
|
|
||||||
|
@Entity
|
||||||
|
public class Customer {
|
||||||
|
|
||||||
|
@Id
|
||||||
|
@GeneratedValue
|
||||||
|
private long id;
|
||||||
|
private String name;
|
||||||
|
private String email;
|
||||||
|
|
||||||
|
public Customer(String name, String email) {
|
||||||
|
this.name = name;
|
||||||
|
this.email = email;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getName() {
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setName(String name) {
|
||||||
|
this.name = name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getEmail() {
|
||||||
|
return email;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setEmail(String email) {
|
||||||
|
this.email = email;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,18 @@
|
|||||||
|
package com.baeldung.customer;
|
||||||
|
|
||||||
|
import org.springframework.data.jpa.repository.JpaRepository;
|
||||||
|
import org.springframework.data.jpa.repository.Query;
|
||||||
|
import org.springframework.data.repository.query.Param;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public interface CustomerRepository extends JpaRepository<Customer, Long> {
|
||||||
|
|
||||||
|
List<Customer> findByName(String name);
|
||||||
|
|
||||||
|
List<Customer> findByNameAndEmail(String name, String email);
|
||||||
|
|
||||||
|
@Query("SELECT c FROM Customer c WHERE (:name is null or c.name = :name) and (:email is null or c.email = :email)")
|
||||||
|
List<Customer> findCustomerByNameAndEmail(@Param("name") String name, @Param("email") String email);
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,66 @@
|
|||||||
|
package com.baeldung.customer;
|
||||||
|
|
||||||
|
import com.baeldung.config.PersistenceConfiguration;
|
||||||
|
import com.baeldung.config.PersistenceProductConfiguration;
|
||||||
|
import com.baeldung.config.PersistenceUserConfiguration;
|
||||||
|
import org.junit.After;
|
||||||
|
import org.junit.Before;
|
||||||
|
import org.junit.Test;
|
||||||
|
import org.junit.runner.RunWith;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.boot.test.autoconfigure.orm.jpa.DataJpaTest;
|
||||||
|
import org.springframework.test.context.junit4.SpringRunner;
|
||||||
|
|
||||||
|
import javax.persistence.EntityManager;
|
||||||
|
import javax.persistence.PersistenceContext;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import static org.junit.Assert.assertEquals;
|
||||||
|
|
||||||
|
@DataJpaTest(excludeAutoConfiguration = { PersistenceConfiguration.class, PersistenceUserConfiguration.class, PersistenceProductConfiguration.class })
|
||||||
|
@RunWith(SpringRunner.class)
|
||||||
|
public class CustomerRepositoryIntegrationTest {
|
||||||
|
|
||||||
|
@PersistenceContext
|
||||||
|
private EntityManager entityManager;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private CustomerRepository repository;
|
||||||
|
|
||||||
|
@Before
|
||||||
|
public void before() {
|
||||||
|
entityManager.persist(new Customer("A", "A@example.com"));
|
||||||
|
entityManager.persist(new Customer("D", null));
|
||||||
|
entityManager.persist(new Customer("D", "D@example.com"));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void givenQueryMethod_whenEmailIsNull_thenFoundByNullEmail() {
|
||||||
|
List<Customer> customers = repository.findByNameAndEmail("D", null);
|
||||||
|
|
||||||
|
assertEquals(1, customers.size());
|
||||||
|
Customer actual = customers.get(0);
|
||||||
|
|
||||||
|
assertEquals(null, actual.getEmail());
|
||||||
|
assertEquals("D", actual.getName());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void givenQueryMethod_whenEmailIsAbsent_thenIgnoreEmail() {
|
||||||
|
List<Customer> customers = repository.findByName("D");
|
||||||
|
|
||||||
|
assertEquals(2, customers.size());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void givenQueryAnnotation_whenEmailIsNull_thenIgnoreEmail() {
|
||||||
|
List<Customer> customers = repository.findCustomerByNameAndEmail("D", null);
|
||||||
|
|
||||||
|
assertEquals(2, customers.size());
|
||||||
|
}
|
||||||
|
|
||||||
|
@After
|
||||||
|
public void cleanUp() {
|
||||||
|
repository.deleteAll();
|
||||||
|
}
|
||||||
|
}
|
19
pom.xml
19
pom.xml
@ -332,7 +332,7 @@
|
|||||||
<module>parent-spring-5</module>
|
<module>parent-spring-5</module>
|
||||||
<module>parent-java</module>
|
<module>parent-java</module>
|
||||||
<module>parent-kotlin</module>
|
<module>parent-kotlin</module>
|
||||||
|
<!-- <module>akka-http</module> --> <!-- Unit test is failing -->
|
||||||
<module>akka-streams</module>
|
<module>akka-streams</module>
|
||||||
<module>algorithms-genetic</module>
|
<module>algorithms-genetic</module>
|
||||||
<module>algorithms-miscellaneous-1</module>
|
<module>algorithms-miscellaneous-1</module>
|
||||||
@ -391,6 +391,7 @@
|
|||||||
<module>core-java-lang-syntax</module>
|
<module>core-java-lang-syntax</module>
|
||||||
<module>core-java-lang</module>
|
<module>core-java-lang</module>
|
||||||
<module>core-java-lang-oop</module>
|
<module>core-java-lang-oop</module>
|
||||||
|
<module>core-java-lang-oop-2</module>
|
||||||
<module>core-java-networking</module>
|
<module>core-java-networking</module>
|
||||||
<module>core-java-perf</module>
|
<module>core-java-perf</module>
|
||||||
<module>core-java-sun</module>
|
<module>core-java-sun</module>
|
||||||
@ -440,6 +441,7 @@
|
|||||||
<module>jackson-2</module>
|
<module>jackson-2</module>
|
||||||
<module>java-collections-conversions</module>
|
<module>java-collections-conversions</module>
|
||||||
<module>java-collections-maps</module>
|
<module>java-collections-maps</module>
|
||||||
|
<module>java-collections-maps-2</module>
|
||||||
<!-- <module>java-dates</module> --> <!-- We haven't upgraded to java 9. Fixing in BAEL-10841 -->
|
<!-- <module>java-dates</module> --> <!-- We haven't upgraded to java 9. Fixing in BAEL-10841 -->
|
||||||
<!-- <module>java-dates-2</module> --> <!-- We haven't upgraded to java 9. Fixing in BAEL-10841 -->
|
<!-- <module>java-dates-2</module> --> <!-- We haven't upgraded to java 9. Fixing in BAEL-10841 -->
|
||||||
<!-- <module>java-ee-8-security-api</module> --> <!-- long running -->
|
<!-- <module>java-ee-8-security-api</module> --> <!-- long running -->
|
||||||
@ -448,6 +450,7 @@
|
|||||||
<module>java-rmi</module>
|
<module>java-rmi</module>
|
||||||
<module>java-spi</module>
|
<module>java-spi</module>
|
||||||
<module>java-streams</module>
|
<module>java-streams</module>
|
||||||
|
<module>java-streams-2</module>
|
||||||
<module>java-strings</module>
|
<module>java-strings</module>
|
||||||
<module>java-vavr-stream</module>
|
<module>java-vavr-stream</module>
|
||||||
<module>java-websocket</module>
|
<module>java-websocket</module>
|
||||||
@ -480,6 +483,7 @@
|
|||||||
|
|
||||||
<!-- <module>lagom</module> --> <!-- Not a maven project -->
|
<!-- <module>lagom</module> --> <!-- Not a maven project -->
|
||||||
<module>libraries</module>
|
<module>libraries</module>
|
||||||
|
<module>libraries2</module>
|
||||||
<module>libraries-data</module>
|
<module>libraries-data</module>
|
||||||
<module>libraries-apache-commons</module>
|
<module>libraries-apache-commons</module>
|
||||||
<module>libraries-security</module>
|
<module>libraries-security</module>
|
||||||
@ -504,7 +508,6 @@
|
|||||||
<module>mustache</module>
|
<module>mustache</module>
|
||||||
<module>mybatis</module>
|
<module>mybatis</module>
|
||||||
|
|
||||||
<module>noexception</module>
|
|
||||||
|
|
||||||
<module>optaplanner</module>
|
<module>optaplanner</module>
|
||||||
<module>orika</module>
|
<module>orika</module>
|
||||||
@ -616,6 +619,7 @@
|
|||||||
<module>spring-boot-mvc</module>
|
<module>spring-boot-mvc</module>
|
||||||
<module>spring-boot-ops</module>
|
<module>spring-boot-ops</module>
|
||||||
<module>spring-boot-rest</module>
|
<module>spring-boot-rest</module>
|
||||||
|
<module>spring-boot-data</module>
|
||||||
<module>spring-boot-property-exp</module>
|
<module>spring-boot-property-exp</module>
|
||||||
<module>spring-boot-security</module>
|
<module>spring-boot-security</module>
|
||||||
<module>spring-boot-testing</module>
|
<module>spring-boot-testing</module>
|
||||||
@ -663,11 +667,13 @@
|
|||||||
<module>spring-mvc-java</module>
|
<module>spring-mvc-java</module>
|
||||||
<module>spring-mvc-kotlin</module>
|
<module>spring-mvc-kotlin</module>
|
||||||
<module>spring-mvc-simple</module>
|
<module>spring-mvc-simple</module>
|
||||||
|
<module>spring-mvc-simple-2</module>
|
||||||
<module>spring-mvc-velocity</module>
|
<module>spring-mvc-velocity</module>
|
||||||
<module>spring-mvc-webflow</module>
|
<module>spring-mvc-webflow</module>
|
||||||
<module>spring-mvc-xml</module>
|
<module>spring-mvc-xml</module>
|
||||||
|
|
||||||
<module>spring-protobuf</module>
|
<module>spring-protobuf</module>
|
||||||
|
<!-- <module>spring-security-cors</module> --> <!-- PMD violation -->
|
||||||
|
|
||||||
<module>spring-quartz</module>
|
<module>spring-quartz</module>
|
||||||
|
|
||||||
@ -983,7 +989,7 @@
|
|||||||
<module>parent-spring-5</module>
|
<module>parent-spring-5</module>
|
||||||
<module>parent-java</module>
|
<module>parent-java</module>
|
||||||
<module>parent-kotlin</module>
|
<module>parent-kotlin</module>
|
||||||
|
<!-- <module>akka-http</module> --> <!-- Unit test is failing -->
|
||||||
<module>akka-streams</module>
|
<module>akka-streams</module>
|
||||||
<module>algorithms-genetic</module>
|
<module>algorithms-genetic</module>
|
||||||
<module>algorithms-miscellaneous-1</module>
|
<module>algorithms-miscellaneous-1</module>
|
||||||
@ -1039,6 +1045,7 @@
|
|||||||
<module>core-java-lang-syntax</module>
|
<module>core-java-lang-syntax</module>
|
||||||
<module>core-java-lang</module>
|
<module>core-java-lang</module>
|
||||||
<module>core-java-lang-oop</module>
|
<module>core-java-lang-oop</module>
|
||||||
|
<module>core-java-lang-oop-2</module>
|
||||||
<module>core-java-networking</module>
|
<module>core-java-networking</module>
|
||||||
<module>core-java-perf</module>
|
<module>core-java-perf</module>
|
||||||
<module>core-java-sun</module>
|
<module>core-java-sun</module>
|
||||||
@ -1086,6 +1093,7 @@
|
|||||||
<module>jackson-2</module>
|
<module>jackson-2</module>
|
||||||
<module>java-collections-conversions</module>
|
<module>java-collections-conversions</module>
|
||||||
<module>java-collections-maps</module>
|
<module>java-collections-maps</module>
|
||||||
|
<module>java-collections-maps-2</module>
|
||||||
<!-- <module>java-dates</module> --> <!-- We haven't upgraded to java 9. Fixing in BAEL-10841 -->
|
<!-- <module>java-dates</module> --> <!-- We haven't upgraded to java 9. Fixing in BAEL-10841 -->
|
||||||
<module>java-ee-8-security-api</module>
|
<module>java-ee-8-security-api</module>
|
||||||
<module>java-lite</module>
|
<module>java-lite</module>
|
||||||
@ -1093,6 +1101,7 @@
|
|||||||
<module>java-rmi</module>
|
<module>java-rmi</module>
|
||||||
<module>java-spi</module>
|
<module>java-spi</module>
|
||||||
<module>java-streams</module>
|
<module>java-streams</module>
|
||||||
|
<module>java-streams-2</module>
|
||||||
<module>java-strings</module>
|
<module>java-strings</module>
|
||||||
<module>java-vavr-stream</module>
|
<module>java-vavr-stream</module>
|
||||||
<module>java-websocket</module>
|
<module>java-websocket</module>
|
||||||
@ -1149,7 +1158,6 @@
|
|||||||
<module>mustache</module>
|
<module>mustache</module>
|
||||||
<module>mybatis</module>
|
<module>mybatis</module>
|
||||||
|
|
||||||
<module>noexception</module>
|
|
||||||
|
|
||||||
<module>optaplanner</module>
|
<module>optaplanner</module>
|
||||||
<module>orika</module>
|
<module>orika</module>
|
||||||
@ -1253,6 +1261,7 @@
|
|||||||
<module>spring-boot-mvc</module>
|
<module>spring-boot-mvc</module>
|
||||||
<module>spring-boot-ops</module>
|
<module>spring-boot-ops</module>
|
||||||
<module>spring-boot-rest</module>
|
<module>spring-boot-rest</module>
|
||||||
|
<module>spring-boot-data</module>
|
||||||
<module>spring-boot-property-exp</module>
|
<module>spring-boot-property-exp</module>
|
||||||
<module>spring-boot-security</module>
|
<module>spring-boot-security</module>
|
||||||
<module>spring-boot-vue</module>
|
<module>spring-boot-vue</module>
|
||||||
@ -1298,11 +1307,13 @@
|
|||||||
<module>spring-mvc-java</module>
|
<module>spring-mvc-java</module>
|
||||||
<module>spring-mvc-kotlin</module>
|
<module>spring-mvc-kotlin</module>
|
||||||
<module>spring-mvc-simple</module>
|
<module>spring-mvc-simple</module>
|
||||||
|
<module>spring-mvc-simple-2</module>
|
||||||
<module>spring-mvc-velocity</module>
|
<module>spring-mvc-velocity</module>
|
||||||
<module>spring-mvc-webflow</module>
|
<module>spring-mvc-webflow</module>
|
||||||
<module>spring-mvc-xml</module>
|
<module>spring-mvc-xml</module>
|
||||||
|
|
||||||
<module>spring-protobuf</module>
|
<module>spring-protobuf</module>
|
||||||
|
<!-- <module>spring-security-cors</module> --> <!-- PMD violation -->
|
||||||
|
|
||||||
<module>spring-quartz</module>
|
<module>spring-quartz</module>
|
||||||
|
|
||||||
|
@ -19,7 +19,7 @@
|
|||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.typesafe.akka</groupId>
|
<groupId>com.typesafe.akka</groupId>
|
||||||
<artifactId>akka-actor_2.11</artifactId>
|
<artifactId>akka-actor_${scala.version}</artifactId>
|
||||||
<version>${akka.version}</version>
|
<version>${akka.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
@ -44,6 +44,7 @@
|
|||||||
<properties>
|
<properties>
|
||||||
<spring.version>4.3.4.RELEASE</spring.version>
|
<spring.version>4.3.4.RELEASE</spring.version>
|
||||||
<akka.version>2.4.14</akka.version>
|
<akka.version>2.4.14</akka.version>
|
||||||
|
<scala.version>2.11</scala.version>
|
||||||
</properties>
|
</properties>
|
||||||
|
|
||||||
</project>
|
</project>
|
@ -6,15 +6,13 @@
|
|||||||
<version>1.0</version>
|
<version>1.0</version>
|
||||||
<packaging>jar</packaging>
|
<packaging>jar</packaging>
|
||||||
<name>Spring Boot Angular Application</name>
|
<name>Spring Boot Angular Application</name>
|
||||||
|
|
||||||
<parent>
|
<parent>
|
||||||
<groupId>org.springframework.boot</groupId>
|
<groupId>org.springframework.boot</groupId>
|
||||||
<artifactId>spring-boot-starter-parent</artifactId>
|
<artifactId>spring-boot-starter-parent</artifactId>
|
||||||
<version>2.1.3.RELEASE</version>
|
<version>2.1.3.RELEASE</version>
|
||||||
<relativePath/>
|
<relativePath/>
|
||||||
</parent>
|
</parent>
|
||||||
<properties>
|
|
||||||
<java.version>1.8</java.version>
|
|
||||||
</properties>
|
|
||||||
|
|
||||||
<dependencies>
|
<dependencies>
|
||||||
<dependency>
|
<dependency>
|
||||||
@ -46,4 +44,7 @@
|
|||||||
</plugins>
|
</plugins>
|
||||||
</build>
|
</build>
|
||||||
|
|
||||||
|
<properties>
|
||||||
|
<java.version>1.8</java.version>
|
||||||
|
</properties>
|
||||||
</project>
|
</project>
|
@ -1,18 +1,24 @@
|
|||||||
package com.baeldung.integrationtesting;
|
package com.baeldung.integrationtesting;
|
||||||
|
|
||||||
|
import org.springframework.context.annotation.Bean;
|
||||||
import org.springframework.context.annotation.Configuration;
|
import org.springframework.context.annotation.Configuration;
|
||||||
import org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder;
|
import org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder;
|
||||||
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
|
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
|
||||||
import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter;
|
import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter;
|
||||||
|
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
|
||||||
|
|
||||||
@Configuration
|
@Configuration
|
||||||
public class WebSecurityConfigurer extends WebSecurityConfigurerAdapter {
|
public class WebSecurityConfigurer extends WebSecurityConfigurerAdapter {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void configure(AuthenticationManagerBuilder auth) throws Exception {
|
protected void configure(AuthenticationManagerBuilder auth) throws Exception {
|
||||||
|
|
||||||
|
BCryptPasswordEncoder encoder = passwordEncoder();
|
||||||
|
|
||||||
auth.inMemoryAuthentication()
|
auth.inMemoryAuthentication()
|
||||||
|
.passwordEncoder(encoder)
|
||||||
.withUser("spring")
|
.withUser("spring")
|
||||||
.password("{noop}secret")
|
.password(encoder.encode("secret"))
|
||||||
.roles("USER");
|
.roles("USER");
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -27,5 +33,8 @@ public class WebSecurityConfigurer extends WebSecurityConfigurerAdapter {
|
|||||||
.httpBasic();
|
.httpBasic();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Bean
|
||||||
|
public BCryptPasswordEncoder passwordEncoder() {
|
||||||
|
return new BCryptPasswordEncoder();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,18 @@
|
|||||||
|
package com.baeldung.springbootsecurity.oauth2server.config;
|
||||||
|
|
||||||
|
import org.springframework.context.annotation.Bean;
|
||||||
|
import org.springframework.context.annotation.Configuration;
|
||||||
|
import org.springframework.context.annotation.Profile;
|
||||||
|
import org.springframework.security.authentication.AuthenticationManager;
|
||||||
|
import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter;
|
||||||
|
|
||||||
|
@Configuration
|
||||||
|
@Profile("authz")
|
||||||
|
public class AuthenticationMananagerConfig extends WebSecurityConfigurerAdapter {
|
||||||
|
|
||||||
|
@Bean
|
||||||
|
@Override
|
||||||
|
public AuthenticationManager authenticationManagerBean() throws Exception {
|
||||||
|
return super.authenticationManagerBean();
|
||||||
|
}
|
||||||
|
}
|
@ -1,9 +1,11 @@
|
|||||||
package com.baeldung.springbootsecurity.oauth2server.config;
|
package com.baeldung.springbootsecurity.oauth2server.config;
|
||||||
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.context.annotation.Bean;
|
||||||
import org.springframework.context.annotation.Configuration;
|
import org.springframework.context.annotation.Configuration;
|
||||||
import org.springframework.context.annotation.Profile;
|
import org.springframework.context.annotation.Profile;
|
||||||
import org.springframework.security.authentication.AuthenticationManager;
|
import org.springframework.security.authentication.AuthenticationManager;
|
||||||
|
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
|
||||||
import org.springframework.security.oauth2.config.annotation.configurers.ClientDetailsServiceConfigurer;
|
import org.springframework.security.oauth2.config.annotation.configurers.ClientDetailsServiceConfigurer;
|
||||||
import org.springframework.security.oauth2.config.annotation.web.configuration.AuthorizationServerConfigurerAdapter;
|
import org.springframework.security.oauth2.config.annotation.web.configuration.AuthorizationServerConfigurerAdapter;
|
||||||
import org.springframework.security.oauth2.config.annotation.web.configurers.AuthorizationServerEndpointsConfigurer;
|
import org.springframework.security.oauth2.config.annotation.web.configurers.AuthorizationServerEndpointsConfigurer;
|
||||||
@ -25,15 +27,20 @@ public class AuthorizationServerConfig extends AuthorizationServerConfigurerAdap
|
|||||||
clients
|
clients
|
||||||
.inMemory()
|
.inMemory()
|
||||||
.withClient("baeldung")
|
.withClient("baeldung")
|
||||||
.secret("{noop}baeldung")
|
.secret(passwordEncoder().encode("baeldung"))
|
||||||
.authorizedGrantTypes("client_credentials", "password", "authorization_code")
|
.authorizedGrantTypes("client_credentials", "password", "authorization_code")
|
||||||
.scopes("openid", "read")
|
.scopes("openid", "read")
|
||||||
.autoApprove(true)
|
.autoApprove(true)
|
||||||
.and()
|
.and()
|
||||||
.withClient("baeldung-admin")
|
.withClient("baeldung-admin")
|
||||||
.secret("{noop}baeldung")
|
.secret(passwordEncoder().encode("baeldung"))
|
||||||
.authorizedGrantTypes("authorization_code", "client_credentials", "refresh_token")
|
.authorizedGrantTypes("authorization_code", "client_credentials", "refresh_token")
|
||||||
.scopes("read", "write")
|
.scopes("read", "write")
|
||||||
.autoApprove(true);
|
.autoApprove(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Bean
|
||||||
|
public BCryptPasswordEncoder passwordEncoder() {
|
||||||
|
return new BCryptPasswordEncoder();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -2,10 +2,12 @@ package com.baeldung.springbootsecurity.oauth2server.config;
|
|||||||
|
|
||||||
import org.springframework.context.annotation.Bean;
|
import org.springframework.context.annotation.Bean;
|
||||||
import org.springframework.context.annotation.Configuration;
|
import org.springframework.context.annotation.Configuration;
|
||||||
|
import org.springframework.context.annotation.Profile;
|
||||||
import org.springframework.security.authentication.AuthenticationManager;
|
import org.springframework.security.authentication.AuthenticationManager;
|
||||||
import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter;
|
import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter;
|
||||||
|
|
||||||
@Configuration
|
@Configuration
|
||||||
|
@Profile("!authz")
|
||||||
public class WebSecurityConfiguration extends WebSecurityConfigurerAdapter {
|
public class WebSecurityConfiguration extends WebSecurityConfigurerAdapter {
|
||||||
|
|
||||||
@Bean
|
@Bean
|
||||||
|
@ -1,10 +1,12 @@
|
|||||||
package com.baeldung.springsecuritytaglibs.config;
|
package com.baeldung.springsecuritytaglibs.config;
|
||||||
|
|
||||||
|
import org.springframework.context.annotation.Bean;
|
||||||
import org.springframework.context.annotation.Configuration;
|
import org.springframework.context.annotation.Configuration;
|
||||||
import org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder;
|
import org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder;
|
||||||
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
|
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
|
||||||
import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity;
|
import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity;
|
||||||
import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter;
|
import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter;
|
||||||
|
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
|
||||||
|
|
||||||
@Configuration
|
@Configuration
|
||||||
@EnableWebSecurity
|
@EnableWebSecurity
|
||||||
@ -12,9 +14,11 @@ public class SpringBootSecurityTagLibsConfig extends WebSecurityConfigurerAdapte
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void configure(AuthenticationManagerBuilder auth) throws Exception {
|
protected void configure(AuthenticationManagerBuilder auth) throws Exception {
|
||||||
|
BCryptPasswordEncoder encoder = passwordEncoder();
|
||||||
auth.inMemoryAuthentication()
|
auth.inMemoryAuthentication()
|
||||||
|
.passwordEncoder(encoder)
|
||||||
.withUser("testUser")
|
.withUser("testUser")
|
||||||
.password("{noop}password")
|
.password(encoder.encode("password"))
|
||||||
.roles("ADMIN");
|
.roles("ADMIN");
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -28,4 +32,9 @@ public class SpringBootSecurityTagLibsConfig extends WebSecurityConfigurerAdapte
|
|||||||
.anyRequest().permitAll().and().httpBasic();
|
.anyRequest().permitAll().and().httpBasic();
|
||||||
// @formatter:on
|
// @formatter:on
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Bean
|
||||||
|
public BCryptPasswordEncoder passwordEncoder() {
|
||||||
|
return new BCryptPasswordEncoder();
|
||||||
|
}
|
||||||
}
|
}
|
@ -16,6 +16,7 @@ import java.net.MalformedURLException;
|
|||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
|
|
||||||
import static org.junit.Assert.assertEquals;
|
import static org.junit.Assert.assertEquals;
|
||||||
|
import static org.junit.Assert.assertNull;
|
||||||
import static org.junit.Assert.assertTrue;
|
import static org.junit.Assert.assertTrue;
|
||||||
import static org.springframework.boot.test.context.SpringBootTest.WebEnvironment.RANDOM_PORT;
|
import static org.springframework.boot.test.context.SpringBootTest.WebEnvironment.RANDOM_PORT;
|
||||||
@RunWith(SpringRunner.class)
|
@RunWith(SpringRunner.class)
|
||||||
@ -49,6 +50,6 @@ public class BasicAuthConfigurationIntegrationTest {
|
|||||||
ResponseEntity<String> response = restTemplate.getForEntity(base.toString(), String.class);
|
ResponseEntity<String> response = restTemplate.getForEntity(base.toString(), String.class);
|
||||||
|
|
||||||
assertEquals(HttpStatus.UNAUTHORIZED, response.getStatusCode());
|
assertEquals(HttpStatus.UNAUTHORIZED, response.getStatusCode());
|
||||||
Assert.assertNull(response.getBody());
|
assertNull(response.getBody());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -101,7 +101,7 @@
|
|||||||
<plugin>
|
<plugin>
|
||||||
<groupId>org.codehaus.gmavenplus</groupId>
|
<groupId>org.codehaus.gmavenplus</groupId>
|
||||||
<artifactId>gmavenplus-plugin</artifactId>
|
<artifactId>gmavenplus-plugin</artifactId>
|
||||||
<version>1.6</version>
|
<version>${gmavenplus-plugin.version}</version>
|
||||||
<executions>
|
<executions>
|
||||||
<execution>
|
<execution>
|
||||||
<goals>
|
<goals>
|
||||||
@ -119,6 +119,7 @@
|
|||||||
<start-class>com.baeldung.boot.Application</start-class>
|
<start-class>com.baeldung.boot.Application</start-class>
|
||||||
<git-commit-id-plugin.version>2.2.4</git-commit-id-plugin.version>
|
<git-commit-id-plugin.version>2.2.4</git-commit-id-plugin.version>
|
||||||
<spock.version>1.2-groovy-2.4</spock.version>
|
<spock.version>1.2-groovy-2.4</spock.version>
|
||||||
|
<gmavenplus-plugin.version>1.6</gmavenplus-plugin.version>
|
||||||
</properties>
|
</properties>
|
||||||
|
|
||||||
</project>
|
</project>
|
||||||
|
@ -1,8 +1,12 @@
|
|||||||
package com.baeldung.spring.cloud.archaius.additionalsources.config;
|
package com.baeldung.spring.cloud.archaius.additionalsources.config;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.net.URL;
|
||||||
|
|
||||||
import org.apache.commons.configuration.AbstractConfiguration;
|
import org.apache.commons.configuration.AbstractConfiguration;
|
||||||
import org.springframework.context.annotation.Bean;
|
import org.springframework.context.annotation.Bean;
|
||||||
import org.springframework.context.annotation.Configuration;
|
import org.springframework.context.annotation.Configuration;
|
||||||
|
import org.springframework.core.io.ClassPathResource;
|
||||||
|
|
||||||
import com.netflix.config.DynamicConfiguration;
|
import com.netflix.config.DynamicConfiguration;
|
||||||
import com.netflix.config.FixedDelayPollingScheduler;
|
import com.netflix.config.FixedDelayPollingScheduler;
|
||||||
@ -13,8 +17,9 @@ import com.netflix.config.sources.URLConfigurationSource;
|
|||||||
public class ApplicationPropertiesConfigurations {
|
public class ApplicationPropertiesConfigurations {
|
||||||
|
|
||||||
@Bean
|
@Bean
|
||||||
public AbstractConfiguration addApplicationPropertiesSource() {
|
public AbstractConfiguration addApplicationPropertiesSource() throws IOException {
|
||||||
PolledConfigurationSource source = new URLConfigurationSource("classpath:other-config.properties");
|
URL configPropertyURL = (new ClassPathResource("other-config.properties")).getURL();
|
||||||
|
PolledConfigurationSource source = new URLConfigurationSource(configPropertyURL);
|
||||||
return new DynamicConfiguration(source, new FixedDelayPollingScheduler());
|
return new DynamicConfiguration(source, new FixedDelayPollingScheduler());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,12 +1,10 @@
|
|||||||
package org.baeldung;
|
package com.baeldung.spring.cloud.archaius.additionalsources;
|
||||||
|
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import org.junit.runner.RunWith;
|
import org.junit.runner.RunWith;
|
||||||
import org.springframework.boot.test.context.SpringBootTest;
|
import org.springframework.boot.test.context.SpringBootTest;
|
||||||
import org.springframework.test.context.junit4.SpringRunner;
|
import org.springframework.test.context.junit4.SpringRunner;
|
||||||
|
|
||||||
import com.baeldung.spring.cloud.archaius.additionalsources.AdditionalSourcesSimpleApplication;
|
|
||||||
|
|
||||||
@RunWith(SpringRunner.class)
|
@RunWith(SpringRunner.class)
|
||||||
@SpringBootTest(classes = AdditionalSourcesSimpleApplication.class)
|
@SpringBootTest(classes = AdditionalSourcesSimpleApplication.class)
|
||||||
public class SpringContextIntegrationTest {
|
public class SpringContextIntegrationTest {
|
@ -0,0 +1,15 @@
|
|||||||
|
package com.baeldung.spring.cloud.aws;
|
||||||
|
|
||||||
|
import org.junit.Test;
|
||||||
|
import org.junit.runner.RunWith;
|
||||||
|
import org.springframework.boot.test.context.SpringBootTest;
|
||||||
|
import org.springframework.test.context.junit4.SpringRunner;
|
||||||
|
|
||||||
|
@RunWith(SpringRunner.class)
|
||||||
|
@SpringBootTest(classes = SpringCloudAwsApplication.class)
|
||||||
|
public class SpringContextIntegrationTest {
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void whenSpringContextIsBootstrapped_thenNoExceptions() {
|
||||||
|
}
|
||||||
|
}
|
@ -1,18 +1,22 @@
|
|||||||
package com.baeldung.spring.cloud.config.server;
|
package com.baeldung.spring.cloud.config.server;
|
||||||
|
|
||||||
import org.junit.Ignore;
|
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import org.junit.runner.RunWith;
|
import org.junit.runner.RunWith;
|
||||||
import org.springframework.boot.test.context.SpringBootTest;
|
import org.springframework.boot.test.context.SpringBootTest;
|
||||||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||||
import org.springframework.test.context.web.WebAppConfiguration;
|
import org.springframework.test.context.web.WebAppConfiguration;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* The context will load successfully with some properties provided by docker
|
||||||
|
*
|
||||||
|
*/
|
||||||
@RunWith(SpringJUnit4ClassRunner.class)
|
@RunWith(SpringJUnit4ClassRunner.class)
|
||||||
@SpringBootTest(classes = ConfigServer.class)
|
@SpringBootTest(classes = ConfigServer.class)
|
||||||
@WebAppConfiguration
|
@WebAppConfiguration
|
||||||
@Ignore
|
public class SpringContextLiveTest {
|
||||||
public class ConfigServerListIntegrationTest {
|
|
||||||
@Test
|
@Test
|
||||||
public void contextLoads() {
|
public void whenSpringContextIsBootstrapped_thenNoExceptions() {
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -20,24 +20,24 @@
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.springframework.cloud</groupId>
|
<groupId>org.springframework.cloud</groupId>
|
||||||
<artifactId>spring-cloud-contract-wiremock</artifactId>
|
<artifactId>spring-cloud-contract-wiremock</artifactId>
|
||||||
<version>1.2.2.RELEASE</version>
|
<version>${spring-cloud.version}</version>
|
||||||
<scope>test</scope>
|
<scope>test</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.springframework.cloud</groupId>
|
<groupId>org.springframework.cloud</groupId>
|
||||||
<artifactId>spring-cloud-contract-stub-runner</artifactId>
|
<artifactId>spring-cloud-contract-stub-runner</artifactId>
|
||||||
<version>1.2.2.RELEASE</version>
|
<version>${spring-cloud.version}</version>
|
||||||
<scope>test</scope>
|
<scope>test</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.springframework.boot</groupId>
|
<groupId>org.springframework.boot</groupId>
|
||||||
<artifactId>spring-boot-starter-web</artifactId>
|
<artifactId>spring-boot-starter-web</artifactId>
|
||||||
<version>1.5.9.RELEASE</version>
|
<version>${spring-boot.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.springframework.boot</groupId>
|
<groupId>org.springframework.boot</groupId>
|
||||||
<artifactId>spring-boot-starter-data-rest</artifactId>
|
<artifactId>spring-boot-starter-data-rest</artifactId>
|
||||||
<version>1.5.9.RELEASE</version>
|
<version>${spring-boot.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.baeldung.spring.cloud</groupId>
|
<groupId>com.baeldung.spring.cloud</groupId>
|
||||||
@ -51,5 +51,7 @@
|
|||||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||||
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
|
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
|
||||||
<java.version>1.8</java.version>
|
<java.version>1.8</java.version>
|
||||||
|
<spring-cloud.version>1.2.2.RELEASE</spring-cloud.version>
|
||||||
|
<spring-boot.version>1.5.9.RELEASE</spring-boot.version>
|
||||||
</properties>
|
</properties>
|
||||||
</project>
|
</project>
|
||||||
|
@ -25,12 +25,12 @@
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.springframework.boot</groupId>
|
<groupId>org.springframework.boot</groupId>
|
||||||
<artifactId>spring-boot-starter-web</artifactId>
|
<artifactId>spring-boot-starter-web</artifactId>
|
||||||
<version>1.5.9.RELEASE</version>
|
<version>${spring-boot.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.springframework.boot</groupId>
|
<groupId>org.springframework.boot</groupId>
|
||||||
<artifactId>spring-boot-starter-data-rest</artifactId>
|
<artifactId>spring-boot-starter-data-rest</artifactId>
|
||||||
<version>1.5.9.RELEASE</version>
|
<version>${spring-boot.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
<build>
|
<build>
|
||||||
@ -66,6 +66,7 @@
|
|||||||
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
|
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
|
||||||
<java.version>1.8</java.version>
|
<java.version>1.8</java.version>
|
||||||
<spring-cloud.version>Edgware.SR1</spring-cloud.version>
|
<spring-cloud.version>Edgware.SR1</spring-cloud.version>
|
||||||
|
<spring-boot.version>1.5.9.RELEASE</spring-boot.version>
|
||||||
</properties>
|
</properties>
|
||||||
|
|
||||||
</project>
|
</project>
|
||||||
|
@ -21,6 +21,15 @@
|
|||||||
<version>1.0.0-SNAPSHOT</version>
|
<version>1.0.0-SNAPSHOT</version>
|
||||||
<relativePath>..</relativePath>
|
<relativePath>..</relativePath>
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
|
<dependencies>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
<artifactId>spring-boot-starter-test</artifactId>
|
||||||
|
<version>${spring-boot.version}</version>
|
||||||
|
<scope>test</scope>
|
||||||
|
</dependency>
|
||||||
|
</dependencies>
|
||||||
|
|
||||||
<properties>
|
<properties>
|
||||||
<spring-boot.version>2.0.1.RELEASE</spring-boot.version>
|
<spring-boot.version>2.0.1.RELEASE</spring-boot.version>
|
||||||
|
@ -26,12 +26,6 @@
|
|||||||
<artifactId>spring-boot-starter-web</artifactId>
|
<artifactId>spring-boot-starter-web</artifactId>
|
||||||
<version>${spring-boot.version}</version>
|
<version>${spring-boot.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
|
||||||
<groupId>org.springframework.boot</groupId>
|
|
||||||
<artifactId>spring-boot-starter-test</artifactId>
|
|
||||||
<version>${spring-boot.version}</version>
|
|
||||||
<scope>test</scope>
|
|
||||||
</dependency>
|
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
<dependencyManagement>
|
<dependencyManagement>
|
||||||
|
@ -0,0 +1,16 @@
|
|||||||
|
package com.baeldung.spring.cloud.eureka.client;
|
||||||
|
|
||||||
|
import org.junit.Test;
|
||||||
|
import org.junit.runner.RunWith;
|
||||||
|
import org.springframework.boot.test.context.SpringBootTest;
|
||||||
|
import org.springframework.test.context.junit4.SpringRunner;
|
||||||
|
|
||||||
|
@RunWith(SpringRunner.class)
|
||||||
|
@SpringBootTest
|
||||||
|
public class SpringContextIntegrationTest {
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void whenSpringContextIsBootstrapped_thenNoExceptions() {
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -1,17 +1,16 @@
|
|||||||
package org.baeldung;
|
package com.baeldung.spring.cloud.feign.client;
|
||||||
|
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import org.junit.runner.RunWith;
|
import org.junit.runner.RunWith;
|
||||||
import org.springframework.boot.test.context.SpringBootTest;
|
import org.springframework.boot.test.context.SpringBootTest;
|
||||||
import org.springframework.test.context.junit4.SpringRunner;
|
import org.springframework.test.context.junit4.SpringRunner;
|
||||||
|
|
||||||
import com.baeldung.spring.cloud.aws.InstanceProfileAwsApplication;
|
|
||||||
|
|
||||||
@RunWith(SpringRunner.class)
|
@RunWith(SpringRunner.class)
|
||||||
@SpringBootTest(classes = InstanceProfileAwsApplication.class)
|
@SpringBootTest
|
||||||
public class SpringContextIntegrationTest {
|
public class SpringContextIntegrationTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void whenSpringContextIsBootstrapped_thenNoExceptions() {
|
public void whenSpringContextIsBootstrapped_thenNoExceptions() {
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
@ -0,0 +1,16 @@
|
|||||||
|
package com.baeldung.spring.cloud.eureka.server;
|
||||||
|
|
||||||
|
import org.junit.Test;
|
||||||
|
import org.junit.runner.RunWith;
|
||||||
|
import org.springframework.boot.test.context.SpringBootTest;
|
||||||
|
import org.springframework.test.context.junit4.SpringRunner;
|
||||||
|
|
||||||
|
@RunWith(SpringRunner.class)
|
||||||
|
@SpringBootTest
|
||||||
|
public class SpringContextIntegrationTest {
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void whenSpringContextIsBootstrapped_thenNoExceptions() {
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,18 @@
|
|||||||
|
package com.baeldung.spring.cloud.hystrix.rest.consumer;
|
||||||
|
|
||||||
|
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.web.WebAppConfiguration;
|
||||||
|
|
||||||
|
@RunWith(SpringJUnit4ClassRunner.class)
|
||||||
|
@ContextConfiguration(classes = RestConsumerFeignApplication.class)
|
||||||
|
@WebAppConfiguration
|
||||||
|
public class SpringContextIntegrationTest {
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void whenSpringContextIsBootstrapped_thenNoExceptions() {
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -40,6 +40,13 @@
|
|||||||
<artifactId>spring-boot-starter-actuator</artifactId>
|
<artifactId>spring-boot-starter-actuator</artifactId>
|
||||||
<version>${spring-boot-starter-web.version}</version>
|
<version>${spring-boot-starter-web.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
<artifactId>spring-boot-starter-test</artifactId>
|
||||||
|
<scope>test</scope>
|
||||||
|
<version>${spring-boot-starter-web.version}</version>
|
||||||
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
<dependencyManagement>
|
<dependencyManagement>
|
||||||
@ -53,5 +60,10 @@
|
|||||||
</dependency>
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
</dependencyManagement>
|
</dependencyManagement>
|
||||||
|
|
||||||
|
<properties>
|
||||||
|
<!-- we need the Mockito version provided by Spring Boot -->
|
||||||
|
<mockito.version>1.10.19</mockito.version>
|
||||||
|
</properties>
|
||||||
|
|
||||||
</project>
|
</project>
|
||||||
|
@ -1,18 +1,18 @@
|
|||||||
package org.baeldung;
|
package com.baeldung.spring.cloud.hystrix.rest.consumer;
|
||||||
|
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import org.junit.runner.RunWith;
|
import org.junit.runner.RunWith;
|
||||||
import org.springframework.boot.test.context.SpringBootTest;
|
import org.springframework.test.context.ContextConfiguration;
|
||||||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||||
import org.springframework.test.context.web.WebAppConfiguration;
|
import org.springframework.test.context.web.WebAppConfiguration;
|
||||||
|
|
||||||
import com.baeldung.spring.cloud.config.server.ConfigServer;
|
|
||||||
|
|
||||||
@RunWith(SpringJUnit4ClassRunner.class)
|
@RunWith(SpringJUnit4ClassRunner.class)
|
||||||
@SpringBootTest(classes = ConfigServer.class)
|
@ContextConfiguration(classes = RestConsumerApplication.class)
|
||||||
@WebAppConfiguration
|
@WebAppConfiguration
|
||||||
public class SpringContextIntegrationTest {
|
public class SpringContextIntegrationTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void contextLoads() {
|
public void whenSpringContextIsBootstrapped_thenNoExceptions() {
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
@ -20,6 +20,18 @@
|
|||||||
<artifactId>spring-boot-starter-web</artifactId>
|
<artifactId>spring-boot-starter-web</artifactId>
|
||||||
<version>${spring-boot-starter-web.version}</version>
|
<version>${spring-boot-starter-web.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
<artifactId>spring-boot-starter-test</artifactId>
|
||||||
|
<version>${spring-boot-starter-web.version}</version>
|
||||||
|
<scope>test</scope>
|
||||||
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
|
<properties>
|
||||||
|
<!-- we need the Mockito version provided by Spring Boot -->
|
||||||
|
<mockito.version>1.10.19</mockito.version>
|
||||||
|
</properties>
|
||||||
|
|
||||||
</project>
|
</project>
|
||||||
|
@ -0,0 +1,16 @@
|
|||||||
|
package com.baeldung.spring.cloud.hystrix.rest.producer;
|
||||||
|
|
||||||
|
import org.junit.Test;
|
||||||
|
import org.junit.runner.RunWith;
|
||||||
|
import org.springframework.boot.test.context.SpringBootTest;
|
||||||
|
import org.springframework.test.context.junit4.SpringRunner;
|
||||||
|
|
||||||
|
@RunWith(SpringRunner.class)
|
||||||
|
@SpringBootTest
|
||||||
|
public class SpringContextIntegrationTest {
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void whenSpringContextIsBootstrapped_thenNoExceptions() {
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -25,6 +25,13 @@
|
|||||||
<artifactId>spring-boot-starter-web</artifactId>
|
<artifactId>spring-boot-starter-web</artifactId>
|
||||||
<version>${spring-boot-starter-web.version}</version>
|
<version>${spring-boot-starter-web.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
<artifactId>spring-boot-starter-test</artifactId>
|
||||||
|
<version>${spring-boot-starter-web.version}</version>
|
||||||
|
<scope>test</scope>
|
||||||
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
<dependencyManagement>
|
<dependencyManagement>
|
||||||
|
@ -0,0 +1,16 @@
|
|||||||
|
package com.baeldung.spring.cloud.eureka.client;
|
||||||
|
|
||||||
|
import org.junit.Test;
|
||||||
|
import org.junit.runner.RunWith;
|
||||||
|
import org.springframework.boot.test.context.SpringBootTest;
|
||||||
|
import org.springframework.test.context.junit4.SpringRunner;
|
||||||
|
|
||||||
|
@RunWith(SpringRunner.class)
|
||||||
|
@SpringBootTest
|
||||||
|
public class SpringContextIntegrationTest {
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void whenSpringContextIsBootstrapped_thenNoExceptions() {
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -25,7 +25,13 @@
|
|||||||
<artifactId>commons-configuration</artifactId>
|
<artifactId>commons-configuration</artifactId>
|
||||||
<version>${commons-config.version}</version>
|
<version>${commons-config.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
<artifactId>spring-boot-starter-test</artifactId>
|
||||||
|
<version>${spring-boot-starter-web.version}</version>
|
||||||
|
<scope>test</scope>
|
||||||
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
<dependencyManagement>
|
<dependencyManagement>
|
||||||
|
@ -0,0 +1,16 @@
|
|||||||
|
package com.baeldung.spring.cloud.eureka.server;
|
||||||
|
|
||||||
|
import org.junit.Test;
|
||||||
|
import org.junit.runner.RunWith;
|
||||||
|
import org.springframework.boot.test.context.SpringBootTest;
|
||||||
|
import org.springframework.test.context.junit4.SpringRunner;
|
||||||
|
|
||||||
|
@RunWith(SpringRunner.class)
|
||||||
|
@SpringBootTest
|
||||||
|
public class SpringContextIntegrationTest {
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void whenSpringContextIsBootstrapped_thenNoExceptions() {
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -33,6 +33,13 @@
|
|||||||
<artifactId>rxjava</artifactId>
|
<artifactId>rxjava</artifactId>
|
||||||
<version>${rxjava.version}</version>
|
<version>${rxjava.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
<artifactId>spring-boot-starter-test</artifactId>
|
||||||
|
<version>${spring-boot-starter-web.version}</version>
|
||||||
|
<scope>test</scope>
|
||||||
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
<dependencyManagement>
|
<dependencyManagement>
|
||||||
|
@ -0,0 +1,16 @@
|
|||||||
|
package com.baeldung.spring.cloud.zuul.config;
|
||||||
|
|
||||||
|
import org.junit.Test;
|
||||||
|
import org.junit.runner.RunWith;
|
||||||
|
import org.springframework.boot.test.context.SpringBootTest;
|
||||||
|
import org.springframework.test.context.junit4.SpringRunner;
|
||||||
|
|
||||||
|
@RunWith(SpringRunner.class)
|
||||||
|
@SpringBootTest
|
||||||
|
public class SpringContextIntegrationTest {
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void whenSpringContextIsBootstrapped_thenNoExceptions() {
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -48,7 +48,7 @@
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.springframework.boot</groupId>
|
<groupId>org.springframework.boot</groupId>
|
||||||
<artifactId>spring-boot-starter-test</artifactId>
|
<artifactId>spring-boot-starter-test</artifactId>
|
||||||
<version>1.5.10.RELEASE</version>
|
<version>${spring-boot.version}</version>
|
||||||
<scope>test</scope>
|
<scope>test</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
@ -59,6 +59,7 @@
|
|||||||
<freemarker.version>2.3.28</freemarker.version>
|
<freemarker.version>2.3.28</freemarker.version>
|
||||||
<servletapi.version>3.1.0</servletapi.version>
|
<servletapi.version>3.1.0</servletapi.version>
|
||||||
<failOnMissingWebXml>false</failOnMissingWebXml>
|
<failOnMissingWebXml>false</failOnMissingWebXml>
|
||||||
|
<spring-boot.version>1.5.10.RELEASE</spring-boot.version>
|
||||||
</properties>
|
</properties>
|
||||||
|
|
||||||
</project>
|
</project>
|
||||||
|
@ -95,28 +95,28 @@
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.github.tomakehurst</groupId>
|
<groupId>com.github.tomakehurst</groupId>
|
||||||
<artifactId>wiremock</artifactId>
|
<artifactId>wiremock</artifactId>
|
||||||
<version>1.58</version>
|
<version>${wiremock.version}</version>
|
||||||
<scope>test</scope>
|
<scope>test</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.fasterxml.jackson.jaxrs</groupId>
|
<groupId>com.fasterxml.jackson.jaxrs</groupId>
|
||||||
<artifactId>jackson-jaxrs-json-provider</artifactId>
|
<artifactId>jackson-jaxrs-json-provider</artifactId>
|
||||||
<version>2.9.7</version>
|
<version>${jackson.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.fasterxml.jackson.core</groupId>
|
<groupId>com.fasterxml.jackson.core</groupId>
|
||||||
<artifactId>jackson-databind</artifactId>
|
<artifactId>jackson-databind</artifactId>
|
||||||
<version>2.9.7</version>
|
<version>${jackson.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.slf4j</groupId>
|
<groupId>org.slf4j</groupId>
|
||||||
<artifactId>slf4j-jdk14</artifactId>
|
<artifactId>slf4j-jdk14</artifactId>
|
||||||
<version>1.7.25</version>
|
<version>${org.slf4j.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.assertj</groupId>
|
<groupId>org.assertj</groupId>
|
||||||
<artifactId>assertj-core</artifactId>
|
<artifactId>assertj-core</artifactId>
|
||||||
<version>3.10.0</version>
|
<version>${assertj-core.version}</version>
|
||||||
<scope>test</scope>
|
<scope>test</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
@ -124,7 +124,7 @@
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.springframework.boot</groupId>
|
<groupId>org.springframework.boot</groupId>
|
||||||
<artifactId>spring-boot-starter-test</artifactId>
|
<artifactId>spring-boot-starter-test</artifactId>
|
||||||
<version>1.5.10.RELEASE</version>
|
<version>${spring-boot.version}</version>
|
||||||
<scope>test</scope>
|
<scope>test</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
@ -228,6 +228,9 @@
|
|||||||
<httpcore.version>4.4.9</httpcore.version>
|
<httpcore.version>4.4.9</httpcore.version>
|
||||||
<httpclient.version>4.5.5</httpclient.version>
|
<httpclient.version>4.5.5</httpclient.version>
|
||||||
<servlet-api-version>4.0.0</servlet-api-version>
|
<servlet-api-version>4.0.0</servlet-api-version>
|
||||||
|
<wiremock.version>1.58</wiremock.version>
|
||||||
|
<assertj-core.version>3.10.0</assertj-core.version>
|
||||||
|
<spring-boot.version>1.5.10.RELEASE</spring-boot.version>
|
||||||
</properties>
|
</properties>
|
||||||
|
|
||||||
</project>
|
</project>
|
||||||
|
37
spring-mvc-simple-2/pom.xml
Normal file
37
spring-mvc-simple-2/pom.xml
Normal file
@ -0,0 +1,37 @@
|
|||||||
|
<?xml version="1.0"?>
|
||||||
|
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"
|
||||||
|
xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
|
||||||
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
<artifactId>spring-mvc-simple-2</artifactId>
|
||||||
|
<packaging>war</packaging>
|
||||||
|
<name>spring-mvc-simple-2</name>
|
||||||
|
|
||||||
|
<parent>
|
||||||
|
<groupId>com.baeldung</groupId>
|
||||||
|
<artifactId>parent-boot-2</artifactId>
|
||||||
|
<version>0.0.1-SNAPSHOT</version>
|
||||||
|
<relativePath>../parent-boot-2</relativePath>
|
||||||
|
</parent>
|
||||||
|
|
||||||
|
<dependencies>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
<artifactId>spring-boot-starter-web</artifactId>
|
||||||
|
</dependency>
|
||||||
|
</dependencies>
|
||||||
|
|
||||||
|
<properties>
|
||||||
|
<maven.compiler.source>1.8</maven.compiler.source>
|
||||||
|
<maven.compiler.target>1.8</maven.compiler.target>
|
||||||
|
</properties>
|
||||||
|
|
||||||
|
<build>
|
||||||
|
<plugins>
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
|
<artifactId>maven-war-plugin</artifactId>
|
||||||
|
</plugin>
|
||||||
|
</plugins>
|
||||||
|
<finalName>spring-mvc-simple2</finalName>
|
||||||
|
</build>
|
||||||
|
</project>
|
@ -0,0 +1,11 @@
|
|||||||
|
package com.baeldung.spring;
|
||||||
|
|
||||||
|
import org.springframework.boot.SpringApplication;
|
||||||
|
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||||
|
|
||||||
|
@SpringBootApplication
|
||||||
|
public class Application {
|
||||||
|
public static void main(String[] args) {
|
||||||
|
SpringApplication.run(Application.class, args);
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,97 @@
|
|||||||
|
package com.baeldung.spring.headers.controller;
|
||||||
|
|
||||||
|
import java.net.InetSocketAddress;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
import org.apache.commons.logging.Log;
|
||||||
|
import org.apache.commons.logging.LogFactory;
|
||||||
|
import org.springframework.http.HttpHeaders;
|
||||||
|
import org.springframework.http.HttpStatus;
|
||||||
|
import org.springframework.http.ResponseEntity;
|
||||||
|
import org.springframework.util.MultiValueMap;
|
||||||
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RequestHeader;
|
||||||
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
|
@RestController
|
||||||
|
public class ReadHeaderRestController {
|
||||||
|
private static final Log LOG = LogFactory.getLog(ReadHeaderRestController.class);
|
||||||
|
|
||||||
|
@GetMapping("/")
|
||||||
|
public ResponseEntity<String> index() {
|
||||||
|
return new ResponseEntity<String>("Index", HttpStatus.OK);
|
||||||
|
}
|
||||||
|
|
||||||
|
@GetMapping("/greeting")
|
||||||
|
public ResponseEntity<String> greeting(@RequestHeader(value = "accept-language") String language) {
|
||||||
|
String greeting = "";
|
||||||
|
String firstLanguage = (language.length() > 1 ? language.substring(0, 2) : language);
|
||||||
|
switch (firstLanguage) {
|
||||||
|
case "es":
|
||||||
|
greeting = "Hola!";
|
||||||
|
break;
|
||||||
|
case "de":
|
||||||
|
greeting = "Hallo!";
|
||||||
|
break;
|
||||||
|
case "fr":
|
||||||
|
greeting = "Bonjour!";
|
||||||
|
break;
|
||||||
|
case "en":
|
||||||
|
default:
|
||||||
|
greeting = "Hello!";
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
return new ResponseEntity<String>(greeting, HttpStatus.OK);
|
||||||
|
}
|
||||||
|
|
||||||
|
@GetMapping("/double")
|
||||||
|
public ResponseEntity<String> doubleNumber(@RequestHeader("my-number") int myNumber) {
|
||||||
|
return new ResponseEntity<String>(
|
||||||
|
String.format("%d * 2 = %d", myNumber, (myNumber * 2)),
|
||||||
|
HttpStatus.OK);
|
||||||
|
}
|
||||||
|
|
||||||
|
@GetMapping("/listHeaders")
|
||||||
|
public ResponseEntity<String> listAllHeaders(@RequestHeader Map<String, String> headers) {
|
||||||
|
|
||||||
|
headers.forEach((key, value) -> {
|
||||||
|
LOG.info(String.format("Header '%s' = %s", key, value));
|
||||||
|
});
|
||||||
|
|
||||||
|
return new ResponseEntity<String>(String.format("Listed %d headers", headers.size()), HttpStatus.OK);
|
||||||
|
}
|
||||||
|
|
||||||
|
@GetMapping("/multiValue")
|
||||||
|
public ResponseEntity<String> multiValue(@RequestHeader MultiValueMap<String, String> headers) {
|
||||||
|
headers.forEach((key, value) -> {
|
||||||
|
LOG.info(String.format("Header '%s' = %s", key, value.stream().collect(Collectors.joining("|"))));
|
||||||
|
});
|
||||||
|
|
||||||
|
return new ResponseEntity<String>(String.format("Listed %d headers", headers.size()), HttpStatus.OK);
|
||||||
|
}
|
||||||
|
|
||||||
|
@GetMapping("/getBaseUrl")
|
||||||
|
public ResponseEntity<String> getBaseUrl(@RequestHeader HttpHeaders headers) {
|
||||||
|
InetSocketAddress host = headers.getHost();
|
||||||
|
String url = "http://" + host.getHostName() + ":" + host.getPort();
|
||||||
|
return new ResponseEntity<String>(String.format("Base URL = %s", url), HttpStatus.OK);
|
||||||
|
}
|
||||||
|
|
||||||
|
@GetMapping("/nonRequiredHeader")
|
||||||
|
public ResponseEntity<String> evaluateNonRequiredHeader(
|
||||||
|
@RequestHeader(value = "optional-header", required = false) String optionalHeader) {
|
||||||
|
|
||||||
|
return new ResponseEntity<String>(
|
||||||
|
String.format("Was the optional header present? %s!", (optionalHeader == null ? "No" : "Yes")),
|
||||||
|
HttpStatus.OK);
|
||||||
|
}
|
||||||
|
|
||||||
|
@GetMapping("/default")
|
||||||
|
public ResponseEntity<String> evaluateDefaultHeaderValue(
|
||||||
|
@RequestHeader(value = "optional-header", defaultValue = "3600") int optionalHeader) {
|
||||||
|
|
||||||
|
return new ResponseEntity<String>(String.format("Optional Header is %d", optionalHeader), HttpStatus.OK);
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,13 @@
|
|||||||
|
package com.baeldung;
|
||||||
|
|
||||||
|
import org.junit.jupiter.api.Test;
|
||||||
|
import org.springframework.boot.test.context.SpringBootTest;
|
||||||
|
|
||||||
|
import com.baeldung.spring.Application;
|
||||||
|
|
||||||
|
@SpringBootTest(classes = Application.class)
|
||||||
|
public class AppContextIntegrationTest {
|
||||||
|
@Test
|
||||||
|
public void contextLoads() {
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,86 @@
|
|||||||
|
package com.baeldung.headers.controller;
|
||||||
|
|
||||||
|
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get;
|
||||||
|
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.content;
|
||||||
|
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
|
||||||
|
|
||||||
|
import org.apache.commons.logging.Log;
|
||||||
|
import org.apache.commons.logging.LogFactory;
|
||||||
|
import org.junit.jupiter.api.BeforeEach;
|
||||||
|
import org.junit.jupiter.api.Test;
|
||||||
|
import org.junit.jupiter.api.extension.ExtendWith;
|
||||||
|
import org.springframework.context.annotation.Configuration;
|
||||||
|
import org.springframework.test.context.junit.jupiter.SpringExtension;
|
||||||
|
import org.springframework.test.context.junit.jupiter.web.SpringJUnitWebConfig;
|
||||||
|
import org.springframework.test.web.servlet.MockMvc;
|
||||||
|
import org.springframework.test.web.servlet.setup.MockMvcBuilders;
|
||||||
|
|
||||||
|
import com.baeldung.spring.headers.controller.ReadHeaderRestController;
|
||||||
|
|
||||||
|
@SpringJUnitWebConfig(ReadHeaderRestControllerIntegrationTest.Config.class)
|
||||||
|
@ExtendWith(SpringExtension.class)
|
||||||
|
public class ReadHeaderRestControllerIntegrationTest {
|
||||||
|
private static final Log LOG = LogFactory.getLog(ReadHeaderRestControllerIntegrationTest.class);
|
||||||
|
|
||||||
|
@Configuration
|
||||||
|
static class Config {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private MockMvc mockMvc;
|
||||||
|
|
||||||
|
@BeforeEach
|
||||||
|
public void setUp() {
|
||||||
|
mockMvc = MockMvcBuilders.standaloneSetup(new ReadHeaderRestController())
|
||||||
|
.build();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void whenGetRequestSentToAllHeaders_thenStatusOkAndTextReturned() throws Exception {
|
||||||
|
mockMvc.perform(get("/listHeaders").header("my-header", "Test"))
|
||||||
|
.andExpect(status().isOk())
|
||||||
|
.andExpect(content().string("Listed 1 headers"));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void whenGetRequestSentToMultiValue_thenStatusOkAndTextReturned() throws Exception {
|
||||||
|
mockMvc.perform(get("/multiValue").header("my-header", "ABC", "DEF", "GHI"))
|
||||||
|
.andExpect(status().isOk())
|
||||||
|
.andExpect(content().string("Listed 1 headers"));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void whenGetRequestSentToGreeting_thenStatusOKAndGreetingReturned() throws Exception {
|
||||||
|
mockMvc.perform(get("/greeting").header("accept-language", "de"))
|
||||||
|
.andExpect(status().isOk())
|
||||||
|
.andExpect(content().string("Hallo!"));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void whenGetRequestSentToDouble_thenStatusOKAndCorrectResultReturned() throws Exception {
|
||||||
|
mockMvc.perform(get("/double").header("my-number", 2))
|
||||||
|
.andExpect(status().isOk())
|
||||||
|
.andExpect(content().string("2 * 2 = 4"));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void whenGetRequestSentToGetBaseUrl_thenStatusOkAndHostReturned() throws Exception {
|
||||||
|
mockMvc.perform(get("/getBaseUrl").header("host", "localhost:8080"))
|
||||||
|
.andExpect(status().isOk())
|
||||||
|
.andExpect(content().string("Base URL = http://localhost:8080"));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void whenGetRequestSentToNonRequiredHeaderWithoutHeader_thenStatusOKAndMessageReturned() throws Exception {
|
||||||
|
mockMvc.perform(get("/nonRequiredHeader"))
|
||||||
|
.andExpect(status().isOk())
|
||||||
|
.andExpect(content().string("Was the optional header present? No!"));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void whenGetRequestSentToDefaultWithoutHeader_thenStatusOKAndMessageReturned() throws Exception {
|
||||||
|
mockMvc.perform(get("/default"))
|
||||||
|
.andExpect(status().isOk())
|
||||||
|
.andExpect(content().string("Optional Header is 3600"));
|
||||||
|
}
|
||||||
|
}
|
@ -22,7 +22,7 @@
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.sun.mail</groupId>
|
<groupId>com.sun.mail</groupId>
|
||||||
<artifactId>javax.mail</artifactId>
|
<artifactId>javax.mail</artifactId>
|
||||||
<version>1.6.1</version>
|
<version>${javax.mail.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>javax.servlet</groupId>
|
<groupId>javax.servlet</groupId>
|
||||||
@ -182,6 +182,7 @@
|
|||||||
<scribejava.version>5.1.0</scribejava.version>
|
<scribejava.version>5.1.0</scribejava.version>
|
||||||
<json.version>20180130</json.version>
|
<json.version>20180130</json.version>
|
||||||
<apache-tiles.version>3.0.8</apache-tiles.version>
|
<apache-tiles.version>3.0.8</apache-tiles.version>
|
||||||
|
<javax.mail.version>1.6.1</javax.mail.version>
|
||||||
</properties>
|
</properties>
|
||||||
|
|
||||||
</project>
|
</project>
|
||||||
|
@ -88,7 +88,7 @@
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.springframework.boot</groupId>
|
<groupId>org.springframework.boot</groupId>
|
||||||
<artifactId>spring-boot-starter-test</artifactId>
|
<artifactId>spring-boot-starter-test</artifactId>
|
||||||
<version>1.5.10.RELEASE</version>
|
<version>${spring-boot.version}</version>
|
||||||
<scope>test</scope>
|
<scope>test</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
@ -118,6 +118,7 @@
|
|||||||
|
|
||||||
<!-- Spring -->
|
<!-- Spring -->
|
||||||
<org.springframework.version>5.0.2.RELEASE</org.springframework.version>
|
<org.springframework.version>5.0.2.RELEASE</org.springframework.version>
|
||||||
|
<spring-boot.version>1.5.10.RELEASE</spring-boot.version>
|
||||||
|
|
||||||
<!-- persistence -->
|
<!-- persistence -->
|
||||||
<mysql-connector-java.version>5.1.40</mysql-connector-java.version>
|
<mysql-connector-java.version>5.1.40</mysql-connector-java.version>
|
||||||
|
@ -27,12 +27,17 @@
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>io.projectreactor</groupId>
|
<groupId>io.projectreactor</groupId>
|
||||||
<artifactId>reactor-bus</artifactId>
|
<artifactId>reactor-bus</artifactId>
|
||||||
<version>2.0.8.RELEASE</version>
|
<version>${reactor.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>io.projectreactor</groupId>
|
<groupId>io.projectreactor</groupId>
|
||||||
<artifactId>reactor-core</artifactId>
|
<artifactId>reactor-core</artifactId>
|
||||||
<version>2.0.8.RELEASE</version>
|
<version>${reactor.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
|
<properties>
|
||||||
|
<spring-cloud-sleuth.version>2.0.2.RELEASE</spring-cloud-sleuth.version>
|
||||||
|
<reactor.version>2.0.8.RELEASE</reactor.version>
|
||||||
|
</properties>
|
||||||
</project>
|
</project>
|
||||||
|
@ -8,6 +8,13 @@
|
|||||||
<version>1.0-SNAPSHOT</version>
|
<version>1.0-SNAPSHOT</version>
|
||||||
<name>spring-rest-hal-browser</name>
|
<name>spring-rest-hal-browser</name>
|
||||||
|
|
||||||
|
<parent>
|
||||||
|
<artifactId>parent-boot-1</artifactId>
|
||||||
|
<groupId>com.baeldung</groupId>
|
||||||
|
<version>0.0.1-SNAPSHOT</version>
|
||||||
|
<relativePath>../parent-boot-1</relativePath>
|
||||||
|
</parent>
|
||||||
|
|
||||||
<dependencies>
|
<dependencies>
|
||||||
<!-- https://mvnrepository.com/artifact/org.springframework.boot/spring-boot-starter-web -->
|
<!-- https://mvnrepository.com/artifact/org.springframework.boot/spring-boot-starter-web -->
|
||||||
<dependency>
|
<dependency>
|
||||||
|
@ -20,17 +20,17 @@
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.fasterxml.jackson.core</groupId>
|
<groupId>com.fasterxml.jackson.core</groupId>
|
||||||
<artifactId>jackson-core</artifactId>
|
<artifactId>jackson-core</artifactId>
|
||||||
<version>2.9.7</version>
|
<version>${jackson.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.fasterxml.jackson.core</groupId>
|
<groupId>com.fasterxml.jackson.core</groupId>
|
||||||
<artifactId>jackson-annotations</artifactId>
|
<artifactId>jackson-annotations</artifactId>
|
||||||
<version>2.9.7</version>
|
<version>${jackson.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.fasterxml.jackson.core</groupId>
|
<groupId>com.fasterxml.jackson.core</groupId>
|
||||||
<artifactId>jackson-databind</artifactId>
|
<artifactId>jackson-databind</artifactId>
|
||||||
<version>2.9.7</version>
|
<version>${jackson.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<!-- Spring Security -->
|
<!-- Spring Security -->
|
||||||
@ -139,7 +139,7 @@
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.jayway.jsonpath</groupId>
|
<groupId>com.jayway.jsonpath</groupId>
|
||||||
<artifactId>json-path</artifactId>
|
<artifactId>json-path</artifactId>
|
||||||
<version>2.4.0</version>
|
<version>${json-path.version}</version>
|
||||||
<scope>test</scope>
|
<scope>test</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
@ -213,6 +213,7 @@
|
|||||||
<!-- Maven plugins -->
|
<!-- Maven plugins -->
|
||||||
<maven-war-plugin.version>2.6</maven-war-plugin.version>
|
<maven-war-plugin.version>2.6</maven-war-plugin.version>
|
||||||
<cargo-maven2-plugin.version>1.6.1</cargo-maven2-plugin.version>
|
<cargo-maven2-plugin.version>1.6.1</cargo-maven2-plugin.version>
|
||||||
|
<json-path.version>2.4.0</json-path.version>
|
||||||
|
|
||||||
</properties>
|
</properties>
|
||||||
|
|
||||||
|
@ -137,7 +137,7 @@
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.springframework.boot</groupId>
|
<groupId>org.springframework.boot</groupId>
|
||||||
<artifactId>spring-boot-starter-test</artifactId>
|
<artifactId>spring-boot-starter-test</artifactId>
|
||||||
<version>1.5.10.RELEASE</version>
|
<version>${spring-boot.version}</version>
|
||||||
<scope>test</scope>
|
<scope>test</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
@ -211,7 +211,7 @@
|
|||||||
<!-- Maven plugins -->
|
<!-- Maven plugins -->
|
||||||
<maven-war-plugin.version>2.6</maven-war-plugin.version>
|
<maven-war-plugin.version>2.6</maven-war-plugin.version>
|
||||||
<cargo-maven2-plugin.version>1.6.1</cargo-maven2-plugin.version>
|
<cargo-maven2-plugin.version>1.6.1</cargo-maven2-plugin.version>
|
||||||
|
<spring-boot.version>1.5.10.RELEASE</spring-boot.version>
|
||||||
</properties>
|
</properties>
|
||||||
|
|
||||||
</project>
|
</project>
|
@ -32,7 +32,7 @@
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.stormpath.spring</groupId>
|
<groupId>com.stormpath.spring</groupId>
|
||||||
<artifactId>stormpath-default-spring-boot-starter</artifactId>
|
<artifactId>stormpath-default-spring-boot-starter</artifactId>
|
||||||
<version>1.5.4</version>
|
<version>${stormpath-spring.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
@ -60,5 +60,9 @@
|
|||||||
</plugin>
|
</plugin>
|
||||||
</plugins>
|
</plugins>
|
||||||
</build>
|
</build>
|
||||||
|
|
||||||
|
<properties>
|
||||||
|
<stormpath-spring.version>1.5.4</stormpath-spring.version>
|
||||||
|
</properties>
|
||||||
|
|
||||||
</project>
|
</project>
|
||||||
|
@ -10,10 +10,6 @@
|
|||||||
<packaging>jar</packaging>
|
<packaging>jar</packaging>
|
||||||
<description>Spring Session with JDBC tutorial</description>
|
<description>Spring Session with JDBC tutorial</description>
|
||||||
|
|
||||||
<properties>
|
|
||||||
<h2.version>1.4.197</h2.version>
|
|
||||||
</properties>
|
|
||||||
|
|
||||||
<parent>
|
<parent>
|
||||||
<artifactId>parent-boot-2</artifactId>
|
<artifactId>parent-boot-2</artifactId>
|
||||||
<groupId>com.baeldung</groupId>
|
<groupId>com.baeldung</groupId>
|
||||||
@ -52,5 +48,8 @@
|
|||||||
</plugins>
|
</plugins>
|
||||||
</build>
|
</build>
|
||||||
|
|
||||||
|
<properties>
|
||||||
|
<h2.version>1.4.197</h2.version>
|
||||||
|
</properties>
|
||||||
|
|
||||||
</project>
|
</project>
|
@ -15,12 +15,6 @@
|
|||||||
<version>1.0.0-SNAPSHOT</version>
|
<version>1.0.0-SNAPSHOT</version>
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
<properties>
|
|
||||||
<java.version>1.8</java.version>
|
|
||||||
<tensorflow.version>1.12.0</tensorflow.version>
|
|
||||||
<junit.jupiter.version>5.4.0</junit.jupiter.version>
|
|
||||||
</properties>
|
|
||||||
|
|
||||||
<dependencies>
|
<dependencies>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.tensorflow</groupId>
|
<groupId>org.tensorflow</groupId>
|
||||||
@ -49,4 +43,10 @@
|
|||||||
</plugin>
|
</plugin>
|
||||||
</plugins>
|
</plugins>
|
||||||
</build>
|
</build>
|
||||||
|
|
||||||
|
<properties>
|
||||||
|
<java.version>1.8</java.version>
|
||||||
|
<tensorflow.version>1.12.0</tensorflow.version>
|
||||||
|
<junit.jupiter.version>5.4.0</junit.jupiter.version>
|
||||||
|
</properties>
|
||||||
</project>
|
</project>
|
@ -42,7 +42,7 @@
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.fasterxml.jackson.core</groupId>
|
<groupId>com.fasterxml.jackson.core</groupId>
|
||||||
<artifactId>jackson-databind</artifactId>
|
<artifactId>jackson-databind</artifactId>
|
||||||
<version>2.9.4</version>
|
<version>${jackson.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.springframework.boot</groupId>
|
<groupId>org.springframework.boot</groupId>
|
||||||
@ -68,12 +68,12 @@
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.h2database</groupId>
|
<groupId>com.h2database</groupId>
|
||||||
<artifactId>h2</artifactId>
|
<artifactId>h2</artifactId>
|
||||||
<version>1.4.197</version>
|
<version>${h2.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.projectlombok</groupId>
|
<groupId>org.projectlombok</groupId>
|
||||||
<artifactId>lombok</artifactId>
|
<artifactId>lombok</artifactId>
|
||||||
<version>1.18.2</version>
|
<version>${lombok.version}</version>
|
||||||
<scope>compile</scope>
|
<scope>compile</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
@ -145,6 +145,7 @@
|
|||||||
<jmeter.version>5.0</jmeter.version>
|
<jmeter.version>5.0</jmeter.version>
|
||||||
<grinder.version>3.11</grinder.version>
|
<grinder.version>3.11</grinder.version>
|
||||||
<spring.boot.version>2.0.5.RELEASE</spring.boot.version>
|
<spring.boot.version>2.0.5.RELEASE</spring.boot.version>
|
||||||
|
<h2.version>1.4.197</h2.version>
|
||||||
</properties>
|
</properties>
|
||||||
|
|
||||||
</project>
|
</project>
|
@ -18,7 +18,7 @@
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>junit</groupId>
|
<groupId>junit</groupId>
|
||||||
<artifactId>junit</artifactId>
|
<artifactId>junit</artifactId>
|
||||||
<version>4.12</version>
|
<version>${junit.version}</version>
|
||||||
<scope>test</scope>
|
<scope>test</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user