diff --git a/algorithms/pom.xml b/algorithms/pom.xml
new file mode 100644
index 0000000000..0c85a19534
--- /dev/null
+++ b/algorithms/pom.xml
@@ -0,0 +1,44 @@
+
+ 4.0.0
+ com.baeldung
+ algorithms
+ 0.0.1-SNAPSHOT
+
+
+ 4.12
+ 3.6.0
+ 1.5.0
+
+
+
+
+ junit
+ junit
+ ${junit.version}
+ test
+
+
+
+
+ install
+
+
+
+ org.apache.maven.plugins
+ maven-compiler-plugin
+ ${maven-compiler-plugin.version}
+
+ 1.8
+ 1.8
+
+
+
+ org.codehaus.mojo
+ exec-maven-plugin
+ ${exec-maven-plugin.version}
+
+
+
+
+
\ No newline at end of file
diff --git a/algorithms/src/main/java/com/baeldung/algorithms/dijkstra/Dijkstra.java b/algorithms/src/main/java/com/baeldung/algorithms/dijkstra/Dijkstra.java
new file mode 100644
index 0000000000..b82eedbc3f
--- /dev/null
+++ b/algorithms/src/main/java/com/baeldung/algorithms/dijkstra/Dijkstra.java
@@ -0,0 +1,59 @@
+package com.baeldung.algorithms.dijkstra;
+
+import java.util.HashSet;
+import java.util.LinkedList;
+import java.util.Map.Entry;
+import java.util.Set;
+
+public class Dijkstra {
+
+ public static Graph calculateShortestPathFromSource(Graph graph, Node source) {
+
+ source.setDistance(0);
+
+ Set settledNodes = new HashSet<>();
+ Set unsettledNodes = new HashSet<>();
+ unsettledNodes.add(source);
+
+ while (unsettledNodes.size() != 0) {
+ Node currentNode = getLowestDistanceNode(unsettledNodes);
+ unsettledNodes.remove(currentNode);
+ for (Entry adjacencyPair : currentNode
+ .getAdjacentNodes()
+ .entrySet()) {
+ Node adjacentNode = adjacencyPair.getKey();
+ Integer edgeWeigh = adjacencyPair.getValue();
+
+ if (!settledNodes.contains(adjacentNode)) {
+ CalculateMinimumDistance(adjacentNode, edgeWeigh, currentNode);
+ unsettledNodes.add(adjacentNode);
+ }
+ }
+ settledNodes.add(currentNode);
+ }
+ return graph;
+ }
+
+ private static void CalculateMinimumDistance(Node evaluationNode, Integer edgeWeigh, Node sourceNode) {
+ Integer sourceDistance = sourceNode.getDistance();
+ if (sourceDistance + edgeWeigh < evaluationNode.getDistance()) {
+ evaluationNode.setDistance(sourceDistance + edgeWeigh);
+ LinkedList shortestPath = new LinkedList<>(sourceNode.getShortestPath());
+ shortestPath.add(sourceNode);
+ evaluationNode.setShortestPath(shortestPath);
+ }
+ }
+
+ private static Node getLowestDistanceNode(Set unsettledNodes) {
+ Node lowestDistanceNode = null;
+ int lowestDistance = Integer.MAX_VALUE;
+ for (Node node : unsettledNodes) {
+ int nodeDistance = node.getDistance();
+ if (nodeDistance < lowestDistance) {
+ lowestDistance = nodeDistance;
+ lowestDistanceNode = node;
+ }
+ }
+ return lowestDistanceNode;
+ }
+}
diff --git a/algorithms/src/main/java/com/baeldung/algorithms/dijkstra/Graph.java b/algorithms/src/main/java/com/baeldung/algorithms/dijkstra/Graph.java
new file mode 100644
index 0000000000..f24d6ae60e
--- /dev/null
+++ b/algorithms/src/main/java/com/baeldung/algorithms/dijkstra/Graph.java
@@ -0,0 +1,21 @@
+package com.baeldung.algorithms.dijkstra;
+
+import java.util.HashSet;
+import java.util.Set;
+
+public class Graph {
+
+ private Set nodes = new HashSet<>();
+
+ public void addNode(Node nodeA) {
+ nodes.add(nodeA);
+ }
+
+ public Set getNodes() {
+ return nodes;
+ }
+
+ public void setNodes(Set nodes) {
+ this.nodes = nodes;
+ }
+}
diff --git a/algorithms/src/main/java/com/baeldung/algorithms/dijkstra/Node.java b/algorithms/src/main/java/com/baeldung/algorithms/dijkstra/Node.java
new file mode 100644
index 0000000000..b00127a259
--- /dev/null
+++ b/algorithms/src/main/java/com/baeldung/algorithms/dijkstra/Node.java
@@ -0,0 +1,58 @@
+package com.baeldung.algorithms.dijkstra;
+
+import java.util.HashMap;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Map;
+
+public class Node {
+
+ private String name;
+
+ private LinkedList shortestPath = new LinkedList<>();
+
+ private Integer distance = Integer.MAX_VALUE;
+
+ private Map adjacentNodes = new HashMap<>();
+
+ public Node(String name) {
+ this.name = name;
+ }
+
+ public void addDestination(Node destination, int distance) {
+ adjacentNodes.put(destination, distance);
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public Map getAdjacentNodes() {
+ return adjacentNodes;
+ }
+
+ public void setAdjacentNodes(Map adjacentNodes) {
+ this.adjacentNodes = adjacentNodes;
+ }
+
+ public Integer getDistance() {
+ return distance;
+ }
+
+ public void setDistance(Integer distance) {
+ this.distance = distance;
+ }
+
+ public List getShortestPath() {
+ return shortestPath;
+ }
+
+ public void setShortestPath(LinkedList shortestPath) {
+ this.shortestPath = shortestPath;
+ }
+
+}
diff --git a/algorithms/src/test/java/algorithms/DijkstraAlgorithmTest.java b/algorithms/src/test/java/algorithms/DijkstraAlgorithmTest.java
new file mode 100644
index 0000000000..86ee62c827
--- /dev/null
+++ b/algorithms/src/test/java/algorithms/DijkstraAlgorithmTest.java
@@ -0,0 +1,85 @@
+package algorithms;
+
+import com.baeldung.algorithms.dijkstra.Dijkstra;
+import com.baeldung.algorithms.dijkstra.Graph;
+import com.baeldung.algorithms.dijkstra.Node;
+import org.junit.Test;
+
+import java.util.Arrays;
+import java.util.List;
+
+import static org.junit.Assert.assertTrue;
+
+public class DijkstraAlgorithmTest {
+
+ @Test
+ public void whenSPPSolved_thenCorrect() {
+
+ Node nodeA = new Node("A");
+ Node nodeB = new Node("B");
+ Node nodeC = new Node("C");
+ Node nodeD = new Node("D");
+ Node nodeE = new Node("E");
+ Node nodeF = new Node("F");
+
+ nodeA.addDestination(nodeB, 10);
+ nodeA.addDestination(nodeC, 15);
+
+ nodeB.addDestination(nodeD, 12);
+ nodeB.addDestination(nodeF, 15);
+
+ nodeC.addDestination(nodeE, 10);
+
+ nodeD.addDestination(nodeE, 2);
+ nodeD.addDestination(nodeF, 1);
+
+ nodeF.addDestination(nodeE, 5);
+
+ Graph graph = new Graph();
+
+ graph.addNode(nodeA);
+ graph.addNode(nodeB);
+ graph.addNode(nodeC);
+ graph.addNode(nodeD);
+ graph.addNode(nodeE);
+ graph.addNode(nodeF);
+
+ graph = Dijkstra.calculateShortestPathFromSource(graph, nodeA);
+
+ List shortestPathForNodeB = Arrays.asList(nodeA);
+ List shortestPathForNodeC = Arrays.asList(nodeA);
+ List shortestPathForNodeD = Arrays.asList(nodeA, nodeB);
+ List shortestPathForNodeE = Arrays.asList(nodeA, nodeB, nodeD);
+ List shortestPathForNodeF = Arrays.asList(nodeA, nodeB, nodeD);
+
+ for (Node node : graph.getNodes()) {
+ switch (node.getName()) {
+ case "B":
+ assertTrue(node
+ .getShortestPath()
+ .equals(shortestPathForNodeB));
+ break;
+ case "C":
+ assertTrue(node
+ .getShortestPath()
+ .equals(shortestPathForNodeC));
+ break;
+ case "D":
+ assertTrue(node
+ .getShortestPath()
+ .equals(shortestPathForNodeD));
+ break;
+ case "E":
+ assertTrue(node
+ .getShortestPath()
+ .equals(shortestPathForNodeE));
+ break;
+ case "F":
+ assertTrue(node
+ .getShortestPath()
+ .equals(shortestPathForNodeF));
+ break;
+ }
+ }
+ }
+}
diff --git a/aws/.gitignore b/aws/.gitignore
new file mode 100644
index 0000000000..b83d22266a
--- /dev/null
+++ b/aws/.gitignore
@@ -0,0 +1 @@
+/target/
diff --git a/aws-lambda/pom.xml b/aws/pom.xml
similarity index 93%
rename from aws-lambda/pom.xml
rename to aws/pom.xml
index c02d9d59dd..f3ae672a2f 100644
--- a/aws-lambda/pom.xml
+++ b/aws/pom.xml
@@ -2,10 +2,10 @@
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
4.0.0
com.baeldung
- aws-lambda
+ aws
0.1.0-SNAPSHOT
jar
- aws-lambda
+ aws
diff --git a/aws-lambda/src/main/java/com/baeldung/LambdaMethodHandler.java b/aws/src/main/java/com/baeldung/lambda/LambdaMethodHandler.java
similarity index 89%
rename from aws-lambda/src/main/java/com/baeldung/LambdaMethodHandler.java
rename to aws/src/main/java/com/baeldung/lambda/LambdaMethodHandler.java
index 6cce694912..dc21476290 100644
--- a/aws-lambda/src/main/java/com/baeldung/LambdaMethodHandler.java
+++ b/aws/src/main/java/com/baeldung/lambda/LambdaMethodHandler.java
@@ -1,4 +1,4 @@
-package com.baeldung;
+package com.baeldung.lambda;
import com.amazonaws.services.lambda.runtime.Context;
diff --git a/aws-lambda/src/main/java/com/baeldung/LambdaRequestHandler.java b/aws/src/main/java/com/baeldung/lambda/LambdaRequestHandler.java
similarity index 92%
rename from aws-lambda/src/main/java/com/baeldung/LambdaRequestHandler.java
rename to aws/src/main/java/com/baeldung/lambda/LambdaRequestHandler.java
index 37f114db25..85385555d2 100644
--- a/aws-lambda/src/main/java/com/baeldung/LambdaRequestHandler.java
+++ b/aws/src/main/java/com/baeldung/lambda/LambdaRequestHandler.java
@@ -1,4 +1,4 @@
-package com.baeldung;
+package com.baeldung.lambda;
import com.amazonaws.services.lambda.runtime.Context;
import com.amazonaws.services.lambda.runtime.RequestHandler;
diff --git a/aws-lambda/src/main/java/com/baeldung/LambdaRequestStreamHandler.java b/aws/src/main/java/com/baeldung/lambda/LambdaRequestStreamHandler.java
similarity index 87%
rename from aws-lambda/src/main/java/com/baeldung/LambdaRequestStreamHandler.java
rename to aws/src/main/java/com/baeldung/lambda/LambdaRequestStreamHandler.java
index aba65628ad..6e8a33c42d 100644
--- a/aws-lambda/src/main/java/com/baeldung/LambdaRequestStreamHandler.java
+++ b/aws/src/main/java/com/baeldung/lambda/LambdaRequestStreamHandler.java
@@ -1,7 +1,6 @@
-package com.baeldung;
+package com.baeldung.lambda;
import com.amazonaws.services.lambda.runtime.Context;
-import com.amazonaws.services.lambda.runtime.RequestHandler;
import com.amazonaws.services.lambda.runtime.RequestStreamHandler;
import org.apache.commons.io.IOUtils;
diff --git a/ejb/ejb-client/pom.xml b/ejb/ejb-client/pom.xml
index 2580a1e869..ba5763a3e7 100755
--- a/ejb/ejb-client/pom.xml
+++ b/ejb/ejb-client/pom.xml
@@ -1,16 +1,21 @@
- 4.0.0
- ejb-client
- ejb-client
-
-
- com.baeldung.ejb
- ejb
- 1.0-SNAPSHOT
-
-
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ 4.0.0
+
+ com.baeldung.ejb
+ ejb
+ 1.0-SNAPSHOT
+
+ ejb-client
+ EJB3 Client Maven
+ EJB3 Client Maven
+
+
+ 4.12
+ 2.19
+
+
org.wildfly
@@ -45,10 +50,4 @@
-
-
- 4.12
- 2.19.1
-
-
\ No newline at end of file
diff --git a/ejb/ejb-client/src/test/java/com/baeldung/ejb/setup/test/EJBSetupTest.java b/ejb/ejb-client/src/test/java/com/baeldung/ejb/setup/test/EJBSetupTest.java
index 1a8165cee6..fa92873a73 100755
--- a/ejb/ejb-client/src/test/java/com/baeldung/ejb/setup/test/EJBSetupTest.java
+++ b/ejb/ejb-client/src/test/java/com/baeldung/ejb/setup/test/EJBSetupTest.java
@@ -1,16 +1,18 @@
package com.baeldung.ejb.setup.test;
-import static org.junit.Assert.*;
-import org.junit.Test;
import com.baeldung.ejb.client.EJBClient;
import com.baeldung.ejb.tutorial.HelloWorldBean;
+import org.junit.Test;
+
+import static org.junit.Assert.assertEquals;
public class EJBSetupTest {
@Test
- public void testEJBClient() {
+ public void EJBClientTest() {
EJBClient ejbClient = new EJBClient();
HelloWorldBean bean = new HelloWorldBean();
assertEquals(bean.getHelloWorld(), ejbClient.getEJBRemoteMessage());
}
+
}
diff --git a/ejb/ejb-remote/pom.xml b/ejb/ejb-remote/pom.xml
index 601ad69447..beb182ff8b 100755
--- a/ejb/ejb-remote/pom.xml
+++ b/ejb/ejb-remote/pom.xml
@@ -1,45 +1,95 @@
- 4.0.0
-
- com.baeldung.ejb
- ejb
- 1.0-SNAPSHOT
-
- ejb-remote
- ejb
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ 4.0.0
-
-
-
- javax
- javaee-api
- ${javaee-api.version}
- provided
-
-
+
+ com.baeldung.ejb
+ ejb
+ 1.0-SNAPSHOT
+
-
-
-
- org.wildfly.plugins
- wildfly-maven-plugin
- ${wildfly-maven-plugin.version}
-
- 127.0.0.1
- 9990
- testUser
- admin1234!
- ${build.finalName}.jar
-
-
-
-
-
-
-
+ ejb-remote
+ ejb
+
+
+
+ javax
+ javaee-api
+ ${javaee-api.version}
+ provided
+
+
+
+
+
+
+
+ wildfly-standalone
+
+ true
+
+
+
+
+ org.codehaus.cargo
+ cargo-maven2-plugin
+ ${cargo-maven2-plugin.version}
+
+
+
+
+ wildfly10x
+
+ http://download.jboss.org/wildfly/10.1.0.Final/wildfly-10.1.0.Final.zip
+
+
+
+
+
+ 127.0.0.1
+ 9990
+ testUser:admin1234!
+
+
+
+
+
+
+
+
+
+
+
+ wildfly-runtime
+
+ false
+
+
+
+
+ org.wildfly.plugins
+ wildfly-maven-plugin
+ 1.1.0.Alpha5
+
+ 127.0.0.1
+ 9990
+ testUser
+ admin1234!
+ ${build.finalName}.jar
+
+
+
+
+
+
+
+
+
7.0
- 1.1.0.Beta1
+ 1.6.1
-
\ No newline at end of file
+
+
+
+
diff --git a/ejb/pom.xml b/ejb/pom.xml
index 7676165b8b..b00f80a817 100755
--- a/ejb/pom.xml
+++ b/ejb/pom.xml
@@ -1,89 +1,82 @@
- 4.0.0
- com.baeldung.ejb
- ejb
- 1.0-SNAPSHOT
- pom
- ejb
- EJB Tutorial
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ 4.0.0
+ com.baeldung.ejb
+ ejb
+ 1.0-SNAPSHOT
+ pom
+ ejb
+ EJB Tutorial
-
-
- jboss-public-repository-group
- JBoss Public Maven Repository Group
- http://repository.jboss.org/nexus/content/groups/public/
- default
-
- true
- never
-
-
- true
- never
-
-
-
+
+
+ jboss-public-repository-group
+ JBoss Public Maven Repository Group
+ http://repository.jboss.org/nexus/content/groups/public/
+ default
+
+ true
+ never
+
+
+ true
+ never
+
+
+
-
-
-
- com.baeldung.ejb
- ejb-remote
- 1.0-SNAPSHOT
- ejb
-
+
+
+
+ com.baeldung.ejb
+ ejb-remote
+ 1.0-SNAPSHOT
+ ejb
+
-
- javax
- javaee-api
- ${javaee-api.version}
- provided
-
+
+ javax
+ javaee-api
+ 7.0
+ provided
+
-
- org.wildfly
- wildfly-ejb-client-bom
- ${wildfly.version}
- pom
- import
-
-
-
+
+ org.wildfly
+ wildfly-ejb-client-bom
+ 10.1.0.Final
+ pom
+ import
+
+
+
-
-
-
-
- maven-compiler-plugin
- ${maven-compiler-plugin.version}
-
- 1.8
- 1.8
-
-
+
+
+
+
+ maven-compiler-plugin
+ 3.1
+
+ 1.8
+ 1.8
+
+
-
- maven-ejb-plugin
- ${maven-ejb-plugin.version}
-
- 3.2
-
-
-
-
-
+
+ maven-ejb-plugin
+ 2.4
+
+ 3.2
+
+
+
+
+
ejb-remote
ejb-client
-
-
- 7.0
- 10.1.0.Final
- 3.6.0
- 2.5.1
-
\ No newline at end of file
diff --git a/pom.xml b/pom.xml
index 19bec5bf81..89afb5f698 100644
--- a/pom.xml
+++ b/pom.xml
@@ -15,6 +15,8 @@
+ aws
+ algorithms
annotations
apache-cxf
apache-fop
diff --git a/spring-reactor/pom.xml b/spring-reactor/pom.xml
index cdabb2f538..7b6b1318cf 100644
--- a/spring-reactor/pom.xml
+++ b/spring-reactor/pom.xml
@@ -27,6 +27,10 @@
io.projectreactor
reactor-bus
+
+ org.springframework.boot
+ spring-boot-starter-test
+
diff --git a/spring-reactor/src/main/java/com/baeldung/Application.java b/spring-reactor/src/main/java/com/baeldung/Application.java
index b635a39e97..9030d41d26 100644
--- a/spring-reactor/src/main/java/com/baeldung/Application.java
+++ b/spring-reactor/src/main/java/com/baeldung/Application.java
@@ -4,13 +4,12 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.CommandLineRunner;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
-import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
+import org.springframework.context.annotation.Import;
import com.baeldung.consumer.NotificationConsumer;
-import reactor.Environment;
import reactor.bus.EventBus;
import static reactor.bus.selector.Selectors.$;
@@ -18,6 +17,7 @@ import static reactor.bus.selector.Selectors.$;
@Configuration
@EnableAutoConfiguration
@ComponentScan
+@Import(Config.class)
public class Application implements CommandLineRunner {
@Autowired
@@ -26,16 +26,6 @@ public class Application implements CommandLineRunner {
@Autowired
private NotificationConsumer notificationConsumer;
- @Bean
- Environment env() {
- return Environment.initializeIfEmpty().assignErrorJournal();
- }
-
- @Bean
- EventBus createEventBus(Environment env) {
- return EventBus.create(env, Environment.THREAD_POOL);
- }
-
@Override
public void run(String... args) throws Exception {
eventBus.on($("notificationConsumer"), notificationConsumer);
diff --git a/spring-reactor/src/main/java/com/baeldung/Config.java b/spring-reactor/src/main/java/com/baeldung/Config.java
new file mode 100644
index 0000000000..28f40dda02
--- /dev/null
+++ b/spring-reactor/src/main/java/com/baeldung/Config.java
@@ -0,0 +1,22 @@
+package com.baeldung;
+
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+
+import reactor.Environment;
+import reactor.bus.EventBus;
+
+@Configuration
+public class Config {
+
+ @Bean
+ Environment env() {
+ return Environment.initializeIfEmpty().assignErrorJournal();
+ }
+
+ @Bean
+ EventBus createEventBus(Environment env) {
+ return EventBus.create(env, Environment.THREAD_POOL);
+ }
+
+}
diff --git a/spring-reactor/src/test/java/com/baeldung/DataLoader.java b/spring-reactor/src/test/java/com/baeldung/DataLoader.java
new file mode 100644
index 0000000000..2ec3d9e526
--- /dev/null
+++ b/spring-reactor/src/test/java/com/baeldung/DataLoader.java
@@ -0,0 +1,20 @@
+package com.baeldung;
+
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.springframework.test.context.ContextConfiguration;
+import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
+import org.springframework.web.client.RestTemplate;
+
+
+@RunWith(SpringJUnit4ClassRunner.class)
+@ContextConfiguration(classes = {Application.class})
+public class DataLoader {
+
+ @Test
+ public void exampleTest() {
+ RestTemplate restTemplate = new RestTemplate();
+ restTemplate.getForObject("http://localhost:8080/startNotification/10", String.class);
+ }
+
+}
diff --git a/spring-rest/pom.xml b/spring-rest/pom.xml
index 9bb3c12945..da26d8abe9 100644
--- a/spring-rest/pom.xml
+++ b/spring-rest/pom.xml
@@ -357,18 +357,4 @@
-
-
-
- org.codehaus.mojo
- findbugs-maven-plugin
- ${findbugs-maven-plugin.version}
-
- Max
- FindDeadLocalStores,FindNullDeref
-
-
-
-
-